Skip to content
Open
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
4 changes: 3 additions & 1 deletion src/foundation/utility/cl-base.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@
.sb-spacing-wrapper {
display: flex;
flex-flow: row nowrap;
background-color: #d606c1;
padding: var(--spacing-md);
border-radius: var(--radius-sm);
background-color: var(--color-grays-100);
}

.sb-cover {
Expand Down
22 changes: 22 additions & 0 deletions src/tokens/spacing/spacing-tokens.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import type { Meta, StoryObj } from '@storybook/react';
import tokens from '../transformed.tokens.json';
import SpacingTokens from './spacing-tokens';

const meta = {
title: 'Tokens/Spacing',
component: SpacingTokens,
} satisfies Meta<typeof SpacingTokens>;

export default meta;
type Story = StoryObj<typeof meta>;

export const Spacing: Story = {
args: {
spacing: Object.keys(tokens['spacing']).map((name) => {
return {
name,
value: tokens['spacing'][name as keyof typeof tokens['spacing']].value,
};
}),
},
};
57 changes: 57 additions & 0 deletions src/tokens/spacing/spacing-tokens.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
// Utility classes for token display components.
import clBase from '../../foundation/utility/cl-base.module.scss';

type SpacingTokensProps = {
spacing: {
name: string;
value: number;
}[];
};

export default function SpacingTokens({
spacing,
}: SpacingTokensProps) {
return (
<div>
<h1 className={clBase['sb-title']}>Spacing Tokens</h1>
<ul className={clBase['sb-list']}>
{spacing.map((item) => (
<li className={clBase['sb-list__item']} key={item.name}>
<span
className={clBase['sb-list__label']}
style={{ width: '100px' }}>
{item.name}
</span>
<span className={clBase['sb-list__value']}>{item.value}px</span>
<span className={clBase['sb-list__custom-property']}>
<code
className={clBase['sb-custom-property-name']}
style={{ width: '272px' }}>
var(--spacing-{item.name})
</code>
</span>
<ul
className={clBase['sb-spacing-wrapper']}
style={{
gap: `${item.value}px`,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an improvement over the original UI Kit version, but let's use the variable instead of the hardcoded value:

Suggested change
gap: `${item.value}px`,
gap: `var(--spacing-${item.name})`,

}}
>
{Array(4).fill(1).map((_, index) => (
<li
key={index}
className={clBase['sb-list__visualization']}
style={{
width: '50px',
height: '50px',
backgroundColor: 'var(--colors-sb-visualization)',
}}
></li>
))}
</ul>
</li>
))}
</ul>
</div>
);
}