@crystallize/design-system 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +106 -0
- package/dist/index.css +1813 -0
- package/dist/index.d.ts +345 -2
- package/dist/index.js +2631 -5
- package/dist/index.mjs +2574 -0
- package/package.json +90 -78
- package/readme.md +9 -0
- package/src/Tokens.stories.tsx +18 -0
- package/src/action-menu/ActionMenu.stories.tsx +25 -0
- package/src/action-menu/action-item.tsx +16 -0
- package/src/action-menu/action-menu.css +38 -0
- package/src/action-menu/action-menu.tsx +25 -0
- package/src/action-menu/index.tsx +3 -0
- package/src/avatar/Avatar.stories.tsx +20 -0
- package/src/avatar/avatar.css +23 -0
- package/src/avatar/avatar.tsx +34 -0
- package/src/avatar/get-initials.ts +5 -0
- package/src/avatar/index.ts +1 -0
- package/src/button/Button.stories.tsx +105 -0
- package/src/button/button.css +116 -0
- package/src/button/button.tsx +136 -0
- package/src/button/index.ts +3 -0
- package/src/card/card.css +7 -0
- package/src/card/card.stories.tsx +24 -0
- package/src/card/card.tsx +27 -0
- package/src/card/index.ts +3 -0
- package/src/checkbox/checkbox.css +30 -0
- package/src/checkbox/checkbox.stories.tsx +62 -0
- package/src/checkbox/checkbox.test.tsx +16 -0
- package/src/checkbox/checkbox.tsx +28 -0
- package/src/checkbox/index.ts +1 -0
- package/src/colors/Colors.stories.tsx +127 -0
- package/src/colors/color-defaults.json +15 -0
- package/src/colors/color-pairing.json +12 -0
- package/src/colors/colors.json +158 -0
- package/src/colors/index.ts +1 -0
- package/src/colors/old-to-new.txt +19 -0
- package/src/colors/types.ts +29 -0
- package/src/dialog/Dialog.stories.tsx +168 -0
- package/src/dialog/Dialog.test.tsx +25 -0
- package/src/dialog/config.tsx +139 -0
- package/src/dialog/confirm-dialog.tsx +70 -0
- package/src/dialog/destroyFns.ts +1 -0
- package/src/dialog/dialog.css +27 -0
- package/src/dialog/dialog.tsx +94 -0
- package/src/dialog/index.tsx +40 -0
- package/src/dialog/types.ts +70 -0
- package/src/dropdown-menu/DropdownMenu.stories.tsx +38 -0
- package/src/dropdown-menu/dropdown-menu-item.tsx +15 -0
- package/src/dropdown-menu/dropdown-menu-label.tsx +10 -0
- package/src/dropdown-menu/dropdown-menu-root.tsx +33 -0
- package/src/dropdown-menu/dropdown-menu.css +20 -0
- package/src/dropdown-menu/index.ts +11 -0
- package/src/icon-button/IconButton.stories.tsx +45 -0
- package/src/icon-button/icon-button.css +48 -0
- package/src/icon-button/icon-button.tsx +39 -0
- package/src/icon-button/index.ts +3 -0
- package/src/iconography/Icon.stories.tsx +47 -0
- package/src/iconography/add.tsx +30 -0
- package/src/iconography/arrow.tsx +15 -0
- package/src/iconography/atom.tsx +59 -0
- package/src/iconography/cancel.tsx +26 -0
- package/src/iconography/catalogue.tsx +26 -0
- package/src/iconography/copy.tsx +24 -0
- package/src/iconography/crystal.tsx +93 -0
- package/src/iconography/customers.tsx +38 -0
- package/src/iconography/edit.tsx +30 -0
- package/src/iconography/error.tsx +40 -0
- package/src/iconography/fulfilment.tsx +58 -0
- package/src/iconography/glasses.tsx +62 -0
- package/src/iconography/graphQL.tsx +90 -0
- package/src/iconography/grid.tsx +84 -0
- package/src/iconography/hooks.tsx +26 -0
- package/src/iconography/image.tsx +47 -0
- package/src/iconography/index.ts +63 -0
- package/src/iconography/info.tsx +41 -0
- package/src/iconography/key.tsx +19 -0
- package/src/iconography/language.tsx +38 -0
- package/src/iconography/nail-polish.tsx +84 -0
- package/src/iconography/order.tsx +38 -0
- package/src/iconography/particle.tsx +88 -0
- package/src/iconography/percentage.tsx +44 -0
- package/src/iconography/price-tag.tsx +40 -0
- package/src/iconography/shapes.tsx +48 -0
- package/src/iconography/subscription.tsx +34 -0
- package/src/iconography/topics.tsx +58 -0
- package/src/iconography/triangle.tsx +27 -0
- package/src/iconography/usage.tsx +34 -0
- package/src/iconography/users.tsx +44 -0
- package/src/iconography/warning.tsx +51 -0
- package/src/index.css +14 -0
- package/src/index.ts +33 -0
- package/src/inline-radio/index.ts +1 -0
- package/src/inline-radio/inline-radio.css +36 -0
- package/src/inline-radio/inline-radio.stories.tsx +81 -0
- package/src/inline-radio/inline-radio.tsx +41 -0
- package/src/input/Input.stories.tsx +26 -0
- package/src/input/index.ts +1 -0
- package/src/input/input.css +7 -0
- package/src/input/input.tsx +20 -0
- package/src/input-with-label/InputWithLabel.stories.tsx +98 -0
- package/src/input-with-label/index.ts +3 -0
- package/src/input-with-label/input-with-label.css +35 -0
- package/src/input-with-label/input-with-label.tsx +59 -0
- package/src/label/index.ts +1 -0
- package/src/label/label.css +3 -0
- package/src/label/label.stories.tsx +19 -0
- package/src/label/label.tsx +13 -0
- package/src/progress/Progress.stories.tsx +26 -0
- package/src/progress/index.ts +1 -0
- package/src/progress/progress.css +7 -0
- package/src/progress/progress.tsx +17 -0
- package/src/radio/index.ts +1 -0
- package/src/radio/radio.css +20 -0
- package/src/radio/radio.stories.tsx +142 -0
- package/src/radio/radio.tsx +19 -0
- package/src/select/index.ts +1 -0
- package/src/select/select-item.tsx +18 -0
- package/src/select/select-root.tsx +50 -0
- package/src/select/select.css +44 -0
- package/src/select/select.stories.tsx +74 -0
- package/src/select/select.ts +9 -0
- package/src/slider/Slider.stories.tsx +54 -0
- package/src/slider/index.ts +1 -0
- package/src/slider/slider.css +27 -0
- package/src/slider/slider.tsx +20 -0
- package/src/spinner/Spinner.stories.tsx +19 -0
- package/src/spinner/index.tsx +48 -0
- package/src/spinner/spinner.css +11 -0
- package/src/tag/Tag.stories.tsx +32 -0
- package/src/tag/index.ts +1 -0
- package/src/tag/tag.css +7 -0
- package/src/tag/tag.tsx +27 -0
- package/src/vite-env.d.ts +1 -0
- package/tailwind.config.cjs +51 -0
- package/LICENSE +0 -21
- package/README.md +0 -35
- package/dist/components/Button.d.ts +0 -11
- package/dist/components/Typography.d.ts +0 -14
- package/dist/design-system.cjs.development.js +0 -164
- package/dist/design-system.cjs.development.js.map +0 -1
- package/dist/design-system.cjs.production.min.js +0 -2
- package/dist/design-system.cjs.production.min.js.map +0 -1
- package/dist/design-system.esm.js +0 -156
- package/dist/design-system.esm.js.map +0 -1
- package/dist/styles/theme.d.ts +0 -2
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { ComponentPropsWithRef, forwardRef } from 'react';
|
|
2
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './button.css';
|
|
5
|
+
import { Spinner } from '../spinner';
|
|
6
|
+
|
|
7
|
+
export const buttonTokens = {
|
|
8
|
+
variant: {
|
|
9
|
+
default: 'c-btn',
|
|
10
|
+
elevate: 'c-btn-elevate',
|
|
11
|
+
},
|
|
12
|
+
intent: {
|
|
13
|
+
default: 'c-btn',
|
|
14
|
+
action: 'c-btn-action',
|
|
15
|
+
danger: 'c-btn-danger',
|
|
16
|
+
},
|
|
17
|
+
size: {
|
|
18
|
+
xs: 'c-btn-xs',
|
|
19
|
+
sm: 'c-btn-sm',
|
|
20
|
+
md: 'c-btn-md',
|
|
21
|
+
lg: 'c-btn-lg',
|
|
22
|
+
},
|
|
23
|
+
} as const;
|
|
24
|
+
|
|
25
|
+
type ButtonStylesProps = VariantProps<typeof buttonStyles>;
|
|
26
|
+
const buttonStyles = cva('c-btn', {
|
|
27
|
+
variants: {
|
|
28
|
+
intent: {
|
|
29
|
+
default: '',
|
|
30
|
+
action: '',
|
|
31
|
+
danger: '',
|
|
32
|
+
},
|
|
33
|
+
variant: {
|
|
34
|
+
default: '',
|
|
35
|
+
elevate: '',
|
|
36
|
+
},
|
|
37
|
+
status: {
|
|
38
|
+
loading: 'c-btn-loading',
|
|
39
|
+
},
|
|
40
|
+
size: {
|
|
41
|
+
xs: 'c-btn-xs',
|
|
42
|
+
sm: 'c-btn-sm',
|
|
43
|
+
md: 'c-btn-md',
|
|
44
|
+
lg: 'c-btn-lg',
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
compoundVariants: [
|
|
48
|
+
{
|
|
49
|
+
intent: 'default',
|
|
50
|
+
variant: 'elevate',
|
|
51
|
+
class: 'c-btn-elevate',
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
intent: 'action',
|
|
55
|
+
variant: 'default',
|
|
56
|
+
class: 'c-btn-action',
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
intent: 'danger',
|
|
60
|
+
variant: 'default',
|
|
61
|
+
class: 'c-btn-danger',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
intent: 'danger',
|
|
65
|
+
variant: 'elevate',
|
|
66
|
+
class: 'c-btn-danger c-btn-elevate',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
defaultVariants: {
|
|
70
|
+
intent: 'default',
|
|
71
|
+
variant: 'default',
|
|
72
|
+
size: 'sm',
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
export type ButtonProps = ComponentPropsWithRef<'button'> &
|
|
77
|
+
ButtonStylesProps & {
|
|
78
|
+
prepend?: React.ReactNode;
|
|
79
|
+
append?: React.ReactNode;
|
|
80
|
+
as?: React.ElementType;
|
|
81
|
+
// To support this button being used as a link
|
|
82
|
+
to?: string;
|
|
83
|
+
href?: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const spinnerSizeMap: Record<NonNullable<ButtonProps['size']>, number> = {
|
|
87
|
+
xs: 10,
|
|
88
|
+
sm: 12,
|
|
89
|
+
md: 14,
|
|
90
|
+
lg: 16,
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
94
|
+
(
|
|
95
|
+
{
|
|
96
|
+
children,
|
|
97
|
+
className,
|
|
98
|
+
type = 'button',
|
|
99
|
+
as: El = 'button',
|
|
100
|
+
size,
|
|
101
|
+
variant,
|
|
102
|
+
intent,
|
|
103
|
+
prepend,
|
|
104
|
+
append,
|
|
105
|
+
status,
|
|
106
|
+
...delegated
|
|
107
|
+
},
|
|
108
|
+
ref,
|
|
109
|
+
) => {
|
|
110
|
+
let isAnchor = false;
|
|
111
|
+
|
|
112
|
+
if ('to' in delegated || 'href' in delegated) {
|
|
113
|
+
isAnchor = true;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<El
|
|
118
|
+
ref={ref}
|
|
119
|
+
type={isAnchor ? undefined : type}
|
|
120
|
+
className={buttonStyles({ size, variant, intent, status, className })}
|
|
121
|
+
{...delegated}
|
|
122
|
+
>
|
|
123
|
+
{!prepend ? null : <span className="c-btn__prepend">{prepend}</span>}
|
|
124
|
+
{children}
|
|
125
|
+
{status !== 'loading' ? null : (
|
|
126
|
+
<span className="c-btn__loading-spinner">
|
|
127
|
+
<Spinner size={size ? spinnerSizeMap[size] : spinnerSizeMap.md} />
|
|
128
|
+
</span>
|
|
129
|
+
)}
|
|
130
|
+
{!append ? null : <span className="c-btn__append">{append}</span>}
|
|
131
|
+
</El>
|
|
132
|
+
);
|
|
133
|
+
},
|
|
134
|
+
);
|
|
135
|
+
|
|
136
|
+
Button.displayName = 'Button';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { StoryObj, Meta } from '@storybook/react';
|
|
2
|
+
import { Card } from '.';
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof Card> = {
|
|
5
|
+
title: 'Components/Card',
|
|
6
|
+
component: Card,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export default meta;
|
|
10
|
+
type Story = StoryObj<typeof Card>;
|
|
11
|
+
|
|
12
|
+
export const Default: Story = {
|
|
13
|
+
args: {
|
|
14
|
+
children: 'Hello World 🌍',
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const WhiteCard: Story = {
|
|
19
|
+
name: 'Elevated Card',
|
|
20
|
+
args: {
|
|
21
|
+
children: 'Hello World 🌍',
|
|
22
|
+
variant: 'elevate',
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HTMLAttributes } from 'react';
|
|
2
|
+
import { cva, VariantProps } from 'class-variance-authority';
|
|
3
|
+
|
|
4
|
+
import './card.css';
|
|
5
|
+
|
|
6
|
+
type CardStylesProps = VariantProps<typeof cardStyles>;
|
|
7
|
+
const cardStyles = cva('c-card', {
|
|
8
|
+
variants: {
|
|
9
|
+
variant: {
|
|
10
|
+
default: 'c-card',
|
|
11
|
+
elevate: 'c-card-elevate',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
defaultVariants: {
|
|
15
|
+
variant: 'default',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
type CardProps = HTMLAttributes<HTMLDivElement> & CardStylesProps;
|
|
20
|
+
|
|
21
|
+
export function Card({ children, className, variant, ...delegated }: CardProps) {
|
|
22
|
+
return (
|
|
23
|
+
<section className={cardStyles({ variant, className })} {...delegated}>
|
|
24
|
+
{children}
|
|
25
|
+
</section>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
.c-checkbox {
|
|
2
|
+
@apply flex h-3.5 w-3.5 cursor-pointer items-center justify-center rounded-sm border border-solid border-gray-100-800 bg-elevate;
|
|
3
|
+
|
|
4
|
+
&[aria-checked='true'] {
|
|
5
|
+
@apply border-cyan-700-200 bg-cyan-200-700;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
&:focus {
|
|
9
|
+
@apply outline-none ring-1 ring-cyan-700-200 ring-offset-1;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:disabled {
|
|
13
|
+
@apply cursor-default opacity-40;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&:readonly {
|
|
17
|
+
@apply cursor-default;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&__svg {
|
|
21
|
+
@apply h-2 w-2;
|
|
22
|
+
|
|
23
|
+
&-p1 {
|
|
24
|
+
@apply fill-cyan-700-200;
|
|
25
|
+
}
|
|
26
|
+
&-p2 {
|
|
27
|
+
@apply stroke-cyan-700-200;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { Label } from '../label';
|
|
5
|
+
import { Checkbox } from './checkbox';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof Checkbox> = {
|
|
8
|
+
title: 'Components/Checkbox',
|
|
9
|
+
component: Checkbox,
|
|
10
|
+
argTypes: {},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export default meta;
|
|
14
|
+
|
|
15
|
+
type Story = StoryObj<typeof Checkbox>;
|
|
16
|
+
|
|
17
|
+
export const Example: Story = {
|
|
18
|
+
render: () => {
|
|
19
|
+
return <Checkbox defaultChecked={true} />;
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const Uncontrolled: Story = {
|
|
24
|
+
render: () => {
|
|
25
|
+
return <Checkbox defaultChecked={true} />;
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const Controlled: Story = {
|
|
30
|
+
render: () => {
|
|
31
|
+
const [checked, setChecked] = useState(false);
|
|
32
|
+
return <Checkbox checked={checked} onCheckedChange={c => setChecked(Boolean(c))} />;
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export const WithLabel: Story = {
|
|
37
|
+
render: () => {
|
|
38
|
+
return (
|
|
39
|
+
<div className="flex items-center space-x-2">
|
|
40
|
+
<Checkbox id="with-label-c1" defaultChecked={true} />
|
|
41
|
+
<Label htmlFor="with-label-c1">Accept terms and conditions.</Label>
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const Disabled: Story = {
|
|
48
|
+
render: () => {
|
|
49
|
+
return (
|
|
50
|
+
<div className="space-y-4">
|
|
51
|
+
<div className="flex items-center space-x-2">
|
|
52
|
+
<Checkbox id="disabled-c1" defaultChecked={true} disabled />
|
|
53
|
+
<Label htmlFor="disabled-c1">Accept terms and conditions.</Label>
|
|
54
|
+
</div>
|
|
55
|
+
<div className="flex items-center space-x-2">
|
|
56
|
+
<Checkbox id="disabled-c2" defaultChecked={false} disabled />
|
|
57
|
+
<Label htmlFor="disabled-c2">Accept terms and conditions.</Label>
|
|
58
|
+
</div>
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
},
|
|
62
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
2
|
+
|
|
3
|
+
import { Checkbox } from '.';
|
|
4
|
+
|
|
5
|
+
describe('testing the checkbox', () => {
|
|
6
|
+
it('should trigger the onCheckedChange', () => {
|
|
7
|
+
const onChange = vi.fn();
|
|
8
|
+
|
|
9
|
+
render(<Checkbox onCheckedChange={onChange} defaultChecked={true} data-testid="chk" />);
|
|
10
|
+
|
|
11
|
+
fireEvent.click(screen.getByTestId('chk'));
|
|
12
|
+
|
|
13
|
+
expect(onChange).toBeCalledWith(false);
|
|
14
|
+
expect(onChange).toBeCalledTimes(1);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
|
|
2
|
+
import { ComponentProps, forwardRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import './checkbox.css';
|
|
5
|
+
|
|
6
|
+
export type CheckboxRef = HTMLButtonElement;
|
|
7
|
+
export type CheckboxProps = ComponentProps<typeof CheckboxPrimitive.Root>;
|
|
8
|
+
|
|
9
|
+
export const Checkbox = forwardRef<CheckboxRef, CheckboxProps>((props, ref) => {
|
|
10
|
+
return (
|
|
11
|
+
<CheckboxPrimitive.Root {...props} ref={ref} className="c-checkbox">
|
|
12
|
+
<CheckboxPrimitive.Indicator>
|
|
13
|
+
<svg viewBox="0 0 9 9" fill="none" className="c-checkbox__svg">
|
|
14
|
+
<path
|
|
15
|
+
className="c-checkbox__svg-p1"
|
|
16
|
+
d="M1.12 5.51a.559.559 0 01.832-.101l2.201 1.953-.427.624a.326.326 0 01-.486.06L1.21 6.245a.559.559 0 01-.09-.734z"
|
|
17
|
+
/>
|
|
18
|
+
<path
|
|
19
|
+
className="c-checkbox__svg-p2"
|
|
20
|
+
d="M7.883 1.087c.043.03.053.09.023.132L3.669 7.132l-.154-.105L7.754 1.11a.093.093 0 01.129-.023z"
|
|
21
|
+
/>
|
|
22
|
+
</svg>
|
|
23
|
+
</CheckboxPrimitive.Indicator>
|
|
24
|
+
</CheckboxPrimitive.Root>
|
|
25
|
+
);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
Checkbox.displayName = 'Checkbox';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './checkbox';
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react';
|
|
2
|
+
import { cx } from 'class-variance-authority';
|
|
3
|
+
import { useDarkMode } from 'storybook-dark-mode';
|
|
4
|
+
|
|
5
|
+
import rawColors from './colors.json';
|
|
6
|
+
import colorPairing from './color-pairing.json';
|
|
7
|
+
import colorDefaults from './color-defaults.json';
|
|
8
|
+
import type { Color, ColorName, Colors } from './types';
|
|
9
|
+
|
|
10
|
+
const meta: Meta = {
|
|
11
|
+
title: 'Colors',
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const colors: Colors = rawColors;
|
|
15
|
+
|
|
16
|
+
// The application for colors coming from Figma
|
|
17
|
+
const applications: {
|
|
18
|
+
colorName: ColorName;
|
|
19
|
+
shade: number; // Defaults to light mode
|
|
20
|
+
application: string;
|
|
21
|
+
}[] = [
|
|
22
|
+
{
|
|
23
|
+
colorName: 'pink',
|
|
24
|
+
shade: 300,
|
|
25
|
+
application: 'pricelist-bg',
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
colorName: 'pink',
|
|
29
|
+
shade: 600,
|
|
30
|
+
application: 'error',
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
colorName: 'gray',
|
|
34
|
+
shade: 50,
|
|
35
|
+
application: 'bg-gray',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
colorName: 'gray',
|
|
39
|
+
shade: 100,
|
|
40
|
+
application: 'gutter',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
colorName: 'gray',
|
|
44
|
+
shade: 500,
|
|
45
|
+
application: 'label',
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
colorName: 'gray',
|
|
49
|
+
shade: 700,
|
|
50
|
+
application: 'text, btn-text',
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
colorName: 'purple',
|
|
54
|
+
shade: 50,
|
|
55
|
+
application: 'btn-bg',
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
colorName: 'purple',
|
|
59
|
+
shade: 700,
|
|
60
|
+
application: 'pricelist-text',
|
|
61
|
+
},
|
|
62
|
+
];
|
|
63
|
+
|
|
64
|
+
export default meta;
|
|
65
|
+
|
|
66
|
+
function ColorItem({ colorName, color }: { colorName: ColorName; color: Color }) {
|
|
67
|
+
const shades = Object.keys(color);
|
|
68
|
+
|
|
69
|
+
const isDark = useDarkMode();
|
|
70
|
+
|
|
71
|
+
// @ts-expect-error
|
|
72
|
+
const applicationsForMode = !isDark ? applications : applications.map(a => ({ ...a, shade: colorPairing[a.shade] }));
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<div>
|
|
76
|
+
<h2 className="text-gray">{colorName}</h2>
|
|
77
|
+
<div className="grid grid-cols-10">
|
|
78
|
+
{shades.map(shade => {
|
|
79
|
+
// @ts-expect-error
|
|
80
|
+
const def = color[shade] as string;
|
|
81
|
+
|
|
82
|
+
const applicatedAt = applicationsForMode.filter(a => a.colorName === colorName && a.shade == shade);
|
|
83
|
+
const isDefault = colorDefaults[colorName] == shade;
|
|
84
|
+
|
|
85
|
+
const textColor = parseInt(shade) > 400 ? '#fff' : `rgb(var(--c-color-${colorName}-900))`;
|
|
86
|
+
|
|
87
|
+
return (
|
|
88
|
+
<div>
|
|
89
|
+
<div
|
|
90
|
+
style={{ background: def, color: textColor }}
|
|
91
|
+
className={cx('relative flex h-24 flex-1 items-center justify-center')}
|
|
92
|
+
>
|
|
93
|
+
{!isDefault ? null : (
|
|
94
|
+
<div
|
|
95
|
+
className="h-[8px] w-[8px] rounded"
|
|
96
|
+
style={{
|
|
97
|
+
backgroundColor: 'currentColor',
|
|
98
|
+
}}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
<div className="absolute top-2 left-2 right-2 text-center text-sm">{shade}</div>
|
|
102
|
+
</div>
|
|
103
|
+
<div className={cx('p-4 text-center text-sm text-gray')}>
|
|
104
|
+
{applicatedAt.map(a => (
|
|
105
|
+
<div key={a.application}>{a.application}</div>
|
|
106
|
+
))}
|
|
107
|
+
</div>
|
|
108
|
+
</div>
|
|
109
|
+
);
|
|
110
|
+
})}
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const colorNames = Object.keys(colors) as ColorName[];
|
|
117
|
+
|
|
118
|
+
export const Default: StoryObj = {
|
|
119
|
+
args: {},
|
|
120
|
+
render: () => (
|
|
121
|
+
<div>
|
|
122
|
+
{colorNames.map(colorName => (
|
|
123
|
+
<ColorItem key={colorName} colorName={colorName} color={colors[colorName]} />
|
|
124
|
+
))}
|
|
125
|
+
</div>
|
|
126
|
+
),
|
|
127
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cyan": "200",
|
|
3
|
+
"pink": "300",
|
|
4
|
+
"gray": "700",
|
|
5
|
+
"purple": "50",
|
|
6
|
+
"green": "400",
|
|
7
|
+
"orange": "200",
|
|
8
|
+
"s-red": "400",
|
|
9
|
+
"s-orange": "300",
|
|
10
|
+
"s-yellow": "200",
|
|
11
|
+
"s-green": "300",
|
|
12
|
+
"s-blue": "400",
|
|
13
|
+
"s-purple": "400",
|
|
14
|
+
"s-pink": "300"
|
|
15
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cyan": {
|
|
3
|
+
"50": "#eefdfc",
|
|
4
|
+
"100": "#bff6f8",
|
|
5
|
+
"200": "#acf1f5",
|
|
6
|
+
"300": "#73e5ed",
|
|
7
|
+
"400": "#33d0dd",
|
|
8
|
+
"500": "#17b3c3",
|
|
9
|
+
"600": "#1690a4",
|
|
10
|
+
"700": "#197385",
|
|
11
|
+
"800": "#1d5e6d",
|
|
12
|
+
"900": "#1c4e5d"
|
|
13
|
+
},
|
|
14
|
+
"pink": {
|
|
15
|
+
"50": "#fef1f9",
|
|
16
|
+
"100": "#fee5f4",
|
|
17
|
+
"200": "#ffccec",
|
|
18
|
+
"300": "#ffa1db",
|
|
19
|
+
"400": "#ff66c0",
|
|
20
|
+
"500": "#fb39a4",
|
|
21
|
+
"600": "#eb1782",
|
|
22
|
+
"700": "#cd0966",
|
|
23
|
+
"800": "#a90b54",
|
|
24
|
+
"900": "#8d0e49"
|
|
25
|
+
},
|
|
26
|
+
"gray": {
|
|
27
|
+
"50": "#f5f5f6",
|
|
28
|
+
"100": "#e4e5e9",
|
|
29
|
+
"200": "#cccfd5",
|
|
30
|
+
"300": "#a9aeb7",
|
|
31
|
+
"400": "#7e8592",
|
|
32
|
+
"500": "#626778",
|
|
33
|
+
"600": "#545866",
|
|
34
|
+
"700": "#4c4f5a",
|
|
35
|
+
"800": "#40424a",
|
|
36
|
+
"900": "#393a40"
|
|
37
|
+
},
|
|
38
|
+
"purple": {
|
|
39
|
+
"50": "#f7f6f9",
|
|
40
|
+
"100": "#eeecf2",
|
|
41
|
+
"200": "#d8d5e2",
|
|
42
|
+
"300": "#b6b0c9",
|
|
43
|
+
"400": "#8e85ab",
|
|
44
|
+
"500": "#706691",
|
|
45
|
+
"600": "#5b5178",
|
|
46
|
+
"700": "#4b4262",
|
|
47
|
+
"800": "#403953",
|
|
48
|
+
"900": "#393347"
|
|
49
|
+
},
|
|
50
|
+
"green": {
|
|
51
|
+
"50": "#f3f8f8",
|
|
52
|
+
"100": "#dfebee",
|
|
53
|
+
"200": "#c3dade",
|
|
54
|
+
"300": "#9abfc6",
|
|
55
|
+
"400": "#699ca7",
|
|
56
|
+
"500": "#528693",
|
|
57
|
+
"600": "#436a77",
|
|
58
|
+
"700": "#3b5863",
|
|
59
|
+
"800": "#374b53",
|
|
60
|
+
"900": "#314148"
|
|
61
|
+
},
|
|
62
|
+
"orange": {
|
|
63
|
+
"50": "#fff9eb",
|
|
64
|
+
"100": "#ffedc6",
|
|
65
|
+
"200": "#ffde99",
|
|
66
|
+
"300": "#ffbf4a",
|
|
67
|
+
"400": "#ffa520",
|
|
68
|
+
"500": "#f98107",
|
|
69
|
+
"600": "#dd5c02",
|
|
70
|
+
"700": "#b73d06",
|
|
71
|
+
"800": "#942e0c",
|
|
72
|
+
"900": "#7a270d"
|
|
73
|
+
},
|
|
74
|
+
"s-red": {
|
|
75
|
+
"50": "#fef2f2",
|
|
76
|
+
"100": "#ffe1e1",
|
|
77
|
+
"200": "#ffc8c8",
|
|
78
|
+
"300": "#ffadad",
|
|
79
|
+
"400": "#fd6c6c",
|
|
80
|
+
"500": "#f53e3e",
|
|
81
|
+
"600": "#e22020",
|
|
82
|
+
"700": "#be1717",
|
|
83
|
+
"800": "#9d1717",
|
|
84
|
+
"900": "#821a1a"
|
|
85
|
+
},
|
|
86
|
+
"s-orange": {
|
|
87
|
+
"50": "#fff7ed",
|
|
88
|
+
"100": "#ffedd5",
|
|
89
|
+
"200": "#ffd6a5",
|
|
90
|
+
"300": "#ffbb72",
|
|
91
|
+
"400": "#fd943a",
|
|
92
|
+
"500": "#fc7513",
|
|
93
|
+
"600": "#ed5909",
|
|
94
|
+
"700": "#c4420a",
|
|
95
|
+
"800": "#9c3410",
|
|
96
|
+
"900": "#7d2d11"
|
|
97
|
+
},
|
|
98
|
+
"s-yellow": {
|
|
99
|
+
"50": "#fefee8",
|
|
100
|
+
"100": "#fdffb6",
|
|
101
|
+
"200": "#fffe88",
|
|
102
|
+
"300": "#fff744",
|
|
103
|
+
"400": "#fee911",
|
|
104
|
+
"500": "#eecf04",
|
|
105
|
+
"600": "#cda201",
|
|
106
|
+
"700": "#a47404",
|
|
107
|
+
"800": "#875b0c",
|
|
108
|
+
"900": "#734a10"
|
|
109
|
+
},
|
|
110
|
+
"s-green": {
|
|
111
|
+
"50": "#f2ffee",
|
|
112
|
+
"100": "#deffd8",
|
|
113
|
+
"200": "#caffbf",
|
|
114
|
+
"300": "#8dfd78",
|
|
115
|
+
"400": "#53f236",
|
|
116
|
+
"500": "#2cdb0c",
|
|
117
|
+
"600": "#1eb603",
|
|
118
|
+
"700": "#1b8e07",
|
|
119
|
+
"800": "#1a700b",
|
|
120
|
+
"900": "#165b0c"
|
|
121
|
+
},
|
|
122
|
+
"s-blue": {
|
|
123
|
+
"50": "#eff5ff",
|
|
124
|
+
"100": "#dae7ff",
|
|
125
|
+
"200": "#bed5ff",
|
|
126
|
+
"300": "#a0c4ff",
|
|
127
|
+
"400": "#5d96fd",
|
|
128
|
+
"500": "#376ffa",
|
|
129
|
+
"600": "#214fef",
|
|
130
|
+
"700": "#193adc",
|
|
131
|
+
"800": "#1b31b2",
|
|
132
|
+
"900": "#1c2f8c"
|
|
133
|
+
},
|
|
134
|
+
"s-purple": {
|
|
135
|
+
"50": "#f4f3ff",
|
|
136
|
+
"100": "#ebe8ff",
|
|
137
|
+
"200": "#d9d5ff",
|
|
138
|
+
"300": "#bdb2ff",
|
|
139
|
+
"400": "#9d88fd",
|
|
140
|
+
"500": "#7e58fa",
|
|
141
|
+
"600": "#6f35f2",
|
|
142
|
+
"700": "#6023de",
|
|
143
|
+
"800": "#501dba",
|
|
144
|
+
"900": "#431a98"
|
|
145
|
+
},
|
|
146
|
+
"s-pink": {
|
|
147
|
+
"50": "#fff4ff",
|
|
148
|
+
"100": "#ffe7ff",
|
|
149
|
+
"200": "#ffc6ff",
|
|
150
|
+
"300": "#fea9fa",
|
|
151
|
+
"400": "#fc76f4",
|
|
152
|
+
"500": "#f342e7",
|
|
153
|
+
"600": "#d722c8",
|
|
154
|
+
"700": "#b219a1",
|
|
155
|
+
"800": "#921684",
|
|
156
|
+
"900": "#771869"
|
|
157
|
+
}
|
|
158
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as colors } from './colors.json';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
## Names
|
|
2
|
+
|
|
3
|
+
text-dark = dark (shade 700)
|
|
4
|
+
neptune = cyan (shade 100)
|
|
5
|
+
astroid = blue (shade 500)
|
|
6
|
+
cosmos = grey (shade 50)
|
|
7
|
+
glacier = green (shade 200)
|
|
8
|
+
jupiter = grey-two-do-we-need-this (shade 100)
|
|
9
|
+
error = pink (shade 600)
|
|
10
|
+
galaxy = blue-two-do-we-need-this (shade 800)
|
|
11
|
+
success = green-two-do-we-need-this (shade 200)
|
|
12
|
+
|
|
13
|
+
Duplicates:
|
|
14
|
+
density = text-dark
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Classes
|
|
18
|
+
|
|
19
|
+
text-dark-text = text-gray
|