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

4KDST-12: Component Library / Tokens / Breakpoints #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
22 changes: 22 additions & 0 deletions src/tokens/breakpoints/breakpoints-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 BreakpointTokens from './breakpoints-tokens';

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

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

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

type BreakpointTokensProps = {
breakpoint: {
name: string;
value: number;
}[];
};

export default function BreakpointTokens({
breakpoint,
}: BreakpointTokensProps) {
return (
<div>
<h1 className={clBase['sb-title']}>Breakpoint Tokens</h1>
<ul className={clBase['sb-list']} style={{overflow: 'scroll'}}>
{breakpoint.map((item) => (
<li className={clBase['sb-list__item']} style={{minWidth: 'max-content'}} key={item.name}>
<span className={clBase['sb-list__label']}>{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']}>var(--breakpoint-{item.name})</code>
</span>
<span className={clBase['sb-list__visualization']}
style={{
width: `${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, let's use the variable instead of the hardcoded value:

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

height: '25px',
background: 'var(--colors-sb-visualization)',
display: 'block',
}}></span>
</li>
))}
</ul>
</div>
);
}