Skip to content

Commit 6887b77

Browse files
committed
Fixed Storefront tokens preview
1 parent 5f164b4 commit 6887b77

File tree

17 files changed

+26
-22817
lines changed

17 files changed

+26
-22817
lines changed

apps/storefront/app/grunnleggende/designelementer/skygger/page.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ Skygger kan hjelpe svaksynte til å identifisere komponenter. Bruk av skygger og
3030

3131
Vi har ulike styrker på skyggene, fra xsmall til xlarge. De ulike styrkene brukes for å antyde høyden til overflaten. Overflater i høyere høyder har større skygger, mens de på lavere høyder bør ha mindre skygger. Skygger skal skape et hierarki slik at det som ligger over eller under noe annet kommer tydeligere frem.
3232

33-
<TokenList type='boxShadow' />
33+
<TokenList type='shadow' />
3434

3535
### Eksempel
3636

apps/storefront/app/grunnleggende/designelementer/storrelser-og-avstander/page.mdx

+1-5
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,10 @@ Størrelser (`sizing`) brukes til å definere bredde og høyde på elementer.
2525
Avstand (`spacing`) brukes til å sette marging og padding. Settet med avstander som er definert i tokens gir oss mulighet til å definere verdier for _"Auto Layout"_ i Figma og sikrer dermed konsistent design på tvers av grensesnitt.
2626

2727
<TokenList
28-
type='sizing'
28+
type='dimension'
2929
hideValue={true}
3030
/>
3131

32-
<TokenList
33-
type='spacing'
34-
hideValue={true}
35-
/>
3632

3733
## Men hvorfor må vi ha både `sizing` og `spacing` når de er helt like?
3834

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.bar {
2+
height: 36px;
3+
width: 72px;
4+
background-color: var(--ds-color-accent-base-default);
5+
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1-
const TokenBorderRadius = () => {
2-
return (
3-
<div>
4-
dfsdfsd
5-
<div>dsaf</div>
6-
</div>
7-
);
1+
import classes from './TokenBorderRadius.module.css';
2+
3+
const TokenBorderRadius = ({ value }: { value: string }) => {
4+
return <div className={classes.bar} style={{ borderRadius: value }}></div>;
85
};
96

107
export { TokenBorderRadius };

apps/storefront/components/Tokens/TokenList/TokenList.tsx

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { TokenFontSize } from '../TokenFontSize/TokenFontSize';
2121
import { TokenShadow } from '../TokenShadow/TokenShadow';
2222
import { TokenSize } from '../TokenSize/TokenSize';
2323

24+
import { TokenBorderRadius } from '../TokenBorderRadius/TokenBorderRadius';
2425
import classes from './TokenList.module.css';
2526

2627
type TokenListProps = {
@@ -52,7 +53,11 @@ const TokensTable = ({ tokens }: TokenTableProps) => {
5253
<Table.Body>
5354
{tokens.map(([, tokens]) => {
5455
return tokens.map((token) => {
55-
const pxSize = `${parseFloat(token.value as string) * 16}px`;
56+
const value = token.value as string;
57+
const pxSize = /\b\d+px\b/.test(value)
58+
? value
59+
: `${parseFloat(value) * 16}px`;
60+
const isBorderRadius = token.path.includes('border-radius');
5661

5762
return (
5863
<Table.Row key={token.name}>
@@ -66,7 +71,11 @@ const TokensTable = ({ tokens }: TokenTableProps) => {
6671
<Table.Cell>{token.value}</Table.Cell>
6772
<Table.Cell>{pxSize}</Table.Cell>
6873
<Table.Cell>
69-
<TokenSize value={pxSize} />
74+
{isBorderRadius ? (
75+
<TokenBorderRadius value={pxSize} />
76+
) : (
77+
<TokenSize value={pxSize} />
78+
)}
7079
</Table.Cell>
7180
</Table.Row>
7281
);
@@ -252,7 +261,7 @@ const TokenList = ({
252261
{sectionedTokens.map(([section, tokens]) => {
253262
const tokens_ = tokens as [string, Token[]][];
254263
const List = () => {
255-
if (['spacing', 'sizing'].includes(type)) {
264+
if (type === 'dimension') {
256265
return <TokensTable tokens={tokens_} />;
257266
}
258267

apps/storefront/components/Tokens/TokenSize/TokenSize.module.css

+1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@
77
height: 36px;
88
background-color: var(--ds-color-accent-base-default);
99
border-radius: 2px;
10+
max-width: 300px;
1011
}

apps/storefront/tokens/altinn/dark.ts

-32
Original file line numberDiff line numberDiff line change
@@ -3857,38 +3857,6 @@ export const dimension = [
38573857
"sizing",
38583858
"30"
38593859
]
3860-
},
3861-
{
3862-
type: "dimension",
3863-
value: "1px",
3864-
filePath: "../../design-tokens/semantic/style.json",
3865-
isSource: false,
3866-
original: {
3867-
type: "dimension",
3868-
value: "{border-width.1}"
3869-
},
3870-
name: "--ds-border-width-default",
3871-
attributes: {},
3872-
path: [
3873-
"border-width",
3874-
"default"
3875-
]
3876-
},
3877-
{
3878-
type: "dimension",
3879-
value: "2px",
3880-
filePath: "../../design-tokens/semantic/style.json",
3881-
isSource: false,
3882-
original: {
3883-
type: "dimension",
3884-
value: "{border-width.2}"
3885-
},
3886-
name: "--ds-border-width-highlight",
3887-
attributes: {},
3888-
path: [
3889-
"border-width",
3890-
"highlight"
3891-
]
38923860
}
38933861
]
38943862

apps/storefront/tokens/altinn/light.ts

-32
Original file line numberDiff line numberDiff line change
@@ -3857,38 +3857,6 @@ export const dimension = [
38573857
"sizing",
38583858
"30"
38593859
]
3860-
},
3861-
{
3862-
type: "dimension",
3863-
value: "1px",
3864-
filePath: "../../design-tokens/semantic/style.json",
3865-
isSource: false,
3866-
original: {
3867-
type: "dimension",
3868-
value: "{border-width.1}"
3869-
},
3870-
name: "--ds-border-width-default",
3871-
attributes: {},
3872-
path: [
3873-
"border-width",
3874-
"default"
3875-
]
3876-
},
3877-
{
3878-
type: "dimension",
3879-
value: "2px",
3880-
filePath: "../../design-tokens/semantic/style.json",
3881-
isSource: false,
3882-
original: {
3883-
type: "dimension",
3884-
value: "{border-width.2}"
3885-
},
3886-
name: "--ds-border-width-highlight",
3887-
attributes: {},
3888-
path: [
3889-
"border-width",
3890-
"highlight"
3891-
]
38923860
}
38933861
]
38943862

0 commit comments

Comments
 (0)