linkedunion-design-kit 1.9.2 → 1.9.4
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/app/layout.jsx +13 -0
- package/dist/app/page.jsx +25 -0
- package/dist/build/types/app/layout.d.ts +12 -0
- package/dist/build/types/app/layout.js +22 -0
- package/dist/build/types/app/page.d.ts +12 -0
- package/dist/build/types/app/page.js +22 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/src/components/Accordion/Accordion.stories.jsx +33 -0
- package/dist/src/components/Accordion/accordion.jsx +59 -0
- package/dist/src/components/Alerts/Alert/alert.jsx +152 -0
- package/dist/src/components/Alerts/Alert/alert.stories.jsx +344 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.jsx +170 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.stories.jsx +552 -0
- package/dist/src/components/AppIcons/AndroidIcon.jsx +24 -0
- package/dist/src/components/AppIcons/AppIcon.jsx +29 -0
- package/dist/src/components/AppIcons/AppIcon.stories.jsx +223 -0
- package/dist/src/components/AppIcons/AppleIcon.jsx +31 -0
- package/dist/src/components/AppIcons/PlayStoreIcon.jsx +29 -0
- package/dist/src/components/Avatar/Avatar/Avatar.jsx +45 -0
- package/dist/src/components/Avatar/Avatar/Avatar.stories.jsx +95 -0
- package/dist/src/components/Avatar/Avatar/Avatar.test.jsx +9 -0
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.jsx +17 -0
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.stories.jsx +32 -0
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.jsx +20 -0
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.stories.jsx +50 -0
- package/dist/src/components/Badge/Badge.jsx +54 -0
- package/dist/src/components/Badge/Badge.stories.jsx +201 -0
- package/dist/src/components/Button/Button/Button.d.ts +7 -6
- package/dist/src/components/Button/Button/Button.js +32 -9
- package/dist/src/components/Button/Button/Button.jsx +101 -0
- package/dist/src/components/Button/Button/Button.stories.jsx +283 -0
- package/dist/src/components/Button/Button/Button.test.jsx +73 -0
- package/dist/src/components/Button/IconButton/IconButton.jsx +63 -0
- package/dist/src/components/Button/IconButton/IconButton.stories.jsx +128 -0
- package/dist/src/components/Button/IconButton/IconButton.test.jsx +28 -0
- package/dist/src/components/Button/index.js +3 -3
- package/dist/src/components/Card/MultipleNews/MultiNews.jsx +80 -0
- package/dist/src/components/Card/MultipleNews/MultiNews.stories.jsx +104 -0
- package/dist/src/components/Card/PostByCategory/PostByCategory.jsx +60 -0
- package/dist/src/components/Card/PostByCategory/PostByCategory.stories.jsx +106 -0
- package/dist/src/components/Card/SinglePost/SinglePost.jsx +26 -0
- package/dist/src/components/Card/SinglePost/SinglePost.stories.jsx +68 -0
- package/dist/src/components/Card/card.jsx +36 -0
- package/dist/src/components/Card/contactProfile/ContactProfile.jsx +60 -0
- package/dist/src/components/Card/contactProfile/ContactProfile.stories.jsx +103 -0
- package/dist/src/components/Card/photoAlbum/PhotoAlbum.jsx +41 -0
- package/dist/src/components/Card/photoAlbum/PhotoAlbum.stories.jsx +69 -0
- package/dist/src/components/Card/photoGallery/PhotoGallery.jsx +17 -0
- package/dist/src/components/Card/photoGallery/PhotoGallery.stories.jsx +39 -0
- package/dist/src/components/Checkbox/checkbox.jsx +47 -0
- package/dist/src/components/Checkbox/checkbox.stories.jsx +113 -0
- package/dist/src/components/ColorPicker/ColorPicker.jsx +67 -0
- package/dist/src/components/ColorPicker/ColorPicker.stories.jsx +138 -0
- package/dist/src/components/Colors/color.jsx +5 -0
- package/dist/src/components/Colors/color.stories.jsx +20 -0
- package/dist/src/components/Colors/color.test.jsx +23 -0
- package/dist/src/components/Dropdown/Combobox/Combobox.jsx +198 -0
- package/dist/src/components/Dropdown/Combobox/Combobox.stories.jsx +289 -0
- package/dist/src/components/Dropdown/Combobox/utils/renderBadge.jsx +7 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.jsx +102 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.stories.jsx +464 -0
- package/dist/src/components/Dropdown/DropdownMenu/SelectAllSection.jsx +19 -0
- package/dist/src/components/Dropdown/Select.stories.jsx +201 -0
- package/dist/src/components/Dropdown/select.jsx +93 -0
- package/dist/src/components/Icons/LUIcon.jsx +41 -0
- package/dist/src/components/Icons/LUIcon.test.jsx +308 -0
- package/dist/src/components/Icons/stories/IconDropdown.jsx +67 -0
- package/dist/src/components/Icons/stories/IconGallery.jsx +77 -0
- package/dist/src/components/Icons/stories/InteractiveIconSelector.jsx +86 -0
- package/dist/src/components/Icons/stories/LUIcon.stories.jsx +108 -0
- package/dist/src/components/ImageUploader/ImageUploader.stories.jsx +50 -0
- package/dist/src/components/ImageUploader/imageUploader.jsx +94 -0
- package/dist/src/components/Images/LuImage.jsx +19 -0
- package/dist/src/components/Images/LuImage.stories.jsx +154 -0
- package/dist/src/components/Images/LuImage.test.jsx +44 -0
- package/dist/src/components/Input/Input.stories.jsx +250 -0
- package/dist/src/components/Input/input.jsx +110 -0
- package/dist/src/components/Label/Label.jsx +32 -0
- package/dist/src/components/Label/Label.stories.jsx +30 -0
- package/dist/src/components/Pagination/pagination.d.ts +33 -0
- package/dist/src/components/Pagination/pagination.js +68 -0
- package/dist/src/components/Pagination/pagination.jsx +68 -0
- package/dist/src/components/Pagination/pagination.stories.d.ts +74 -0
- package/dist/src/components/Pagination/pagination.stories.js +168 -0
- package/dist/src/components/Pagination/pagination.stories.jsx +114 -0
- package/dist/src/components/RadioGroup/RadioGroup.stories.jsx +146 -0
- package/dist/src/components/RadioGroup/radio-group.jsx +49 -0
- package/dist/src/components/Skeleton/skeleton.d.ts +117 -0
- package/dist/src/components/Skeleton/skeleton.js +140 -0
- package/dist/src/components/Skeleton/skeleton.stories.d.ts +153 -0
- package/dist/src/components/Skeleton/skeleton.stories.js +404 -0
- package/dist/src/components/Slider/Slider.stories.jsx +159 -0
- package/dist/src/components/Slider/slider.jsx +31 -0
- package/dist/src/components/SweetAlert/SweetAlert.jsx +147 -0
- package/dist/src/components/SweetAlert/SweetAlert.stories.jsx +505 -0
- package/dist/src/components/Switch/Switch.stories.jsx +66 -0
- package/dist/src/components/Switch/switch.jsx +61 -0
- package/dist/src/components/Table/Table.d.ts +26 -0
- package/dist/src/components/Table/Table.js +186 -0
- package/dist/src/components/Table/Table.jsx +221 -0
- package/dist/src/components/Table/Table.stories.d.ts +51 -0
- package/dist/src/components/Table/Table.stories.js +408 -0
- package/dist/src/components/Table/Table.stories.jsx +652 -0
- package/dist/src/components/Table/index.d.ts +20 -0
- package/dist/src/components/Table/index.js +20 -0
- package/dist/src/components/Tabs/Tabs.stories.jsx +29 -0
- package/dist/src/components/Tabs/tabs.jsx +32 -0
- package/dist/src/components/Title/Title.jsx +8 -0
- package/dist/src/components/Title/Title.stories.jsx +37 -0
- package/dist/src/components/Title/Title.test.jsx +24 -0
- package/dist/src/components/ToolTip/Tooltip.jsx +18 -0
- package/dist/src/components/ToolTip/Tooltip.stories.jsx +25 -0
- package/dist/src/components/Typography/Body/Body.stories.jsx +34 -0
- package/dist/src/components/Typography/Body/body.jsx +52 -0
- package/dist/src/components/Typography/Caption/Caption.stories.jsx +24 -0
- package/dist/src/components/Typography/Caption/caption.jsx +25 -0
- package/dist/src/components/Typography/Display/Display.stories.jsx +24 -0
- package/dist/src/components/Typography/Display/display.jsx +39 -0
- package/dist/src/components/Typography/Heading/Heading.stories.jsx +37 -0
- package/dist/src/components/Typography/Heading/heading.jsx +53 -0
- package/dist/src/components/ui/avatar.d.ts +3 -10
- package/dist/src/components/ui/avatar.js +12 -27
- package/dist/src/components/ui/avatar.jsx +27 -0
- package/dist/src/components/ui/button.d.ts +10 -0
- package/dist/src/components/ui/button.js +56 -0
- package/dist/src/components/ui/button.jsx +45 -0
- package/dist/src/components/ui/collapsible.d.ts +5 -0
- package/dist/src/components/ui/collapsible.js +5 -0
- package/dist/src/components/ui/collapsible.jsx +5 -0
- package/dist/src/components/ui/command.jsx +67 -0
- package/dist/src/components/ui/dialog.jsx +66 -0
- package/dist/src/components/ui/popover.jsx +33 -0
- package/dist/src/components/ui/tooltip.jsx +38 -0
- package/dist/src/components/ui/typography.jsx +56 -0
- package/dist/src/utils/colors.js +11 -11
- package/dist/src/utils/iconList.d.ts +4 -0
- package/dist/src/utils/iconList.js +4 -0
- package/dist/styles/global.css +209 -67
- package/package.json +1 -1
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.d.ts +0 -17
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.js +0 -68
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { Dummy_Image, Dummy_Title } from "../../../utils/constants";
|
|
2
|
+
import Card from "../card";
|
|
3
|
+
import { PhotoAlbum } from "./PhotoAlbum";
|
|
4
|
+
export default {
|
|
5
|
+
title: "Components/Cards/PhotoAlbum",
|
|
6
|
+
component: PhotoAlbum,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
};
|
|
9
|
+
var Template = function (args) { return <Card {...args}/>; };
|
|
10
|
+
export var Default = Template.bind({});
|
|
11
|
+
Default.args = {
|
|
12
|
+
type: "photoAlbum",
|
|
13
|
+
theme: "theme1",
|
|
14
|
+
item: {
|
|
15
|
+
title: Dummy_Title,
|
|
16
|
+
images: [
|
|
17
|
+
{
|
|
18
|
+
gallery_name: "Sample Gallery",
|
|
19
|
+
gallery_image: "https://randomuser.me/api/portraits/men/32.jpg",
|
|
20
|
+
gallery_id: 1,
|
|
21
|
+
description: "This is a sample image description.",
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
gallery_name: "Another Gallery",
|
|
25
|
+
gallery_image: "https://randomuser.me/api/portraits/women/44.jpg",
|
|
26
|
+
gallery_id: 2,
|
|
27
|
+
description: "This is another sample image description.",
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
gallery_name: "Another Gallery",
|
|
31
|
+
gallery_image: Dummy_Image,
|
|
32
|
+
gallery_id: 2,
|
|
33
|
+
description: "https://randomuser.me/api/portraits/men/45.jpg",
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
image: Dummy_Image,
|
|
38
|
+
editor: {
|
|
39
|
+
card: "",
|
|
40
|
+
cardImage: "",
|
|
41
|
+
cardOverlay: "",
|
|
42
|
+
cardText: "",
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
Default.argTypes = {
|
|
46
|
+
type: {
|
|
47
|
+
control: false,
|
|
48
|
+
table: {
|
|
49
|
+
type: { summary: "string" },
|
|
50
|
+
defaultValue: {
|
|
51
|
+
summary: "photoAlbum",
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
theme: {
|
|
56
|
+
control: {
|
|
57
|
+
type: "select",
|
|
58
|
+
labels: ["theme1", "theme2"],
|
|
59
|
+
},
|
|
60
|
+
options: ["theme1", "theme2"],
|
|
61
|
+
defaultValue: {
|
|
62
|
+
summary: "theme1",
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
href: { control: false },
|
|
66
|
+
btnLabel: { control: false },
|
|
67
|
+
mediaPosition: { control: false },
|
|
68
|
+
orientation: { control: false },
|
|
69
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import LuImage from "../../../components/Images/LuImage";
|
|
2
|
+
import { Heading } from "../../../components/Typography/Heading/heading";
|
|
3
|
+
import LUIcon from "../../../components/Icons/LUIcon";
|
|
4
|
+
export var PhotoGallery = function (_a) {
|
|
5
|
+
var image = _a.image, item = _a.item, _b = _a.altText, altText = _b === void 0 ? "Photo Gallery" : _b, editor = _a.editor;
|
|
6
|
+
return (<div className={"group relative max-w-md cursor-pointer ".concat(editor === null || editor === void 0 ? void 0 : editor.card, " ").concat(editor === null || editor === void 0 ? void 0 : editor.cardImage)}>
|
|
7
|
+
<LuImage src={image} width={448} height={448} alt={altText} className={"aspect-square object-cover transition-transform"}/>
|
|
8
|
+
<div className={"absolute ".concat(editor === null || editor === void 0 ? void 0 : editor.cardOverlay, " inset-0 bg-linear-to-t from-black to-transparent")}></div>
|
|
9
|
+
<Heading variant="h4-700" className={"absolute line-clamp-1 text-white bottom-4 uppercase !px-5 ".concat(editor === null || editor === void 0 ? void 0 : editor.cardText)}>
|
|
10
|
+
{item === null || item === void 0 ? void 0 : item.title}
|
|
11
|
+
</Heading>
|
|
12
|
+
{/* Search icon - appears on hover */}
|
|
13
|
+
<div className="absolute inset-0 flex items-center justify-center bg-black/30 opacity-0 group-hover:!opacity-100 transition-opacity duration-300 ease-out">
|
|
14
|
+
<LUIcon icon="magnifying-glass" size="4xl" className={"".concat(editor === null || editor === void 0 ? void 0 : editor.cardText, " text-gray-100")}/>
|
|
15
|
+
</div>
|
|
16
|
+
</div>);
|
|
17
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Dummy_Image, Dummy_Title } from "../../../utils/constants";
|
|
2
|
+
import Card from "../card";
|
|
3
|
+
import { PhotoGallery } from "./PhotoGallery";
|
|
4
|
+
export default {
|
|
5
|
+
title: "Components/Cards/PhotoGallery",
|
|
6
|
+
component: PhotoGallery,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
};
|
|
9
|
+
var Template = function (args) { return <Card {...args}/>; };
|
|
10
|
+
export var Default = Template.bind({});
|
|
11
|
+
Default.args = {
|
|
12
|
+
type: "photoGallery",
|
|
13
|
+
item: {
|
|
14
|
+
title: Dummy_Title,
|
|
15
|
+
},
|
|
16
|
+
image: Dummy_Image,
|
|
17
|
+
editor: {
|
|
18
|
+
card: "",
|
|
19
|
+
cardImage: "",
|
|
20
|
+
cardOverlay: "",
|
|
21
|
+
cardText: "",
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
Default.argTypes = {
|
|
25
|
+
type: {
|
|
26
|
+
control: false,
|
|
27
|
+
table: {
|
|
28
|
+
type: { summary: "string" },
|
|
29
|
+
defaultValue: {
|
|
30
|
+
summary: "photoGallery",
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
href: { control: false },
|
|
35
|
+
btnLabel: { control: false },
|
|
36
|
+
mediaPosition: { control: false },
|
|
37
|
+
orientation: { control: false },
|
|
38
|
+
theme: { control: false },
|
|
39
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import * as React from "react";
|
|
13
|
+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox";
|
|
14
|
+
import { CheckIcon } from "lucide-react";
|
|
15
|
+
import { cn } from "../../lib/utils";
|
|
16
|
+
import { cva } from "class-variance-authority";
|
|
17
|
+
export var checkboxSize = {
|
|
18
|
+
sm: "size-3.5", // ~14px
|
|
19
|
+
md: "size-4", // ~16px
|
|
20
|
+
lg: "size-5", // ~20px
|
|
21
|
+
};
|
|
22
|
+
var iconSize = {
|
|
23
|
+
sm: "size-3", // ~12px
|
|
24
|
+
md: "size-3.5", // ~14px
|
|
25
|
+
lg: "size-4", // ~16px
|
|
26
|
+
};
|
|
27
|
+
var checkboxCva = cva("peer !border border-input !rounded-xs dark:bg-input/30 data-[state=checked]:bg-blue-600 data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-blue-600 data-[state=checked]:border-blue-600 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive shrink-0 hover:border-blue-600 shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50", {
|
|
28
|
+
variants: {
|
|
29
|
+
size: {
|
|
30
|
+
sm: "size-3.5",
|
|
31
|
+
md: "size-4",
|
|
32
|
+
lg: "size-5",
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
defaultVariants: {
|
|
36
|
+
size: "md",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
function Checkbox(_a) {
|
|
40
|
+
var className = _a.className, _b = _a.size, size = _b === void 0 ? "md" : _b, props = __rest(_a, ["className", "size"]);
|
|
41
|
+
return (<CheckboxPrimitive.Root data-slot="checkbox" className={cn(checkboxCva({ size: size }), className)} {...props}>
|
|
42
|
+
<CheckboxPrimitive.Indicator data-slot="checkbox-indicator" className="flex items-center justify-center text-current transition-none">
|
|
43
|
+
<CheckIcon className={iconSize[size]}/>
|
|
44
|
+
</CheckboxPrimitive.Indicator>
|
|
45
|
+
</CheckboxPrimitive.Root>);
|
|
46
|
+
}
|
|
47
|
+
export { Checkbox };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Checkbox, checkboxSize } from "./checkbox";
|
|
2
|
+
import { Label } from "../Label/Label";
|
|
3
|
+
import { Button } from "../Button/Button/Button";
|
|
4
|
+
var meta = {
|
|
5
|
+
title: "components/Checkbox",
|
|
6
|
+
component: Checkbox,
|
|
7
|
+
parameters: {
|
|
8
|
+
layout: "centered",
|
|
9
|
+
},
|
|
10
|
+
tags: ["autodocs"],
|
|
11
|
+
argTypes: {
|
|
12
|
+
checked: { control: "boolean" },
|
|
13
|
+
defaultChecked: { control: "boolean" },
|
|
14
|
+
disabled: { control: "boolean" },
|
|
15
|
+
onCheckedChange: { action: "checked changed" },
|
|
16
|
+
size: {
|
|
17
|
+
control: { type: "select" },
|
|
18
|
+
options: Object.keys(checkboxSize),
|
|
19
|
+
description: "Checkbox size",
|
|
20
|
+
table: {
|
|
21
|
+
defaultValue: { summary: "md" },
|
|
22
|
+
type: { summary: Object.keys(checkboxSize).join(" | ") },
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
export default meta;
|
|
28
|
+
export var Default = {
|
|
29
|
+
args: {
|
|
30
|
+
id: "default",
|
|
31
|
+
},
|
|
32
|
+
render: function (args) { return (<div className="flex items-center space-x-2">
|
|
33
|
+
<Checkbox {...args}/>
|
|
34
|
+
<Label htmlFor="default" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
35
|
+
Accept terms and conditions
|
|
36
|
+
</Label>
|
|
37
|
+
</div>); },
|
|
38
|
+
};
|
|
39
|
+
export var Checked = {
|
|
40
|
+
args: {
|
|
41
|
+
id: "checked",
|
|
42
|
+
defaultChecked: true,
|
|
43
|
+
},
|
|
44
|
+
render: function (args) { return (<div className="flex items-center space-x-2">
|
|
45
|
+
<Checkbox {...args}/>
|
|
46
|
+
<Label htmlFor="checked" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
47
|
+
Checked option
|
|
48
|
+
</Label>
|
|
49
|
+
</div>); },
|
|
50
|
+
};
|
|
51
|
+
export var Disabled = {
|
|
52
|
+
args: {
|
|
53
|
+
id: "disabled",
|
|
54
|
+
disabled: true,
|
|
55
|
+
},
|
|
56
|
+
render: function (args) { return (<div className="flex items-center space-x-2">
|
|
57
|
+
<Checkbox {...args}/>
|
|
58
|
+
<Label htmlFor="disabled" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
59
|
+
Disabled option
|
|
60
|
+
</Label>
|
|
61
|
+
</div>); },
|
|
62
|
+
};
|
|
63
|
+
export var DisabledChecked = {
|
|
64
|
+
args: {
|
|
65
|
+
id: "disabled-checked",
|
|
66
|
+
disabled: true,
|
|
67
|
+
defaultChecked: true,
|
|
68
|
+
},
|
|
69
|
+
render: function (args) { return (<div className="flex items-center space-x-2">
|
|
70
|
+
<Checkbox {...args}/>
|
|
71
|
+
<Label htmlFor="disabled-checked" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
72
|
+
Disabled checked option
|
|
73
|
+
</Label>
|
|
74
|
+
</div>); },
|
|
75
|
+
};
|
|
76
|
+
export var Form = {
|
|
77
|
+
render: function () { return (<div className="space-y-4">
|
|
78
|
+
<h3 className="text-lg font-medium">Terms of Service</h3>
|
|
79
|
+
<p className="text-sm text-muted-foreground">
|
|
80
|
+
Please read and accept our terms of service to continue.
|
|
81
|
+
</p>
|
|
82
|
+
<form className="space-y-2">
|
|
83
|
+
<div className="flex items-center space-x-2">
|
|
84
|
+
<Checkbox id="terms1"/>
|
|
85
|
+
<label htmlFor="terms1" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
86
|
+
I accept the terms and conditions
|
|
87
|
+
</label>
|
|
88
|
+
</div>
|
|
89
|
+
<div className="flex items-center space-x-2">
|
|
90
|
+
<Checkbox id="terms2"/>
|
|
91
|
+
<Label htmlFor="terms2" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
92
|
+
I agree to receive marketing emails
|
|
93
|
+
</Label>
|
|
94
|
+
</div>
|
|
95
|
+
<Button type="submit" className="mt-4 rounded-md bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700">
|
|
96
|
+
Submit
|
|
97
|
+
</Button>
|
|
98
|
+
</form>
|
|
99
|
+
</div>); },
|
|
100
|
+
};
|
|
101
|
+
export var WithAlert = {
|
|
102
|
+
args: {
|
|
103
|
+
id: "alert-checkbox",
|
|
104
|
+
},
|
|
105
|
+
render: function (args) { return (<div className="flex items-center space-x-2">
|
|
106
|
+
<Checkbox {...args} onCheckedChange={function (checked) {
|
|
107
|
+
window.alert("Checkbox is now ".concat(checked ? "checked" : "unchecked"));
|
|
108
|
+
}}/>
|
|
109
|
+
<Label htmlFor="alert-checkbox" className="text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70">
|
|
110
|
+
Click to show alert
|
|
111
|
+
</Label>
|
|
112
|
+
</div>); },
|
|
113
|
+
};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
13
|
+
import { useState, useEffect } from "react";
|
|
14
|
+
import { Input } from "../Input/input";
|
|
15
|
+
import { getColorPickerSizes, getShapeClass } from ".";
|
|
16
|
+
var useDebounce = function (value, delay) {
|
|
17
|
+
var _a = useState(value), debouncedValue = _a[0], setDebouncedValue = _a[1];
|
|
18
|
+
useEffect(function () {
|
|
19
|
+
var handler = setTimeout(function () {
|
|
20
|
+
setDebouncedValue(value);
|
|
21
|
+
}, delay);
|
|
22
|
+
return function () {
|
|
23
|
+
clearTimeout(handler);
|
|
24
|
+
};
|
|
25
|
+
}, [value, delay]);
|
|
26
|
+
return debouncedValue;
|
|
27
|
+
};
|
|
28
|
+
var ColorPicker = function (_a) {
|
|
29
|
+
var onChange = _a.onChange, _b = _a.value, value = _b === void 0 ? "#000000" : _b, _c = _a.size, size = _c === void 0 ? "md" : _c, _d = _a.variant, variant = _d === void 0 ? "filled" : _d, _e = _a.color, color = _e === void 0 ? "default" : _e, _f = _a.shape, shape = _f === void 0 ? "square" : _f, className = _a.className, props = __rest(_a, ["onChange", "value", "size", "variant", "color", "shape", "className"]);
|
|
30
|
+
var _g = useState(value), hexColor = _g[0], setHexColor = _g[1];
|
|
31
|
+
var debouncedHexColor = useDebounce(hexColor, 200); // Use prop or default
|
|
32
|
+
var sizes = getColorPickerSizes(size || "md");
|
|
33
|
+
// Handle input changes (color picker or text field)
|
|
34
|
+
var handleColorChange = function (newColor) {
|
|
35
|
+
var formattedColor = newColor.startsWith("#") ? newColor : "#".concat(newColor);
|
|
36
|
+
setHexColor(formattedColor); // Set the local state immediately
|
|
37
|
+
};
|
|
38
|
+
useEffect(function () {
|
|
39
|
+
if (value !== hexColor) {
|
|
40
|
+
setHexColor(value);
|
|
41
|
+
}
|
|
42
|
+
}, [value]);
|
|
43
|
+
// Trigger onChange callback only when debounced value updates
|
|
44
|
+
useEffect(function () {
|
|
45
|
+
onChange(debouncedHexColor); // Trigger onChange with debounced value
|
|
46
|
+
}, [debouncedHexColor]);
|
|
47
|
+
// Handle hex input change
|
|
48
|
+
var handleHexChange = function (e) {
|
|
49
|
+
var inputValue = e.target.value;
|
|
50
|
+
// Ensure it starts with #
|
|
51
|
+
if (inputValue.length > 7) {
|
|
52
|
+
inputValue = inputValue.slice(0, 7); // Limit the input to 7 characters
|
|
53
|
+
}
|
|
54
|
+
handleColorChange(inputValue);
|
|
55
|
+
};
|
|
56
|
+
// Handle color input change (from native color picker)
|
|
57
|
+
var handleColorInputChange = function (e) {
|
|
58
|
+
handleColorChange(e.target.value);
|
|
59
|
+
};
|
|
60
|
+
return (<div className="relative">
|
|
61
|
+
<div className={"".concat(sizes.colorBox, " ").concat(sizes.left, " !border border-gray-200 ").concat(getShapeClass(shape), " top-1/2 -translate-y-1/2 absolute z-10 overflow-hidden")} style={{ backgroundColor: hexColor }}>
|
|
62
|
+
<Input type="color" value={hexColor} onChange={handleColorInputChange} className="h-full w-full opacity-0 cursor-pointer" aria-label="Select color" variant={variant} color={color} shape={shape}/>
|
|
63
|
+
</div>
|
|
64
|
+
<Input type="text" value={hexColor} onChange={handleHexChange} maxLength={7} aria-label="Hex color input" className={"p-1.5 border ".concat(sizes.minWidth, " ").concat(sizes.paddingStart, " ").concat(className || "")} size={size} variant={variant} color={color} shape={shape} {...props}/>
|
|
65
|
+
</div>);
|
|
66
|
+
};
|
|
67
|
+
export default ColorPicker;
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import ColorPicker from "./ColorPicker";
|
|
2
|
+
import { Label } from "../Label/Label";
|
|
3
|
+
import { inputVariantConfig } from "../Input/input";
|
|
4
|
+
export default {
|
|
5
|
+
title: "Components/ColorPicker",
|
|
6
|
+
component: ColorPicker,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
argTypes: {
|
|
9
|
+
size: {
|
|
10
|
+
control: "select",
|
|
11
|
+
options: Object.keys(inputVariantConfig.size),
|
|
12
|
+
},
|
|
13
|
+
variant: {
|
|
14
|
+
control: "select",
|
|
15
|
+
options: Object.keys(inputVariantConfig.variant),
|
|
16
|
+
},
|
|
17
|
+
color: {
|
|
18
|
+
control: "select",
|
|
19
|
+
options: Object.keys(inputVariantConfig.color),
|
|
20
|
+
},
|
|
21
|
+
shape: {
|
|
22
|
+
control: "select",
|
|
23
|
+
options: Object.keys(inputVariantConfig.shape),
|
|
24
|
+
},
|
|
25
|
+
value: {
|
|
26
|
+
control: "color",
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
var Template = function (args) { return <ColorPicker {...args}/>; };
|
|
31
|
+
export var Default = Template.bind({});
|
|
32
|
+
Default.args = {
|
|
33
|
+
// Blue color
|
|
34
|
+
onChange: function (color) {
|
|
35
|
+
console.log("Selected color:", color);
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
export var Sizes = function () { return (<div className="space-y-4">
|
|
39
|
+
<div>
|
|
40
|
+
<Label variant="label-sm">Small</Label>
|
|
41
|
+
<ColorPicker size="sm" value="#ef4444" onChange={function (color) { return console.log("Small:", color); }}/>
|
|
42
|
+
</div>
|
|
43
|
+
<div>
|
|
44
|
+
<Label variant="label-sm">Medium</Label>
|
|
45
|
+
<ColorPicker size="md" value="#10b981" onChange={function (color) { return console.log("Medium:", color); }}/>
|
|
46
|
+
</div>
|
|
47
|
+
<div>
|
|
48
|
+
<Label variant="label-sm">Large</Label>
|
|
49
|
+
<ColorPicker size="lg" value="#8b5cf6" onChange={function (color) { return console.log("Large:", color); }}/>
|
|
50
|
+
</div>
|
|
51
|
+
</div>); };
|
|
52
|
+
export var Variants = function () { return (<div className="space-y-4">
|
|
53
|
+
<div>
|
|
54
|
+
<Label variant="label-sm">Filled</Label>
|
|
55
|
+
<ColorPicker variant="filled" value="#f59e0b" onChange={function (color) { return console.log("Filled:", color); }}/>
|
|
56
|
+
</div>
|
|
57
|
+
<div>
|
|
58
|
+
<Label variant="label-sm">Outlined</Label>
|
|
59
|
+
<ColorPicker variant="outlined" value="#06b6d4" onChange={function (color) { return console.log("Outlined:", color); }}/>
|
|
60
|
+
</div>
|
|
61
|
+
</div>); };
|
|
62
|
+
export var Colors = function () { return (<div className="space-y-4">
|
|
63
|
+
<div>
|
|
64
|
+
<Label variant="label-sm">Default</Label>
|
|
65
|
+
<ColorPicker color="default" value="#6366f1" onChange={function (color) { return console.log("Default:", color); }}/>
|
|
66
|
+
</div>
|
|
67
|
+
<div>
|
|
68
|
+
<Label variant="label-sm">Danger</Label>
|
|
69
|
+
<ColorPicker color="danger" value="#dc2626" onChange={function (color) { return console.log("Danger:", color); }}/>
|
|
70
|
+
</div>
|
|
71
|
+
<div>
|
|
72
|
+
<Label variant="label-sm">Warning</Label>
|
|
73
|
+
<ColorPicker color="warning" value="#d97706" onChange={function (color) { return console.log("Warning:", color); }}/>
|
|
74
|
+
</div>
|
|
75
|
+
<div>
|
|
76
|
+
<Label variant="label-sm">Success</Label>
|
|
77
|
+
<ColorPicker color="success" value="#059669" onChange={function (color) { return console.log("Success:", color); }}/>
|
|
78
|
+
</div>
|
|
79
|
+
</div>); };
|
|
80
|
+
export var Shapes = function () { return (<div className="space-y-4">
|
|
81
|
+
<div>
|
|
82
|
+
<Label variant="label-sm">Square</Label>
|
|
83
|
+
<ColorPicker shape="square" value="#ec4899" onChange={function (color) { return console.log("Square:", color); }}/>
|
|
84
|
+
</div>
|
|
85
|
+
<div>
|
|
86
|
+
<Label variant="label-sm">Rounded</Label>
|
|
87
|
+
<ColorPicker shape="rounded" value="#14b8a6" onChange={function (color) { return console.log("Rounded:", color); }}/>
|
|
88
|
+
</div>
|
|
89
|
+
</div>); };
|
|
90
|
+
export var AllCombinations = function () { return (<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
|
91
|
+
<div>
|
|
92
|
+
<Label variant="label-sm">Small + Filled + Danger + Rounded</Label>
|
|
93
|
+
<ColorPicker size="sm" variant="filled" color="danger" shape="rounded" value="#ef4444" onChange={function (color) { return console.log("Combo 1:", color); }}/>
|
|
94
|
+
</div>
|
|
95
|
+
<div>
|
|
96
|
+
<Label variant="label-sm">Medium + Outlined + Success + Square</Label>
|
|
97
|
+
<ColorPicker size="md" variant="outlined" color="success" shape="square" value="#10b981" onChange={function (color) { return console.log("Combo 2:", color); }}/>
|
|
98
|
+
</div>
|
|
99
|
+
<div>
|
|
100
|
+
<Label variant="label-sm">Large + Filled + Warning + Rounded</Label>
|
|
101
|
+
<ColorPicker size="lg" variant="filled" color="warning" shape="rounded" value="#f59e0b" onChange={function (color) { return console.log("Combo 3:", color); }}/>
|
|
102
|
+
</div>
|
|
103
|
+
<div>
|
|
104
|
+
<Label variant="label-sm">Small + Outlined + Default + Square</Label>
|
|
105
|
+
<ColorPicker size="sm" variant="outlined" color="default" shape="square" value="#6366f1" onChange={function (color) { return console.log("Combo 4:", color); }}/>
|
|
106
|
+
</div>
|
|
107
|
+
<div>
|
|
108
|
+
<Label variant="label-sm">Large + Outlined + Danger + Rounded</Label>
|
|
109
|
+
<ColorPicker size="lg" variant="outlined" color="danger" shape="rounded" value="#dc2626" onChange={function (color) { return console.log("Combo 5:", color); }}/>
|
|
110
|
+
</div>
|
|
111
|
+
<div>
|
|
112
|
+
<Label variant="label-sm">Medium + Filled + Success + Square</Label>
|
|
113
|
+
<ColorPicker size="md" variant="filled" color="success" shape="square" value="#059669" onChange={function (color) { return console.log("Combo 6:", color); }}/>
|
|
114
|
+
</div>
|
|
115
|
+
</div>); };
|
|
116
|
+
export var WithCustomClassName = Template.bind({});
|
|
117
|
+
WithCustomClassName.args = {
|
|
118
|
+
value: "#8b5cf6",
|
|
119
|
+
className: "border-2 border-purple-500 shadow-lg",
|
|
120
|
+
onChange: function (color) { return console.log("Custom styled:", color); },
|
|
121
|
+
};
|
|
122
|
+
export var Disabled = Template.bind({});
|
|
123
|
+
Disabled.args = {
|
|
124
|
+
value: "#6b7280",
|
|
125
|
+
disabled: true,
|
|
126
|
+
onChange: function (color) { return console.log("Disabled:", color); },
|
|
127
|
+
};
|
|
128
|
+
export var Playground = Template.bind({});
|
|
129
|
+
Playground.args = {
|
|
130
|
+
value: "#3b82f6",
|
|
131
|
+
size: "md",
|
|
132
|
+
variant: "filled",
|
|
133
|
+
color: "default",
|
|
134
|
+
shape: "square",
|
|
135
|
+
onChange: function (color) {
|
|
136
|
+
alert("onChange: ".concat(color));
|
|
137
|
+
},
|
|
138
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { colors } from "../../utils/colors";
|
|
2
|
+
import { Color } from "./color";
|
|
3
|
+
export default {
|
|
4
|
+
title: "Components/Color",
|
|
5
|
+
component: Color,
|
|
6
|
+
};
|
|
7
|
+
var Template = function (args) { return (<Color {...args}/>); };
|
|
8
|
+
export var _Color = Template.bind({});
|
|
9
|
+
_Color.args = {
|
|
10
|
+
color: "black", // Default color
|
|
11
|
+
};
|
|
12
|
+
_Color.argTypes = {
|
|
13
|
+
color: {
|
|
14
|
+
control: {
|
|
15
|
+
type: "select",
|
|
16
|
+
labels: Object.keys(colors),
|
|
17
|
+
},
|
|
18
|
+
options: Object.keys(colors),
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { colors } from "../../utils/colors";
|
|
3
|
+
import { Color } from "./color";
|
|
4
|
+
describe("TextColor Component", function () {
|
|
5
|
+
it("renders with default color (black)", function () {
|
|
6
|
+
render(<Color />);
|
|
7
|
+
var textElement = screen.getByText("black");
|
|
8
|
+
expect(textElement).toBeInTheDocument();
|
|
9
|
+
expect(textElement).toHaveStyle({ color: colors.black });
|
|
10
|
+
});
|
|
11
|
+
it("renders with a specified color", function () {
|
|
12
|
+
render(<Color color="blue-500"/>);
|
|
13
|
+
var textElement = screen.getByText("blue-500");
|
|
14
|
+
expect(textElement).toBeInTheDocument();
|
|
15
|
+
expect(textElement).toHaveStyle({ color: colors["blue-500"] });
|
|
16
|
+
});
|
|
17
|
+
it("handles invalid color gracefully", function () {
|
|
18
|
+
render(<Color color={"invalid-color"}/>);
|
|
19
|
+
var textElement = screen.getByText("invalid-color");
|
|
20
|
+
expect(textElement).toBeInTheDocument();
|
|
21
|
+
expect(textElement).toHaveStyle({ color: colors.black }); // It should default to black
|
|
22
|
+
});
|
|
23
|
+
});
|