Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add import variables content #129

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pages/variables/_meta.en.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"creating-variables": "Creating variables",
"references": "References"
"references": "References",
"importing-variables": "Importing variables"
}
57 changes: 57 additions & 0 deletions pages/variables/importing-variables.en.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Importing variables

import Callout from 'nextra-theme-docs/callout'

<img src='/import-variables.png' alt="Importing Variables Into Tokens Studio for Figma="800"/>

Already have variables setup in your file but want to sync them into Tokens Studio for Figma? You can find the `Import Variables` option in the Styles & Variables menu at the bottom of the plugin. Once you click on ‘Import Variables’, you are presented with two options in the following modal. `Convert Numbers to Dimensions` and `Use REM for Dimension Values`.

## Convert Numbers to Dimensions
---
<img src='/number-to-dimension.png' alt="Converting Number Variables to Dimension Tokens" width="800"/>

With ‘Convert Numbers to Dimensions’ selected, number variables are converted to tokens under the `Dimension` type.

**Note:** Spacing variables aren’t converted into tokens under the ‘Spacing’ type but are instead created as a token-group named `Spacing`, under the `Dimension` type.
If the option is unchecked then the same will be imported but under the `Number` type.

## REM for Dimension Values
---
<img src='/rem-for-dimension.png' alt="Converting Number Variables to REM Tokens" width="800"/>

Selecting the ‘Use REM for Dimension Values’ option converts all your variables using numbers by dividing back for isntance a value of `16` to be `1 rem`.

## Using References As Values
---

<Callout emoji="💡">
- If your number value is a reference, then when have both import options checked the plugin's going to create tokens with the following value, `NaNrem` (Not a Number).

- If you have numbers to dimensions unchecked and rem for dimensons checked, the plugin's going to create tokens with `Obeject Object` as values.
</Callout>

**NOTE:** To have the correct number references created as tokens, you need to have the option `Convert to Dimensions` checked and `REM for Dimension` unchecked.

### NaNrem
<img src='/value-nanrem.png' alt="NaNrem As Token Value With Incorrect Option Checked" width="800"/>

### Object Object
<img src='/value-object-object.png' alt="Object Object As Token Value With Incorrect Option Checked" width="800"/>

## Import Structure
---
<img src='/modes-collections.png' alt="Translation of Variable Modes and Collections to Tokens Studio" width="800"/>

- Variable collections are imported as folders in the plugin
- Modes are imported as sets under their respective folders

<img src='/import-updated-variables.png' alt="Converting Number Variables to REM Tokens" width="800"/>

## Limitations
- If you've imported variables and then create variables from tokens will not update your existing variables but will instead delete the collections.
- If any changes were made to your variables, you need to use the `Import Variables` function and not the `Sync Variables` function to update your tokens.

<Callout emoji="💡">
Importing variables doesn't officialy link/connect to tokens. So applying tokens won't apply its corresponding variable, yet.
</Callout>

Binary file added public/import-updated-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/import-variables.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/modes-collections.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/number-to-dimension.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/rem-for-dimensions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/value-nanrem.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/value-object-object.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.