@crystallize/design-system 1.3.1 → 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.
Files changed (146) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/dist/index.css +1813 -0
  3. package/dist/index.d.ts +345 -2
  4. package/dist/index.js +2631 -5
  5. package/dist/index.mjs +2574 -0
  6. package/package.json +90 -78
  7. package/readme.md +9 -0
  8. package/src/Tokens.stories.tsx +18 -0
  9. package/src/action-menu/ActionMenu.stories.tsx +25 -0
  10. package/src/action-menu/action-item.tsx +16 -0
  11. package/src/action-menu/action-menu.css +38 -0
  12. package/src/action-menu/action-menu.tsx +25 -0
  13. package/src/action-menu/index.tsx +3 -0
  14. package/src/avatar/Avatar.stories.tsx +20 -0
  15. package/src/avatar/avatar.css +23 -0
  16. package/src/avatar/avatar.tsx +34 -0
  17. package/src/avatar/get-initials.ts +5 -0
  18. package/src/avatar/index.ts +1 -0
  19. package/src/button/Button.stories.tsx +105 -0
  20. package/src/button/button.css +116 -0
  21. package/src/button/button.tsx +136 -0
  22. package/src/button/index.ts +3 -0
  23. package/src/card/card.css +7 -0
  24. package/src/card/card.stories.tsx +24 -0
  25. package/src/card/card.tsx +27 -0
  26. package/src/card/index.ts +3 -0
  27. package/src/checkbox/checkbox.css +30 -0
  28. package/src/checkbox/checkbox.stories.tsx +62 -0
  29. package/src/checkbox/checkbox.test.tsx +16 -0
  30. package/src/checkbox/checkbox.tsx +28 -0
  31. package/src/checkbox/index.ts +1 -0
  32. package/src/colors/Colors.stories.tsx +127 -0
  33. package/src/colors/color-defaults.json +15 -0
  34. package/src/colors/color-pairing.json +12 -0
  35. package/src/colors/colors.json +158 -0
  36. package/src/colors/index.ts +1 -0
  37. package/src/colors/old-to-new.txt +19 -0
  38. package/src/colors/types.ts +29 -0
  39. package/src/dialog/Dialog.stories.tsx +168 -0
  40. package/src/dialog/Dialog.test.tsx +25 -0
  41. package/src/dialog/config.tsx +139 -0
  42. package/src/dialog/confirm-dialog.tsx +70 -0
  43. package/src/dialog/destroyFns.ts +1 -0
  44. package/src/dialog/dialog.css +27 -0
  45. package/src/dialog/dialog.tsx +94 -0
  46. package/src/dialog/index.tsx +40 -0
  47. package/src/dialog/types.ts +70 -0
  48. package/src/dropdown-menu/DropdownMenu.stories.tsx +38 -0
  49. package/src/dropdown-menu/dropdown-menu-item.tsx +15 -0
  50. package/src/dropdown-menu/dropdown-menu-label.tsx +10 -0
  51. package/src/dropdown-menu/dropdown-menu-root.tsx +33 -0
  52. package/src/dropdown-menu/dropdown-menu.css +20 -0
  53. package/src/dropdown-menu/index.ts +11 -0
  54. package/src/icon-button/IconButton.stories.tsx +45 -0
  55. package/src/icon-button/icon-button.css +48 -0
  56. package/src/icon-button/icon-button.tsx +39 -0
  57. package/src/icon-button/index.ts +3 -0
  58. package/src/iconography/Icon.stories.tsx +47 -0
  59. package/src/iconography/add.tsx +30 -0
  60. package/src/iconography/arrow.tsx +15 -0
  61. package/src/iconography/atom.tsx +59 -0
  62. package/src/iconography/cancel.tsx +26 -0
  63. package/src/iconography/catalogue.tsx +26 -0
  64. package/src/iconography/copy.tsx +24 -0
  65. package/src/iconography/crystal.tsx +93 -0
  66. package/src/iconography/customers.tsx +38 -0
  67. package/src/iconography/edit.tsx +30 -0
  68. package/src/iconography/error.tsx +40 -0
  69. package/src/iconography/fulfilment.tsx +58 -0
  70. package/src/iconography/glasses.tsx +62 -0
  71. package/src/iconography/graphQL.tsx +90 -0
  72. package/src/iconography/grid.tsx +84 -0
  73. package/src/iconography/hooks.tsx +26 -0
  74. package/src/iconography/image.tsx +47 -0
  75. package/src/iconography/index.ts +63 -0
  76. package/src/iconography/info.tsx +41 -0
  77. package/src/iconography/key.tsx +19 -0
  78. package/src/iconography/language.tsx +38 -0
  79. package/src/iconography/nail-polish.tsx +84 -0
  80. package/src/iconography/order.tsx +38 -0
  81. package/src/iconography/particle.tsx +88 -0
  82. package/src/iconography/percentage.tsx +44 -0
  83. package/src/iconography/price-tag.tsx +40 -0
  84. package/src/iconography/shapes.tsx +48 -0
  85. package/src/iconography/subscription.tsx +34 -0
  86. package/src/iconography/topics.tsx +58 -0
  87. package/src/iconography/triangle.tsx +27 -0
  88. package/src/iconography/usage.tsx +34 -0
  89. package/src/iconography/users.tsx +44 -0
  90. package/src/iconography/warning.tsx +51 -0
  91. package/src/index.css +14 -0
  92. package/src/index.ts +33 -0
  93. package/src/inline-radio/index.ts +1 -0
  94. package/src/inline-radio/inline-radio.css +36 -0
  95. package/src/inline-radio/inline-radio.stories.tsx +81 -0
  96. package/src/inline-radio/inline-radio.tsx +41 -0
  97. package/src/input/Input.stories.tsx +26 -0
  98. package/src/input/index.ts +1 -0
  99. package/src/input/input.css +7 -0
  100. package/src/input/input.tsx +20 -0
  101. package/src/input-with-label/InputWithLabel.stories.tsx +98 -0
  102. package/src/input-with-label/index.ts +3 -0
  103. package/src/input-with-label/input-with-label.css +35 -0
  104. package/src/input-with-label/input-with-label.tsx +59 -0
  105. package/src/label/index.ts +1 -0
  106. package/src/label/label.css +3 -0
  107. package/src/label/label.stories.tsx +19 -0
  108. package/src/label/label.tsx +13 -0
  109. package/src/progress/Progress.stories.tsx +26 -0
  110. package/src/progress/index.ts +1 -0
  111. package/src/progress/progress.css +7 -0
  112. package/src/progress/progress.tsx +17 -0
  113. package/src/radio/index.ts +1 -0
  114. package/src/radio/radio.css +20 -0
  115. package/src/radio/radio.stories.tsx +142 -0
  116. package/src/radio/radio.tsx +19 -0
  117. package/src/select/index.ts +1 -0
  118. package/src/select/select-item.tsx +18 -0
  119. package/src/select/select-root.tsx +50 -0
  120. package/src/select/select.css +44 -0
  121. package/src/select/select.stories.tsx +74 -0
  122. package/src/select/select.ts +9 -0
  123. package/src/slider/Slider.stories.tsx +54 -0
  124. package/src/slider/index.ts +1 -0
  125. package/src/slider/slider.css +27 -0
  126. package/src/slider/slider.tsx +20 -0
  127. package/src/spinner/Spinner.stories.tsx +19 -0
  128. package/src/spinner/index.tsx +48 -0
  129. package/src/spinner/spinner.css +11 -0
  130. package/src/tag/Tag.stories.tsx +32 -0
  131. package/src/tag/index.ts +1 -0
  132. package/src/tag/tag.css +7 -0
  133. package/src/tag/tag.tsx +27 -0
  134. package/src/vite-env.d.ts +1 -0
  135. package/tailwind.config.cjs +51 -0
  136. package/LICENSE +0 -21
  137. package/README.md +0 -35
  138. package/dist/components/Button.d.ts +0 -11
  139. package/dist/components/Typography.d.ts +0 -14
  140. package/dist/design-system.cjs.development.js +0 -164
  141. package/dist/design-system.cjs.development.js.map +0 -1
  142. package/dist/design-system.cjs.production.min.js +0 -2
  143. package/dist/design-system.cjs.production.min.js.map +0 -1
  144. package/dist/design-system.esm.js +0 -156
  145. package/dist/design-system.esm.js.map +0 -1
  146. package/dist/styles/theme.d.ts +0 -2
