-
Notifications
You must be signed in to change notification settings - Fork 12
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
chore(spindle-tokens): export design token with Figma variables #1067
Open
herablog
wants to merge
14
commits into
main
Choose a base branch
from
chore/style-dictionary-v4
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
8179f6c
chore: update dependency style-dictionary to v4
renovate[bot] 6de4023
chore(spindle-tokens): update config for v4
herablog bfac07e
chore(spindle-tokens): remove unused files
herablog bbdb2a6
chore(spindle-tokens): install @figma/rest-api-spec
herablog b2925ae
chore(spindle-tokens): export variables from Figma
herablog 9e1d990
chore(spindle-tokens): update config
herablog 9736b47
chore(spindle-tokens): update npm scripts
herablog 120a31a
chore(spindle-tokens): build tokens
herablog 474ead6
refactor(spindle-tokens): change directory
herablog b618a74
test(spindle-tokens): add transformer test
herablog 76c7712
chore(spindle-tokens): add token to extension
herablog 4e93c93
chore(spindle-tokens): add shadow token
herablog e02aa7a
chore(spindle-tokens): remove unused dist files
herablog 3c21d90
chore(spindle-tokens): replace @figma-export
herablog File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 was deleted.
Oops, something went wrong.
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,137 @@ | ||
{ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. こりはテスト用のサンプルレスポンスです |
||
"status": 200, | ||
"error": false, | ||
"meta": { | ||
"variableCollections": { | ||
"VariableCollectionId:1:28": { | ||
"defaultModeId": "1:0", | ||
"id": "VariableCollectionId:1:28", | ||
"name": "Animation Property", | ||
"remote": false, | ||
"modes": [ | ||
{ | ||
"modeId": "1:0", | ||
"name": "Mode 1" | ||
} | ||
], | ||
"key": "eb62ada576e591a0c3574220cef976e5f0d05088", | ||
"hiddenFromPublishing": false, | ||
"variableIds": [ | ||
"VariableID:1:29", | ||
"VariableID:1:32" | ||
] | ||
}, | ||
"VariableCollectionId:1:35": { | ||
"defaultModeId": "1:1", | ||
"id": "VariableCollectionId:1:35", | ||
"name": "Animation", | ||
"remote": false, | ||
"modes": [ | ||
{ | ||
"modeId": "1:1", | ||
"name": "Mode 1" | ||
} | ||
], | ||
"key": "17df3e6309aee435dbfda6b0b07bce80ff4f3e23", | ||
"hiddenFromPublishing": false, | ||
"variableIds": [ | ||
"VariableID:1:37", | ||
"VariableID:1:38" | ||
] | ||
} | ||
}, | ||
"variables": { | ||
"VariableID:1:29": { | ||
"id": "VariableID:1:29", | ||
"name": "Easing/Ease Out", | ||
"remote": false, | ||
"key": "3fca60793a42018ca2054c2df23c17b26ad3bd1e", | ||
"variableCollectionId": "VariableCollectionId:1:28", | ||
"resolvedType": "STRING", | ||
"description": "", | ||
"hiddenFromPublishing": false, | ||
"valuesByMode": { | ||
"1:0": "[0,0,0,1]" | ||
}, | ||
"scopes": [ | ||
"ALL_SCOPES" | ||
], | ||
"codeSyntax": {} | ||
}, | ||
"VariableID:1:32": { | ||
"id": "VariableID:1:32", | ||
"name": "Duration/Fast", | ||
"remote": false, | ||
"key": "a5db0d4a42b1890a9d71bf0674d68b2faf5a3463", | ||
"variableCollectionId": "VariableCollectionId:1:28", | ||
"resolvedType": "STRING", | ||
"description": "", | ||
"hiddenFromPublishing": false, | ||
"valuesByMode": { | ||
"1:0": "150ms" | ||
}, | ||
"scopes": [ | ||
"ALL_SCOPES" | ||
], | ||
"codeSyntax": {} | ||
}, | ||
"VariableID:1:37": { | ||
"id": "VariableID:1:37", | ||
"name": "Move/Easing", | ||
"remote": false, | ||
"key": "4ab6da23a8dc80b44a1872a23c80b0863550fd3e", | ||
"variableCollectionId": "VariableCollectionId:1:35", | ||
"resolvedType": "STRING", | ||
"description": "", | ||
"hiddenFromPublishing": false, | ||
"valuesByMode": { | ||
"1:1": { | ||
"type": "VARIABLE_ALIAS", | ||
"id": "VariableID:1:29" | ||
} | ||
}, | ||
"scopes": [ | ||
"ALL_SCOPES" | ||
], | ||
"codeSyntax": {} | ||
}, | ||
"VariableID:1:38": { | ||
"id": "VariableID:1:38", | ||
"name": "Move/Duration", | ||
"remote": false, | ||
"key": "2103542e02f6289ce3ff6aedfceb9fe10c0c75bb", | ||
"variableCollectionId": "VariableCollectionId:1:35", | ||
"resolvedType": "STRING", | ||
"description": "", | ||
"hiddenFromPublishing": false, | ||
"valuesByMode": { | ||
"1:1": { | ||
"type": "VARIABLE_ALIAS", | ||
"id": "VariableID:1:33" | ||
} | ||
}, | ||
"scopes": [ | ||
"ALL_SCOPES" | ||
], | ||
"codeSyntax": {} | ||
}, | ||
"VariableID:1:33": { | ||
"id": "VariableID:1:33", | ||
"name": "Duration/Neutral", | ||
"remote": false, | ||
"key": "0f62f41685a787f14e972ad58dccaa5978da10eb", | ||
"variableCollectionId": "VariableCollectionId:1:28", | ||
"resolvedType": "STRING", | ||
"description": "", | ||
"hiddenFromPublishing": false, | ||
"valuesByMode": { | ||
"1:0": "350ms" | ||
}, | ||
"scopes": [ | ||
"ALL_SCOPES" | ||
], | ||
"codeSyntax": {} | ||
} | ||
} | ||
} | ||
} |
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,35 @@ | ||
import { | ||
transformAnimation, | ||
transformAnimationProperty, | ||
} from './animation-transformer'; | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const animationResponse = require('./animation-response.json'); | ||
|
||
describe('transform Animation', () => { | ||
it('should transform animation properties correctly', () => { | ||
const variables = animationResponse; | ||
const transformedProperties = transformAnimationProperty(variables); | ||
|
||
expect(transformedProperties).toEqual({ | ||
'Easing/Ease Out': { $type: 'cubicBezier', $value: [0, 0, 0, 1] }, | ||
'Duration/Fast': { $type: 'transition', $value: '150ms' }, | ||
}); | ||
}); | ||
|
||
it('should transform animation correctly', () => { | ||
const variables = animationResponse; | ||
const transformedProperties = transformAnimation(variables); | ||
|
||
expect(transformedProperties).toEqual({ | ||
'Move/Easing': { | ||
$type: 'transition', | ||
$value: '{Animation.Easing/Ease Out}', | ||
}, | ||
'Move/Duration': { | ||
$type: 'transition', | ||
$value: '{Animation.Duration/Neutral}', | ||
}, | ||
}); | ||
}); | ||
}); |
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,59 @@ | ||
import { GetLocalVariablesResponse, VariableAlias } from '@figma/rest-api-spec'; | ||
|
||
export function transformAnimationProperty( | ||
variables: GetLocalVariablesResponse, | ||
) { | ||
const animationPropertyCollections = Object.values( | ||
variables.meta.variableCollections, | ||
).filter((value) => { | ||
return value.name === 'Animation Property'; | ||
})[0]; | ||
|
||
const animationPropertyResult: { [key: string]: { [key: string]: string } } = | ||
{}; | ||
|
||
animationPropertyCollections.variableIds.forEach((variableId) => { | ||
const variable = variables.meta.variables[variableId]; | ||
const isEasing = variable.name.startsWith('Easing'); | ||
const value = isEasing | ||
? JSON.parse(Object.values(variable.valuesByMode)[0] as string) | ||
: (Object.values(variable.valuesByMode)[0] as string); | ||
const type = isEasing ? 'cubicBezier' : 'transition'; | ||
animationPropertyResult[variable.name] = { | ||
$type: type, | ||
$value: value, | ||
}; | ||
}); | ||
|
||
return animationPropertyResult; | ||
} | ||
|
||
export function transformAnimation(variables: GetLocalVariablesResponse) { | ||
const animationCollection = Object.values( | ||
variables.meta.variableCollections, | ||
).filter((value) => { | ||
return value.name === 'Animation'; | ||
})[0]; | ||
|
||
const animationResult: { [key: string]: { [key: string]: string } } = {}; | ||
|
||
animationCollection.variableIds.forEach((variableId) => { | ||
const variable = variables.meta.variables[variableId]; | ||
const value = variable.valuesByMode[animationCollection.modes[0].modeId]; | ||
|
||
if ( | ||
(value as VariableAlias).type && | ||
(value as VariableAlias).type === 'VARIABLE_ALIAS' | ||
) { | ||
const alias = value as VariableAlias; | ||
const resolvedName = variables.meta.variables[alias.id].name; | ||
|
||
animationResult[variable.name] = { | ||
$type: 'transition', | ||
$value: `{Animation.${resolvedName}}`, | ||
}; | ||
} | ||
}); | ||
|
||
return animationResult; | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
書き出しは今使われている設定に合わせます。(allは作ってないですが)
ref: https://unpkg.com/browse/@openameba/[email protected]/dist/css/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
それでいうとallは対応しないんです?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
使ってるのかなぁと形式変わっちゃうしなぁの2点で作ってないですが、作ることもできます〜