-
Notifications
You must be signed in to change notification settings - Fork 41
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
feat(design): implementation for style-dictionary #2807
base: main
Are you sure you want to change the base?
Conversation
View your CI Pipeline Execution ↗ for commit 8da2421.
☁️ Nx Cloud last updated this comment at |
Codecov ReportAll modified and coverable lines are covered by tests ✅
✅ All tests successful. No failed tests found. Additional details and impacted files☔ View full report in Codecov by Sentry. |
2746fa8
to
2bcaba6
Compare
3b74582
to
c1a5710
Compare
4d93534
to
81f3f8b
Compare
81f3f8b
to
845f153
Compare
7380b7a
to
7b72471
Compare
b59aa4e
to
1fcb1ad
Compare
117bbb5
to
29bdbb0
Compare
3892851
to
5e67bd4
Compare
usesDtcg | ||
}); | ||
|
||
const replacePrivateTokenReferences = (token: TransformedToken, strValue: string): string => { |
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.
Could you add a unit test covering private references?
beforeEach(() => jest.clearAllMocks()); | ||
|
||
test('should have otter prefix', () => { | ||
expect(metadataFormat.name).toMatch(new RegExp(`^${OTTER_NAME_PREFIX}`)); |
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.
Maybe we could have test with example of metadata generated?
packages/@o3r/style-dictionary/src/transforms/unit.transform.spec.ts
Outdated
Show resolved
Hide resolved
|
||
const numberPossiblePattern = /^(.*?)\s*[a-z]*$/; | ||
|
||
const applyRatio = (value: any, ratio: number) => { |
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.
could we consider something like calc(var(--my-variable) * ratio) or we will never get this use case?
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.
Just to make sure we are aligned on the context (before answering :D):
The purpose of the transform
functions are to transform the value of a token before being generated to CSS.
A token can have different types including number
, dimension
, string
, etc... with an associated value based on its type.
A token can actually contain CSS rules (or CSS function call) but in this case it will not be interpreted and the token should be flagged as string
.
So in your case, if the token as the value calc(var(--my-variable) * ratio)
the ratio will not be apply to it.
If you are talking about the final CSS generated, and you prefer to have --new-variable: calc(var(--my-variable) * ratio)
instead of the current --my-variable: <value * ratio>
then it should be handle by preprocessor
(because it would request the creation of a new token) and this transform
should not be used.
(This feature has never been requested so this preprocessor
does not exist today :))
return getNode(ext[node], tail); | ||
}; | ||
|
||
const convertOtterNotationToToken = (token: TransformedToken): TransformedToken => { |
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.
What is this method meant to do?
from what I understand token.themeable is meant to add the !default modifier, is it what o3rExpectOverride will do?
Should we add this in the documentation?
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.
It is a bit more than !default
but yes.
The purpose of this function is to convert the properties we have on the $extensions (following DT standard) to the feature existing on Style Dictionary (not part of the standard).
Today the only case we have are themeable
and private
.
As you mentioned, themeable
is resulting to !default
suffix in Sass but it can be other annotation to other languages (it has not effect on CSS Variable).
I added comment to the function to give short explanation.
549f010
to
b812152
Compare
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.
config.mjs
seems too generic. Can this file have a more specific name?
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.
This is the standard name from Style Dictionary, cf. https://styledictionary.com/getting-started/using_the_cli/#build
deprecate: target file listing interface to migrate to single map docs: provide readme regarding Style Dictionary usage
b812152
to
8da2421
Compare
Proposed change
The purpose of this PR is to expose the
@o3r/design
features as style-dictionary modules.Todo
ng-add
schematicsRelated issues
- No issue associated -