-
Notifications
You must be signed in to change notification settings - Fork 1
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
fix(docs): change TOKEN_COLUMNS to avoid conflicting tokens with the same name #1736
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e3f392c
fixing colors, avoid accessing nox-existing properties
rssilva 8738fb2
fix same name tokens collision once they are added to TOKEN_COLUMNS
rssilva 4b4201b
add changeset
rssilva 99abcc4
removing unnecessary column
rssilva 1c3d017
using category instead name to the prop, wrapping table with a div to…
rssilva 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@localyze-pluto/design-tokens": patch | ||
"@localyze-pluto/components": patch | ||
--- | ||
|
||
Fix storybook pages by avoiding wrong parsed token names and name conflict |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ import { | |
hexToRgb, | ||
hexToHsla, | ||
} from "../utils"; | ||
import { Box } from "../../../components/src/primitives/Box"; | ||
import { Box, BoxProps } from "../../../components/src/primitives/Box"; | ||
import { Text } from "../../../components/src/primitives/Text"; | ||
import { TokenColumn } from "../types/TokenColumn"; | ||
import { Token } from "../types/Token"; | ||
|
@@ -35,7 +35,9 @@ const TEXT_PREVIEW = ( | |
); | ||
|
||
type TokenColumnsProps = { | ||
[key: string]: Array<TokenColumn>; | ||
[category: string]: { | ||
[key: string]: Array<TokenColumn>; | ||
}; | ||
}; | ||
|
||
const getTokenFromVariable = (tokens: unknown, token: Token): string => { | ||
|
@@ -105,7 +107,7 @@ const FONT_SIZE = reduce( | |
name: "Name", | ||
transform: getTokenNameFromTuple(prefix), | ||
}, | ||
{ name: "Pixels", transform: getTokenComment }, | ||
{ name: "Weight", transform: getTokenValue }, | ||
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. 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. I'm removing this column since it doesn't make sense on font size! |
||
{ name: "Rems", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
|
@@ -114,11 +116,7 @@ const FONT_SIZE = reduce( | |
attribute: "fontSize", | ||
children: TEXT_PREVIEW, | ||
componentProps: { | ||
p: "space40", | ||
textOverflow: "ellipsis", | ||
whiteSpace: "nowrap", | ||
overflow: "hidden", | ||
maxWidth: "600px", | ||
lineHeight: "1" as BoxProps["lineHeight"], | ||
}, | ||
}), | ||
}, | ||
|
@@ -132,6 +130,34 @@ const FONT_SIZE = reduce( | |
{}, | ||
); | ||
|
||
const FONT_WEIGHT = reduce( | ||
filter(keys(fontWeightTokens), (item) => item !== "default"), | ||
(acc, prefix) => { | ||
const columns = [ | ||
{ | ||
name: "Name", | ||
transform: getTokenNameFromTuple(prefix), | ||
}, | ||
{ name: "Weight", transform: getTokenValue }, | ||
{ name: "Rems", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(fontWeightTokens), | ||
attribute: "fontWeight", | ||
children: TEXT_PREVIEW, | ||
}), | ||
}, | ||
]; | ||
|
||
return { | ||
...acc, | ||
[prefix]: columns, | ||
}; | ||
}, | ||
{}, | ||
); | ||
|
||
const SPACE = reduce( | ||
filter(keys(spaceTokens), (item) => item !== "default"), | ||
(acc, prefix) => { | ||
|
@@ -172,112 +198,106 @@ const SPACE = reduce( | |
); | ||
|
||
export const TOKEN_COLUMNS: TokenColumnsProps = { | ||
[getTokenKey(borderRadiiTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderRadiiTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderRadiiTokens), | ||
attribute: "borderRadius", | ||
componentProps: { | ||
borderStyle: "borderStyleSolid", | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
overrideProps: { | ||
pill: { | ||
h: "30px", | ||
borderRadius: { | ||
[getTokenKey(borderRadiiTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderRadiiTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderRadiiTokens), | ||
attribute: "borderRadius", | ||
componentProps: { | ||
borderStyle: "borderStyleSolid", | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
overrideProps: { | ||
pill: { | ||
h: "30px", | ||
}, | ||
}, | ||
}, | ||
}), | ||
}, | ||
], | ||
[getTokenKey(borderWidthTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderWidthTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderWidthTokens), | ||
attribute: "borderWidth", | ||
componentProps: { | ||
borderStyle: "borderStyleSolid", | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
}), | ||
}, | ||
], | ||
[getTokenKey(borderStyleTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderStyleTokens), | ||
}, | ||
{ name: "Style", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderStyleTokens), | ||
attribute: "borderStyle", | ||
componentProps: { | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
}), | ||
}, | ||
], | ||
}), | ||
}, | ||
], | ||
}, | ||
|
||
[getTokenKey(iconSizeTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(iconSizeTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenComment }, | ||
{ name: "Rems", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(iconSizeTokens), | ||
component: Icon, | ||
componentProps: { | ||
decorative: true, | ||
display: "flex", | ||
icon: "book-open", | ||
}, | ||
attribute: "size", | ||
children: ( | ||
<Box.div | ||
backgroundColor="colorBackgroundPrimaryWeakest" | ||
h="50px" | ||
w="50px" | ||
/> | ||
), | ||
}), | ||
}, | ||
], | ||
[getTokenKey(fontWeightTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(fontWeightTokens), | ||
}, | ||
{ name: "Weight", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(fontWeightTokens), | ||
attribute: "fontWeight", | ||
children: TEXT_PREVIEW, | ||
}), | ||
}, | ||
], | ||
...SPACE, | ||
...FONT_SIZE, | ||
...COLORS, | ||
borderWidth: { | ||
[getTokenKey(borderWidthTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderWidthTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderWidthTokens), | ||
attribute: "borderWidth", | ||
componentProps: { | ||
borderStyle: "borderStyleSolid", | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
}), | ||
}, | ||
], | ||
}, | ||
borderStyle: { | ||
[getTokenKey(borderStyleTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(borderStyleTokens), | ||
}, | ||
{ name: "Style", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(borderStyleTokens), | ||
attribute: "borderStyle", | ||
componentProps: { | ||
w: "50px", | ||
h: "50px", | ||
}, | ||
}), | ||
}, | ||
], | ||
}, | ||
iconSize: { | ||
[getTokenKey(iconSizeTokens)]: [ | ||
{ | ||
name: "Name", | ||
transform: getTokenName(iconSizeTokens), | ||
}, | ||
{ name: "Pixels", transform: getTokenComment }, | ||
{ name: "Rems", transform: getTokenValue }, | ||
{ | ||
name: "Preview", | ||
transform: createPreview({ | ||
prefix: getTokenKey(iconSizeTokens), | ||
component: Icon, | ||
componentProps: { | ||
decorative: true, | ||
display: "flex", | ||
icon: "book-open", | ||
}, | ||
attribute: "size", | ||
children: ( | ||
<Box.div | ||
backgroundColor="colorBackgroundPrimaryWeakest" | ||
h="50px" | ||
w="50px" | ||
/> | ||
), | ||
}), | ||
}, | ||
], | ||
}, | ||
space: { ...SPACE }, | ||
fontSize: { ...FONT_SIZE }, | ||
fontWeight: { ...FONT_WEIGHT }, | ||
color: { ...COLORS }, | ||
}; |
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.
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.
I noticed that we are using
category
in the type. What do you think of also using it here? Or maybe changing there toname
so we have the same naming in both places?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.
good call! I'm changing to category