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
if (figma.currentPage.selection.length !== 1) { | |
figma.notify("🚫 Select a component"); | |
return; | |
} | |
const [componentNode] = figma.currentPage.selection; | |
if (componentNode.type !== "COMPONENT") { | |
figma.notify("🚫 Select a component"); | |
return; | |
} |
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
// Create a list of all component nodes in the Figma file. | |
const componentNodes = figma.root.children.flatMap(pageNode => { | |
return pageNode.findAll(node => node.type === 'COMPONENT'); | |
}) as readonly ComponentNode[]; | |
// Create a list of component nodes that have more than one child node. | |
const unflattenedComponentNodes = componentNodes.filter(componentNode => { | |
const childrenNodes = componentNode.findAll(() => true); | |
return childrenNodes.length > 1; | |
}); |
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 components = figma.root.children.flatMap(pageNode => { | |
return pageNode.findAll(node => node.type === 'COMPONENT'); | |
}); | |
const styles = [ | |
...figma.getLocalEffectStyles(), | |
...figma.getLocalGridStyles(), | |
...figma.getLocalPaintStyles(), | |
...figma.getLocalTextStyles(), | |
]; |
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
// Get the list of color styles in the current Figma file. | |
const colorStyles = figma.getLocalPaintStyles(); | |
const updatedColorStyles = colorStyles.filter(style => { | |
const { paints } = style; | |
if (paints.length !== 1) { | |
// Skip styles containing multiple colors. | |
return false; | |
} | |
const [paint] = paints; |
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
// | |
// The Scripter environment. | |
// | |
// What's declared in there is available to scripts in their global namespace. | |
// | |
// symbolic type aliases | |
type int = number | |
type float = number | |
type byte = number |
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
import android.content.Context | |
import android.content.res.ColorStateList | |
import android.content.res.TypedArray | |
import android.graphics.drawable.Drawable | |
import androidx.annotation.StyleableRes | |
import androidx.appcompat.content.res.AppCompatResources | |
/** | |
* Utility methods for extracting [ColorStateList]s and [Drawable]s from a [TypedArray]. |
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
package com.lyft.android.lint.checks | |
import com.android.SdkConstants | |
import com.android.tools.lint.detector.api.* | |
import com.intellij.psi.PsiMethod | |
import org.jetbrains.uast.UCallExpression | |
class AppCompatViewConstructorDetector : Detector(), Detector.UastScanner { | |
companion object { |
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
<animated-vector | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:aapt="http://schemas.android.com/aapt"> | |
<aapt:attr name="android:drawable"> | |
<vector | |
android:name="heartbreak" | |
android:width="56dp" | |
android:height="56dp" | |
android:viewportWidth="56" | |
android:viewportHeight="56"> |
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
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.util.AttributeSet | |
import android.view.View | |
import kotlin.math.cos | |
import kotlin.math.sin | |
import kotlin.math.sqrt |
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
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.util.AttributeSet | |
import android.view.View | |
import androidx.annotation.ColorInt | |
import java.lang.Math.pow | |
import kotlin.math.cos |