-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Use the Figma API to parse variables. There are three main areas we now parse: 1. boundVariables from nodes that use variables. This change supports background color, stroke color, text color, and rounded corner sizes. 2. explicitVariableModes from nodes where Figma set a mode to be used on that node and children. 3. All the variable data (collections, modes, variables) from a new variables API call. boundVariables and explicitVariableModes are stored in the view generated for each node. The rest of the variable data is stored in a variable map data structure stored in the serialized file. Three new functions are introduced to override the current theme or mode. 1. DesignVariableCollection(themeName) declares a CompositionLocalProvider object that changes the current theme (collection in Figma) to the specified theme name. This theme name must exist as a collection in the Figma file, or it will do nothing. 2. DesignVariableModeValues(modeValues) declares a CompositionLocalProvider hash map that maps collection names to mode names. This changes the mode for the specified collection. For example if the default mode in Figma is set to 'light', this can be used to change the mode to 'dark'. 3. DesignMaterialThemeProvider(Boolean) declares a CompositionLocalProvider boolean to specify whether the material theme on the device should be used to override the theme in Figma. This only works for variables that were created from the Material Theme Builder plugin, or were made in a way to match -- e.g. the collection name is "material-theme" and the variable names match the Material Theme names such as "Schemes/Primary". When it is time to render a node that uses variables, we need to translate the variable into a value. This is achieved by using the helper class VariableManager, which takes the current VariableState containing the current collection and mode, along with the variable map in the serialized file, and looks up the correct value for the variable.
- Loading branch information
Showing
85 changed files
with
1,445 additions
and
81 deletions.
There are no files selected for viewing
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
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
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
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
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
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
Oops, something went wrong.