linkedunion-design-kit 1.7.4 → 1.7.5
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/src/components/Card/PhotoGallery.css +11 -0
- package/dist/src/components/Label/Label.js +5 -5
- package/dist/src/components/Typography/Heading/heading.js +6 -6
- package/dist/src/components/ui/caption.js +1 -1
- package/dist/styles/global.css +0 -4
- package/package.json +1 -1
- package/dist/app/layout.jsx +0 -13
- package/dist/app/page.jsx +0 -5
- package/dist/src/components/Accordion/Accordion.stories.jsx +0 -25
- package/dist/src/components/Avatar/Avatar.jsx +0 -17
- package/dist/src/components/Avatar/Avatar.stories.jsx +0 -31
- package/dist/src/components/Avatar/Avatar.test.jsx +0 -51
- package/dist/src/components/Button/Button.jsx +0 -93
- package/dist/src/components/Button/Button.stories.jsx +0 -248
- package/dist/src/components/Button/Button.test.jsx +0 -73
- package/dist/src/components/Button/IconButton.jsx +0 -70
- package/dist/src/components/Button/IconButton.stories.jsx +0 -53
- package/dist/src/components/Button/IconButton.test.jsx +0 -27
- package/dist/src/components/Card/MultipleNews/MultiNews.jsx +0 -73
- package/dist/src/components/Card/MultipleNews/MultiNews.stories.jsx +0 -52
- package/dist/src/components/Card/PhotoGallery.jsx +0 -17
- package/dist/src/components/Card/PhotoGallery.stories.jsx +0 -34
- package/dist/src/components/Card/PostByCategory/PostByCategory.jsx +0 -60
- package/dist/src/components/Card/PostByCategory/PostByCategory.stories.jsx +0 -54
- package/dist/src/components/Card/SinglePost.d.ts +0 -2
- package/dist/src/components/Card/SinglePost.js +0 -10
- package/dist/src/components/Card/SinglePost.jsx +0 -27
- package/dist/src/components/Card/SinglePost.stories.d.ts +0 -7
- package/dist/src/components/Card/SinglePost.stories.js +0 -46
- package/dist/src/components/Card/SinglePost.stories.jsx +0 -46
- package/dist/src/components/Card/card.jsx +0 -33
- package/dist/src/components/Card/contactProfile/ContactProfile.jsx +0 -60
- package/dist/src/components/Card/contactProfile/ContactProfile.stories.jsx +0 -52
- package/dist/src/components/Checkbox/checkbox.stories.jsx +0 -91
- package/dist/src/components/ColorPicker/ColorPicker.jsx +0 -65
- package/dist/src/components/ColorPicker/ColorPicker.stories.jsx +0 -14
- package/dist/src/components/Colors/color.jsx +0 -5
- package/dist/src/components/Colors/color.stories.jsx +0 -20
- package/dist/src/components/Colors/color.test.jsx +0 -23
- package/dist/src/components/Icons/IconList.test.jsx +0 -57
- package/dist/src/components/Icons/IconView.jsx +0 -25
- package/dist/src/components/Icons/IconView.stories.jsx +0 -8
- package/dist/src/components/Icons/LUIcon.jsx +0 -37
- package/dist/src/components/Icons/LUIcon.stories.jsx +0 -63
- package/dist/src/components/Icons/SingleIcon.test.jsx +0 -56
- package/dist/src/components/ImageUploader/ImageUploader.stories.jsx +0 -18
- package/dist/src/components/ImageUploader/imageUploader.jsx +0 -83
- package/dist/src/components/Images/LuImage.jsx +0 -19
- package/dist/src/components/Images/LuImage.stories.jsx +0 -154
- package/dist/src/components/Images/LuImage.test.jsx +0 -44
- package/dist/src/components/Input/Input.stories.jsx +0 -34
- package/dist/src/components/Label/Label.jsx +0 -32
- package/dist/src/components/Label/Label.stories.jsx +0 -30
- package/dist/src/components/MediaCard/Card.jsx +0 -36
- package/dist/src/components/MediaCard/Card.stories.jsx +0 -56
- package/dist/src/components/MediaCard/Card.test.jsx +0 -27
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.jsx +0 -22
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.test.jsx +0 -60
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.jsx +0 -27
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.test.jsx +0 -87
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.jsx +0 -23
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.test.jsx +0 -87
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.jsx +0 -24
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.test.jsx +0 -61
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.jsx +0 -25
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.test.jsx +0 -87
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.jsx +0 -23
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.test.jsx +0 -87
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.jsx +0 -30
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.stories.jsx +0 -65
- package/dist/src/components/RadioButton/RadioButton.stories.jsx +0 -40
- package/dist/src/components/RadioButton/radio-button.jsx +0 -29
- package/dist/src/components/Slider/Slider.stories.jsx +0 -159
- package/dist/src/components/Slider/slider.jsx +0 -31
- package/dist/src/components/Switch/Switch.stories.jsx +0 -66
- package/dist/src/components/Tabs/Tabs.stories.jsx +0 -29
- package/dist/src/components/Title/Title.jsx +0 -8
- package/dist/src/components/Title/Title.stories.jsx +0 -37
- package/dist/src/components/Title/Title.test.jsx +0 -24
- package/dist/src/components/ToolTip/Tooltip.jsx +0 -18
- package/dist/src/components/ToolTip/Tooltip.stories.jsx +0 -25
- package/dist/src/components/Typography/Body/Body.stories.jsx +0 -34
- package/dist/src/components/Typography/Body/body.jsx +0 -52
- package/dist/src/components/Typography/Caption/Caption.stories.jsx +0 -24
- package/dist/src/components/Typography/Display/Display.stories.jsx +0 -24
- package/dist/src/components/Typography/Display/display.jsx +0 -39
- package/dist/src/components/Typography/Heading/Heading.stories.jsx +0 -24
- package/dist/src/components/Typography/Heading/heading.jsx +0 -60
- package/dist/src/components/ui/accordion.jsx +0 -39
- package/dist/src/components/ui/caption.jsx +0 -25
- package/dist/src/components/ui/checkbox.jsx +0 -24
- package/dist/src/components/ui/input.jsx +0 -18
- package/dist/src/components/ui/switch.jsx +0 -61
- package/dist/src/components/ui/tabs.jsx +0 -31
- package/dist/src/components/ui/tooltip.jsx +0 -38
- package/dist/src/components/ui/typography.jsx +0 -56
|
@@ -25,12 +25,12 @@ import * as LabelPrimitive from "@radix-ui/react-label";
|
|
|
25
25
|
import { cva } from "class-variance-authority";
|
|
26
26
|
import { cn } from "../../lib/utils";
|
|
27
27
|
export var variant = {
|
|
28
|
-
"label-xl": "!text-xl",
|
|
29
|
-
"label-lg": "!text-lg",
|
|
30
|
-
"label-md": "!text-base",
|
|
31
|
-
"label-sm": "!text-sm !
|
|
28
|
+
"label-xl": "!text-xl !leading-normal",
|
|
29
|
+
"label-lg": "!text-lg !leading-normal",
|
|
30
|
+
"label-md": "!text-base !leading-normal",
|
|
31
|
+
"label-sm": "!text-sm !leading-normal",
|
|
32
32
|
};
|
|
33
|
-
var labelVariants = cva("
|
|
33
|
+
var labelVariants = cva("select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50 !font-normal m-0", {
|
|
34
34
|
variants: { variant: variant },
|
|
35
35
|
defaultVariants: {
|
|
36
36
|
variant: "label-sm",
|
|
@@ -24,23 +24,23 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
24
24
|
import { cva } from "class-variance-authority";
|
|
25
25
|
import { cn } from "../../../lib/utils";
|
|
26
26
|
export var variant = {
|
|
27
|
-
h1: "text-5xl font-normal",
|
|
27
|
+
h1: "!text-5xl !font-normal",
|
|
28
28
|
"h1-500": "!text-5xl !font-medium",
|
|
29
29
|
"h1-600": "!text-5xl !font-semibold",
|
|
30
30
|
"h1-700": "!text-5xl !font-bold",
|
|
31
|
-
h2: "text-4xl font-normal",
|
|
31
|
+
h2: "!text-4xl !font-normal",
|
|
32
32
|
"h2-500": "!text-4xl !font-medium",
|
|
33
33
|
"h2-600": "!text-4xl !font-semibold",
|
|
34
34
|
"h2-700": "!text-4xl !font-bold",
|
|
35
|
-
h3: "text-3xl font-normal",
|
|
35
|
+
h3: "!text-3xl !font-normal",
|
|
36
36
|
"h3-500": "!text-3xl !font-medium",
|
|
37
37
|
"h3-600": "!text-3xl !font-semibold",
|
|
38
38
|
"h3-700": "!text-3xl !font-bold",
|
|
39
|
-
h4: "text-2xl font-normal",
|
|
39
|
+
h4: "!text-2xl !font-normal",
|
|
40
40
|
"h4-500": "!text-2xl !font-medium",
|
|
41
41
|
"h4-600": "!text-2xl !font-semibold",
|
|
42
42
|
"h4-700": "!text-2xl !font-bold",
|
|
43
|
-
h5: "text-xl font-normal",
|
|
43
|
+
h5: "!text-xl !font-normal",
|
|
44
44
|
"h5-500": "!text-xl !font-medium",
|
|
45
45
|
"h5-600": "!text-xl !font-semibold",
|
|
46
46
|
"h5-700": "!text-xl !font-bold",
|
|
@@ -64,6 +64,6 @@ function Heading(_a) {
|
|
|
64
64
|
if (variant === null || variant === void 0 ? void 0 : variant.startsWith("h")) {
|
|
65
65
|
Tag = variant.split("-")[0];
|
|
66
66
|
}
|
|
67
|
-
return (_jsx(Tag, __assign({ className: cn(headingVariants({ variant: variant, className: className }), "m-0") }, props, { children: children })));
|
|
67
|
+
return (_jsx(Tag, __assign({ className: cn(headingVariants({ variant: variant, className: className }), "m-0 !leading-normal") }, props, { children: children })));
|
|
68
68
|
}
|
|
69
69
|
export { Heading, headingVariants };
|
|
@@ -29,6 +29,6 @@ export var variantClasses = {
|
|
|
29
29
|
};
|
|
30
30
|
function Caption(_a) {
|
|
31
31
|
var className = _a.className, children = _a.children, _b = _a.variant, variant = _b === void 0 ? "md" : _b, props = __rest(_a, ["className", "children", "variant"]);
|
|
32
|
-
return (_jsx("p", __assign({ className: cn("font-normal leading-normal inline", variantClasses[variant], className) }, props, { children: children })));
|
|
32
|
+
return (_jsx("p", __assign({ className: cn("!font-normal !leading-normal inline", variantClasses[variant], className) }, props, { children: children })));
|
|
33
33
|
}
|
|
34
34
|
export { Caption };
|
package/dist/styles/global.css
CHANGED
|
@@ -1221,10 +1221,6 @@
|
|
|
1221
1221
|
--tw-leading: 1;
|
|
1222
1222
|
line-height: 1;
|
|
1223
1223
|
}
|
|
1224
|
-
.leading-normal {
|
|
1225
|
-
--tw-leading: var(--leading-normal);
|
|
1226
|
-
line-height: var(--leading-normal);
|
|
1227
|
-
}
|
|
1228
1224
|
.\!font-bold {
|
|
1229
1225
|
--tw-font-weight: var(--font-weight-bold) !important;
|
|
1230
1226
|
font-weight: var(--font-weight-bold) !important;
|
package/package.json
CHANGED
package/dist/app/layout.jsx
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Inter } from "next/font/google";
|
|
2
|
-
import "@/styles/globals.css";
|
|
3
|
-
var inter = Inter({ subsets: ["latin"] });
|
|
4
|
-
export var metadata = {
|
|
5
|
-
title: "Create Next App",
|
|
6
|
-
description: "Generated by create next app",
|
|
7
|
-
};
|
|
8
|
-
export default function RootLayout(_a) {
|
|
9
|
-
var children = _a.children;
|
|
10
|
-
return (<html lang="en">
|
|
11
|
-
<body className={inter.className}>{children}</body>
|
|
12
|
-
</html>);
|
|
13
|
-
}
|
package/dist/app/page.jsx
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "../ui/accordion";
|
|
2
|
-
import ColorPicker from "../ColorPicker/ColorPicker";
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/Accordion",
|
|
5
|
-
component: Accordion,
|
|
6
|
-
tags: ["autodocs"],
|
|
7
|
-
};
|
|
8
|
-
var Template = function (args) { return (<Accordion type="single" collapsible defaultValue="menus" {...args}></Accordion>); };
|
|
9
|
-
export var _Accordion = Template.bind({});
|
|
10
|
-
_Accordion.args = {
|
|
11
|
-
children: (<AccordionItem value="menus">
|
|
12
|
-
<AccordionTrigger>Menus</AccordionTrigger>
|
|
13
|
-
<AccordionContent>
|
|
14
|
-
<ColorPicker value="#000000" onChange={function () { return console.log("color"); }}/>
|
|
15
|
-
</AccordionContent>
|
|
16
|
-
</AccordionItem>),
|
|
17
|
-
};
|
|
18
|
-
_Accordion.argTypes = {
|
|
19
|
-
children: {
|
|
20
|
-
description: "Pass `AccordionItem` components as children. Each item includes an `AccordionTrigger` (the clickable label) and `AccordionContent` (collapsible body). You can customize both with any valid React nodes \n\nFor more details and usage examples, refer to the [ShadCN Accordion documentation](https://ui.shadcn.com/docs/components/accordion).",
|
|
21
|
-
table: {
|
|
22
|
-
type: { summary: "React.ReactNode" },
|
|
23
|
-
},
|
|
24
|
-
},
|
|
25
|
-
};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import LUIcon from "../Icons/LUIcon";
|
|
2
|
-
import Image from "next/image";
|
|
3
|
-
import { avatarPadding, avatarShape, avatarSize } from ".";
|
|
4
|
-
var Avatar = function (_a) {
|
|
5
|
-
var image = _a.image, _b = _a.icon, icon = _b === void 0 ? "user" : _b, _c = _a.shape, shape = _c === void 0 ? "square" : _c, _d = _a.size, size = _d === void 0 ? "md" : _d, className = _a.className;
|
|
6
|
-
var sizeClasses = avatarSize[size];
|
|
7
|
-
var paddingClass = avatarPadding[size];
|
|
8
|
-
return (<>
|
|
9
|
-
{image ? (<div className={"relative overflow-hidden bg-blue-200 ".concat(avatarShape[shape], " ").concat(className, " ").concat(sizeClasses)} data-testid="lu-avatar">
|
|
10
|
-
<Image src={image} alt="avatar" className={"object-cover w-full h-full"} width={0} height={0} sizes="100%" //Image takes 100% of the parent container
|
|
11
|
-
/>
|
|
12
|
-
</div>) : (<div className={"bg-gray-100 ".concat(paddingClass, " ").concat(avatarShape[shape], " ").concat(className, " ").concat(sizeClasses)} data-testid="lu-icon">
|
|
13
|
-
<LUIcon data-testid="lu-icon" size={size} icon={icon} className={"text-gray-950 w-full h-full"}/>
|
|
14
|
-
</div>)}
|
|
15
|
-
</>);
|
|
16
|
-
};
|
|
17
|
-
export default Avatar;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Avatar from "./Avatar";
|
|
2
|
-
import { avatarShape, avatarSize } from ".";
|
|
3
|
-
export default {
|
|
4
|
-
title: "Components/Avatar",
|
|
5
|
-
component: Avatar,
|
|
6
|
-
};
|
|
7
|
-
var Template = function (args) { return <Avatar {...args}/>; };
|
|
8
|
-
export var _Avatar = Template.bind({});
|
|
9
|
-
_Avatar.args = {
|
|
10
|
-
image: "/images/avatar.png",
|
|
11
|
-
shape: "square",
|
|
12
|
-
size: "md",
|
|
13
|
-
className: "",
|
|
14
|
-
icon: "user",
|
|
15
|
-
};
|
|
16
|
-
_Avatar.argTypes = {
|
|
17
|
-
shape: {
|
|
18
|
-
control: {
|
|
19
|
-
type: "select",
|
|
20
|
-
labels: Object.keys(avatarShape),
|
|
21
|
-
},
|
|
22
|
-
options: Object.keys(avatarShape),
|
|
23
|
-
},
|
|
24
|
-
size: {
|
|
25
|
-
control: {
|
|
26
|
-
type: "select",
|
|
27
|
-
labels: Object.keys(avatarSize),
|
|
28
|
-
},
|
|
29
|
-
options: Object.keys(avatarSize),
|
|
30
|
-
},
|
|
31
|
-
};
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import Avatar from "./Avatar";
|
|
3
|
-
jest.mock("../Icons/LUIcon", function () { return ({
|
|
4
|
-
__esModule: true,
|
|
5
|
-
default: jest.fn(function (_a) {
|
|
6
|
-
var icon = _a.icon, className = _a.className;
|
|
7
|
-
return (<div data-testid="mock-luIcon" className={className}>
|
|
8
|
-
{icon || "user"}
|
|
9
|
-
</div>);
|
|
10
|
-
}),
|
|
11
|
-
}); });
|
|
12
|
-
// Mock Next.js Image component
|
|
13
|
-
jest.mock("next/image", function () { return ({
|
|
14
|
-
__esModule: true,
|
|
15
|
-
default: function (_a) {
|
|
16
|
-
var src = _a.src, alt = _a.alt;
|
|
17
|
-
return (
|
|
18
|
-
// eslint-disable-next-line @next/next/no-img-element
|
|
19
|
-
<img src={src} alt={alt}/>);
|
|
20
|
-
},
|
|
21
|
-
}); });
|
|
22
|
-
describe("Avatar Component", function () {
|
|
23
|
-
it("renders image when image prop is provided", function () {
|
|
24
|
-
render(<Avatar image="/images/avatar.png"/>);
|
|
25
|
-
var avatarImage = screen.getByRole("img", { name: /avatar/i });
|
|
26
|
-
expect(avatarImage).toBeInTheDocument();
|
|
27
|
-
expect(avatarImage).toHaveAttribute("src", "/images/avatar.png");
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
it("renders icon when no image is provided", function () {
|
|
31
|
-
render(<Avatar />);
|
|
32
|
-
var icon = screen.getByTestId("lu-icon");
|
|
33
|
-
expect(icon).toBeInTheDocument();
|
|
34
|
-
});
|
|
35
|
-
it("applies shape and size class names correctly", function () {
|
|
36
|
-
render(<Avatar image="/images/avatar.png" shape="square" size="lg"/>);
|
|
37
|
-
var avatarWrapper = screen.getByTestId("lu-avatar");
|
|
38
|
-
expect(avatarWrapper).toHaveClass("rounded-none");
|
|
39
|
-
expect(avatarWrapper).toHaveClass("w-[42px]");
|
|
40
|
-
expect(avatarWrapper).toHaveClass("h-[42px]");
|
|
41
|
-
});
|
|
42
|
-
it("applies additional class names", function () {
|
|
43
|
-
render(<Avatar image="/images/avatar.png" className="custom-class"/>);
|
|
44
|
-
var avatarWrapper = screen.getByTestId("lu-avatar");
|
|
45
|
-
expect(avatarWrapper).toHaveClass("custom-class");
|
|
46
|
-
});
|
|
47
|
-
it("renders the correct icon when image is not provided", function () {
|
|
48
|
-
render(<Avatar icon="user"/>);
|
|
49
|
-
var icon = screen.getByTestId("lu-icon");
|
|
50
|
-
expect(icon).toBeInTheDocument();
|
|
51
|
-
});
|
|
@@ -1,93 +0,0 @@
|
|
|
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 { Slot } from "@radix-ui/react-slot";
|
|
14
|
-
import { cva } from "class-variance-authority";
|
|
15
|
-
import { cn } from "../../lib/utils";
|
|
16
|
-
import LUIcon from "../Icons/LUIcon";
|
|
17
|
-
export var color = {
|
|
18
|
-
blue: "bg-blue-600 text-white hover:bg-blue-700 focus-visible:ring-blue-300 active:bg-blue-800 disabled:bg-gray-100 disabled:text-gray-400",
|
|
19
|
-
red: "bg-red-600 text-white hover:bg-red-700 focus-visible:ring-red-300 active:bg-red-800 disabled:bg-gray-100 disabled:text-gray-400",
|
|
20
|
-
green: "bg-green-600 text-white hover:bg-green-700 focus-visible:ring-green-300 active:bg-green-800 disabled:bg-gray-100 disabled:text-gray-400",
|
|
21
|
-
yellow: "bg-yellow-500 text-white hover:bg-yellow-600 focus-visible:ring-yellow-200 active:bg-yellow-700 disabled:bg-gray-100 disabled:text-gray-400",
|
|
22
|
-
indigo: "bg-indigo-600 text-white hover:bg-indigo-700 focus-visible:ring-indigo-300 active:bg-indigo-800 disabled:bg-gray-100 disabled:text-gray-400",
|
|
23
|
-
gray: "bg-gray-600 text-white hover:bg-gray-700 focus-visible:ring-gray-300 active:bg-gray-800 disabled:bg-gray-100 disabled:text-gray-400",
|
|
24
|
-
};
|
|
25
|
-
export var size = {
|
|
26
|
-
xl: "!py-3.5 !px-6 text-base font-normal leading-normal",
|
|
27
|
-
lg: "!py-3 !px-5 text-base font-normal leading-normal",
|
|
28
|
-
md: "!py-2.5 !px-5 text-sm font-normal leading-5",
|
|
29
|
-
sm: "!py-2 !px-3 text-sm font-normal leading-5",
|
|
30
|
-
};
|
|
31
|
-
export var shape = {
|
|
32
|
-
"rounded-sm": "!rounded-sm",
|
|
33
|
-
"rounded-full": "!rounded-full",
|
|
34
|
-
};
|
|
35
|
-
export var variant = {
|
|
36
|
-
default: "",
|
|
37
|
-
link: "bg-transparent hover:bg-transparent focus:bg-transparent active:bg-transparent !p-0 underline-offset-4 hover:underline",
|
|
38
|
-
};
|
|
39
|
-
// Link variant text colors based on the color prop
|
|
40
|
-
export var linkColor = {
|
|
41
|
-
blue: "text-blue-600 hover:text-blue-700",
|
|
42
|
-
red: "text-red-600 hover:text-red-700",
|
|
43
|
-
green: "text-green-600 hover:text-green-700",
|
|
44
|
-
yellow: "text-yellow-500 hover:text-yellow-600",
|
|
45
|
-
indigo: "text-indigo-600 hover:text-indigo-700",
|
|
46
|
-
gray: "text-gray-600 hover:text-gray-700",
|
|
47
|
-
};
|
|
48
|
-
var buttonVariants = cva("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
|
|
49
|
-
variants: {
|
|
50
|
-
color: color,
|
|
51
|
-
size: size,
|
|
52
|
-
shape: shape,
|
|
53
|
-
variant: variant,
|
|
54
|
-
},
|
|
55
|
-
defaultVariants: {
|
|
56
|
-
color: "blue",
|
|
57
|
-
size: "md",
|
|
58
|
-
shape: "rounded-sm",
|
|
59
|
-
variant: "default",
|
|
60
|
-
},
|
|
61
|
-
});
|
|
62
|
-
function Button(_a) {
|
|
63
|
-
var className = _a.className, _b = _a.color, color = _b === void 0 ? "blue" : _b, size = _a.size, shape = _a.shape, _c = _a.variant, variant = _c === void 0 ? "default" : _c, _d = _a.asChild, asChild = _d === void 0 ? false : _d, startIcon = _a.startIcon, endIcon = _a.endIcon, props = __rest(_a, ["className", "color", "size", "shape", "variant", "asChild", "startIcon", "endIcon"]);
|
|
64
|
-
var Comp = asChild ? Slot : "button";
|
|
65
|
-
// Map button size to appropriate icon sizes for start and end icons
|
|
66
|
-
var getIconSizes = function () {
|
|
67
|
-
if (size === "xl" || size === "lg" || size === "md") {
|
|
68
|
-
return {
|
|
69
|
-
startIcon: "md", // 16px (size-6) - matches iconSize.xl
|
|
70
|
-
endIcon: "xs", // 12px (size-3.5)
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
startIcon: "sm", // 14px (size-4)
|
|
75
|
-
endIcon: "xs", // 12px (size-3.5)
|
|
76
|
-
};
|
|
77
|
-
};
|
|
78
|
-
// Get icon sizes based on button size
|
|
79
|
-
var iconSizes = getIconSizes();
|
|
80
|
-
// Use the calculated sizes based on button size
|
|
81
|
-
var startIconSizeValue = iconSizes.startIcon;
|
|
82
|
-
var endIconSizeValue = iconSizes.endIcon;
|
|
83
|
-
// Apply appropriate text color for link variant
|
|
84
|
-
var extraClasses = variant === "link" && color
|
|
85
|
-
? linkColor[color]
|
|
86
|
-
: "";
|
|
87
|
-
return (<Comp data-slot="button" className={cn(buttonVariants({ variant: variant, color: color, size: size, shape: shape, className: className }), extraClasses)} {...props}>
|
|
88
|
-
{startIcon && (<LUIcon size={startIconSizeValue} data-testid="start-icon" icon={startIcon}/>)}
|
|
89
|
-
{props.children}
|
|
90
|
-
{endIcon && (<LUIcon size={endIconSizeValue} data-testid="end-icon" icon={endIcon}/>)}
|
|
91
|
-
</Comp>);
|
|
92
|
-
}
|
|
93
|
-
export { Button, buttonVariants };
|
|
@@ -1,248 +0,0 @@
|
|
|
1
|
-
import { Button, size, color, shape, variant } from "./Button";
|
|
2
|
-
var meta = {
|
|
3
|
-
title: "Components/Button",
|
|
4
|
-
component: Button,
|
|
5
|
-
tags: ["autodocs"],
|
|
6
|
-
parameters: {
|
|
7
|
-
docs: {
|
|
8
|
-
description: {
|
|
9
|
-
component: "Button component with default variants: color: blue, size: md, shape: rounded-sm, variant: default",
|
|
10
|
-
},
|
|
11
|
-
},
|
|
12
|
-
controls: {
|
|
13
|
-
expanded: true,
|
|
14
|
-
sort: "requiredFirst",
|
|
15
|
-
hideNoControlsWarning: true,
|
|
16
|
-
exclude: [],
|
|
17
|
-
},
|
|
18
|
-
},
|
|
19
|
-
args: {
|
|
20
|
-
// Default values for all stories
|
|
21
|
-
color: "blue",
|
|
22
|
-
size: "md",
|
|
23
|
-
shape: "rounded-sm",
|
|
24
|
-
variant: "default",
|
|
25
|
-
},
|
|
26
|
-
argTypes: {
|
|
27
|
-
color: {
|
|
28
|
-
control: {
|
|
29
|
-
type: "select",
|
|
30
|
-
},
|
|
31
|
-
options: Object.keys(color),
|
|
32
|
-
description: "The color and visual style of the button",
|
|
33
|
-
defaultValue: "blue",
|
|
34
|
-
table: {
|
|
35
|
-
defaultValue: { summary: "blue" },
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
size: {
|
|
39
|
-
control: {
|
|
40
|
-
type: "select",
|
|
41
|
-
},
|
|
42
|
-
options: Object.keys(size),
|
|
43
|
-
description: "The size of the button",
|
|
44
|
-
defaultValue: "md",
|
|
45
|
-
table: {
|
|
46
|
-
defaultValue: { summary: "md" },
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
shape: {
|
|
50
|
-
control: {
|
|
51
|
-
type: "select",
|
|
52
|
-
},
|
|
53
|
-
options: Object.keys(shape),
|
|
54
|
-
description: "The shape of the button",
|
|
55
|
-
defaultValue: "rounded-sm",
|
|
56
|
-
table: {
|
|
57
|
-
defaultValue: { summary: "rounded-sm" },
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
variant: {
|
|
61
|
-
control: {
|
|
62
|
-
type: "select",
|
|
63
|
-
},
|
|
64
|
-
options: Object.keys(variant),
|
|
65
|
-
description: "The variant of the button (default or link)",
|
|
66
|
-
defaultValue: "default",
|
|
67
|
-
table: {
|
|
68
|
-
defaultValue: { summary: "default" },
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
startIcon: {
|
|
72
|
-
control: "text",
|
|
73
|
-
description: "Icon to display at the start of the button",
|
|
74
|
-
},
|
|
75
|
-
endIcon: {
|
|
76
|
-
control: "text",
|
|
77
|
-
description: "Icon to display at the end of the button",
|
|
78
|
-
},
|
|
79
|
-
disabled: {
|
|
80
|
-
control: "boolean",
|
|
81
|
-
description: "Whether the button is disabled",
|
|
82
|
-
},
|
|
83
|
-
asChild: {
|
|
84
|
-
control: "boolean",
|
|
85
|
-
description: "Whether to render as a child component",
|
|
86
|
-
},
|
|
87
|
-
onClick: {
|
|
88
|
-
action: "clicked",
|
|
89
|
-
description: "Function called when button is clicked",
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
};
|
|
93
|
-
export default meta;
|
|
94
|
-
// Display Default button with explicit default values
|
|
95
|
-
export var Default = {
|
|
96
|
-
args: {
|
|
97
|
-
children: "Button Text",
|
|
98
|
-
color: "blue",
|
|
99
|
-
size: "md",
|
|
100
|
-
shape: "rounded-sm",
|
|
101
|
-
variant: "default",
|
|
102
|
-
onClick: function () {
|
|
103
|
-
alert("Button clicked!");
|
|
104
|
-
},
|
|
105
|
-
},
|
|
106
|
-
};
|
|
107
|
-
export var Blue = {
|
|
108
|
-
args: {
|
|
109
|
-
children: "Blue Button",
|
|
110
|
-
color: "blue",
|
|
111
|
-
size: "md",
|
|
112
|
-
},
|
|
113
|
-
};
|
|
114
|
-
export var Red = {
|
|
115
|
-
args: {
|
|
116
|
-
children: "Red Button",
|
|
117
|
-
color: "red",
|
|
118
|
-
size: "md",
|
|
119
|
-
},
|
|
120
|
-
};
|
|
121
|
-
export var Green = {
|
|
122
|
-
args: {
|
|
123
|
-
children: "Green Button",
|
|
124
|
-
color: "green",
|
|
125
|
-
size: "md",
|
|
126
|
-
},
|
|
127
|
-
};
|
|
128
|
-
export var Yellow = {
|
|
129
|
-
args: {
|
|
130
|
-
children: "Yellow Button",
|
|
131
|
-
color: "yellow",
|
|
132
|
-
size: "md",
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
export var Indigo = {
|
|
136
|
-
args: {
|
|
137
|
-
children: "Indigo Button",
|
|
138
|
-
color: "indigo",
|
|
139
|
-
size: "md",
|
|
140
|
-
},
|
|
141
|
-
};
|
|
142
|
-
export var Gray = {
|
|
143
|
-
args: {
|
|
144
|
-
children: "Gray Button",
|
|
145
|
-
color: "gray",
|
|
146
|
-
size: "md",
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
export var WithStartIcon = {
|
|
150
|
-
args: {
|
|
151
|
-
children: "Button with Start Icon",
|
|
152
|
-
startIcon: "arrow-right",
|
|
153
|
-
size: "md",
|
|
154
|
-
},
|
|
155
|
-
};
|
|
156
|
-
export var WithEndIcon = {
|
|
157
|
-
args: {
|
|
158
|
-
children: "Button with End Icon",
|
|
159
|
-
endIcon: "arrow-right",
|
|
160
|
-
size: "md",
|
|
161
|
-
},
|
|
162
|
-
};
|
|
163
|
-
export var WithBothIcons = {
|
|
164
|
-
args: {
|
|
165
|
-
children: "Button with Icons",
|
|
166
|
-
startIcon: "plus",
|
|
167
|
-
endIcon: "arrow-right",
|
|
168
|
-
size: "md",
|
|
169
|
-
},
|
|
170
|
-
};
|
|
171
|
-
export var Small = {
|
|
172
|
-
args: {
|
|
173
|
-
children: "Small Button",
|
|
174
|
-
size: "sm",
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
export var Medium = {
|
|
178
|
-
args: {
|
|
179
|
-
children: "Medium Button",
|
|
180
|
-
size: "md",
|
|
181
|
-
},
|
|
182
|
-
};
|
|
183
|
-
export var Large = {
|
|
184
|
-
args: {
|
|
185
|
-
children: "Large Button",
|
|
186
|
-
size: "lg",
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
export var ExtraLarge = {
|
|
190
|
-
args: {
|
|
191
|
-
children: "Extra Large Button",
|
|
192
|
-
size: "xl",
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
export var DefaultVariant = {
|
|
196
|
-
args: {
|
|
197
|
-
children: "Default Variant Button",
|
|
198
|
-
variant: "default",
|
|
199
|
-
},
|
|
200
|
-
};
|
|
201
|
-
export var LinkVariant = {
|
|
202
|
-
args: {
|
|
203
|
-
children: "Link Style Button",
|
|
204
|
-
variant: "link",
|
|
205
|
-
color: "blue",
|
|
206
|
-
},
|
|
207
|
-
};
|
|
208
|
-
export var LinkVariantRed = {
|
|
209
|
-
args: {
|
|
210
|
-
children: "Red Link Button",
|
|
211
|
-
variant: "link",
|
|
212
|
-
color: "red",
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
export var LinkVariantGreen = {
|
|
216
|
-
args: {
|
|
217
|
-
children: "Green Link Button",
|
|
218
|
-
variant: "link",
|
|
219
|
-
color: "green",
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
export var RoundedSmall = {
|
|
223
|
-
args: {
|
|
224
|
-
children: "Rounded Small",
|
|
225
|
-
shape: "rounded-sm",
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
export var RoundedFull = {
|
|
229
|
-
args: {
|
|
230
|
-
children: "Rounded Full",
|
|
231
|
-
shape: "rounded-full",
|
|
232
|
-
},
|
|
233
|
-
};
|
|
234
|
-
export var Disabled = {
|
|
235
|
-
args: {
|
|
236
|
-
children: "Disabled Button",
|
|
237
|
-
disabled: true,
|
|
238
|
-
},
|
|
239
|
-
};
|
|
240
|
-
// Color variants
|
|
241
|
-
// Example of color with different button states
|
|
242
|
-
export var DisabledButton = {
|
|
243
|
-
args: {
|
|
244
|
-
children: "Disabled Button",
|
|
245
|
-
color: "blue",
|
|
246
|
-
disabled: true,
|
|
247
|
-
},
|
|
248
|
-
};
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import { Dummy_label } from "../../utils/constants";
|
|
3
|
-
import { Button } from "./Button";
|
|
4
|
-
describe("Button Component", function () {
|
|
5
|
-
it("renders default button component", function () {
|
|
6
|
-
render(<Button>{Dummy_label}</Button>);
|
|
7
|
-
expect(screen.getByRole("button")).toBeInTheDocument();
|
|
8
|
-
});
|
|
9
|
-
});
|
|
10
|
-
// it("renders button with a custom label", () => {
|
|
11
|
-
// render(<Button>{Dummy_label}</Button>);
|
|
12
|
-
// expect(
|
|
13
|
-
// screen.getByRole("button", { name: Dummy_label }),
|
|
14
|
-
// ).toBeInTheDocument();
|
|
15
|
-
// });
|
|
16
|
-
// it("calls onClick handler when clicked", () => {
|
|
17
|
-
// const handleClick = jest.fn();
|
|
18
|
-
// render(<Button onClick={handleClick}>Click</Button>);
|
|
19
|
-
// fireEvent.click(screen.getByRole("button"));
|
|
20
|
-
// expect(handleClick).toHaveBeenCalledTimes(1);
|
|
21
|
-
// });
|
|
22
|
-
// it("renders startIcon when provided", () => {
|
|
23
|
-
// render(<Button startIcon={<span>*</span>}>{Dummy_label}</Button>);
|
|
24
|
-
// expect(screen.getByTestId("start-icon")).toBeInTheDocument();
|
|
25
|
-
// });
|
|
26
|
-
// it("renders endIcon when provided", () => {
|
|
27
|
-
// render(<Button endIcon={<span>*</span>}>{Dummy_label}</Button>);
|
|
28
|
-
// expect(screen.getByTestId("end-icon")).toBeInTheDocument();
|
|
29
|
-
// });
|
|
30
|
-
// it("applies correct color, shape, and size classes", () => {
|
|
31
|
-
// render(
|
|
32
|
-
// <Button color="primary" shape="rounded-full" size="lg">
|
|
33
|
-
// {Dummy_label}
|
|
34
|
-
// </Button>,
|
|
35
|
-
// );
|
|
36
|
-
// const buttonElement = screen.getByRole("button");
|
|
37
|
-
// expect(buttonElement).toHaveClass(
|
|
38
|
-
// buttonColors["primary"],
|
|
39
|
-
// buttonShapes["rounded-full"],
|
|
40
|
-
// buttonSizes["lg"],
|
|
41
|
-
// );
|
|
42
|
-
// });
|
|
43
|
-
// it("applies additional className when provided", () => {
|
|
44
|
-
// render(<Button className="custom-class">{Dummy_label}</Button>);
|
|
45
|
-
// expect(screen.getByRole("button")).toHaveClass("custom-class");
|
|
46
|
-
// });
|
|
47
|
-
// it("renders without crashing when no props are provided", () => {
|
|
48
|
-
// render(<Button>{Dummy_label}</Button>);
|
|
49
|
-
// expect(screen.getByRole("button")).toBeInTheDocument();
|
|
50
|
-
// });
|
|
51
|
-
// it("renders button with both startIcon and endIcon", () => {
|
|
52
|
-
// render(
|
|
53
|
-
// <Button startIcon={<span>*</span>} endIcon={<span>*</span>}>
|
|
54
|
-
// {Dummy_label}
|
|
55
|
-
// </Button>,
|
|
56
|
-
// );
|
|
57
|
-
// expect(screen.getByTestId("start-icon")).toBeInTheDocument();
|
|
58
|
-
// expect(screen.getByTestId("end-icon")).toBeInTheDocument();
|
|
59
|
-
// });
|
|
60
|
-
// it("does not render startIcon when not provided", () => {
|
|
61
|
-
// render(<Button>{Dummy_label}</Button>);
|
|
62
|
-
// expect(screen.queryByTestId("start-icon")).not.toBeInTheDocument();
|
|
63
|
-
// });
|
|
64
|
-
// it("does not render endIcon when not provided", () => {
|
|
65
|
-
// render(<Button>{Dummy_label}</Button>);
|
|
66
|
-
// expect(screen.queryByTestId("end-icon")).not.toBeInTheDocument();
|
|
67
|
-
// });
|
|
68
|
-
// it("renders correctly without a className prop", () => {
|
|
69
|
-
// render(<Button>{Dummy_label}</Button>);
|
|
70
|
-
// const buttonElement = screen.getByRole("button");
|
|
71
|
-
// expect(buttonElement).not.toHaveClass("custom-class");
|
|
72
|
-
// });
|
|
73
|
-
// });
|