@shipfox/react-ui 0.4.0 → 0.6.0
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/.storybook/main.ts +20 -10
- package/.storybook/preview.tsx +11 -0
- package/.storybook/vitest.setup.ts +4 -0
- package/.turbo/turbo-build.log +16 -3
- package/.turbo/turbo-check.log +2 -2
- package/.turbo/turbo-type.log +1 -1
- package/CHANGELOG.md +15 -0
- package/README.md +56 -1
- package/argos.config.ts +33 -0
- package/dist/build-css-entry.js +5 -0
- package/dist/build-css-entry.js.map +1 -0
- package/dist/components/button/button-link.d.ts +14 -0
- package/dist/components/button/button-link.d.ts.map +1 -0
- package/dist/components/button/button-link.js +63 -0
- package/dist/components/button/button-link.js.map +1 -0
- package/dist/components/button/button-link.stories.js +127 -0
- package/dist/components/button/button-link.stories.js.map +1 -0
- package/dist/components/button/button.d.ts +1 -1
- package/dist/components/button/button.d.ts.map +1 -1
- package/dist/components/button/button.js +7 -6
- package/dist/components/button/button.js.map +1 -1
- package/dist/components/button/button.stories.js +1 -13
- package/dist/components/button/button.stories.js.map +1 -1
- package/dist/components/button/icon-button.d.ts +14 -0
- package/dist/components/button/icon-button.d.ts.map +1 -0
- package/dist/components/button/icon-button.js +53 -0
- package/dist/components/button/icon-button.js.map +1 -0
- package/dist/components/button/icon-button.stories.js +254 -0
- package/dist/components/button/icon-button.stories.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.d.ts.map +1 -1
- package/dist/components/button/index.js +2 -0
- package/dist/components/button/index.js.map +1 -1
- package/dist/components/code-block/code-block-footer.d.ts.map +1 -1
- package/dist/components/code-block/code-block-footer.js +29 -15
- package/dist/components/code-block/code-block-footer.js.map +1 -1
- package/dist/components/code-block/code-content.d.ts.map +1 -1
- package/dist/components/code-block/code-content.js +2 -2
- package/dist/components/code-block/code-content.js.map +1 -1
- package/dist/components/dynamic-item/dynamic-item.stories.js +1 -1
- package/dist/components/dynamic-item/dynamic-item.stories.js.map +1 -1
- package/dist/components/icon/icon.d.ts +3 -0
- package/dist/components/icon/icon.d.ts.map +1 -1
- package/dist/components/icon/icon.js +5 -2
- package/dist/components/icon/icon.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/modal/index.d.ts +3 -0
- package/dist/components/modal/index.d.ts.map +1 -0
- package/dist/components/modal/index.js +3 -0
- package/dist/components/modal/index.js.map +1 -0
- package/dist/components/modal/modal.d.ts +37 -0
- package/dist/components/modal/modal.d.ts.map +1 -0
- package/dist/components/modal/modal.js +262 -0
- package/dist/components/modal/modal.js.map +1 -0
- package/dist/components/modal/modal.stories.js +497 -0
- package/dist/components/modal/modal.stories.js.map +1 -0
- package/dist/components/moving-border/index.d.ts +2 -0
- package/dist/components/moving-border/index.d.ts.map +1 -0
- package/dist/components/moving-border/index.js +3 -0
- package/dist/components/moving-border/index.js.map +1 -0
- package/dist/components/typography/text.d.ts.map +1 -1
- package/dist/components/typography/text.js +1 -1
- package/dist/components/typography/text.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useMediaQuery.d.ts +2 -0
- package/dist/hooks/useMediaQuery.d.ts.map +1 -0
- package/dist/hooks/useMediaQuery.js +74 -0
- package/dist/hooks/useMediaQuery.js.map +1 -0
- package/dist/onboarding/sign-in.stories.js +93 -0
- package/dist/onboarding/sign-in.stories.js.map +1 -0
- package/dist/styles.css +1 -0
- package/index.css +30 -4
- package/package.json +19 -7
- package/src/build-css-entry.ts +3 -0
- package/src/components/button/button-link.stories.tsx +86 -0
- package/src/components/button/button-link.tsx +76 -0
- package/src/components/button/button.stories.tsx +1 -7
- package/src/components/button/button.tsx +8 -6
- package/src/components/button/icon-button.stories.tsx +182 -0
- package/src/components/button/icon-button.tsx +69 -0
- package/src/components/button/index.ts +2 -0
- package/src/components/code-block/code-block-footer.tsx +37 -30
- package/src/components/code-block/code-content.tsx +5 -2
- package/src/components/dynamic-item/dynamic-item.stories.tsx +1 -1
- package/src/components/icon/icon.tsx +6 -0
- package/src/components/index.ts +1 -0
- package/src/components/modal/index.ts +23 -0
- package/src/components/modal/modal.stories.tsx +384 -0
- package/src/components/modal/modal.tsx +309 -0
- package/src/components/moving-border/index.ts +1 -0
- package/src/components/typography/text.tsx +9 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useMediaQuery.ts +87 -0
- package/src/onboarding/sign-in.stories.tsx +73 -0
- package/tsconfig.build.json +7 -1
- package/vite.css.config.ts +30 -0
- package/vitest.config.ts +30 -3
package/.storybook/main.ts
CHANGED
|
@@ -1,17 +1,27 @@
|
|
|
1
|
-
import
|
|
1
|
+
import {resolve} from 'node:path';
|
|
2
2
|
import type {StorybookConfig} from '@storybook/react-vite';
|
|
3
|
+
import tailwindcss from '@tailwindcss/vite';
|
|
4
|
+
import react from '@vitejs/plugin-react';
|
|
3
5
|
|
|
4
|
-
const config: StorybookConfig
|
|
6
|
+
const config: StorybookConfig = {
|
|
5
7
|
framework: '@storybook/react-vite',
|
|
6
8
|
stories: ['../src/**/*.stories.@(js|jsx|ts|tsx|mdx)'],
|
|
7
|
-
addons: ['storybook-addon-pseudo-states'],
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
addons: ['storybook-addon-pseudo-states', '@storybook/addon-vitest'],
|
|
10
|
+
viteFinal: (config) => {
|
|
11
|
+
config.plugins = config.plugins ?? [];
|
|
12
|
+
|
|
13
|
+
config.plugins.push(react(), tailwindcss());
|
|
14
|
+
|
|
15
|
+
config.resolve = config.resolve ?? {};
|
|
16
|
+
config.resolve.alias = {
|
|
17
|
+
...config.resolve.alias,
|
|
18
|
+
components: resolve(__dirname, '../src/components'),
|
|
19
|
+
hooks: resolve(__dirname, '../src/hooks'),
|
|
20
|
+
utils: resolve(__dirname, '../src/utils'),
|
|
21
|
+
state: resolve(__dirname, '../src/state'),
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return config;
|
|
15
25
|
},
|
|
16
26
|
};
|
|
17
27
|
|
package/.storybook/preview.tsx
CHANGED
|
@@ -9,6 +9,17 @@ const withTheme: Decorator = (Story, context) => {
|
|
|
9
9
|
const preview: Preview = {
|
|
10
10
|
decorators: [withTheme],
|
|
11
11
|
parameters: {
|
|
12
|
+
viewport: {
|
|
13
|
+
viewports: {
|
|
14
|
+
large: {
|
|
15
|
+
name: 'Large Viewport',
|
|
16
|
+
styles: {
|
|
17
|
+
width: '1280px',
|
|
18
|
+
height: '2000px',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
},
|
|
12
23
|
options: {
|
|
13
24
|
storySort: {
|
|
14
25
|
method: 'alphabetical',
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,6 +1,19 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
4
|
-
> swc
|
|
3
|
+
> @shipfox/react-ui@0.6.0 build /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
|
+
> swc && pnpm run build:css
|
|
5
5
|
|
|
6
|
-
Successfully compiled:
|
|
6
|
+
Successfully compiled: 114 files with swc (419.67ms)
|
|
7
|
+
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
8
|
+
|
|
9
|
+
> @shipfox/react-ui@0.6.0 build:css /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
10
|
+
> vite build --config vite.css.config.ts && rm -f dist/css-entry.js dist/css-entry.js.map
|
|
11
|
+
|
|
12
|
+
[36mvite v7.2.2 [32mbuilding client environment for production...[36m[39m
|
|
13
|
+
transforming...
|
|
14
|
+
[32m✓[39m 2 modules transformed.
|
|
15
|
+
rendering chunks...
|
|
16
|
+
computing gzip size...
|
|
17
|
+
[2mdist/[22m[35mstyles.css [39m[1m[2m84.61 kB[22m[1m[22m[2m │ gzip: 13.44 kB[22m
|
|
18
|
+
[2mdist/[22m[36mcss-entry.js [39m[1m[2m 0.00 kB[22m[1m[22m[2m │ gzip: 0.02 kB[22m
|
|
19
|
+
[32m✓ built in 1.97s[39m
|
package/.turbo/turbo-check.log
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.6.0 check /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> biome-check --fix
|
|
5
5
|
|
|
6
|
-
Checked
|
|
6
|
+
Checked 133 files in 500ms. No fixes applied.
|
package/.turbo/turbo-type.log
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
WARN Issue while reading "/runnertmp/_work/tooling/tooling/.npmrc". Failed to replace env in config: ${NPM_ACCESS_TOKEN}
|
|
2
2
|
|
|
3
|
-
> @shipfox/react-ui@0.
|
|
3
|
+
> @shipfox/react-ui@0.6.0 type /runnertmp/_work/tooling/tooling/libs/react/ui
|
|
4
4
|
> tsc-emit
|
|
5
5
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# @shipfox/react-ui
|
|
2
2
|
|
|
3
|
+
## 0.6.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 3a95f26: Add Argos CI Upload Screenshots
|
|
8
|
+
- 35f3c64: Add CSS bundle
|
|
9
|
+
- 3a95f26: Add Modal components
|
|
10
|
+
|
|
11
|
+
## 0.5.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- ec0b437: Add Button Link and Icon Button components
|
|
16
|
+
- 7b73bd6: Integrate Argos CI
|
|
17
|
+
|
|
3
18
|
## 0.4.0
|
|
4
19
|
|
|
5
20
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -14,8 +14,63 @@ yarn add @shipfox/react-ui
|
|
|
14
14
|
npm install @shipfox/react-ui
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
+
### CSS Styles
|
|
18
|
+
|
|
19
|
+
This package includes a pre-built, minified CSS bundle with all Tailwind CSS styles and design tokens. Import it in your application:
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import "@shipfox/react-ui/dist/styles.css"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Or in your HTML:
|
|
26
|
+
|
|
27
|
+
```html
|
|
28
|
+
<link rel="stylesheet" href="node_modules/@shipfox/react-ui/dist/styles.css" />
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The CSS bundle is self-contained and includes all design tokens, so you don't need to configure Tailwind CSS in your consuming project.
|
|
32
|
+
|
|
17
33
|
## Storybook
|
|
18
34
|
|
|
19
|
-
The storybook is [publicly accessible online](react-ui.shipfox.vercel.app).
|
|
35
|
+
The storybook is [publicly accessible online](https://react-ui.shipfox.vercel.app).
|
|
20
36
|
|
|
21
37
|
You can also launch it locally by running `pnpm storybook` from within this package's directory.
|
|
38
|
+
|
|
39
|
+
## Visual Testing with Argos
|
|
40
|
+
|
|
41
|
+
This library uses [Argos](https://argos-ci.com/) for automated visual regression testing. Argos captures screenshots of all Storybook stories and compares them across pull requests to detect unintended visual changes.
|
|
42
|
+
|
|
43
|
+
### How it works
|
|
44
|
+
|
|
45
|
+
1. On every pull request, GitHub Actions builds Storybook and uploads screenshots to Argos
|
|
46
|
+
2. Argos compares the screenshots with the baseline from the main branch
|
|
47
|
+
3. If visual differences are detected, they are highlighted in the Argos dashboard
|
|
48
|
+
4. Reviewers can approve or reject changes directly from the PR
|
|
49
|
+
|
|
50
|
+
### Running Argos locally
|
|
51
|
+
|
|
52
|
+
To upload screenshots to Argos from your local machine:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Build Storybook
|
|
56
|
+
pnpm storybook:build
|
|
57
|
+
|
|
58
|
+
# Upload to Argos (requires ARGOS_TOKEN environment variable)
|
|
59
|
+
pnpm argos
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Configuration
|
|
63
|
+
|
|
64
|
+
Argos configuration is located in `argos.config.ts`. You can customize:
|
|
65
|
+
|
|
66
|
+
- Screenshot capture settings
|
|
67
|
+
- Ignored patterns
|
|
68
|
+
- Comparison threshold
|
|
69
|
+
- Reference branch
|
|
70
|
+
|
|
71
|
+
### Setting up Argos
|
|
72
|
+
|
|
73
|
+
1. Create an account on [Argos](https://argos-ci.com/)
|
|
74
|
+
2. Connect your GitHub repository
|
|
75
|
+
3. Add the `ARGOS_TOKEN` secret to your GitHub repository settings
|
|
76
|
+
4. Argos will automatically run on all pull requests
|
package/argos.config.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
const config = {
|
|
2
|
+
// Upload Storybook build output
|
|
3
|
+
buildDir: 'storybook-static',
|
|
4
|
+
|
|
5
|
+
// Project token (can also be set via ARGOS_TOKEN env var)
|
|
6
|
+
// token: process.env.ARGOS_TOKEN,
|
|
7
|
+
|
|
8
|
+
// Repository information (optional, auto-detected from git)
|
|
9
|
+
// repository: 'shipfox/tooling',
|
|
10
|
+
|
|
11
|
+
// Branch information (optional, auto-detected from git)
|
|
12
|
+
// branch: process.env.GITHUB_REF_NAME,
|
|
13
|
+
|
|
14
|
+
// Commit information (optional, auto-detected from git)
|
|
15
|
+
// commit: process.env.GITHUB_SHA,
|
|
16
|
+
|
|
17
|
+
// Parallel upload settings for faster uploads
|
|
18
|
+
parallel: {
|
|
19
|
+
total: -1, // Auto-detect based on available resources
|
|
20
|
+
nonce: process.env.GITHUB_RUN_ID || Date.now().toString(),
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// Ignore certain screenshots or patterns
|
|
24
|
+
// ignore: ['**/private/**'],
|
|
25
|
+
|
|
26
|
+
// Reference branch for comparisons (usually main)
|
|
27
|
+
reference: 'main',
|
|
28
|
+
|
|
29
|
+
// Threshold for visual changes (0 = any change, 1 = no changes)
|
|
30
|
+
threshold: 0,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export default config;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/build-css-entry.ts"],"sourcesContent":["// This file is only used for building CSS\n// It imports the CSS file which Vite will process and bundle\nimport '../index.css';\n"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,6DAA6D;AAC7D,OAAO,eAAe"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { type IconName } from '../../components/icon';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
export declare const buttonLinkVariants: (props?: ({
|
|
5
|
+
variant?: "base" | "muted" | "interactive" | "subtle" | null | undefined;
|
|
6
|
+
size?: "xs" | "sm" | "md" | "xl" | null | undefined;
|
|
7
|
+
underline?: boolean | null | undefined;
|
|
8
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
9
|
+
export declare function ButtonLink({ className, variant, size, underline, asChild, children, iconLeft, iconRight, ...props }: ComponentProps<'a'> & VariantProps<typeof buttonLinkVariants> & {
|
|
10
|
+
asChild?: boolean;
|
|
11
|
+
iconLeft?: IconName;
|
|
12
|
+
iconRight?: IconName;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=button-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"button-link.d.ts","sourceRoot":"","sources":["../../../src/components/button/button-link.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,kBAAkB;;;;8EA8B9B,CAAC;AASF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,OAAO,EACP,IAAW,EACX,SAAS,EACT,OAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,GAAG,CAAC,GACpB,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB,2CAeF"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
3
|
+
import { cva } from 'class-variance-authority';
|
|
4
|
+
import { Icon } from '../../components/icon/index.js';
|
|
5
|
+
import { cn } from '../../utils/cn.js';
|
|
6
|
+
export const buttonLinkVariants = cva('inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors disabled:pointer-events-none outline-none font-medium', {
|
|
7
|
+
variants: {
|
|
8
|
+
variant: {
|
|
9
|
+
base: 'text-foreground-neutral-base hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',
|
|
10
|
+
interactive: 'text-foreground-highlight-interactive hover:text-foreground-highlight-interactive-hover focus-visible:text-foreground-highlight-interactive disabled:text-foreground-neutral-disabled',
|
|
11
|
+
muted: 'text-foreground-neutral-muted hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',
|
|
12
|
+
subtle: 'text-foreground-neutral-subtle hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled'
|
|
13
|
+
},
|
|
14
|
+
size: {
|
|
15
|
+
xs: 'text-xs',
|
|
16
|
+
sm: 'text-sm',
|
|
17
|
+
md: 'text-md',
|
|
18
|
+
xl: 'text-xl'
|
|
19
|
+
},
|
|
20
|
+
underline: {
|
|
21
|
+
true: 'underline decoration-solid [text-underline-position:from-font]',
|
|
22
|
+
false: ''
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
defaultVariants: {
|
|
26
|
+
variant: 'base',
|
|
27
|
+
size: 'sm',
|
|
28
|
+
underline: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
const iconSizeMap = {
|
|
32
|
+
xs: 14,
|
|
33
|
+
sm: 14,
|
|
34
|
+
md: 16,
|
|
35
|
+
xl: 20
|
|
36
|
+
};
|
|
37
|
+
export function ButtonLink({ className, variant, size = 'sm', underline, asChild = false, children, iconLeft, iconRight, ...props }) {
|
|
38
|
+
const Comp = asChild ? Slot : 'a';
|
|
39
|
+
const iconSize = iconSizeMap[size];
|
|
40
|
+
return /*#__PURE__*/ _jsxs(Comp, {
|
|
41
|
+
"data-slot": "button-link",
|
|
42
|
+
className: cn(buttonLinkVariants({
|
|
43
|
+
variant,
|
|
44
|
+
size,
|
|
45
|
+
underline,
|
|
46
|
+
className
|
|
47
|
+
})),
|
|
48
|
+
...props,
|
|
49
|
+
children: [
|
|
50
|
+
iconLeft && /*#__PURE__*/ _jsx(Icon, {
|
|
51
|
+
name: iconLeft,
|
|
52
|
+
size: iconSize
|
|
53
|
+
}),
|
|
54
|
+
children,
|
|
55
|
+
iconRight && /*#__PURE__*/ _jsx(Icon, {
|
|
56
|
+
name: iconRight,
|
|
57
|
+
size: iconSize
|
|
58
|
+
})
|
|
59
|
+
]
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=button-link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/button-link.tsx"],"sourcesContent":["import {Slot} from '@radix-ui/react-slot';\nimport {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon, type IconName} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const buttonLinkVariants = cva(\n 'inline-flex items-center justify-center gap-4 whitespace-nowrap transition-colors disabled:pointer-events-none outline-none font-medium',\n {\n variants: {\n variant: {\n base: 'text-foreground-neutral-base hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n interactive:\n 'text-foreground-highlight-interactive hover:text-foreground-highlight-interactive-hover focus-visible:text-foreground-highlight-interactive disabled:text-foreground-neutral-disabled',\n muted:\n 'text-foreground-neutral-muted hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n subtle:\n 'text-foreground-neutral-subtle hover:text-foreground-neutral-base focus-visible:text-foreground-neutral-base disabled:text-foreground-neutral-disabled',\n },\n size: {\n xs: 'text-xs',\n sm: 'text-sm',\n md: 'text-md',\n xl: 'text-xl',\n },\n underline: {\n true: 'underline decoration-solid [text-underline-position:from-font]',\n false: '',\n },\n },\n defaultVariants: {\n variant: 'base',\n size: 'sm',\n underline: false,\n },\n },\n);\n\nconst iconSizeMap = {\n xs: 14,\n sm: 14,\n md: 16,\n xl: 20,\n} as const;\n\nexport function ButtonLink({\n className,\n variant,\n size = 'sm',\n underline,\n asChild = false,\n children,\n iconLeft,\n iconRight,\n ...props\n}: ComponentProps<'a'> &\n VariantProps<typeof buttonLinkVariants> & {\n asChild?: boolean;\n iconLeft?: IconName;\n iconRight?: IconName;\n }) {\n const Comp = asChild ? Slot : 'a';\n const iconSize = iconSizeMap[size as keyof typeof iconSizeMap];\n\n return (\n <Comp\n data-slot=\"button-link\"\n className={cn(buttonLinkVariants({variant, size, underline, className}))}\n {...props}\n >\n {iconLeft && <Icon name={iconLeft} size={iconSize} />}\n {children}\n {iconRight && <Icon name={iconRight} size={iconSize} />}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","buttonLinkVariants","variants","variant","base","interactive","muted","subtle","size","xs","sm","md","xl","underline","true","false","defaultVariants","iconSizeMap","ButtonLink","className","asChild","children","iconLeft","iconRight","props","Comp","iconSize","data-slot","name"],"mappings":";AAAA,SAAQA,IAAI,QAAO,uBAAuB;AAC1C,SAAQC,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAsB,kBAAkB;AAEpD,SAAQC,EAAE,QAAO,WAAW;AAE5B,OAAO,MAAMC,qBAAqBH,IAChC,2IACA;IACEI,UAAU;QACRC,SAAS;YACPC,MAAM;YACNC,aACE;YACFC,OACE;YACFC,QACE;QACJ;QACAC,MAAM;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;QACAC,WAAW;YACTC,MAAM;YACNC,OAAO;QACT;IACF;IACAC,iBAAiB;QACfb,SAAS;QACTK,MAAM;QACNK,WAAW;IACb;AACF,GACA;AAEF,MAAMI,cAAc;IAClBR,IAAI;IACJC,IAAI;IACJC,IAAI;IACJC,IAAI;AACN;AAEA,OAAO,SAASM,WAAW,EACzBC,SAAS,EACThB,OAAO,EACPK,OAAO,IAAI,EACXK,SAAS,EACTO,UAAU,KAAK,EACfC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACT,GAAGC,OAMF;IACD,MAAMC,OAAOL,UAAUvB,OAAO;IAC9B,MAAM6B,WAAWT,WAAW,CAACT,KAAiC;IAE9D,qBACE,MAACiB;QACCE,aAAU;QACVR,WAAWnB,GAAGC,mBAAmB;YAACE;YAASK;YAAMK;YAAWM;QAAS;QACpE,GAAGK,KAAK;;YAERF,0BAAY,KAACvB;gBAAK6B,MAAMN;gBAAUd,MAAMkB;;YACxCL;YACAE,2BAAa,KAACxB;gBAAK6B,MAAML;gBAAWf,MAAMkB;;;;AAGjD"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ButtonLink } from './button-link.js';
|
|
3
|
+
const meta = {
|
|
4
|
+
title: 'Components/Button/ButtonLink',
|
|
5
|
+
component: ButtonLink,
|
|
6
|
+
tags: [
|
|
7
|
+
'autodocs'
|
|
8
|
+
],
|
|
9
|
+
argTypes: {
|
|
10
|
+
variant: {
|
|
11
|
+
control: 'select',
|
|
12
|
+
options: [
|
|
13
|
+
'base',
|
|
14
|
+
'interactive',
|
|
15
|
+
'muted',
|
|
16
|
+
'subtle'
|
|
17
|
+
]
|
|
18
|
+
},
|
|
19
|
+
size: {
|
|
20
|
+
control: 'select',
|
|
21
|
+
options: [
|
|
22
|
+
'xs',
|
|
23
|
+
'sm',
|
|
24
|
+
'md',
|
|
25
|
+
'xl'
|
|
26
|
+
]
|
|
27
|
+
},
|
|
28
|
+
underline: {
|
|
29
|
+
control: 'boolean'
|
|
30
|
+
},
|
|
31
|
+
asChild: {
|
|
32
|
+
control: 'boolean'
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
args: {
|
|
36
|
+
children: 'Label',
|
|
37
|
+
variant: 'base',
|
|
38
|
+
size: 'sm',
|
|
39
|
+
underline: false,
|
|
40
|
+
href: '#'
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export default meta;
|
|
44
|
+
export const Default = {};
|
|
45
|
+
export const Variants = {
|
|
46
|
+
render: (args)=>/*#__PURE__*/ _jsxs("div", {
|
|
47
|
+
className: "flex gap-16 items-center",
|
|
48
|
+
children: [
|
|
49
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
50
|
+
...args,
|
|
51
|
+
variant: "base",
|
|
52
|
+
children: "Base"
|
|
53
|
+
}),
|
|
54
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
55
|
+
...args,
|
|
56
|
+
variant: "interactive",
|
|
57
|
+
children: "Interactive"
|
|
58
|
+
}),
|
|
59
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
60
|
+
...args,
|
|
61
|
+
variant: "muted",
|
|
62
|
+
children: "Muted"
|
|
63
|
+
}),
|
|
64
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
65
|
+
...args,
|
|
66
|
+
variant: "subtle",
|
|
67
|
+
children: "Subtle"
|
|
68
|
+
})
|
|
69
|
+
]
|
|
70
|
+
})
|
|
71
|
+
};
|
|
72
|
+
export const WithUnderline = {
|
|
73
|
+
render: (args)=>/*#__PURE__*/ _jsxs("div", {
|
|
74
|
+
className: "flex gap-16 items-center",
|
|
75
|
+
children: [
|
|
76
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
77
|
+
...args,
|
|
78
|
+
variant: "base",
|
|
79
|
+
underline: true,
|
|
80
|
+
children: "Base"
|
|
81
|
+
}),
|
|
82
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
83
|
+
...args,
|
|
84
|
+
variant: "interactive",
|
|
85
|
+
underline: true,
|
|
86
|
+
children: "Interactive"
|
|
87
|
+
}),
|
|
88
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
89
|
+
...args,
|
|
90
|
+
variant: "muted",
|
|
91
|
+
underline: true,
|
|
92
|
+
children: "Muted"
|
|
93
|
+
}),
|
|
94
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
95
|
+
...args,
|
|
96
|
+
variant: "subtle",
|
|
97
|
+
underline: true,
|
|
98
|
+
children: "Subtle"
|
|
99
|
+
})
|
|
100
|
+
]
|
|
101
|
+
})
|
|
102
|
+
};
|
|
103
|
+
export const WithIcons = {
|
|
104
|
+
render: (args)=>/*#__PURE__*/ _jsxs("div", {
|
|
105
|
+
className: "flex gap-16 items-center",
|
|
106
|
+
children: [
|
|
107
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
108
|
+
...args,
|
|
109
|
+
iconLeft: "addLine",
|
|
110
|
+
children: "Icon Left"
|
|
111
|
+
}),
|
|
112
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
113
|
+
...args,
|
|
114
|
+
iconRight: "chevronRight",
|
|
115
|
+
children: "Icon Right"
|
|
116
|
+
}),
|
|
117
|
+
/*#__PURE__*/ _jsx(ButtonLink, {
|
|
118
|
+
...args,
|
|
119
|
+
iconLeft: "addLine",
|
|
120
|
+
iconRight: "chevronRight",
|
|
121
|
+
children: "Both Icons"
|
|
122
|
+
})
|
|
123
|
+
]
|
|
124
|
+
})
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=button-link.stories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/button-link.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {ButtonLink} from './button-link';\n\nconst meta = {\n title: 'Components/Button/ButtonLink',\n component: ButtonLink,\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: 'select',\n options: ['base', 'interactive', 'muted', 'subtle'],\n },\n size: {\n control: 'select',\n options: ['xs', 'sm', 'md', 'xl'],\n },\n underline: {control: 'boolean'},\n asChild: {control: 'boolean'},\n },\n args: {\n children: 'Label',\n variant: 'base',\n size: 'sm',\n underline: false,\n href: '#',\n },\n} satisfies Meta<typeof ButtonLink>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {};\n\nexport const Variants: Story = {\n render: (args) => (\n <div className=\"flex gap-16 items-center\">\n <ButtonLink {...args} variant=\"base\">\n Base\n </ButtonLink>\n <ButtonLink {...args} variant=\"interactive\">\n Interactive\n </ButtonLink>\n <ButtonLink {...args} variant=\"muted\">\n Muted\n </ButtonLink>\n <ButtonLink {...args} variant=\"subtle\">\n Subtle\n </ButtonLink>\n </div>\n ),\n};\n\nexport const WithUnderline: Story = {\n render: (args) => (\n <div className=\"flex gap-16 items-center\">\n <ButtonLink {...args} variant=\"base\" underline>\n Base\n </ButtonLink>\n <ButtonLink {...args} variant=\"interactive\" underline>\n Interactive\n </ButtonLink>\n <ButtonLink {...args} variant=\"muted\" underline>\n Muted\n </ButtonLink>\n <ButtonLink {...args} variant=\"subtle\" underline>\n Subtle\n </ButtonLink>\n </div>\n ),\n};\n\nexport const WithIcons: Story = {\n render: (args) => (\n <div className=\"flex gap-16 items-center\">\n <ButtonLink {...args} iconLeft=\"addLine\">\n Icon Left\n </ButtonLink>\n <ButtonLink {...args} iconRight=\"chevronRight\">\n Icon Right\n </ButtonLink>\n <ButtonLink {...args} iconLeft=\"addLine\" iconRight=\"chevronRight\">\n Both Icons\n </ButtonLink>\n </div>\n ),\n};\n"],"names":["ButtonLink","meta","title","component","tags","argTypes","variant","control","options","size","underline","asChild","args","children","href","Default","Variants","render","div","className","WithUnderline","WithIcons","iconLeft","iconRight"],"mappings":";AACA,SAAQA,UAAU,QAAO,gBAAgB;AAEzC,MAAMC,OAAO;IACXC,OAAO;IACPC,WAAWH;IACXI,MAAM;QAAC;KAAW;IAClBC,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,SAAS;gBAAC;gBAAQ;gBAAe;gBAAS;aAAS;QACrD;QACAC,MAAM;YACJF,SAAS;YACTC,SAAS;gBAAC;gBAAM;gBAAM;gBAAM;aAAK;QACnC;QACAE,WAAW;YAACH,SAAS;QAAS;QAC9BI,SAAS;YAACJ,SAAS;QAAS;IAC9B;IACAK,MAAM;QACJC,UAAU;QACVP,SAAS;QACTG,MAAM;QACNC,WAAW;QACXI,MAAM;IACR;AACF;AAEA,eAAeb,KAAK;AAGpB,OAAO,MAAMc,UAAiB,CAAC,EAAE;AAEjC,OAAO,MAAMC,WAAkB;IAC7BC,QAAQ,CAACL,qBACP,MAACM;YAAIC,WAAU;;8BACb,KAACnB;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;8BAAO;;8BAGrC,KAACN;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;8BAAc;;8BAG5C,KAACN;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;8BAAQ;;8BAGtC,KAACN;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;8BAAS;;;;AAK7C,EAAE;AAEF,OAAO,MAAMc,gBAAuB;IAClCH,QAAQ,CAACL,qBACP,MAACM;YAAIC,WAAU;;8BACb,KAACnB;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;oBAAOI,SAAS;8BAAC;;8BAG/C,KAACV;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;oBAAcI,SAAS;8BAAC;;8BAGtD,KAACV;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;oBAAQI,SAAS;8BAAC;;8BAGhD,KAACV;oBAAY,GAAGY,IAAI;oBAAEN,SAAQ;oBAASI,SAAS;8BAAC;;;;AAKvD,EAAE;AAEF,OAAO,MAAMW,YAAmB;IAC9BJ,QAAQ,CAACL,qBACP,MAACM;YAAIC,WAAU;;8BACb,KAACnB;oBAAY,GAAGY,IAAI;oBAAEU,UAAS;8BAAU;;8BAGzC,KAACtB;oBAAY,GAAGY,IAAI;oBAAEW,WAAU;8BAAe;;8BAG/C,KAACvB;oBAAY,GAAGY,IAAI;oBAAEU,UAAS;oBAAUC,WAAU;8BAAe;;;;AAKxE,EAAE"}
|
|
@@ -2,7 +2,7 @@ import { type VariantProps } from 'class-variance-authority';
|
|
|
2
2
|
import { type IconName } from '../../components/icon';
|
|
3
3
|
import type { ComponentProps } from 'react';
|
|
4
4
|
export declare const buttonVariants: (props?: ({
|
|
5
|
-
variant?: "transparent" | "primary" | "secondary" | "danger" | "transparentMuted" | null | undefined;
|
|
5
|
+
variant?: "transparent" | "success" | "primary" | "secondary" | "danger" | "transparentMuted" | null | undefined;
|
|
6
6
|
size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
7
7
|
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
8
8
|
export declare function Button({ className, variant, size, asChild, children, iconLeft, iconRight, ...props }: ComponentProps<'button'> & VariantProps<typeof buttonVariants> & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,cAAc;;;
|
|
1
|
+
{"version":3,"file":"button.d.ts","sourceRoot":"","sources":["../../../src/components/button/button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,cAAc;;;8EAgC1B,CAAC;AAEF,wBAAgB,MAAM,CAAC,EACrB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,OAAe,EACf,QAAQ,EACR,QAAQ,EACR,SAAS,EACT,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,cAAc,CAAC,GAAG;IACpC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,SAAS,CAAC,EAAE,QAAQ,CAAC;CACtB,2CAUF"}
|
|
@@ -9,16 +9,17 @@ export const buttonVariants = cva('rounded-6 inline-flex items-center justify-ce
|
|
|
9
9
|
primary: 'bg-background-button-inverted-default text-foreground-contrast-primary shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',
|
|
10
10
|
secondary: 'bg-background-button-neutral-default text-foreground-neutral-base shadow-button-neutral hover:bg-background-button-neutral-hover active:bg-background-button-neutral-pressed disabled:bg-background-neutral-disabled focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled disabled:shadow-none',
|
|
11
11
|
danger: 'bg-background-button-danger-default text-foreground-neutral-on-color shadow-button-danger hover:bg-background-button-danger-hover active:bg-background-button-danger-pressed focus-visible:shadow-button-danger-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',
|
|
12
|
+
success: 'bg-background-button-success-default text-foreground-neutral-on-color shadow-button-success hover:bg-background-button-success-hover active:bg-background-button-success-pressed focus-visible:shadow-button-success-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',
|
|
12
13
|
transparent: 'bg-background-button-transparent-default text-foreground-neutral-base hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',
|
|
13
14
|
transparentMuted: 'bg-background-button-transparent-default text-foreground-neutral-muted hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled'
|
|
14
15
|
},
|
|
15
16
|
size: {
|
|
16
|
-
'2xs': 'px-6 text-xs gap-4',
|
|
17
|
-
xs: 'px-6
|
|
18
|
-
sm: 'px-8
|
|
19
|
-
md: 'px-10
|
|
20
|
-
lg: 'px-12
|
|
21
|
-
xl: 'px-12
|
|
17
|
+
'2xs': 'h-20 px-6 text-xs gap-4',
|
|
18
|
+
xs: 'h-24 px-6 text-xs gap-4',
|
|
19
|
+
sm: 'h-28 px-8 text-sm gap-6',
|
|
20
|
+
md: 'h-32 px-10 text-md gap-8',
|
|
21
|
+
lg: 'h-36 px-12 text-lg gap-8',
|
|
22
|
+
xl: 'h-40 px-12 text-xl gap-10'
|
|
22
23
|
}
|
|
23
24
|
},
|
|
24
25
|
defaultVariants: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {Slot} from '@radix-ui/react-slot';\nimport {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon, type IconName} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const buttonVariants = cva(\n 'rounded-6 inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none',\n {\n variants: {\n variant: {\n primary:\n 'bg-background-button-inverted-default text-foreground-contrast-primary shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n secondary:\n 'bg-background-button-neutral-default text-foreground-neutral-base shadow-button-neutral hover:bg-background-button-neutral-hover active:bg-background-button-neutral-pressed disabled:bg-background-neutral-disabled focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled disabled:shadow-none',\n danger:\n 'bg-background-button-danger-default text-foreground-neutral-on-color shadow-button-danger hover:bg-background-button-danger-hover active:bg-background-button-danger-pressed focus-visible:shadow-button-danger-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n transparent:\n 'bg-background-button-transparent-default text-foreground-neutral-base hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n transparentMuted:\n 'bg-background-button-transparent-default text-foreground-neutral-muted hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n },\n size: {\n '2xs': 'px-6 text-xs gap-4',\n xs: 'px-6
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/button.tsx"],"sourcesContent":["import {Slot} from '@radix-ui/react-slot';\nimport {cva, type VariantProps} from 'class-variance-authority';\nimport {Icon, type IconName} from 'components/icon';\nimport type {ComponentProps} from 'react';\nimport {cn} from 'utils/cn';\n\nexport const buttonVariants = cva(\n 'rounded-6 inline-flex items-center justify-center whitespace-nowrap transition-colors disabled:pointer-events-none shrink-0 outline-none',\n {\n variants: {\n variant: {\n primary:\n 'bg-background-button-inverted-default text-foreground-contrast-primary shadow-button-inverted hover:bg-background-button-inverted-hover active:bg-background-button-inverted-pressed focus-visible:shadow-button-inverted-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n secondary:\n 'bg-background-button-neutral-default text-foreground-neutral-base shadow-button-neutral hover:bg-background-button-neutral-hover active:bg-background-button-neutral-pressed disabled:bg-background-neutral-disabled focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled disabled:shadow-none',\n danger:\n 'bg-background-button-danger-default text-foreground-neutral-on-color shadow-button-danger hover:bg-background-button-danger-hover active:bg-background-button-danger-pressed focus-visible:shadow-button-danger-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n success:\n 'bg-background-button-success-default text-foreground-neutral-on-color shadow-button-success hover:bg-background-button-success-hover active:bg-background-button-success-pressed focus-visible:shadow-button-success-focus disabled:bg-background-neutral-disabled disabled:text-foreground-neutral-disabled disabled:shadow-none',\n transparent:\n 'bg-background-button-transparent-default text-foreground-neutral-base hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n transparentMuted:\n 'bg-background-button-transparent-default text-foreground-neutral-muted hover:bg-background-button-transparent-hover active:bg-background-button-transparent-pressed focus-visible:shadow-button-neutral-focus disabled:text-foreground-neutral-disabled',\n },\n size: {\n '2xs': 'h-20 px-6 text-xs gap-4',\n xs: 'h-24 px-6 text-xs gap-4',\n sm: 'h-28 px-8 text-sm gap-6',\n md: 'h-32 px-10 text-md gap-8',\n lg: 'h-36 px-12 text-lg gap-8',\n xl: 'h-40 px-12 text-xl gap-10',\n },\n },\n defaultVariants: {\n variant: 'primary',\n size: 'md',\n },\n },\n);\n\nexport function Button({\n className,\n variant,\n size,\n asChild = false,\n children,\n iconLeft,\n iconRight,\n ...props\n}: ComponentProps<'button'> &\n VariantProps<typeof buttonVariants> & {\n asChild?: boolean;\n iconLeft?: IconName;\n iconRight?: IconName;\n }) {\n const Comp = asChild ? Slot : 'button';\n\n return (\n <Comp data-slot=\"button\" className={cn(buttonVariants({variant, size, className}))} {...props}>\n {iconLeft && <Icon name={iconLeft} />}\n {children}\n {iconRight && <Icon name={iconRight} />}\n </Comp>\n );\n}\n"],"names":["Slot","cva","Icon","cn","buttonVariants","variants","variant","primary","secondary","danger","success","transparent","transparentMuted","size","xs","sm","md","lg","xl","defaultVariants","Button","className","asChild","children","iconLeft","iconRight","props","Comp","data-slot","name"],"mappings":";AAAA,SAAQA,IAAI,QAAO,uBAAuB;AAC1C,SAAQC,GAAG,QAA0B,2BAA2B;AAChE,SAAQC,IAAI,QAAsB,kBAAkB;AAEpD,SAAQC,EAAE,QAAO,WAAW;AAE5B,OAAO,MAAMC,iBAAiBH,IAC5B,4IACA;IACEI,UAAU;QACRC,SAAS;YACPC,SACE;YACFC,WACE;YACFC,QACE;YACFC,SACE;YACFC,aACE;YACFC,kBACE;QACJ;QACAC,MAAM;YACJ,OAAO;YACPC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;YACJC,IAAI;QACN;IACF;IACAC,iBAAiB;QACfb,SAAS;QACTO,MAAM;IACR;AACF,GACA;AAEF,OAAO,SAASO,OAAO,EACrBC,SAAS,EACTf,OAAO,EACPO,IAAI,EACJS,UAAU,KAAK,EACfC,QAAQ,EACRC,QAAQ,EACRC,SAAS,EACT,GAAGC,OAMF;IACD,MAAMC,OAAOL,UAAUtB,OAAO;IAE9B,qBACE,MAAC2B;QAAKC,aAAU;QAASP,WAAWlB,GAAGC,eAAe;YAACE;YAASO;YAAMQ;QAAS;QAAM,GAAGK,KAAK;;YAC1FF,0BAAY,KAACtB;gBAAK2B,MAAML;;YACxBD;YACAE,2BAAa,KAACvB;gBAAK2B,MAAMJ;;;;AAGhC"}
|
|
@@ -5,6 +5,7 @@ const variantOptions = [
|
|
|
5
5
|
'primary',
|
|
6
6
|
'secondary',
|
|
7
7
|
'danger',
|
|
8
|
+
'success',
|
|
8
9
|
'transparent',
|
|
9
10
|
'transparentMuted'
|
|
10
11
|
];
|
|
@@ -61,9 +62,6 @@ export const Variants = {
|
|
|
61
62
|
/*#__PURE__*/ _jsx("th", {
|
|
62
63
|
children: "Hover"
|
|
63
64
|
}),
|
|
64
|
-
/*#__PURE__*/ _jsx("th", {
|
|
65
|
-
children: "Active"
|
|
66
|
-
}),
|
|
67
65
|
/*#__PURE__*/ _jsx("th", {
|
|
68
66
|
children: "Focus"
|
|
69
67
|
}),
|
|
@@ -100,15 +98,6 @@ export const Variants = {
|
|
|
100
98
|
children: "Click me"
|
|
101
99
|
})
|
|
102
100
|
}),
|
|
103
|
-
/*#__PURE__*/ _jsx("td", {
|
|
104
|
-
children: /*#__PURE__*/ _jsx(Button, {
|
|
105
|
-
...args,
|
|
106
|
-
variant: variant,
|
|
107
|
-
className: "active",
|
|
108
|
-
size: size,
|
|
109
|
-
children: "Click me"
|
|
110
|
-
})
|
|
111
|
-
}),
|
|
112
101
|
/*#__PURE__*/ _jsx("td", {
|
|
113
102
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
114
103
|
...args,
|
|
@@ -137,7 +126,6 @@ export const Variants = {
|
|
|
137
126
|
Variants.parameters = {
|
|
138
127
|
pseudo: {
|
|
139
128
|
hover: '.hover',
|
|
140
|
-
active: '.active',
|
|
141
129
|
focusVisible: '.focus'
|
|
142
130
|
}
|
|
143
131
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/components/button/button.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code} from 'components/typography';\nimport {Button} from './button';\n\nconst variantOptions = [\n 'primary',\n 'secondary',\n 'danger',\n 'transparent',\n 'transparentMuted',\n] as const;\nconst sizeOptions = ['2xs', 'xs', 'sm', 'md', 'lg', 'xl'] as const;\n\nconst meta = {\n title: 'Components/Button',\n component: Button,\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: 'select',\n options: variantOptions,\n },\n size: {\n control: 'select',\n options: sizeOptions,\n },\n asChild: {control: 'boolean'},\n },\n args: {\n children: 'Click me',\n variant: 'primary',\n size: 'md',\n },\n} satisfies Meta<typeof Button>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {};\n\nexport const Variants: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n {sizeOptions.map((size) => (\n <table key={size} className=\"w-fit border-separate border-spacing-x-32 border-spacing-y-16\">\n <thead>\n <tr>\n <th>{size}</th>\n <th>Default</th>\n <th>Hover</th>\n <th>
|
|
1
|
+
{"version":3,"sources":["../../../src/components/button/button.stories.tsx"],"sourcesContent":["import type {Meta, StoryObj} from '@storybook/react';\nimport {Code} from 'components/typography';\nimport {Button} from './button';\n\nconst variantOptions = [\n 'primary',\n 'secondary',\n 'danger',\n 'success',\n 'transparent',\n 'transparentMuted',\n] as const;\nconst sizeOptions = ['2xs', 'xs', 'sm', 'md', 'lg', 'xl'] as const;\n\nconst meta = {\n title: 'Components/Button',\n component: Button,\n tags: ['autodocs'],\n argTypes: {\n variant: {\n control: 'select',\n options: variantOptions,\n },\n size: {\n control: 'select',\n options: sizeOptions,\n },\n asChild: {control: 'boolean'},\n },\n args: {\n children: 'Click me',\n variant: 'primary',\n size: 'md',\n },\n} satisfies Meta<typeof Button>;\n\nexport default meta;\ntype Story = StoryObj<typeof meta>;\n\nexport const Default: Story = {};\n\nexport const Variants: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-32\">\n {sizeOptions.map((size) => (\n <table key={size} className=\"w-fit border-separate border-spacing-x-32 border-spacing-y-16\">\n <thead>\n <tr>\n <th>{size}</th>\n <th>Default</th>\n <th>Hover</th>\n <th>Focus</th>\n <th>Disabled</th>\n </tr>\n </thead>\n <tbody>\n {variantOptions.map((variant) => (\n <tr key={variant}>\n <td>\n <Code variant=\"label\" className=\"text-foreground-neutral-subtle\">\n {variant}\n </Code>\n </td>\n <td>\n <Button {...args} variant={variant} size={size}>\n Click me\n </Button>\n </td>\n <td>\n <Button {...args} variant={variant} className=\"hover\" size={size}>\n Click me\n </Button>\n </td>\n <td>\n <Button {...args} variant={variant} className=\"focus\" size={size}>\n Click me\n </Button>\n </td>\n <td>\n <Button {...args} variant={variant} disabled size={size}>\n Click me\n </Button>\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n ))}\n </div>\n ),\n};\n\nVariants.parameters = {\n pseudo: {\n hover: '.hover',\n focusVisible: '.focus',\n },\n};\n\nexport const Icons: Story = {\n render: (args) => (\n <div className=\"flex flex-col gap-16\">\n <div>\n <Button {...args} iconLeft=\"google\">\n Click me\n </Button>\n </div>\n <div>\n <Button {...args} iconRight=\"microsoft\">\n Click me\n </Button>\n </div>\n <div>\n <Button {...args} iconLeft=\"google\" iconRight=\"microsoft\">\n Click me\n </Button>\n </div>\n </div>\n ),\n};\n"],"names":["Code","Button","variantOptions","sizeOptions","meta","title","component","tags","argTypes","variant","control","options","size","asChild","args","children","Default","Variants","render","div","className","map","table","thead","tr","th","tbody","td","disabled","parameters","pseudo","hover","focusVisible","Icons","iconLeft","iconRight"],"mappings":";AACA,SAAQA,IAAI,QAAO,wBAAwB;AAC3C,SAAQC,MAAM,QAAO,WAAW;AAEhC,MAAMC,iBAAiB;IACrB;IACA;IACA;IACA;IACA;IACA;CACD;AACD,MAAMC,cAAc;IAAC;IAAO;IAAM;IAAM;IAAM;IAAM;CAAK;AAEzD,MAAMC,OAAO;IACXC,OAAO;IACPC,WAAWL;IACXM,MAAM;QAAC;KAAW;IAClBC,UAAU;QACRC,SAAS;YACPC,SAAS;YACTC,SAAST;QACX;QACAU,MAAM;YACJF,SAAS;YACTC,SAASR;QACX;QACAU,SAAS;YAACH,SAAS;QAAS;IAC9B;IACAI,MAAM;QACJC,UAAU;QACVN,SAAS;QACTG,MAAM;IACR;AACF;AAEA,eAAeR,KAAK;AAGpB,OAAO,MAAMY,UAAiB,CAAC,EAAE;AAEjC,OAAO,MAAMC,WAAkB;IAC7BC,QAAQ,CAACJ,qBACP,KAACK;YAAIC,WAAU;sBACZjB,YAAYkB,GAAG,CAAC,CAACT,qBAChB,MAACU;oBAAiBF,WAAU;;sCAC1B,KAACG;sCACC,cAAA,MAACC;;kDACC,KAACC;kDAAIb;;kDACL,KAACa;kDAAG;;kDACJ,KAACA;kDAAG;;kDACJ,KAACA;kDAAG;;kDACJ,KAACA;kDAAG;;;;;sCAGR,KAACC;sCACExB,eAAemB,GAAG,CAAC,CAACZ,wBACnB,MAACe;;sDACC,KAACG;sDACC,cAAA,KAAC3B;gDAAKS,SAAQ;gDAAQW,WAAU;0DAC7BX;;;sDAGL,KAACkB;sDACC,cAAA,KAAC1B;gDAAQ,GAAGa,IAAI;gDAAEL,SAASA;gDAASG,MAAMA;0DAAM;;;sDAIlD,KAACe;sDACC,cAAA,KAAC1B;gDAAQ,GAAGa,IAAI;gDAAEL,SAASA;gDAASW,WAAU;gDAAQR,MAAMA;0DAAM;;;sDAIpE,KAACe;sDACC,cAAA,KAAC1B;gDAAQ,GAAGa,IAAI;gDAAEL,SAASA;gDAASW,WAAU;gDAAQR,MAAMA;0DAAM;;;sDAIpE,KAACe;sDACC,cAAA,KAAC1B;gDAAQ,GAAGa,IAAI;gDAAEL,SAASA;gDAASmB,QAAQ;gDAAChB,MAAMA;0DAAM;;;;mCAtBpDH;;;mBAZHG;;AA6CpB,EAAE;AAEFK,SAASY,UAAU,GAAG;IACpBC,QAAQ;QACNC,OAAO;QACPC,cAAc;IAChB;AACF;AAEA,OAAO,MAAMC,QAAe;IAC1Bf,QAAQ,CAACJ,qBACP,MAACK;YAAIC,WAAU;;8BACb,KAACD;8BACC,cAAA,KAAClB;wBAAQ,GAAGa,IAAI;wBAAEoB,UAAS;kCAAS;;;8BAItC,KAACf;8BACC,cAAA,KAAClB;wBAAQ,GAAGa,IAAI;wBAAEqB,WAAU;kCAAY;;;8BAI1C,KAAChB;8BACC,cAAA,KAAClB;wBAAQ,GAAGa,IAAI;wBAAEoB,UAAS;wBAASC,WAAU;kCAAY;;;;;AAMlE,EAAE"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type VariantProps } from 'class-variance-authority';
|
|
2
|
+
import { type IconName } from '../../components/icon';
|
|
3
|
+
import type { ComponentProps } from 'react';
|
|
4
|
+
export declare const iconButtonVariants: (props?: ({
|
|
5
|
+
variant?: "transparent" | "primary" | null | undefined;
|
|
6
|
+
size?: "2xs" | "xs" | "sm" | "md" | "lg" | "xl" | null | undefined;
|
|
7
|
+
radius?: "full" | "rounded" | null | undefined;
|
|
8
|
+
muted?: boolean | null | undefined;
|
|
9
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
10
|
+
export declare function IconButton({ className, variant, size, radius, muted, asChild, children, icon, ...props }: ComponentProps<'button'> & VariantProps<typeof iconButtonVariants> & {
|
|
11
|
+
asChild?: boolean;
|
|
12
|
+
icon?: IconName;
|
|
13
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
//# sourceMappingURL=icon-button.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"icon-button.d.ts","sourceRoot":"","sources":["../../../src/components/button/icon-button.tsx"],"names":[],"mappings":"AACA,OAAO,EAAM,KAAK,YAAY,EAAC,MAAM,0BAA0B,CAAC;AAChE,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,iBAAiB,CAAC;AACpD,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,OAAO,CAAC;AAG1C,eAAO,MAAM,kBAAkB;;;;;8EAkC9B,CAAC;AAEF,wBAAgB,UAAU,CAAC,EACzB,SAAS,EACT,OAAO,EACP,IAAI,EACJ,MAAM,EACN,KAAK,EACL,OAAe,EACf,QAAQ,EACR,IAAI,EACJ,GAAG,KAAK,EACT,EAAE,cAAc,CAAC,QAAQ,CAAC,GACzB,YAAY,CAAC,OAAO,kBAAkB,CAAC,GAAG;IACxC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,QAAQ,CAAC;CACjB,2CAYF"}
|