@reitwagen/design-components 0.1.0 → 0.2.1
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/dist/components/Button/Button.js +1 -1
- package/dist/components/Chip/Chip.d.ts +3 -0
- package/dist/components/Chip/Chip.d.ts.map +1 -1
- package/dist/components/Chip/Chip.js +4 -3
- package/dist/components/Chip/Chip.stories.d.ts +1 -0
- package/dist/components/Chip/Chip.stories.d.ts.map +1 -1
- package/dist/components/Chip/Chip.stories.js +27 -1
- package/dist/components/Toggle/Toggle.d.ts +15 -0
- package/dist/components/Toggle/Toggle.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.js +82 -0
- package/dist/components/Toggle/Toggle.stories.d.ts +33 -0
- package/dist/components/Toggle/Toggle.stories.d.ts.map +1 -0
- package/dist/components/Toggle/Toggle.stories.js +112 -0
- package/dist/components/Toggle/index.d.ts +2 -0
- package/dist/components/Toggle/index.d.ts.map +1 -0
- package/dist/components/Toggle/index.js +5 -0
- package/dist/index.css +144 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +2 -1
|
@@ -24,8 +24,8 @@ const buttonVariants = (0, class_variance_authority_1.cva)("ui:flex ui:items-cen
|
|
|
24
24
|
small: "ui:text-button3 ui:rounded-[10px] ui:h-[34px] ui:px-[14px] ui:py-[8px]",
|
|
25
25
|
},
|
|
26
26
|
disabled: {
|
|
27
|
-
false: "ui:cursor-pointer",
|
|
28
27
|
true: "ui:pointer-events-none",
|
|
28
|
+
false: "ui:cursor-pointer",
|
|
29
29
|
},
|
|
30
30
|
full: {
|
|
31
31
|
true: "ui:flex-1 ui:w-full",
|
|
@@ -15,5 +15,8 @@ type ChipOwnProps = VariantProps<typeof chipVariants> & {
|
|
|
15
15
|
};
|
|
16
16
|
type ChipProps<C extends ElementType> = PolymorphicComponentProps<C, ChipOwnProps>;
|
|
17
17
|
export declare function Chip<C extends ElementType = "button">({ className, as, children, variant, size, disabled, isSelected, isActive, leftContent, rightContent, ...props }: ChipProps<C>): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
export declare namespace Chip {
|
|
19
|
+
var displayName: string;
|
|
20
|
+
}
|
|
18
21
|
export {};
|
|
19
22
|
//# sourceMappingURL=Chip.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAO,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,QAAA,MAAM,YAAY;;;;;;8EA4HjB,CAAC;AAEF,KAAK,YAAY,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,SAAS,WAAW,IAAI,yBAAyB,CAC/D,CAAC,EACD,YAAY,CACb,CAAC;AAEF,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ,EAAE,EACrD,SAAS,EACT,EAAE,EACF,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,SAAS,CAAC,CAAC,CAAC,2CAuBd"}
|
|
1
|
+
{"version":3,"file":"Chip.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAO,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAG7D,QAAA,MAAM,YAAY;;;;;;8EA4HjB,CAAC;AAEF,KAAK,YAAY,GAAG,YAAY,CAAC,OAAO,YAAY,CAAC,GAAG;IACtD,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,WAAW,CAAC,EAAE,SAAS,CAAC;IACxB,YAAY,CAAC,EAAE,SAAS,CAAC;CAC1B,CAAC;AAEF,KAAK,SAAS,CAAC,CAAC,SAAS,WAAW,IAAI,yBAAyB,CAC/D,CAAC,EACD,YAAY,CACb,CAAC;AAEF,wBAAgB,IAAI,CAAC,CAAC,SAAS,WAAW,GAAG,QAAQ,EAAE,EACrD,SAAS,EACT,EAAE,EACF,QAAQ,EACR,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,WAAW,EACX,YAAY,EACZ,GAAG,KAAK,EACT,EAAE,SAAS,CAAC,CAAC,CAAC,2CAuBd;yBAnCe,IAAI"}
|
|
@@ -17,16 +17,16 @@ const chipVariants = (0, class_variance_authority_1.cva)("ui:flex ui:items-cente
|
|
|
17
17
|
small: "ui:text-button3 ui:h-[26px] ui:px-[10px] ui:py-[4.5px]",
|
|
18
18
|
},
|
|
19
19
|
disabled: {
|
|
20
|
-
false: "ui:cursor-pointer",
|
|
21
20
|
true: "ui:pointer-events-none",
|
|
21
|
+
false: "ui:cursor-pointer",
|
|
22
22
|
},
|
|
23
23
|
isSelected: {
|
|
24
|
-
false: "",
|
|
25
24
|
true: "",
|
|
25
|
+
false: "",
|
|
26
26
|
},
|
|
27
27
|
isActive: {
|
|
28
|
-
false: "",
|
|
29
28
|
true: "",
|
|
29
|
+
false: "",
|
|
30
30
|
},
|
|
31
31
|
},
|
|
32
32
|
compoundVariants: [
|
|
@@ -136,3 +136,4 @@ function Chip({ className, as, children, variant, size, disabled, isSelected, is
|
|
|
136
136
|
className,
|
|
137
137
|
})), disabled: disabled || undefined, ...props, children: [leftContent, (0, jsx_runtime_1.jsx)("span", { children: children }), rightContent] }));
|
|
138
138
|
}
|
|
139
|
+
Chip.displayName = "Chip";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCmB,CAAC;AAE9B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAkBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC"}
|
|
1
|
+
{"version":3,"file":"Chip.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Chip/Chip.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAE9B,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuCmB,CAAC;AAE9B,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAEnC,eAAO,MAAM,QAAQ,EAAE,KAqCtB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAkBlB,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,KAmBlB,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Text = exports.Line = exports.Fill = void 0;
|
|
3
|
+
exports.Text = exports.Line = exports.Fill = exports.Variants = void 0;
|
|
4
4
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
5
|
const Chip_1 = require("./Chip");
|
|
6
6
|
const meta = {
|
|
@@ -44,6 +44,32 @@ const meta = {
|
|
|
44
44
|
},
|
|
45
45
|
};
|
|
46
46
|
exports.default = meta;
|
|
47
|
+
exports.Variants = {
|
|
48
|
+
parameters: {
|
|
49
|
+
docs: {
|
|
50
|
+
description: {
|
|
51
|
+
story: `
|
|
52
|
+
- Chip의 variant 스타일을 변경하려면 <code>variant</code> 속성을 사용하세요. 사용할 수 있는 값에는 <code>fill</code>, <code>line</code>, <code>text</code> 가 있어요. 기본값은 <code>fill</code> 입니다.
|
|
53
|
+
`,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
render: (props) => ((0, jsx_runtime_1.jsxs)("div", { className: "ui:flex ui:gap-2", children: [(0, jsx_runtime_1.jsx)(Chip_1.Chip, { variant: "fill", size: "large", ...props, children: props.children }), (0, jsx_runtime_1.jsx)(Chip_1.Chip, { variant: "line", size: "large", ...props, children: props.children }), (0, jsx_runtime_1.jsx)(Chip_1.Chip, { variant: "text", size: "small", ...props, children: props.children })] })),
|
|
58
|
+
args: {
|
|
59
|
+
children: "Button text",
|
|
60
|
+
disabled: false,
|
|
61
|
+
},
|
|
62
|
+
argTypes: {
|
|
63
|
+
isSelected: {
|
|
64
|
+
control: { type: "boolean" },
|
|
65
|
+
options: ["true", "false"],
|
|
66
|
+
},
|
|
67
|
+
isActive: {
|
|
68
|
+
control: { type: "boolean" },
|
|
69
|
+
options: ["true", "false"],
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
};
|
|
47
73
|
exports.Fill = {
|
|
48
74
|
render: (props) => ((0, jsx_runtime_1.jsx)(Chip_1.Chip, { variant: "fill", ...props, children: props.children })),
|
|
49
75
|
args: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ButtonHTMLAttributes } from "react";
|
|
2
|
+
import { type VariantProps } from "class-variance-authority";
|
|
3
|
+
declare const toggleVariants: (props?: ({
|
|
4
|
+
disabled?: boolean | null | undefined;
|
|
5
|
+
checked?: boolean | null | undefined;
|
|
6
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
7
|
+
export interface ToggleProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, "disabled">, VariantProps<typeof toggleVariants> {
|
|
8
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
export declare function Toggle({ checked: controlledChecked, defaultChecked, disabled, onCheckedChange, ...props }: ToggleProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export declare namespace Toggle {
|
|
12
|
+
var displayName: string;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=Toggle.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/Toggle.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAY,MAAM,OAAO,CAAC;AACvD,OAAO,EAAO,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAGlE,QAAA,MAAM,cAAc;;;8EAmCnB,CAAC;AA6BF,MAAM,WAAW,WACf,SAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,EAAE,UAAU,CAAC,EAC/D,YAAY,CAAC,OAAO,cAAc,CAAC;IACrC,eAAe,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;CAC9C;AAED,wBAAgB,MAAM,CAAC,EACrB,OAAO,EAAE,iBAAiB,EAC1B,cAAc,EACd,QAAQ,EACR,eAAe,EACf,GAAG,KAAK,EACT,EAAE,WAAW,2CAkCb;yBAxCe,MAAM"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.Toggle = Toggle;
|
|
5
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const class_variance_authority_1 = require("class-variance-authority");
|
|
8
|
+
const style_1 = require("../../utils/style");
|
|
9
|
+
const toggleVariants = (0, class_variance_authority_1.cva)("ui:focus:ring-0 ui:ring-0 ui:h-[31px] ui:w-[51px] ui:rounded-full ui:inline-flex ui:items-center ui:rounded-full ui:transition-colors ui:duration-100", {
|
|
10
|
+
variants: {
|
|
11
|
+
disabled: {
|
|
12
|
+
true: "ui:pointer-events-none",
|
|
13
|
+
false: "ui:cursor-pointer",
|
|
14
|
+
},
|
|
15
|
+
checked: {
|
|
16
|
+
true: "ui:bg-blue-700",
|
|
17
|
+
false: "ui:bg-gray-100",
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
compoundVariants: [
|
|
21
|
+
{
|
|
22
|
+
disabled: false,
|
|
23
|
+
checked: false,
|
|
24
|
+
className: "ui:active:bg-gray-200",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
disabled: true,
|
|
28
|
+
checked: false,
|
|
29
|
+
className: "ui:bg-gray-50",
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
disabled: true,
|
|
33
|
+
checked: true,
|
|
34
|
+
className: "ui:bg-blue-300",
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
defaultVariants: {
|
|
38
|
+
disabled: false,
|
|
39
|
+
checked: false,
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
const thumbVariants = (0, class_variance_authority_1.cva)("ui:focus:ring-0 ui:ring-0 ui:bg-white ui:rounded-full ui:transition-transform", {
|
|
43
|
+
variants: {
|
|
44
|
+
disabled: {
|
|
45
|
+
true: "",
|
|
46
|
+
false: "",
|
|
47
|
+
},
|
|
48
|
+
checked: {
|
|
49
|
+
true: "ui:w-[25px] ui:h-[25px] ui:translate-x-6",
|
|
50
|
+
false: "ui:w-[21px] ui:h-[21px] ui:translate-x-1",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
compoundVariants: [
|
|
54
|
+
{
|
|
55
|
+
disabled: false,
|
|
56
|
+
checked: false,
|
|
57
|
+
className: "ui:active:bg-gray-100",
|
|
58
|
+
},
|
|
59
|
+
],
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
disabled: false,
|
|
62
|
+
checked: false,
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
function Toggle({ checked: controlledChecked, defaultChecked, disabled, onCheckedChange, ...props }) {
|
|
66
|
+
const [uncontrolledChecked, setUncontrolledChecked] = (0, react_1.useState)(defaultChecked);
|
|
67
|
+
const isChecked = controlledChecked ?? uncontrolledChecked;
|
|
68
|
+
const handleClick = () => {
|
|
69
|
+
if (disabled) {
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (controlledChecked === undefined) {
|
|
73
|
+
setUncontrolledChecked(!isChecked);
|
|
74
|
+
}
|
|
75
|
+
onCheckedChange?.(!isChecked);
|
|
76
|
+
};
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)("button", { role: "switch", onClick: handleClick, "aria-checked": isChecked, className: (0, style_1.cn)(toggleVariants({
|
|
78
|
+
checked: isChecked,
|
|
79
|
+
disabled,
|
|
80
|
+
})), disabled: disabled || undefined, ...props, children: (0, jsx_runtime_1.jsx)("span", { className: thumbVariants({ checked: isChecked, disabled }) }) }));
|
|
81
|
+
}
|
|
82
|
+
Toggle.displayName = "Toggle";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { StoryObj } from "@storybook/react";
|
|
2
|
+
import { Toggle } from "./Toggle";
|
|
3
|
+
declare const meta: {
|
|
4
|
+
title: string;
|
|
5
|
+
component: typeof Toggle;
|
|
6
|
+
tags: string[];
|
|
7
|
+
parameters: {
|
|
8
|
+
docs: {
|
|
9
|
+
description: {
|
|
10
|
+
component: string;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
argTypes: {
|
|
15
|
+
disabled: {
|
|
16
|
+
control: {
|
|
17
|
+
type: "boolean";
|
|
18
|
+
};
|
|
19
|
+
options: string[];
|
|
20
|
+
};
|
|
21
|
+
checked: {
|
|
22
|
+
control: {
|
|
23
|
+
type: "boolean";
|
|
24
|
+
};
|
|
25
|
+
options: string[];
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export default meta;
|
|
30
|
+
type Story = StoryObj<typeof meta>;
|
|
31
|
+
export declare const Controlled: Story;
|
|
32
|
+
export declare const UnControlled: Story;
|
|
33
|
+
//# sourceMappingURL=Toggle.stories.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Toggle.stories.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/Toggle.stories.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAQ,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEvD,OAAO,EAAE,MAAM,EAAe,MAAM,UAAU,CAAC;AAE/C,QAAA,MAAM,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;CAwBqB,CAAC;AAEhC,eAAe,IAAI,CAAC;AACpB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAC;AAcnC,eAAO,MAAM,UAAU,EAAE,KA8CxB,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KA2B1B,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UnControlled = exports.Controlled = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const test_1 = require("@storybook/test");
|
|
7
|
+
const Toggle_1 = require("./Toggle");
|
|
8
|
+
const meta = {
|
|
9
|
+
title: "Components/Toggle",
|
|
10
|
+
component: Toggle_1.Toggle,
|
|
11
|
+
tags: ["autodocs"],
|
|
12
|
+
parameters: {
|
|
13
|
+
docs: {
|
|
14
|
+
description: {
|
|
15
|
+
component: `
|
|
16
|
+
즉각적인 상태 전환(켜기/끄기)을 위한 요소로, 활성화/비활성화 기능을 나타냅니다.
|
|
17
|
+
|
|
18
|
+
`,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
argTypes: {
|
|
23
|
+
disabled: {
|
|
24
|
+
control: { type: "boolean" },
|
|
25
|
+
options: ["true", "false"],
|
|
26
|
+
},
|
|
27
|
+
checked: {
|
|
28
|
+
control: { type: "boolean" },
|
|
29
|
+
options: ["true", "false"],
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
exports.default = meta;
|
|
34
|
+
function ToggleWithControlled(props) {
|
|
35
|
+
const [checked, setChecked] = (0, react_1.useState)(props.checked);
|
|
36
|
+
return ((0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { ...props, checked: checked, onCheckedChange: () => setChecked(!checked) }));
|
|
37
|
+
}
|
|
38
|
+
exports.Controlled = {
|
|
39
|
+
parameters: {
|
|
40
|
+
docs: {
|
|
41
|
+
description: {
|
|
42
|
+
story: `
|
|
43
|
+
### 상태를 외부에서 관리하는 방식
|
|
44
|
+
|
|
45
|
+
Toggle의 상태를 외부에서 관리하려면 <code>checked</code>와 <code>onCheckedChange</code> 속성을 함께 사용하세요.
|
|
46
|
+
`,
|
|
47
|
+
},
|
|
48
|
+
source: {
|
|
49
|
+
code: `
|
|
50
|
+
function Controlled() {
|
|
51
|
+
const [checked, setChecked] = useState(props.checked);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Toggle
|
|
55
|
+
checked={checked}
|
|
56
|
+
onCheckedChange={() => setChecked(!checked)}
|
|
57
|
+
/>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
`.trim(),
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
render: (props) => (0, jsx_runtime_1.jsx)(ToggleWithControlled, { ...props }),
|
|
65
|
+
args: {
|
|
66
|
+
checked: false,
|
|
67
|
+
disabled: false,
|
|
68
|
+
},
|
|
69
|
+
argTypes: {
|
|
70
|
+
checked: {
|
|
71
|
+
control: { type: "boolean" },
|
|
72
|
+
options: ["true", "false"],
|
|
73
|
+
},
|
|
74
|
+
disabled: {
|
|
75
|
+
control: { type: "boolean" },
|
|
76
|
+
options: ["true", "false"],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
play: async ({ canvasElement }) => {
|
|
80
|
+
const canvas = (0, test_1.within)(canvasElement);
|
|
81
|
+
const toggle = canvas.getByRole("switch");
|
|
82
|
+
await test_1.userEvent.click(toggle);
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
exports.UnControlled = {
|
|
86
|
+
parameters: {
|
|
87
|
+
docs: {
|
|
88
|
+
description: {
|
|
89
|
+
story: `
|
|
90
|
+
### 상태를 내부에서 관리하는 방식
|
|
91
|
+
|
|
92
|
+
Toggle의 상태를 내부에서 자동으로 관리하려면 <code>defaultChecked</code> 속성을 사용하세요. 이 속성은 Toggle이 처음 화면에 표시될 때 선택 상태를 정해주고, 그 후에는 컴포넌트가 스스로 상태를 관리해요. 상태 변화를 추적하지 않아도 될 때 유용해요.
|
|
93
|
+
`,
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
render: (props) => (0, jsx_runtime_1.jsx)(Toggle_1.Toggle, { defaultChecked: true, ...props }),
|
|
98
|
+
args: {
|
|
99
|
+
defaultChecked: true,
|
|
100
|
+
},
|
|
101
|
+
argTypes: {
|
|
102
|
+
defaultChecked: {
|
|
103
|
+
control: { type: "boolean" },
|
|
104
|
+
options: ["true", "false"],
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
play: async ({ canvasElement }) => {
|
|
108
|
+
const canvas = (0, test_1.within)(canvasElement);
|
|
109
|
+
const toggle = canvas.getByRole("switch");
|
|
110
|
+
await test_1.userEvent.click(toggle);
|
|
111
|
+
},
|
|
112
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/Toggle/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.css
CHANGED
|
@@ -277,9 +277,21 @@
|
|
|
277
277
|
.ui\:grid {
|
|
278
278
|
display: grid;
|
|
279
279
|
}
|
|
280
|
+
.ui\:inline-flex {
|
|
281
|
+
display: inline-flex;
|
|
282
|
+
}
|
|
283
|
+
.ui\:h-\[21px\] {
|
|
284
|
+
height: 21px;
|
|
285
|
+
}
|
|
286
|
+
.ui\:h-\[25px\] {
|
|
287
|
+
height: 25px;
|
|
288
|
+
}
|
|
280
289
|
.ui\:h-\[26px\] {
|
|
281
290
|
height: 26px;
|
|
282
291
|
}
|
|
292
|
+
.ui\:h-\[31px\] {
|
|
293
|
+
height: 31px;
|
|
294
|
+
}
|
|
283
295
|
.ui\:h-\[32px\] {
|
|
284
296
|
height: 32px;
|
|
285
297
|
}
|
|
@@ -298,6 +310,15 @@
|
|
|
298
310
|
.ui\:h-px {
|
|
299
311
|
height: 1px;
|
|
300
312
|
}
|
|
313
|
+
.ui\:w-\[21px\] {
|
|
314
|
+
width: 21px;
|
|
315
|
+
}
|
|
316
|
+
.ui\:w-\[25px\] {
|
|
317
|
+
width: 25px;
|
|
318
|
+
}
|
|
319
|
+
.ui\:w-\[51px\] {
|
|
320
|
+
width: 51px;
|
|
321
|
+
}
|
|
301
322
|
.ui\:w-full {
|
|
302
323
|
width: 100%;
|
|
303
324
|
}
|
|
@@ -307,6 +328,14 @@
|
|
|
307
328
|
.ui\:flex-1 {
|
|
308
329
|
flex: 1;
|
|
309
330
|
}
|
|
331
|
+
.ui\:translate-x-1 {
|
|
332
|
+
--tw-translate-x: calc(var(--ui-spacing) * 1);
|
|
333
|
+
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
334
|
+
}
|
|
335
|
+
.ui\:translate-x-6 {
|
|
336
|
+
--tw-translate-x: calc(var(--ui-spacing) * 6);
|
|
337
|
+
translate: var(--tw-translate-x) var(--tw-translate-y);
|
|
338
|
+
}
|
|
310
339
|
.ui\:cursor-pointer {
|
|
311
340
|
cursor: pointer;
|
|
312
341
|
}
|
|
@@ -383,6 +412,9 @@
|
|
|
383
412
|
.ui\:bg-blue-600 {
|
|
384
413
|
background-color: var(--ui-color-blue-600);
|
|
385
414
|
}
|
|
415
|
+
.ui\:bg-blue-700 {
|
|
416
|
+
background-color: var(--ui-color-blue-700);
|
|
417
|
+
}
|
|
386
418
|
.ui\:bg-gray-50 {
|
|
387
419
|
background-color: var(--ui-color-gray-50);
|
|
388
420
|
}
|
|
@@ -599,11 +631,20 @@
|
|
|
599
631
|
.ui\:text-white {
|
|
600
632
|
color: var(--ui-color-white);
|
|
601
633
|
}
|
|
634
|
+
.ui\:ring-0 {
|
|
635
|
+
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
636
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
637
|
+
}
|
|
602
638
|
.ui\:transition-colors {
|
|
603
639
|
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
|
604
640
|
transition-timing-function: var(--tw-ease, var(--ui-default-transition-timing-function));
|
|
605
641
|
transition-duration: var(--tw-duration, var(--ui-default-transition-duration));
|
|
606
642
|
}
|
|
643
|
+
.ui\:transition-transform {
|
|
644
|
+
transition-property: transform, translate, scale, rotate;
|
|
645
|
+
transition-timing-function: var(--tw-ease, var(--ui-default-transition-timing-function));
|
|
646
|
+
transition-duration: var(--tw-duration, var(--ui-default-transition-duration));
|
|
647
|
+
}
|
|
607
648
|
.ui\:duration-100 {
|
|
608
649
|
--tw-duration: 100ms;
|
|
609
650
|
transition-duration: 100ms;
|
|
@@ -616,6 +657,12 @@
|
|
|
616
657
|
-webkit-user-select: none;
|
|
617
658
|
user-select: none;
|
|
618
659
|
}
|
|
660
|
+
.ui\:focus\:ring-0 {
|
|
661
|
+
&:focus {
|
|
662
|
+
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(0px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
|
663
|
+
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
619
666
|
.ui\:active\:bg-blue-50 {
|
|
620
667
|
&:active {
|
|
621
668
|
background-color: var(--ui-color-blue-50);
|
|
@@ -823,11 +870,91 @@
|
|
|
823
870
|
}
|
|
824
871
|
}
|
|
825
872
|
@layer utilities;
|
|
873
|
+
@property --tw-translate-x {
|
|
874
|
+
syntax: "*";
|
|
875
|
+
inherits: false;
|
|
876
|
+
initial-value: 0;
|
|
877
|
+
}
|
|
878
|
+
@property --tw-translate-y {
|
|
879
|
+
syntax: "*";
|
|
880
|
+
inherits: false;
|
|
881
|
+
initial-value: 0;
|
|
882
|
+
}
|
|
883
|
+
@property --tw-translate-z {
|
|
884
|
+
syntax: "*";
|
|
885
|
+
inherits: false;
|
|
886
|
+
initial-value: 0;
|
|
887
|
+
}
|
|
826
888
|
@property --tw-border-style {
|
|
827
889
|
syntax: "*";
|
|
828
890
|
inherits: false;
|
|
829
891
|
initial-value: solid;
|
|
830
892
|
}
|
|
893
|
+
@property --tw-shadow {
|
|
894
|
+
syntax: "*";
|
|
895
|
+
inherits: false;
|
|
896
|
+
initial-value: 0 0 #0000;
|
|
897
|
+
}
|
|
898
|
+
@property --tw-shadow-color {
|
|
899
|
+
syntax: "*";
|
|
900
|
+
inherits: false;
|
|
901
|
+
}
|
|
902
|
+
@property --tw-shadow-alpha {
|
|
903
|
+
syntax: "<percentage>";
|
|
904
|
+
inherits: false;
|
|
905
|
+
initial-value: 100%;
|
|
906
|
+
}
|
|
907
|
+
@property --tw-inset-shadow {
|
|
908
|
+
syntax: "*";
|
|
909
|
+
inherits: false;
|
|
910
|
+
initial-value: 0 0 #0000;
|
|
911
|
+
}
|
|
912
|
+
@property --tw-inset-shadow-color {
|
|
913
|
+
syntax: "*";
|
|
914
|
+
inherits: false;
|
|
915
|
+
}
|
|
916
|
+
@property --tw-inset-shadow-alpha {
|
|
917
|
+
syntax: "<percentage>";
|
|
918
|
+
inherits: false;
|
|
919
|
+
initial-value: 100%;
|
|
920
|
+
}
|
|
921
|
+
@property --tw-ring-color {
|
|
922
|
+
syntax: "*";
|
|
923
|
+
inherits: false;
|
|
924
|
+
}
|
|
925
|
+
@property --tw-ring-shadow {
|
|
926
|
+
syntax: "*";
|
|
927
|
+
inherits: false;
|
|
928
|
+
initial-value: 0 0 #0000;
|
|
929
|
+
}
|
|
930
|
+
@property --tw-inset-ring-color {
|
|
931
|
+
syntax: "*";
|
|
932
|
+
inherits: false;
|
|
933
|
+
}
|
|
934
|
+
@property --tw-inset-ring-shadow {
|
|
935
|
+
syntax: "*";
|
|
936
|
+
inherits: false;
|
|
937
|
+
initial-value: 0 0 #0000;
|
|
938
|
+
}
|
|
939
|
+
@property --tw-ring-inset {
|
|
940
|
+
syntax: "*";
|
|
941
|
+
inherits: false;
|
|
942
|
+
}
|
|
943
|
+
@property --tw-ring-offset-width {
|
|
944
|
+
syntax: "<length>";
|
|
945
|
+
inherits: false;
|
|
946
|
+
initial-value: 0px;
|
|
947
|
+
}
|
|
948
|
+
@property --tw-ring-offset-color {
|
|
949
|
+
syntax: "*";
|
|
950
|
+
inherits: false;
|
|
951
|
+
initial-value: #fff;
|
|
952
|
+
}
|
|
953
|
+
@property --tw-ring-offset-shadow {
|
|
954
|
+
syntax: "*";
|
|
955
|
+
inherits: false;
|
|
956
|
+
initial-value: 0 0 #0000;
|
|
957
|
+
}
|
|
831
958
|
@property --tw-duration {
|
|
832
959
|
syntax: "*";
|
|
833
960
|
inherits: false;
|
|
@@ -835,7 +962,24 @@
|
|
|
835
962
|
@layer properties {
|
|
836
963
|
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
|
837
964
|
*, ::before, ::after, ::backdrop {
|
|
965
|
+
--tw-translate-x: 0;
|
|
966
|
+
--tw-translate-y: 0;
|
|
967
|
+
--tw-translate-z: 0;
|
|
838
968
|
--tw-border-style: solid;
|
|
969
|
+
--tw-shadow: 0 0 #0000;
|
|
970
|
+
--tw-shadow-color: initial;
|
|
971
|
+
--tw-shadow-alpha: 100%;
|
|
972
|
+
--tw-inset-shadow: 0 0 #0000;
|
|
973
|
+
--tw-inset-shadow-color: initial;
|
|
974
|
+
--tw-inset-shadow-alpha: 100%;
|
|
975
|
+
--tw-ring-color: initial;
|
|
976
|
+
--tw-ring-shadow: 0 0 #0000;
|
|
977
|
+
--tw-inset-ring-color: initial;
|
|
978
|
+
--tw-inset-ring-shadow: 0 0 #0000;
|
|
979
|
+
--tw-ring-inset: initial;
|
|
980
|
+
--tw-ring-offset-width: 0px;
|
|
981
|
+
--tw-ring-offset-color: #fff;
|
|
982
|
+
--tw-ring-offset-shadow: 0 0 #0000;
|
|
839
983
|
--tw-duration: initial;
|
|
840
984
|
}
|
|
841
985
|
}
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,qBAAqB,CAAC;AAGpC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -17,5 +17,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
17
17
|
/* ------------------------------- COMPONENTS ------------------------------- */
|
|
18
18
|
__exportStar(require("./components/Button"), exports);
|
|
19
19
|
__exportStar(require("./components/Chip"), exports);
|
|
20
|
+
__exportStar(require("./components/Toggle"), exports);
|
|
20
21
|
/* --------------------------------- ICONS ---------------------------------- */
|
|
21
22
|
__exportStar(require("./components/Icons"), exports);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reitwagen/design-components",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"sideEffects": [
|
|
5
5
|
"**/*.css"
|
|
6
6
|
],
|
|
@@ -32,6 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@storybook/addon-docs": "^10.0.7",
|
|
34
34
|
"@storybook/react": "^10.0.7",
|
|
35
|
+
"@storybook/test": "^8.6.14",
|
|
35
36
|
"@svgr/core": "^8.1.0",
|
|
36
37
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
37
38
|
"@svgr/plugin-prettier": "^8.1.0",
|