This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const find = ["Move in", "move in", "Homehero", "wifi", "Wifi", "WiFi"]; | |
const replace = ["Move-in", "move-in", "HomeHero", "Wi-Fi"]; | |
const layers = figma.currentPage.findAll((node) => node.type === "TEXT"); | |
figma.currentPage.selection = layers; | |
const { selection } = figma.currentPage; | |
async function lintTextNodes(): Promise<String> { | |
figma.root.children.flatMap((pageNode) => | |
pageNode.selection.forEach(async (node) => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Note: this uses the Scripter API so won't work via regular Figma plugin code | |
// Download here: https://www.figma.com/community/plugin/757836922707087381/Scripter | |
const layers = figma.currentPage.findAll(isImage); | |
figma.currentPage.selection = layers | |
for (let shape of await find(selection(), n => isImage(n) && n)) { | |
// Update image paints to use "FILL" scale mode | |
shape.fills = shape.fills.map(p => | |
isImage(p) ? {...p, scaleMode: "FILL",} : p) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// NOTE: This uses the Scripter API so won't work as a normal Figma plugin | |
// Download here: https://www.figma.com/community/plugin/757836922707087381/Scripter | |
const layers = figma.currentPage.findAll(); | |
const frames = layers.filter(isFrame); | |
async function renameFrames() { | |
let items = frames; | |
if (items.length > 0) { | |
for (const node of items) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let iconName: String | |
let getInstances | |
const { selection } = figma.currentPage | |
function getInstanceByName(node) { | |
iconName = selection[0].name | |
} | |
getInstanceByName(selection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { selection } = figma.currentPage; | |
const direction = "VERTICAL" // "HORIZONTAL" | |
const spacing = 24 // any number | |
const padding = 24 // any number | |
const vAlignment = "CENTER" // "MIN" (left) or "MAX" (right) | |
const hAlignment = "SPACE_BETWEEN" // "MIN" (top), "MAX" (bottom), "SPACE_BETWEEN" (stretch) | |
selection.forEach((node: FrameNode) => { | |
node.layoutMode = direction | |
node.itemSpacing = spacing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selection.forEach((node: any) => { | |
node.isMask && node.remove(); | |
for (const child of node.children) { | |
child.isMask && child.remove(); | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function buildSlides() { | |
const frame = figma.createFrame() | |
const width = 1440 | |
const height = width * 9/16 | |
frame.name = "Slide" | |
frame.resize(width, height) | |
} | |
buildSlides() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func saveWorkoutToHealthKit() async throws { | |
guard HKHealthStore.isHealthDataAvailable() else { | |
print("HealthKit is not available on this device.") | |
return | |
} | |
let healthStore = HealthKitManager.shared.healthStore | |
if HKHealthStore.isHealthDataAvailable() { | |
let energyBurnedType = HKObjectType.quantityType(forIdentifier: .activeEnergyBurned)! |