package/package.json CHANGED
@@ -1,88 +1,100 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.3.1",
4
- "license": "MIT",
5
- "main": "dist/index.js",
6
- "typings": "dist/index.d.ts",
7
- "files": [
8
- "dist"
9
- ],
10
- "engines": {
11
- "node": ">=12"
12
- },
13
- "scripts": {
14
- "start": "tsdx watch",
15
- "build": "tsdx build",
16
- "test": "tsdx test --passWithNoTests",
17
- "lint": "tsdx lint",
18
- "prepare": "tsdx build",
19
- "size": "size-limit",
20
- "analyze": "size-limit --why",
21
- "storybook": "start-storybook -p 6006",
22
- "build-storybook": "build-storybook"
3
+ "version": "1.3.2",
4
+ "types": "./dist/index.d.ts",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "publishConfig": {
8
+ "access": "public"
23
9
  },
24
- "peerDependencies": {
25
- "react": ">=16",
26
- "styled-components": "^5.2.3"
27
- },
28
- "husky": {
29
- "hooks": {
30
- "pre-commit": "tsdx lint"
10
+ "exports": {
11
+ ".": {
12
+ "require": "./dist/index.js",
13
+ "import": "./dist/index.mjs",
14
+ "types": "./dist/index.d.ts"
15
+ },
16
+ "./tailwind-config": "./tailwind.config.cjs",
17
+ "./styles.css": {
18
+ "import": "./dist/index.css",
19
+ "require": "./dist/index.css"
31
20
  }
32
21
  },
33
- "prettier": {
34
- "printWidth": 80,
35
- "semi": true,
36
- "singleQuote": true,
37
- "trailingComma": "es5"
22
+ "dependencies": {
23
+ "@radix-ui/react-checkbox": "1.0.1",
24
+ "@radix-ui/react-dialog": "1.0.2",
25
+ "@radix-ui/react-dropdown-menu": "2.0.1",
26
+ "@radix-ui/react-progress": "^1.0.1",
27
+ "@radix-ui/react-radio-group": "1.1.0",
28
+ "@radix-ui/react-select": "1.1.2",
29
+ "@radix-ui/react-slider": "^1.1.0",
30
+ "class-variance-authority": "^0.4.0",
31
+ "hex-rgb": "4.3.0",
32
+ "react": "17.0.1",
33
+ "react-dom": "17.0.1"
38
34
  },
39
- "author": "Deeksha Sharma",
40
- "module": "dist/design-system.esm.js",
41
- "private": false,
42
- "size-limit": [
43
- {
44
- "path": "dist/design-system.cjs.production.min.js",
45
- "limit": "10 KB"
46
- },
35
+ "devDependencies": {
36
+ "@mdx-js/react": "^2.2.1",
37
+ "@storybook/addon-actions": "7.0.0-beta.14",
38
+ "@storybook/addon-backgrounds": "7.0.0-beta.14",
39
+ "@storybook/addon-docs": "7.0.0-beta.14",
40
+ "@storybook/addon-essentials": "7.0.0-beta.14",
41
+ "@storybook/addon-highlight": "7.0.0-beta.14",
42
+ "@storybook/addon-interactions": "7.0.0-beta.14",
43
+ "@storybook/addon-links": "7.0.0-beta.14",
44
+ "@storybook/addon-measure": "7.0.0-beta.14",
45
+ "@storybook/addon-outline": "7.0.0-beta.14",
46
+ "@storybook/addons": "^6.5.15",
47
+ "@storybook/react": "7.0.0-beta.14",
48
+ "@storybook/react-vite": "7.0.0-beta.14",
49
+ "@storybook/testing-library": "^0.0.13",
50
+ "@storybook/theming": "7.0.0-beta.14",
51
+ "@types/react": "17.0.1",
52
+ "@types/react-dom": "17.0.1",
53
+ "@vitejs/plugin-react": "^3.0.1",
54
+ "@testing-library/jest-dom": "^5.16.4",
55
+ "@testing-library/react": "^12.0.0",
56
+ "@types/testing-library__jest-dom": "^5.14.5",
57
+ "concurrently": "^7.6.0",
58
+ "postcss": "^8.4.21",
59
+ "storybook": "7.0.0-beta.14",
60
+ "storybook-addon-designs": "^6.3.1",
61
+ "storybook-dark-mode": "^2.0.5",
62
+ "tailwindcss": "^3.2.4",
63
+ "tsconfig": "0.0.0",
64
+ "tsup": "^6.5.0",
65
+ "typescript": "^4.9.4",
66
+ "vite": "^4.1.1",
67
+ "vitest": "^0.28.4"
68
+ },
69
+ "keywords": [
70
+ "react",
71
+ "design system"
72
+ ],
73
+ "license": "MIT",
74
+ "contributors": [
47
75
  {
48
- "path": "dist/design-system.esm.js",
49
- "limit": "10 KB"
76
+ "email": "daniel.salvado@gmail.com",
77
+ "name": "Daniel Salvado",
78
+ "url": "https://www.danielsalvado.com/"
50
79
  }
51
80
  ],
52
- "devDependencies": {
53
- "@babel/core": "^7.13.14",
54
- "@size-limit/preset-small-lib": "^4.10.2",
55
- "@storybook/addon-essentials": "^6.2.3",
56
- "@storybook/addon-info": "^5.3.21",
57
- "@storybook/addon-links": "^6.2.3",
58
- "@storybook/addons": "^6.2.3",
59
- "@storybook/react": "^6.2.3",
60
- "@testing-library/jest-dom": "^5.11.10",
61
- "@testing-library/react": "^11.2.6",
62
- "@types/react": "^17.0.3",
63
- "@types/react-dom": "^17.0.3",
64
- "@types/styled-components": "^5.1.9",
65
- "@types/testing-library__jest-dom": "^5.9.5",
66
- "babel-loader": "^8.2.2",
67
- "chromatic": "^5.7.1",
68
- "husky": "^6.0.0",
69
- "react": "^17.0.2",
70
- "react-dom": "^17.0.2",
71
- "react-is": "^17.0.2",
72
- "size-limit": "^4.10.2",
73
- "tsdx": "^0.14.1",
74
- "tslib": "^2.2.0",
75
- "typescript": "^4.2.3",
76
- "styled-components": "^5.2.3"
77
- },
78
- "repository": {
79
- "type": "git",
80
- "url": "https://github.com/CrystallizeAPI/design-system"
81
- },
82
- "release": {
83
- "branches": [
84
- "main",
85
- "beta"
86
- ]
81
+ "files": [
82
+ "dist",
83
+ "src",
84
+ "CHANGELOG.md",
85
+ "readme.md",
86
+ "tailwind.config.cjs"
87
+ ],
88
+ "scripts": {
89
+ "build:storybook": "storybook build -s public",
90
+ "build:tw": "tailwindcss --content ./src/**/*.tsx,!./src/**/*.stories.tsx -c ./tailwind.config.cjs -i src/index.css -o dist/index.css --minify",
91
+ "build:tsup": "tsup src/index.ts --format esm,cjs --dts",
92
+ "build": "pnpm build:tw && pnpm build:tsup && pnpm build:storybook",
93
+ "dev:tw": "tailwindcss --content ./src/**/*.tsx,!./src/**/*.stories.tsx -c ./tailwind.config.cjs -i src/index.css -o dist/index.css --watch & tsup src/index.ts --format esm --dts --watch",
94
+ "dev:tsup": "tsup src/index.ts --format esm --dts --watch",
95
+ "dev:storybook": "storybook dev -p 6006 --no-open -s public",
96
+ "dev": "concurrently \"npm:dev:*\"",
97
+ "test": "vitest run src/",
98
+ "test:watch": "vitest src/"
87
99
  }
88
- }
100
+ }
package/readme.md ADDED
@@ -0,0 +1,9 @@
1
+ # @crystallize/design-system
2
+
3
+ Buttons, colors and all the other visual primitives from Crystallize
4
+
5
+ [Changelog](https://unpkg.com/@crystallize/design-system/CHANGELOG.md)
6
+
7
+ ## Documentation
8
+ [https://design-system.crystallize.com](https://design-system.crystallize.com)
9
+
@@ -0,0 +1,18 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { tokens } from '.';
3
+
4
+ function DisplayTokens() {
5
+ return <pre>{JSON.stringify(tokens, null, 2)}</pre>;
6
+ }
7
+
8
+ const meta: Meta<typeof DisplayTokens> = {
9
+ title: 'Tokens',
10
+ component: DisplayTokens,
11
+ argTypes: {},
12
+ };
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof DisplayTokens>;
17
+
18
+ export const Default: Story = {};
@@ -0,0 +1,25 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { ActionMenu } from '.';
4
+
5
+ const meta: Meta<typeof ActionMenu> = {
6
+ title: 'Components/ActionMenu',
7
+ component: ActionMenu,
8
+ argTypes: {},
9
+ };
10
+
11
+ export default meta;
12
+
13
+ type Story = StoryObj<typeof ActionMenu>;
14
+
15
+ export const Default: Story = {
16
+ args: {},
17
+ render: () => (
18
+ <ActionMenu>
19
+ <ActionMenu.Item onSelect={() => console.warn('Download')}>Download</ActionMenu.Item>
20
+ <ActionMenu.Item className="danger" onSelect={() => console.warn('Delete')}>
21
+ Delete
22
+ </ActionMenu.Item>
23
+ </ActionMenu>
24
+ ),
25
+ };
@@ -0,0 +1,16 @@
1
+ import { cx } from 'class-variance-authority';
2
+ import type { HTMLAttributes } from 'react';
3
+
4
+ import { DropdownMenu } from '../dropdown-menu';
5
+
6
+ type ItemProps = HTMLAttributes<HTMLLIElement> & {
7
+ onSelect?: () => void;
8
+ };
9
+
10
+ export function Item({ children, className, onSelect }: ItemProps) {
11
+ return (
12
+ <DropdownMenu.Item onClick={onSelect} className={cx(className, 'c-action-menu-item')}>
13
+ {children}
14
+ </DropdownMenu.Item>
15
+ );
16
+ }
@@ -0,0 +1,38 @@
1
+ .c-action-menu {
2
+ @apply flex h-8 w-8 shrink-0 rotate-0 cursor-pointer flex-col items-center justify-center gap-[2px] rounded-md border-none bg-transparent p-1 -outline-offset-1 transition;
3
+ &-dot {
4
+ @apply h-[4px] w-[4px] rounded-full bg-gray;
5
+ }
6
+ &[data-state='open'],
7
+ [aria-expanded='true'] {
8
+ @apply flex-row gap-[3px];
9
+ }
10
+ &:focus-visible {
11
+ @apply outline outline-1 outline-inherit;
12
+ outline-color: currentColor;
13
+ }
14
+
15
+ &:not(:disabled):hover {
16
+ @apply gap-[3px] bg-gray-100-800 outline outline-1 outline-purple-200-700;
17
+ }
18
+
19
+ &:not(:disabled):active {
20
+ @apply scale-95 bg-purple-100-800;
21
+ }
22
+ }
23
+
24
+ .c-action-menu-item {
25
+ @apply flex cursor-pointer items-center gap-2 py-2.5 px-5 font-sans text-sm font-medium text-gray;
26
+
27
+ &:hover {
28
+ @apply bg-gray-50-900;
29
+ }
30
+
31
+ &:focus {
32
+ @apply bg-gray-50-900 outline-none;
33
+ }
34
+
35
+ &.danger {
36
+ @apply text-pink-600-300;
37
+ }
38
+ }
@@ -0,0 +1,25 @@
1
+ import type { ReactNode } from 'react';
2
+
3
+ import { DropdownMenu } from '../dropdown-menu';
4
+
5
+ import { Item } from './action-item';
6
+
7
+ type ActionMenuProps = {
8
+ children: ReactNode;
9
+ tabIndex?: number;
10
+ };
11
+
12
+ export function ActionMenu({ children, tabIndex }: ActionMenuProps) {
13
+ return (
14
+ <DropdownMenu.Root content={children} alignContent="center">
15
+ <button tabIndex={tabIndex} type="button" className="c-action-menu" aria-label="more options">
16
+ <span className="sr-only">Open more options</span>
17
+ <span className="c-action-menu-dot"></span>
18
+ <span className="c-action-menu-dot"></span>
19
+ <span className="c-action-menu-dot"></span>
20
+ </button>
21
+ </DropdownMenu.Root>
22
+ );
23
+ }
24
+
25
+ ActionMenu.Item = Item;
@@ -0,0 +1,3 @@
1
+ import './action-menu.css';
2
+
3
+ export { ActionMenu } from './action-menu';
@@ -0,0 +1,20 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+
3
+ import { Avatar } from '.';
4
+
5
+ const meta: Meta<typeof Avatar> = {
6
+ title: 'Components/Avatar',
7
+ component: Avatar,
8
+ argTypes: {},
9
+ };
10
+
11
+ export default meta;
12
+
13
+ type Story = StoryObj<typeof Avatar>;
14
+
15
+ export const Default: Story = {
16
+ args: {
17
+ name: 'Crystallize Team',
18
+ size: 'md',
19
+ },
20
+ };
@@ -0,0 +1,23 @@
1
+ .c-avatar {
2
+ @apply flex items-center justify-center rounded-full border border-solid border-cyan-800-100 bg-cyan-200-700 text-cyan-800-100;
3
+ }
4
+
5
+ .c-avatar-initials {
6
+ @apply font-bold leading-none tracking-tight;
7
+ }
8
+
9
+ .c-avatar-md {
10
+ @apply h-7 w-7 text-xs;
11
+ }
12
+
13
+ .c-avatar-lg {
14
+ @apply h-9 w-9 text-sm;
15
+ }
16
+
17
+ .c-avatar-xl {
18
+ @apply h-12 w-12 text-base;
19
+ }
20
+
21
+ .c-avatar-2xl {
22
+ @apply h-16 w-16 text-xl;
23
+ }
@@ -0,0 +1,34 @@
1
+ import { forwardRef } from 'react';
2
+ import { cva, VariantProps } from 'class-variance-authority';
3
+
4
+ import { getInitials } from './get-initials';
5
+ import './avatar.css';
6
+
7
+ const avatarClassName = cva(['c-avatar'], {
8
+ variants: {
9
+ size: {
10
+ md: 'c-avatar-md',
11
+ lg: 'c-avatar-lg',
12
+ xl: 'c-avatar-xl',
13
+ '2xl': 'c-avatar-2xl',
14
+ },
15
+ },
16
+ defaultVariants: {
17
+ size: 'md',
18
+ },
19
+ });
20
+
21
+ type AvatarProps = React.ComponentPropsWithRef<'div'> &
22
+ VariantProps<typeof avatarClassName> & {
23
+ name: string;
24
+ };
25
+
26
+ export const Avatar = forwardRef<HTMLDivElement, AvatarProps>(({ name, size, className, ...delegated }, ref) => {
27
+ return (
28
+ <div ref={ref} {...delegated} title={name} className={avatarClassName({ size, className })}>
29
+ <span className="c-avatar-initials">{getInitials(name)}</span>
30
+ </div>
31
+ );
32
+ });
33
+
34
+ Avatar.displayName = 'Avatar';
@@ -0,0 +1,5 @@
1
+ export const getInitials = (name: string) => {
2
+ const [first, second] = name.split(' ');
3
+ const initials = `${first?.charAt(0) ?? ''}${second?.charAt(0) ?? ''}`;
4
+ return initials.toUpperCase();
5
+ };
@@ -0,0 +1 @@
1
+ export { Avatar } from './avatar';
@@ -0,0 +1,105 @@
1
+ import type { StoryObj, Meta } from '@storybook/react';
2
+ import { Button } from '.';
3
+
4
+ const meta: Meta<typeof Button> = {
5
+ title: 'Components/Button',
6
+ component: Button,
7
+ argTypes: {
8
+ variant: {
9
+ defaultValue: 'default',
10
+ },
11
+ intent: {
12
+ defaultValue: 'default',
13
+ },
14
+ size: {
15
+ defaultValue: 'sm',
16
+ },
17
+ },
18
+ };
19
+
20
+ export default meta;
21
+ type Story = StoryObj<typeof Button>;
22
+
23
+ const variants = ['default', 'elevate'] as const;
24
+ const intent = ['default', 'action', 'danger'] as const;
25
+ const sizes = ['xs', 'sm', 'md', 'lg'] as const;
26
+
27
+ export const AllButton: Story = {
28
+ name: 'All Buttons',
29
+ render: () => {
30
+ return (
31
+ <div>
32
+ <div className="grid grid-cols-6 justify-items-center gap-6">
33
+ {sizes.map(size =>
34
+ variants.map(variant =>
35
+ intent.map(intent => (
36
+ <Button variant={variant} size={size} intent={intent} status="loading">
37
+ Button
38
+ </Button>
39
+ )),
40
+ ),
41
+ )}
42
+ </div>
43
+ </div>
44
+ );
45
+ },
46
+ };
47
+
48
+ export const Default: Story = {
49
+ args: {
50
+ intent: 'default',
51
+ variant: 'default',
52
+ children: 'Button',
53
+ },
54
+ };
55
+
56
+ export const Elevate: Story = {
57
+ args: {
58
+ intent: 'default',
59
+ variant: 'elevate',
60
+ children: 'Button',
61
+ },
62
+ };
63
+
64
+ export const Action: Story = {
65
+ args: {
66
+ intent: 'action',
67
+ variant: 'default',
68
+ children: 'Button',
69
+ },
70
+ };
71
+
72
+ export const Danger: Story = {
73
+ args: {
74
+ intent: 'danger',
75
+ variant: 'default',
76
+ children: 'Button',
77
+ },
78
+ };
79
+
80
+ export const Prepend: Story = {
81
+ args: {
82
+ intent: 'default',
83
+ variant: 'default',
84
+ children: 'Button',
85
+ prepend: '🤓',
86
+ },
87
+ };
88
+
89
+ export const Append: Story = {
90
+ args: {
91
+ intent: 'default',
92
+ variant: 'default',
93
+ children: 'Button',
94
+ append: '🤓',
95
+ },
96
+ };
97
+
98
+ export const IsLoading: Story = {
99
+ args: {
100
+ intent: 'default',
101
+ variant: 'default',
102
+ children: 'Button',
103
+ status: 'loading',
104
+ },
105
+ };
@@ -0,0 +1,116 @@
1
+ .c-btn {
2
+ @apply inline-grid cursor-pointer grid-flow-col items-center gap-2 whitespace-nowrap rounded border-none bg-transparent font-sans font-semibold text-gray no-underline -outline-offset-1;
3
+
4
+ &:focus-visible {
5
+ @apply outline outline-1 outline-inherit;
6
+ outline-color: currentColor;
7
+ }
8
+
9
+ &:disabled {
10
+ @apply cursor-default text-gray-300-600;
11
+ }
12
+
13
+ &__prepend,
14
+ &__append {
15
+ @apply flex items-center;
16
+ }
17
+
18
+ &__prepend {
19
+ @apply -ml-2;
20
+ }
21
+ &__append {
22
+ @apply -mr-2;
23
+ }
24
+
25
+ &__loading-spinner {
26
+ @apply absolute left-1 flex items-center justify-center;
27
+ }
28
+ }
29
+
30
+ .c-btn {
31
+ &,
32
+ .c-btn__loading-spinner {
33
+ @apply bg-purple-50-900;
34
+ }
35
+
36
+ &:not(:disabled):hover {
37
+ @apply outline outline-1 outline-purple-200-700;
38
+ }
39
+
40
+ &:not(:disabled):active {
41
+ @apply bg-purple-100-800;
42
+ }
43
+ }
44
+
45
+ .c-btn-loading {
46
+ @apply relative;
47
+
48
+ .c-btn__prepend,
49
+ .c-btn__append {
50
+ @apply opacity-0 transition-opacity;
51
+ }
52
+ }
53
+
54
+ .c-btn-elevate {
55
+ @apply shadow;
56
+
57
+ &,
58
+ .c-btn__loading-spinner {
59
+ @apply bg-elevate;
60
+ }
61
+
62
+ &:not(:disabled):hover {
63
+ @apply outline-gray-100-800;
64
+ }
65
+
66
+ &:not(:disabled):active {
67
+ @apply bg-purple-50-900;
68
+ }
69
+ }
70
+
71
+ .c-btn-action {
72
+ &,
73
+ .c-btn__loading-spinner {
74
+ @apply bg-cyan-100-800;
75
+ }
76
+
77
+ &:not(:disabled):hover {
78
+ @apply outline outline-1 outline-cyan-300-600;
79
+ }
80
+
81
+ &:not(:disabled):active {
82
+ @apply bg-cyan-200-700;
83
+ }
84
+ }
85
+
86
+ .c-btn-danger {
87
+ @apply text-pink-600-300;
88
+
89
+ &:not(:disabled):hover {
90
+ @apply outline-pink-300-600;
91
+ }
92
+ }
93
+
94
+ .c-btn-xs {
95
+ @apply h-6 py-2 px-4;
96
+
97
+ .c-btn__loading-spinner {
98
+ @apply left-[3px];
99
+ }
100
+ }
101
+
102
+ .c-btn-sm {
103
+ @apply h-9 px-6 text-sm;
104
+ }
105
+
106
+ .c-btn-md {
107
+ @apply h-11 px-8 text-base;
108
+ }
109
+
110
+ .c-btn-lg {
111
+ @apply h-14 px-10 text-lg;
112
+
113
+ .c-btn__loading-spinner {
114
+ @apply left-2;
115
+ }
116
+ }