-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
157 additions
and
200 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import fetch from "node-fetch"; | ||
|
||
async function getFigmaData( | ||
FILE_KEY, | ||
FIGMA_TOKEN | ||
) { | ||
const response = await fetch( | ||
`https://api.figma.com/v1/files/${FILE_KEY}/variables/local`, | ||
{ | ||
method: "GET", | ||
headers: { | ||
"X-Figma-Token": FIGMA_TOKEN, | ||
"Content-Type": "application/json", | ||
}, | ||
} | ||
); | ||
if (!response.ok) { | ||
throw new Error( | ||
`Error fetching Figma data: ${response.statusText}` | ||
); | ||
} | ||
return response.json(); | ||
} | ||
|
||
async function postFigmaVariables( | ||
FILE_KEY, | ||
FIGMA_TOKEN, | ||
newData | ||
) { | ||
const response = await fetch( | ||
`https://api.figma.com/v1/files/${FILE_KEY}/variables`, | ||
{ | ||
method: "POST", | ||
headers: { | ||
"X-Figma-Token": FIGMA_TOKEN, | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify(newData), | ||
} | ||
); | ||
if (!response.ok) { | ||
const errorText = await response.text(); | ||
throw new Error( | ||
`Error updating variables: ${response.statusText}. Response: ${errorText}` | ||
); | ||
} | ||
return response.json(); | ||
} | ||
|
||
export { getFigmaData, postFigmaVariables }; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
export const VARIABLE_TYPES = { | ||
COLOR: "COLOR", | ||
FLOAT: "FLOAT", | ||
STRING: "STRING", | ||
FONT_WEIGHT: "FONT_WEIGHT", | ||
FONT_SIZE: "FONT_SIZE", | ||
LINE_HEIGHT: "LINE_HEIGHT", | ||
}; | ||
|
||
export const COLLECTION_NAMES = { | ||
BRAND: "Brand", | ||
COLOR_SCHEME: "Mode", | ||
PALETTE: "Palette", | ||
}; | ||
|
||
export const MODE_NAMES = { | ||
DEFAULT: "Mode 1", | ||
LIGHT: "Light", | ||
DARK: "Dark", | ||
}; |
2 changes: 1 addition & 1 deletion
2
tokens/figma/extract-json-data.mjs → tokens/figma/utils/extract-json-data.mjs
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.