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

fix: add support of inset in shadow-css transformer #72

Merged
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
5 changes: 3 additions & 2 deletions src/transformer/shadow-css.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ describe('Transformer: shadowCss', () => {
"offsetX": "0px",
"offsetY": "0px",
"blur": "0px",
"spread": "3px"
"spread": "3px",
"inset": true
},
{
"color": "#ffffff",
Expand All @@ -68,7 +69,7 @@ describe('Transformer: shadowCss', () => {
}] as StyleDictionary.TransformedToken[];

expect(shadows.filter(shadowCss.matcher as Matcher).map(item => shadowCss.transformer(item, {}))).toStrictEqual([
"0px 0px 0px 3px #00000066, 2px 2px 4px 0px #ffffff"
"0px 0px 0px 3px #00000066 inset, 2px 2px 4px 0px #ffffff"
]);
})
})
4 changes: 3 additions & 1 deletion src/transformer/shadow-css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ type TokenShadow = {
offsetY: string
blur: string
spread: string
inset: boolean
}

const formatShadow = ({
Expand All @@ -15,7 +16,8 @@ const formatShadow = ({
blur = '0',
spread = '0',
color,
}: TokenShadow ): string => `${offsetX} ${offsetY} ${blur} ${spread} ${color}`;
inset = false
}: TokenShadow ): string => `${offsetX} ${offsetY} ${blur} ${spread} ${color} ${inset ? 'inset' : ''}`.trim();

export const shadowCss: StyleDictionary.Transform = {
type: `value`,
Expand Down
Loading