linkedunion-design-kit 1.9.1 → 1.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/src/components/Accordion/accordion.js +1 -1
- package/dist/src/components/Alerts/Alert/alert.d.ts +19 -0
- package/dist/src/components/Alerts/Alert/alert.js +156 -0
- package/dist/src/components/Alerts/Alert/alert.stories.d.ts +30 -0
- package/dist/src/components/Alerts/Alert/alert.stories.js +166 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.d.ts +45 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.js +168 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.stories.d.ts +69 -0
- package/dist/src/components/Alerts/AlertDialog/alert-dialog.stories.js +213 -0
- package/dist/src/components/Alerts/AlertDialog/index.d.ts +44 -0
- package/dist/src/components/Alerts/AlertDialog/index.js +189 -0
- package/dist/src/components/Avatar/Avatar/Avatar.d.ts +12 -3
- package/dist/src/components/Avatar/Avatar/Avatar.js +49 -11
- package/dist/src/components/Avatar/Avatar/Avatar.stories.d.ts +16 -2
- package/dist/src/components/Avatar/Avatar/Avatar.stories.js +51 -25
- package/dist/src/components/Avatar/Avatar/Avatar.test.js +6 -46
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.d.ts +17 -0
- package/dist/src/components/Avatar/Avatar/Avatar1.stories.js +68 -0
- package/dist/src/components/Avatar/Avatar/index.d.ts +51 -28
- package/dist/src/components/Avatar/Avatar/index.js +76 -28
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.js +1 -1
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.stories.js +1 -1
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.d.ts +3 -0
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.js +18 -0
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.stories.d.ts +44 -0
- package/dist/src/components/Avatar/StatusIndicator/StatusIndicator.stories.js +41 -0
- package/dist/src/components/Avatar/StatusIndicator/index.d.ts +27 -0
- package/dist/src/components/Avatar/StatusIndicator/index.js +29 -0
- package/dist/src/components/Avatar/StatusIndicator/type.d.ts +6 -0
- package/dist/src/components/Badge/Badge.d.ts +21 -0
- package/dist/src/components/Badge/Badge.js +59 -0
- package/dist/src/components/Badge/Badge.stories.d.ts +719 -0
- package/dist/src/components/Badge/Badge.stories.js +145 -0
- package/dist/src/components/Badge/index.d.ts +47 -0
- package/dist/src/components/Badge/index.js +49 -0
- package/dist/src/components/Button/Button/Button.d.ts +2 -2
- package/dist/src/components/Button/Button/Button.stories.d.ts +4 -4
- package/dist/src/components/Button/IconButton/IconButton.d.ts +2 -2
- package/dist/src/components/Button/IconButton/IconButton.stories.d.ts +4 -4
- package/dist/src/components/Dropdown/Combobox/Combobox.d.ts +3 -0
- package/dist/src/components/Dropdown/Combobox/Combobox.js +160 -0
- package/dist/src/components/Dropdown/Combobox/Combobox.stories.d.ts +13 -0
- package/dist/src/components/Dropdown/Combobox/Combobox.stories.js +225 -0
- package/dist/src/components/Dropdown/Combobox/index.d.ts +35 -0
- package/dist/src/components/Dropdown/Combobox/index.js +36 -0
- package/dist/src/components/Dropdown/Combobox/type.d.ts +25 -0
- package/dist/src/components/Dropdown/Combobox/utils/getLabelVariant.d.ts +3 -0
- package/dist/src/components/Dropdown/Combobox/utils/getLabelVariant.js +7 -0
- package/dist/src/components/Dropdown/Combobox/utils/renderBadge.d.ts +6 -0
- package/dist/src/components/Dropdown/Combobox/utils/renderBadge.js +5 -0
- package/dist/src/components/Dropdown/Combobox/utils/useResponsiveBadge.d.ts +1 -0
- package/dist/src/components/Dropdown/Combobox/utils/useResponsiveBadge.js +14 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.d.ts +37 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.js +96 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.stories.d.ts +25 -0
- package/dist/src/components/Dropdown/DropdownMenu/DropdownMenu.stories.js +253 -0
- package/dist/src/components/Dropdown/DropdownMenu/SelectAllSection.d.ts +3 -0
- package/dist/src/components/Dropdown/DropdownMenu/SelectAllSection.js +9 -0
- package/dist/src/components/Dropdown/DropdownMenu/index.d.ts +20 -0
- package/dist/src/components/Dropdown/DropdownMenu/index.js +21 -0
- package/dist/src/components/Dropdown/DropdownMenu/type.d.ts +7 -0
- package/dist/src/components/Dropdown/select.js +3 -3
- package/dist/src/components/Icons/LUIcon.d.ts +1 -1
- package/dist/src/components/Icons/LUIcon.js +15 -8
- package/dist/src/components/Icons/LUIcon.test.d.ts +0 -1
- package/dist/src/components/Icons/LUIcon.test.js +306 -253
- package/dist/src/components/Icons/index.d.ts +23 -8
- package/dist/src/components/Icons/index.js +43 -28
- package/dist/src/components/Icons/stories/InteractiveIconSelector.js +3 -3
- package/dist/src/components/Icons/stories/LUIcon.stories.d.ts +9 -5
- package/dist/src/components/Icons/stories/LUIcon.stories.js +28 -43
- package/dist/src/components/Icons/type.d.ts +0 -1
- package/dist/src/components/SweetAlert/SweetAlert.d.ts +40 -0
- package/dist/src/components/SweetAlert/SweetAlert.js +150 -0
- package/dist/src/components/SweetAlert/SweetAlert.stories.d.ts +86 -0
- package/dist/src/components/SweetAlert/SweetAlert.stories.js +305 -0
- package/dist/src/components/SweetAlert/index.d.ts +24 -0
- package/dist/src/components/SweetAlert/index.js +137 -0
- package/dist/src/components/ui/avatar.d.ts +10 -3
- package/dist/src/components/ui/avatar.js +27 -12
- package/dist/src/components/ui/command.d.ts +22 -0
- package/dist/src/components/ui/command.js +65 -0
- package/dist/src/components/ui/dialog.d.ts +15 -0
- package/dist/src/components/ui/dialog.js +68 -0
- package/dist/src/components/ui/popover.d.ts +7 -0
- package/dist/src/components/ui/popover.js +42 -0
- package/dist/src/utils/constants.d.ts +1 -0
- package/dist/src/utils/constants.js +1 -0
- package/dist/styles/global.css +727 -53
- package/dist/tailwind.config.js +6 -0
- package/package.json +6 -1
- package/dist/app/layout.jsx +0 -13
- package/dist/app/page.jsx +0 -5
- package/dist/next.config.d.ts +0 -8
- package/dist/next.config.js +0 -10
- package/dist/src/components/Accordion/Accordion.stories.jsx +0 -33
- package/dist/src/components/Accordion/accordion.jsx +0 -59
- package/dist/src/components/AppIcons/AndroidIcon.jsx +0 -24
- package/dist/src/components/AppIcons/AppIcon.jsx +0 -29
- package/dist/src/components/AppIcons/AppIcon.stories.jsx +0 -223
- package/dist/src/components/AppIcons/AppleIcon.jsx +0 -31
- package/dist/src/components/AppIcons/PlayStoreIcon.jsx +0 -29
- package/dist/src/components/Avatar/Avatar/Avatar.jsx +0 -17
- package/dist/src/components/Avatar/Avatar/Avatar.stories.jsx +0 -31
- package/dist/src/components/Avatar/Avatar/Avatar.test.jsx +0 -51
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.jsx +0 -17
- package/dist/src/components/Avatar/AvatarGroup/AvatarGroup.stories.jsx +0 -32
- package/dist/src/components/Button/Button/Button.jsx +0 -73
- package/dist/src/components/Button/Button/Button.stories.jsx +0 -283
- package/dist/src/components/Button/Button/Button.test.jsx +0 -73
- package/dist/src/components/Button/Button/index.d.ts +0 -63
- package/dist/src/components/Button/Button/index.js +0 -64
- package/dist/src/components/Button/Button.d.ts +0 -20
- package/dist/src/components/Button/Button.js +0 -83
- package/dist/src/components/Button/Button.stories.d.ts +0 -725
- package/dist/src/components/Button/Button.stories.js +0 -288
- package/dist/src/components/Button/Button.test.js +0 -10
- package/dist/src/components/Button/IconButton/IconButton.jsx +0 -63
- package/dist/src/components/Button/IconButton/IconButton.stories.jsx +0 -128
- package/dist/src/components/Button/IconButton/IconButton.test.jsx +0 -28
- package/dist/src/components/Button/IconButton/index.d.ts +0 -0
- package/dist/src/components/Button/IconButton/index.js +0 -1
- package/dist/src/components/Button/IconButton.d.ts +0 -33
- package/dist/src/components/Button/IconButton.js +0 -79
- package/dist/src/components/Button/IconButton.stories.d.ts +0 -4
- package/dist/src/components/Button/IconButton.stories.js +0 -65
- package/dist/src/components/Button/IconButton.test.js +0 -28
- package/dist/src/components/Card/MultipleNews/MultiNews.jsx +0 -80
- package/dist/src/components/Card/MultipleNews/MultiNews.stories.jsx +0 -104
- package/dist/src/components/Card/PostByCategory/PostByCategory.jsx +0 -60
- package/dist/src/components/Card/PostByCategory/PostByCategory.stories.jsx +0 -106
- package/dist/src/components/Card/SinglePost/SinglePost.jsx +0 -26
- package/dist/src/components/Card/SinglePost/SinglePost.stories.jsx +0 -68
- package/dist/src/components/Card/card.jsx +0 -36
- package/dist/src/components/Card/contactProfile/ContactProfile.jsx +0 -60
- package/dist/src/components/Card/contactProfile/ContactProfile.stories.jsx +0 -103
- package/dist/src/components/Card/photoAlbum/PhotoAlbum.jsx +0 -41
- package/dist/src/components/Card/photoAlbum/PhotoAlbum.stories.jsx +0 -69
- package/dist/src/components/Card/photoGallery/PhotoGallery.jsx +0 -17
- package/dist/src/components/Card/photoGallery/PhotoGallery.stories.jsx +0 -39
- package/dist/src/components/Checkbox/checkbox.jsx +0 -47
- package/dist/src/components/Checkbox/checkbox.stories.jsx +0 -113
- package/dist/src/components/ColorPicker/ColorPicker.jsx +0 -67
- package/dist/src/components/ColorPicker/ColorPicker.stories.jsx +0 -138
- 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/Dropdown/Select.stories.jsx +0 -201
- package/dist/src/components/Dropdown/select.jsx +0 -94
- package/dist/src/components/Icons/IconList.test.d.ts +0 -1
- package/dist/src/components/Icons/IconList.test.js +0 -58
- package/dist/src/components/Icons/IconView.d.ts +0 -1
- package/dist/src/components/Icons/IconView.js +0 -8
- package/dist/src/components/Icons/IconView.stories.d.ts +0 -4
- package/dist/src/components/Icons/IconView.stories.js +0 -20
- package/dist/src/components/Icons/LUIcon.jsx +0 -36
- package/dist/src/components/Icons/LUIcon.stories.d.ts +0 -6
- package/dist/src/components/Icons/LUIcon.stories.js +0 -75
- package/dist/src/components/Icons/LUIcon.test.jsx +0 -243
- package/dist/src/components/Icons/SingleIcon.test.d.ts +0 -1
- package/dist/src/components/Icons/SingleIcon.test.js +0 -68
- package/dist/src/components/Icons/stories/IconDropdown.jsx +0 -67
- package/dist/src/components/Icons/stories/IconGallery.jsx +0 -77
- package/dist/src/components/Icons/stories/InteractiveIconSelector.jsx +0 -86
- package/dist/src/components/Icons/stories/LUIcon.stories.jsx +0 -96
- package/dist/src/components/ImageUploader/ImageUploader.stories.jsx +0 -50
- package/dist/src/components/ImageUploader/imageUploader.jsx +0 -94
- 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 -250
- package/dist/src/components/Input/input.jsx +0 -110
- 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.d.ts +0 -3
- package/dist/src/components/MediaCard/Card.js +0 -45
- package/dist/src/components/MediaCard/Card.stories.d.ts +0 -4
- package/dist/src/components/MediaCard/Card.stories.js +0 -57
- package/dist/src/components/MediaCard/Card.test.d.ts +0 -1
- package/dist/src/components/MediaCard/Card.test.js +0 -28
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.d.ts +0 -2
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.js +0 -27
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.test.d.ts +0 -1
- package/dist/src/components/MediaCard/ContactProfile/ContactProfile.test.js +0 -61
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.d.ts +0 -2
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.js +0 -7
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.test.d.ts +0 -1
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme1.test.js +0 -99
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.d.ts +0 -2
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.js +0 -7
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.test.d.ts +0 -1
- package/dist/src/components/MediaCard/ContactProfile/ContactProfileTheme2.test.js +0 -99
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.d.ts +0 -2
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.js +0 -31
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.test.d.ts +0 -1
- package/dist/src/components/MediaCard/PostByCategory/PostByCategory.test.js +0 -62
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.d.ts +0 -2
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.js +0 -7
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.test.d.ts +0 -1
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme1.test.js +0 -99
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.d.ts +0 -2
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.js +0 -7
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.test.d.ts +0 -1
- package/dist/src/components/MediaCard/PostByCategory/PostByCategoryTheme2.test.js +0 -99
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.d.ts +0 -3
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.js +0 -13
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.stories.d.ts +0 -5
- package/dist/src/components/MediaCard/VerticalCard/VerticalCard.stories.js +0 -40
- package/dist/src/components/MediaCard/index.d.ts +0 -9
- package/dist/src/components/MediaCard/index.js +0 -13
- package/dist/src/components/MediaCard/type.d.ts +0 -47
- package/dist/src/components/RadioButton/RadioButton.stories.d.ts +0 -10
- package/dist/src/components/RadioButton/RadioButton.stories.js +0 -82
- package/dist/src/components/RadioButton/RadioGroup.stories.d.ts +0 -10
- package/dist/src/components/RadioButton/RadioGroup.stories.js +0 -131
- package/dist/src/components/RadioButton/radio-button.d.ts +0 -14
- package/dist/src/components/RadioButton/radio-button.js +0 -57
- package/dist/src/components/RadioButton/radio-group.d.ts +0 -21
- package/dist/src/components/RadioButton/radio-group.js +0 -59
- package/dist/src/components/RadioGroup/RadioGroup.stories.jsx +0 -146
- package/dist/src/components/RadioGroup/radio-group.jsx +0 -49
- 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/Switch/switch.jsx +0 -61
- package/dist/src/components/Tabs/Tabs.stories.jsx +0 -29
- package/dist/src/components/Tabs/tabs.jsx +0 -32
- 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/Caption/caption.jsx +0 -25
- 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 -37
- package/dist/src/components/Typography/Heading/heading.jsx +0 -53
- package/dist/src/components/ui/accordion.d.ts +0 -7
- package/dist/src/components/ui/accordion.js +0 -64
- package/dist/src/components/ui/avatar.jsx +0 -27
- package/dist/src/components/ui/caption.d.ts +0 -8
- package/dist/src/components/ui/caption.js +0 -34
- package/dist/src/components/ui/checkbox.d.ts +0 -4
- package/dist/src/components/ui/checkbox.js +0 -31
- package/dist/src/components/ui/input.d.ts +0 -3
- package/dist/src/components/ui/input.js +0 -29
- package/dist/src/components/ui/switch.d.ts +0 -22
- package/dist/src/components/ui/switch.js +0 -70
- package/dist/src/components/ui/tooltip.jsx +0 -38
- package/dist/src/components/ui/typography.jsx +0 -56
- package/dist/src/context/LocalizationContext.d.ts +0 -23
- package/dist/src/context/LocalizationContext.js +0 -17
- package/dist/src/utils/index.d.ts +0 -17
- package/dist/src/utils/index.js +0 -20
- /package/dist/src/components/{MediaCard → Avatar/StatusIndicator}/type.js +0 -0
- /package/dist/src/components/{Button/Button.test.d.ts → Dropdown/Combobox/type.js} +0 -0
- /package/dist/src/components/{Button/IconButton.test.d.ts → Dropdown/DropdownMenu/type.js} +0 -0
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { render, screen } from "@testing-library/react";
|
|
2
|
-
import LUIcon from "./LUIcon";
|
|
3
|
-
import { iconList } from "../../utils/iconList";
|
|
4
|
-
import { iconSize, iconBackground, IconShape, iconWithBgColor, iconColor, getAppliedColor, } from ".";
|
|
5
|
-
describe("LUIcon Component", function () {
|
|
6
|
-
var validIcon = "chart-simple";
|
|
7
|
-
describe("Basic Rendering", function () {
|
|
8
|
-
it("renders correctly when a valid icon is provided", function () {
|
|
9
|
-
var props = {
|
|
10
|
-
size: "xs",
|
|
11
|
-
icon: validIcon,
|
|
12
|
-
};
|
|
13
|
-
render(<LUIcon {...props}/>);
|
|
14
|
-
// Select the element
|
|
15
|
-
var singleIconElement = screen.getByTestId("lu-icon");
|
|
16
|
-
var computedClassName = iconSize[props.size];
|
|
17
|
-
expect(singleIconElement).toHaveClass(computedClassName);
|
|
18
|
-
// Assert that the fill class is applied correctly on the <path>
|
|
19
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
20
|
-
expect(pathElement).toBeInTheDocument();
|
|
21
|
-
var selectedIcon = iconList[props.icon];
|
|
22
|
-
expect(pathElement).toHaveAttribute("d", selectedIcon || "");
|
|
23
|
-
});
|
|
24
|
-
it("renders correctly when an invalid icon is provided", function () {
|
|
25
|
-
var props = {
|
|
26
|
-
size: "md",
|
|
27
|
-
icon: "non-existent-icon", // Invalid icon
|
|
28
|
-
};
|
|
29
|
-
render(<LUIcon {...props}/>);
|
|
30
|
-
var svgElement = screen.getByTestId("lu-icon");
|
|
31
|
-
expect(svgElement).toBeInTheDocument();
|
|
32
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
33
|
-
expect(pathElement).toBeInTheDocument();
|
|
34
|
-
// Since the icon does not exist, path should be an empty string
|
|
35
|
-
expect(pathElement).toHaveAttribute("d", "");
|
|
36
|
-
});
|
|
37
|
-
it("renders correctly when selectedIcon is undefined", function () {
|
|
38
|
-
var props = {
|
|
39
|
-
size: "md",
|
|
40
|
-
icon: "", // Empty string as icon key
|
|
41
|
-
};
|
|
42
|
-
render(<LUIcon {...props}/>);
|
|
43
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
44
|
-
expect(pathElement).toBeInTheDocument();
|
|
45
|
-
expect(pathElement).toHaveAttribute("d", ""); // Expect empty path when selectedIcon is undefined
|
|
46
|
-
});
|
|
47
|
-
it("renders with default props when only icon is provided", function () {
|
|
48
|
-
render(<LUIcon icon={validIcon}/>);
|
|
49
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
50
|
-
expect(iconElement).toBeInTheDocument();
|
|
51
|
-
expect(iconElement).toHaveClass(iconSize.md); // default size
|
|
52
|
-
});
|
|
53
|
-
it("has correct SVG attributes", function () {
|
|
54
|
-
render(<LUIcon icon={validIcon}/>);
|
|
55
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
56
|
-
expect(iconElement).toHaveAttribute("role", "img");
|
|
57
|
-
expect(iconElement).toHaveAttribute("viewBox", "0 0 32 32");
|
|
58
|
-
expect(iconElement).toHaveAttribute("fill", "currentColor");
|
|
59
|
-
});
|
|
60
|
-
});
|
|
61
|
-
describe("Size Variations", function () {
|
|
62
|
-
var sizes = Object.keys(iconSize);
|
|
63
|
-
sizes.forEach(function (size) {
|
|
64
|
-
it("renders correctly with size ".concat(size), function () {
|
|
65
|
-
render(<LUIcon icon={validIcon} size={size}/>);
|
|
66
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
67
|
-
expect(iconElement).toHaveClass(iconSize[size]);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
describe("Variant: Default", function () {
|
|
72
|
-
it("renders default variant correctly", function () {
|
|
73
|
-
render(<LUIcon icon={validIcon} variant="default"/>);
|
|
74
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
75
|
-
expect(iconElement).toBeInTheDocument();
|
|
76
|
-
// Should not have wrapper div in default variant
|
|
77
|
-
expect(screen.queryByTestId("lu-icon-wrapper")).not.toBeInTheDocument();
|
|
78
|
-
});
|
|
79
|
-
it("applies custom className to SVG in default variant", function () {
|
|
80
|
-
var customClass = "custom-test-class";
|
|
81
|
-
render(<LUIcon icon={validIcon} variant="default" className={customClass}/>);
|
|
82
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
83
|
-
expect(iconElement).toHaveClass(customClass);
|
|
84
|
-
});
|
|
85
|
-
it("applies color classes correctly in default variant", function () {
|
|
86
|
-
var colors = Object.keys(iconColor);
|
|
87
|
-
colors.forEach(function (color) {
|
|
88
|
-
var rerender = render(<LUIcon icon={validIcon} variant="default" color={color}/>).rerender;
|
|
89
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
90
|
-
expect(iconElement).toHaveClass(iconColor[color]);
|
|
91
|
-
rerender(<></>); // Clean up for next iteration
|
|
92
|
-
});
|
|
93
|
-
});
|
|
94
|
-
it("does not apply color when color prop is undefined in default variant", function () {
|
|
95
|
-
render(<LUIcon icon={validIcon} variant="default"/>);
|
|
96
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
97
|
-
var classList = Array.from(iconElement.classList);
|
|
98
|
-
// Should not have any color classes
|
|
99
|
-
Object.values(iconColor).forEach(function (colorClass) {
|
|
100
|
-
expect(classList).not.toContain(colorClass);
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
describe("Variant: Padded", function () {
|
|
105
|
-
it("renders padded variant correctly", function () {
|
|
106
|
-
render(<LUIcon icon={validIcon} variant="padded"/>);
|
|
107
|
-
// Find wrapper by test-id
|
|
108
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
109
|
-
expect(wrapperElement).toBeInTheDocument();
|
|
110
|
-
expect(wrapperElement).toHaveClass("inline-flex", "items-center", "justify-center");
|
|
111
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
112
|
-
expect(iconElement).toBeInTheDocument();
|
|
113
|
-
});
|
|
114
|
-
it("applies padding classes correctly in padded variant", function () {
|
|
115
|
-
var sizes = Object.keys(iconBackground);
|
|
116
|
-
sizes.forEach(function (size) {
|
|
117
|
-
var rerender = render(<LUIcon icon={validIcon} variant="padded" size={size}/>).rerender;
|
|
118
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
119
|
-
expect(wrapperElement).toHaveClass(iconBackground[size]);
|
|
120
|
-
rerender(<></>); // Clean up for next iteration
|
|
121
|
-
});
|
|
122
|
-
});
|
|
123
|
-
it("applies custom className to wrapper in padded variant", function () {
|
|
124
|
-
var customClass = "custom-wrapper-class";
|
|
125
|
-
render(<LUIcon icon={validIcon} variant="padded" className={customClass}/>);
|
|
126
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
127
|
-
expect(wrapperElement).toHaveClass(customClass);
|
|
128
|
-
// SVG should not have the custom class in padded variant
|
|
129
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
130
|
-
expect(iconElement).not.toHaveClass(customClass);
|
|
131
|
-
});
|
|
132
|
-
it("applies background color classes correctly in padded variant", function () {
|
|
133
|
-
var colors = Object.keys(iconWithBgColor);
|
|
134
|
-
colors.forEach(function (color) {
|
|
135
|
-
var rerender = render(<LUIcon icon={validIcon} variant="padded" color={color}/>).rerender;
|
|
136
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
137
|
-
expect(wrapperElement).toHaveClass(iconWithBgColor[color]);
|
|
138
|
-
rerender(<></>); // Clean up for next iteration
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
describe("Shape Variations", function () {
|
|
143
|
-
it("renders square shape correctly in padded variant", function () {
|
|
144
|
-
var sizes = Object.keys(IconShape.square);
|
|
145
|
-
sizes.forEach(function (size) {
|
|
146
|
-
var rerender = render(<LUIcon icon={validIcon} variant="padded" shape="square" size={size}/>).rerender;
|
|
147
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
148
|
-
expect(wrapperElement).toHaveClass(IconShape.square[size]);
|
|
149
|
-
rerender(<></>); // Clean up for next iteration
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
it("renders rounded shape correctly in padded variant", function () {
|
|
153
|
-
render(<LUIcon icon={validIcon} variant="padded" shape="rounded"/>);
|
|
154
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
155
|
-
expect(wrapperElement).toHaveClass(IconShape.rounded);
|
|
156
|
-
});
|
|
157
|
-
it("defaults to square shape when shape prop is not provided", function () {
|
|
158
|
-
render(<LUIcon icon={validIcon} variant="padded" size="md"/>);
|
|
159
|
-
var wrapperElement = screen.getByTestId("lu-icon-wrapper");
|
|
160
|
-
expect(wrapperElement).toHaveClass(IconShape.square.md);
|
|
161
|
-
});
|
|
162
|
-
it("shape prop has no effect in default variant", function () {
|
|
163
|
-
render(<LUIcon icon={validIcon} variant="default" shape="rounded"/>);
|
|
164
|
-
// Should not have wrapper div in default variant
|
|
165
|
-
expect(screen.queryByTestId("lu-icon-wrapper")).not.toBeInTheDocument();
|
|
166
|
-
});
|
|
167
|
-
});
|
|
168
|
-
describe("HTML Attributes Forwarding", function () {
|
|
169
|
-
it("forwards additional props to SVG element in default variant", function () {
|
|
170
|
-
var testId = "custom-test-id";
|
|
171
|
-
var ariaLabel = "Custom icon";
|
|
172
|
-
render(<LUIcon icon={validIcon} variant="default" data-testid={testId} aria-label={ariaLabel}/>);
|
|
173
|
-
var iconElement = screen.getByTestId(testId); // Use custom test id
|
|
174
|
-
expect(iconElement).toHaveAttribute("data-testid", testId);
|
|
175
|
-
expect(iconElement).toHaveAttribute("aria-label", ariaLabel);
|
|
176
|
-
});
|
|
177
|
-
it("forwards style prop correctly", function () {
|
|
178
|
-
var customStyle = { opacity: 0.5 };
|
|
179
|
-
render(<LUIcon icon={validIcon} style={customStyle}/>);
|
|
180
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
181
|
-
expect(iconElement).toHaveStyle("opacity: 0.5");
|
|
182
|
-
});
|
|
183
|
-
});
|
|
184
|
-
describe("Edge Cases", function () {
|
|
185
|
-
it("handles empty icon gracefully", function () {
|
|
186
|
-
// Empty string as icon key to test edge case
|
|
187
|
-
render(<LUIcon icon={""}/>);
|
|
188
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
189
|
-
expect(pathElement).toHaveAttribute("d", "");
|
|
190
|
-
});
|
|
191
|
-
it("handles undefined color gracefully", function () {
|
|
192
|
-
render(<LUIcon icon={validIcon} color={undefined}/>);
|
|
193
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
194
|
-
expect(iconElement).toBeInTheDocument();
|
|
195
|
-
});
|
|
196
|
-
it("combines multiple class names correctly", function () {
|
|
197
|
-
var customClass = "custom-class another-class";
|
|
198
|
-
render(<LUIcon icon={validIcon} size="lg" color="blue" className={customClass}/>);
|
|
199
|
-
var iconElement = screen.getByTestId("lu-icon");
|
|
200
|
-
expect(iconElement).toHaveClass(iconSize.lg);
|
|
201
|
-
expect(iconElement).toHaveClass(iconColor.blue);
|
|
202
|
-
expect(iconElement).toHaveClass("custom-class");
|
|
203
|
-
expect(iconElement).toHaveClass("another-class");
|
|
204
|
-
});
|
|
205
|
-
});
|
|
206
|
-
describe("Color Helper Function", function () {
|
|
207
|
-
it("getAppliedColor returns correct class for padded variant", function () {
|
|
208
|
-
var result = getAppliedColor("padded", "blue");
|
|
209
|
-
expect(result).toBe(iconWithBgColor.blue);
|
|
210
|
-
});
|
|
211
|
-
it("getAppliedColor returns correct class for default variant", function () {
|
|
212
|
-
var result = getAppliedColor("default", "blue");
|
|
213
|
-
expect(result).toBe(iconColor.blue);
|
|
214
|
-
});
|
|
215
|
-
it("getAppliedColor returns empty string when color is undefined", function () {
|
|
216
|
-
var result = getAppliedColor("default", undefined);
|
|
217
|
-
expect(result).toBe("");
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
describe("Integration Tests", function () {
|
|
221
|
-
it("renders complex configuration correctly", function () {
|
|
222
|
-
render(<LUIcon icon="info" size="2xl" variant="padded" shape="rounded" color="light-blue" className="test-complex" data-testid="complex-icon"/>);
|
|
223
|
-
var wrapperElement = screen.getByTestId("complex-icon-wrapper");
|
|
224
|
-
expect(wrapperElement).toHaveClass(iconBackground["2xl"]);
|
|
225
|
-
expect(wrapperElement).toHaveClass(IconShape.rounded);
|
|
226
|
-
expect(wrapperElement).toHaveClass(iconWithBgColor["light-blue"]);
|
|
227
|
-
expect(wrapperElement).toHaveClass("test-complex");
|
|
228
|
-
var iconElement = screen.getByTestId("complex-icon"); // Use custom test id
|
|
229
|
-
expect(iconElement).toHaveClass(iconSize["2xl"]);
|
|
230
|
-
expect(iconElement).toHaveAttribute("data-testid", "complex-icon");
|
|
231
|
-
});
|
|
232
|
-
it("handles all icon variants from iconList", function () {
|
|
233
|
-
var iconKeys = Object.keys(iconList);
|
|
234
|
-
// Test first few icons to ensure they all render
|
|
235
|
-
iconKeys.slice(0, 5).forEach(function (iconKey) {
|
|
236
|
-
var rerender = render(<LUIcon icon={iconKey}/>).rerender;
|
|
237
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
238
|
-
expect(pathElement).toHaveAttribute("d", iconList[iconKey]);
|
|
239
|
-
rerender(<></>);
|
|
240
|
-
});
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { render, screen } from "@testing-library/react";
|
|
14
|
-
import LUIcon from "./LUIcon";
|
|
15
|
-
import { iconList } from "../../utils/iconList";
|
|
16
|
-
import { iconSize } from ".";
|
|
17
|
-
describe("LUIcon Component", function () {
|
|
18
|
-
it("renders correctly when a valid icon is provided", function () {
|
|
19
|
-
var props = {
|
|
20
|
-
size: "xs",
|
|
21
|
-
icon: iconList[0].key,
|
|
22
|
-
};
|
|
23
|
-
render(_jsx(LUIcon, __assign({}, props)));
|
|
24
|
-
// Select the element
|
|
25
|
-
var singleIconElement = screen.getByTestId("lu-icon");
|
|
26
|
-
var computedClassName = iconSize[props.size];
|
|
27
|
-
expect(singleIconElement).toHaveClass(computedClassName);
|
|
28
|
-
// Assert that the fill class is applied correctly on the <path>
|
|
29
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
30
|
-
expect(pathElement).toBeInTheDocument();
|
|
31
|
-
var selectedIcon = iconList.find(function (icon) { return icon.key === props.icon; });
|
|
32
|
-
expect(pathElement).toHaveAttribute("d", (selectedIcon === null || selectedIcon === void 0 ? void 0 : selectedIcon.path) || "");
|
|
33
|
-
});
|
|
34
|
-
it("renders correctly when an invalid icon is provided", function () {
|
|
35
|
-
var props = {
|
|
36
|
-
size: "md",
|
|
37
|
-
icon: "non-existent-icon", // Invalid icon
|
|
38
|
-
};
|
|
39
|
-
render(_jsx(LUIcon, __assign({}, props)));
|
|
40
|
-
var svgElement = screen.getByTestId("lu-icon");
|
|
41
|
-
expect(svgElement).toBeInTheDocument();
|
|
42
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
43
|
-
expect(pathElement).toBeInTheDocument();
|
|
44
|
-
// Since the icon does not exist, path should be an empty string
|
|
45
|
-
expect(pathElement).toHaveAttribute("d", "");
|
|
46
|
-
});
|
|
47
|
-
it("applies additional className correctly", function () {
|
|
48
|
-
var props = {
|
|
49
|
-
size: "lg",
|
|
50
|
-
icon: iconList[0].key,
|
|
51
|
-
className: "custom-class",
|
|
52
|
-
};
|
|
53
|
-
render(_jsx(LUIcon, __assign({}, props)));
|
|
54
|
-
var singleIconElement = screen.getByTestId("lu-icon");
|
|
55
|
-
expect(singleIconElement).toHaveClass(iconSize[props.size] || "");
|
|
56
|
-
expect(singleIconElement).toHaveClass("custom-class");
|
|
57
|
-
});
|
|
58
|
-
it("renders correctly when selectedIcon is undefined", function () {
|
|
59
|
-
var props = {
|
|
60
|
-
size: "md",
|
|
61
|
-
icon: "", // Pass an empty string to ensure find() returns undefined
|
|
62
|
-
};
|
|
63
|
-
render(_jsx(LUIcon, __assign({}, props)));
|
|
64
|
-
var pathElement = screen.getByTestId("lu-path");
|
|
65
|
-
expect(pathElement).toBeInTheDocument();
|
|
66
|
-
expect(pathElement).toHaveAttribute("d", ""); // Expect empty path when selectedIcon is undefined
|
|
67
|
-
});
|
|
68
|
-
});
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, useState } from "react";
|
|
2
|
-
import LUIcon from "../LUIcon";
|
|
3
|
-
import { Input } from "../../../components/Input";
|
|
4
|
-
export var IconDropdown = function (_a) {
|
|
5
|
-
var value = _a.value, onChange = _a.onChange, options = _a.options;
|
|
6
|
-
var _b = useState(false), isOpen = _b[0], setIsOpen = _b[1];
|
|
7
|
-
var _c = useState(""), searchTerm = _c[0], setSearchTerm = _c[1];
|
|
8
|
-
var dropdownRef = useRef(null);
|
|
9
|
-
var filteredOptions = options.filter(function (option) {
|
|
10
|
-
return option.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
11
|
-
option
|
|
12
|
-
.replace(/-/g, " ")
|
|
13
|
-
.toLowerCase()
|
|
14
|
-
.includes(searchTerm.toLowerCase());
|
|
15
|
-
});
|
|
16
|
-
useEffect(function () {
|
|
17
|
-
var handleClickOutside = function (event) {
|
|
18
|
-
if (dropdownRef.current &&
|
|
19
|
-
!dropdownRef.current.contains(event.target)) {
|
|
20
|
-
setIsOpen(false);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
document.addEventListener("mousedown", handleClickOutside);
|
|
24
|
-
return function () { return document.removeEventListener("mousedown", handleClickOutside); };
|
|
25
|
-
}, []);
|
|
26
|
-
var handleSelect = function (option) {
|
|
27
|
-
onChange(option);
|
|
28
|
-
setIsOpen(false);
|
|
29
|
-
setSearchTerm("");
|
|
30
|
-
};
|
|
31
|
-
var formatLabel = function (iconKey) {
|
|
32
|
-
return iconKey.replace(/-/g, " ").replace(/\b\w/g, function (l) { return l.toUpperCase(); });
|
|
33
|
-
};
|
|
34
|
-
return (<div ref={dropdownRef} className="relative w-full">
|
|
35
|
-
{/* Dropdown trigger */}
|
|
36
|
-
<div onClick={function () { return setIsOpen(!isOpen); }} className="px-3 py-2 border border-gray-300 rounded bg-white cursor-pointer flex items-center justify-between min-h-9">
|
|
37
|
-
<div className="flex items-center gap-2">
|
|
38
|
-
{value && <LUIcon icon={value} size="xs"/>}
|
|
39
|
-
<span>{value ? formatLabel(value) : "Select an icon..."}</span>
|
|
40
|
-
</div>
|
|
41
|
-
<span className={"transition-transform duration-200 ".concat(isOpen ? "rotate-180" : "rotate-0")}>
|
|
42
|
-
▼
|
|
43
|
-
</span>
|
|
44
|
-
</div>
|
|
45
|
-
|
|
46
|
-
{/* Dropdown menu */}
|
|
47
|
-
{isOpen && (<div className="absolute top-full left-0 right-0 bg-white border border-gray-300 rounded shadow-lg z-[1000] max-h-[300px] overflow-y-auto">
|
|
48
|
-
{/* Search input */}
|
|
49
|
-
<div className="p-2">
|
|
50
|
-
<Input type="text" placeholder="Search icons..." value={searchTerm} onChange={function (e) { return setSearchTerm(e.target.value); }} className="w-full px-2 py-1.5 border border-gray-300 rounded-sm text-sm" onClick={function (e) { return e.stopPropagation(); }}/>
|
|
51
|
-
</div>
|
|
52
|
-
|
|
53
|
-
{/* Options list */}
|
|
54
|
-
<div className="max-h-[200px] overflow-y-auto">
|
|
55
|
-
{filteredOptions.length === 0 ? (<div className="p-3 text-gray-600 italic">No icons found</div>) : (filteredOptions.map(function (option) { return (<div key={option} onClick={function () { return handleSelect(option); }} className={"px-3 py-2 cursor-pointer flex items-center gap-2 transition-colors duration-100 ".concat(value === option
|
|
56
|
-
? "bg-blue-50 border-l-4 border-l-blue-600"
|
|
57
|
-
: "border-l-4 border-l-transparent hover:bg-gray-50")}>
|
|
58
|
-
<LUIcon icon={option} size="xs"/>
|
|
59
|
-
<span className="text-sm">{formatLabel(option)}</span>
|
|
60
|
-
<span className="text-xs text-gray-600 ml-auto">
|
|
61
|
-
{option}
|
|
62
|
-
</span>
|
|
63
|
-
</div>); }))}
|
|
64
|
-
</div>
|
|
65
|
-
</div>)}
|
|
66
|
-
</div>);
|
|
67
|
-
};
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { iconList } from "../../../utils/iconList";
|
|
3
|
-
import LUIcon from "../LUIcon";
|
|
4
|
-
import { Heading } from "../../../components/Typography/Heading/heading";
|
|
5
|
-
import { Body } from "../../../components/Typography/Body/body";
|
|
6
|
-
import { Input } from "../../../components/Input/input";
|
|
7
|
-
export var IconGallery = function () {
|
|
8
|
-
var _a = useState(""), searchTerm = _a[0], setSearchTerm = _a[1];
|
|
9
|
-
var _b = useState(""), selectedIcon = _b[0], setSelectedIcon = _b[1];
|
|
10
|
-
var filteredIcons = Object.keys(iconList)
|
|
11
|
-
.sort()
|
|
12
|
-
.filter(function (iconKey) {
|
|
13
|
-
return iconKey.toLowerCase().includes(searchTerm.toLowerCase()) ||
|
|
14
|
-
iconKey
|
|
15
|
-
.replace(/-/g, " ")
|
|
16
|
-
.toLowerCase()
|
|
17
|
-
.includes(searchTerm.toLowerCase());
|
|
18
|
-
});
|
|
19
|
-
var IconItem = function (_a) {
|
|
20
|
-
var iconKey = _a.iconKey;
|
|
21
|
-
return (<div key={iconKey} onClick={function () { return setSelectedIcon(iconKey); }} className={"flex items-center gap-2 p-2 border rounded cursor-pointer transition-all duration-200 ".concat(selectedIcon === iconKey
|
|
22
|
-
? "border-blue-600 bg-blue-50 border-2"
|
|
23
|
-
: "border-gray-200 bg-white hover:bg-gray-50 hover:border-gray-300")}>
|
|
24
|
-
<LUIcon icon={iconKey} size="sm"/>
|
|
25
|
-
<span className="text-xs font-mono text-gray-700 break-all">
|
|
26
|
-
{iconKey}
|
|
27
|
-
</span>
|
|
28
|
-
</div>);
|
|
29
|
-
};
|
|
30
|
-
var IconPreview = function (_a) {
|
|
31
|
-
var iconKey = _a.iconKey;
|
|
32
|
-
return (<div className="mt-5 p-4 bg-gray-50 rounded-lg border border-gray-200">
|
|
33
|
-
<Heading variant="h4" className="mb-4">
|
|
34
|
-
Preview Selected Icon: {iconKey}
|
|
35
|
-
</Heading>
|
|
36
|
-
<div className="flex gap-4 items-center flex-wrap">
|
|
37
|
-
<div className="flex items-center gap-2">
|
|
38
|
-
<Body variant="body-sm-600">Default:</Body>
|
|
39
|
-
<LUIcon icon={iconKey} size="md"/>
|
|
40
|
-
</div>
|
|
41
|
-
<div className="flex items-center gap-2">
|
|
42
|
-
<Body variant="body-sm-600">Padded:</Body>
|
|
43
|
-
<LUIcon icon={iconKey} size="md" variant="padded" color="blue"/>
|
|
44
|
-
</div>
|
|
45
|
-
<div className="flex items-center gap-2">
|
|
46
|
-
<Body variant="body-sm-600">Large:</Body>
|
|
47
|
-
<LUIcon icon={iconKey} size="xl"/>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
<div className="mt-3 font-mono text-sm">
|
|
51
|
-
<Body variant="body-sm-600">Usage:</Body>
|
|
52
|
-
<br />
|
|
53
|
-
<code className="bg-gray-100 p-1 rounded">{"<LUIcon icon=\"".concat(iconKey, "\" size=\"md\" />")}</code>
|
|
54
|
-
</div>
|
|
55
|
-
</div>);
|
|
56
|
-
};
|
|
57
|
-
return (<div className="p-5">
|
|
58
|
-
<Heading variant="h3" className="mb-5">
|
|
59
|
-
Icon Gallery - All Available Icons ({Object.keys(iconList).length}{" "}
|
|
60
|
-
total)
|
|
61
|
-
</Heading>
|
|
62
|
-
|
|
63
|
-
<div className="mb-5">
|
|
64
|
-
<Input type="text" placeholder="Search icons... (e.g., 'circle', 'info', 'qr')" value={searchTerm} onChange={function (e) { return setSearchTerm(e.target.value); }} className="w-full max-w-md" startIcon="magnifying-glass"/>
|
|
65
|
-
<Body variant="body-sm" className="mt-2 text-gray-600">
|
|
66
|
-
{filteredIcons.length} icons found
|
|
67
|
-
{selectedIcon && (<span className="ml-4 font-semibold">Selected: {selectedIcon}</span>)}
|
|
68
|
-
</Body>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<div className="grid grid-cols-[repeat(auto-fill,minmax(180px,1fr))] gap-3 max-h-[500px] overflow-y-auto border border-gray-200 p-4 rounded-lg">
|
|
72
|
-
{filteredIcons.map(function (iconKey) { return (<IconItem key={iconKey} iconKey={iconKey}/>); })}
|
|
73
|
-
</div>
|
|
74
|
-
|
|
75
|
-
{selectedIcon && <IconPreview iconKey={selectedIcon}/>}
|
|
76
|
-
</div>);
|
|
77
|
-
};
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import { iconList } from "../../../utils/iconList";
|
|
3
|
-
import LUIcon from "../LUIcon";
|
|
4
|
-
import { iconSize, iconWithBgColor } from "../index";
|
|
5
|
-
import { IconDropdown } from "./IconDropdown";
|
|
6
|
-
import { Heading } from "../../../components/Typography/Heading/heading";
|
|
7
|
-
import { Body } from "../../../components/Typography/Body/body";
|
|
8
|
-
import { Label } from "../../../components/Label/Label";
|
|
9
|
-
export var InteractiveIconSelector = function () {
|
|
10
|
-
var _a = useState("info"), selectedIcon = _a[0], setSelectedIcon = _a[1];
|
|
11
|
-
var _b = useState("md"), selectedSize = _b[0], setSelectedSize = _b[1];
|
|
12
|
-
var _c = useState("default"), selectedVariant = _c[0], setSelectedVariant = _c[1];
|
|
13
|
-
var _d = useState("blue"), selectedColor = _d[0], setSelectedColor = _d[1];
|
|
14
|
-
var generateUsageCode = function () {
|
|
15
|
-
var code = "<LUIcon icon=\"".concat(selectedIcon, "\" size=\"").concat(selectedSize, "\"");
|
|
16
|
-
if (selectedVariant === "padded") {
|
|
17
|
-
code += " variant=\"padded\" color=\"".concat(selectedColor, "\"");
|
|
18
|
-
}
|
|
19
|
-
code += " />";
|
|
20
|
-
return code;
|
|
21
|
-
};
|
|
22
|
-
return (<div className="p-5">
|
|
23
|
-
<Heading variant="h3" className="mb-3">
|
|
24
|
-
Interactive Icon Selector
|
|
25
|
-
</Heading>
|
|
26
|
-
<Body variant="body-md" className="mb-6 text-gray-600">
|
|
27
|
-
This demonstrates a custom searchable dropdown that shows icons
|
|
28
|
-
alongside their names.
|
|
29
|
-
</Body>
|
|
30
|
-
|
|
31
|
-
<div className="grid grid-cols-[repeat(auto-fit,minmax(200px,1fr))] gap-4 mb-6">
|
|
32
|
-
<div>
|
|
33
|
-
<Label variant="label-md" className="block mb-2 ">
|
|
34
|
-
Select Icon:
|
|
35
|
-
</Label>
|
|
36
|
-
<IconDropdown value={selectedIcon} onChange={setSelectedIcon} options={Object.keys(iconList).sort()}/>
|
|
37
|
-
</div>
|
|
38
|
-
|
|
39
|
-
<div>
|
|
40
|
-
<Label variant="label-md" className="block mb-2 ">
|
|
41
|
-
Size:
|
|
42
|
-
</Label>
|
|
43
|
-
<select value={selectedSize} onChange={function (e) { return setSelectedSize(e.target.value); }} className="w-full p-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
|
|
44
|
-
{Object.keys(iconSize).map(function (size) { return (<option key={size} value={size}>
|
|
45
|
-
{size}
|
|
46
|
-
</option>); })}
|
|
47
|
-
</select>
|
|
48
|
-
</div>
|
|
49
|
-
|
|
50
|
-
<div>
|
|
51
|
-
<Label variant="label-md" className="block mb-2 ">
|
|
52
|
-
Variant:
|
|
53
|
-
</Label>
|
|
54
|
-
<select value={selectedVariant} onChange={function (e) {
|
|
55
|
-
return setSelectedVariant(e.target.value);
|
|
56
|
-
}} className="w-full p-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
|
|
57
|
-
<option value="default">Default</option>
|
|
58
|
-
<option value="padded">Padded</option>
|
|
59
|
-
</select>
|
|
60
|
-
</div>
|
|
61
|
-
|
|
62
|
-
{selectedVariant === "padded" && (<div>
|
|
63
|
-
<Label variant="label-md" className="block mb-2">
|
|
64
|
-
Color:
|
|
65
|
-
</Label>
|
|
66
|
-
<select value={selectedColor} onChange={function (e) { return setSelectedColor(e.target.value); }} className="w-full p-2 border border-gray-300 rounded focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent">
|
|
67
|
-
{Object.keys(iconWithBgColor).map(function (color) { return (<option key={color} value={color}>
|
|
68
|
-
{color}
|
|
69
|
-
</option>); })}
|
|
70
|
-
</select>
|
|
71
|
-
</div>)}
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
<div className="p-6 border-2 border-dashed border-gray-300 rounded-lg text-center bg-gray-50">
|
|
75
|
-
<Heading variant="h4" className="mb-4">
|
|
76
|
-
Preview:
|
|
77
|
-
</Heading>
|
|
78
|
-
<div className="my-4">
|
|
79
|
-
<LUIcon icon={selectedIcon} size={selectedSize} variant={selectedVariant} color={selectedVariant === "padded" ? selectedColor : undefined}/>
|
|
80
|
-
</div>
|
|
81
|
-
<div className="font-mono text-sm bg-gray-100 p-2 rounded">
|
|
82
|
-
{generateUsageCode()}
|
|
83
|
-
</div>
|
|
84
|
-
</div>
|
|
85
|
-
</div>);
|
|
86
|
-
};
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { iconList } from "../../../utils/iconList";
|
|
2
|
-
import { InteractiveIconSelector as InteractiveIconSelectorComponent, IconGallery as IconGalleryComponent, } from ".";
|
|
3
|
-
import LUIcon from "../LUIcon";
|
|
4
|
-
import { iconColor, IconShape, iconSize, iconWithBgColor } from "..";
|
|
5
|
-
export default {
|
|
6
|
-
title: "Components/Icon",
|
|
7
|
-
component: LUIcon,
|
|
8
|
-
tags: ["autodocs"],
|
|
9
|
-
argTypes: {
|
|
10
|
-
size: {
|
|
11
|
-
control: { type: "select" },
|
|
12
|
-
options: Object.keys(iconSize),
|
|
13
|
-
description: "Size of the icon",
|
|
14
|
-
},
|
|
15
|
-
icon: {
|
|
16
|
-
control: {
|
|
17
|
-
type: "select",
|
|
18
|
-
labels: Object.fromEntries(Object.keys(iconList)
|
|
19
|
-
.sort()
|
|
20
|
-
.map(function (key) { return [key]; })),
|
|
21
|
-
},
|
|
22
|
-
options: Object.keys(iconList).sort(), // Sort alphabetically for easier finding
|
|
23
|
-
description: "Icon to display (searchable dropdown with formatted labels)",
|
|
24
|
-
},
|
|
25
|
-
variant: {
|
|
26
|
-
control: { type: "select" },
|
|
27
|
-
options: ["default", "padded"],
|
|
28
|
-
description: "Type of the icon",
|
|
29
|
-
},
|
|
30
|
-
shape: {
|
|
31
|
-
control: {
|
|
32
|
-
type: "radio",
|
|
33
|
-
options: Object.keys(IconShape),
|
|
34
|
-
},
|
|
35
|
-
options: Object.keys(IconShape),
|
|
36
|
-
description: "Shape of the padded icon",
|
|
37
|
-
if: { arg: "variant", eq: "padded" },
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
};
|
|
41
|
-
var Template = function (args) { return <LUIcon {...args}/>; };
|
|
42
|
-
// Default Icon Story
|
|
43
|
-
export var _DefaultIcon = Template.bind({});
|
|
44
|
-
_DefaultIcon.args = {
|
|
45
|
-
size: "md",
|
|
46
|
-
icon: Object.keys(iconList)[0],
|
|
47
|
-
color: "blue",
|
|
48
|
-
variant: "default",
|
|
49
|
-
};
|
|
50
|
-
_DefaultIcon.argTypes = {
|
|
51
|
-
color: {
|
|
52
|
-
control: { type: "select" },
|
|
53
|
-
options: Object.keys(iconColor),
|
|
54
|
-
description: "Text color (no background)",
|
|
55
|
-
},
|
|
56
|
-
};
|
|
57
|
-
// Padded Icon Story
|
|
58
|
-
export var _PaddedIcon = Template.bind({});
|
|
59
|
-
_PaddedIcon.args = {
|
|
60
|
-
size: "md",
|
|
61
|
-
icon: Object.keys(iconList)[0],
|
|
62
|
-
variant: "padded",
|
|
63
|
-
color: "blue",
|
|
64
|
-
shape: "square",
|
|
65
|
-
};
|
|
66
|
-
_PaddedIcon.argTypes = {
|
|
67
|
-
color: {
|
|
68
|
-
control: { type: "select" },
|
|
69
|
-
options: Object.keys(iconWithBgColor),
|
|
70
|
-
description: "Background color for padded variant",
|
|
71
|
-
},
|
|
72
|
-
};
|
|
73
|
-
// Export stories using separate components for better maintainability
|
|
74
|
-
export var InteractiveIconSelector = function () { return (<InteractiveIconSelectorComponent />); };
|
|
75
|
-
export var IconGallery = function () { return <IconGalleryComponent />; };
|
|
76
|
-
// Set parameters for the stories
|
|
77
|
-
InteractiveIconSelector.parameters = {
|
|
78
|
-
docs: {
|
|
79
|
-
description: {
|
|
80
|
-
story: "Use this interactive tool to select icons with a custom dropdown that shows both the icon and its name. Perfect for developers to quickly find and preview icons.",
|
|
81
|
-
},
|
|
82
|
-
source: {
|
|
83
|
-
code: null, // This hides the source code
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
};
|
|
87
|
-
IconGallery.parameters = {
|
|
88
|
-
docs: {
|
|
89
|
-
description: {
|
|
90
|
-
story: "Browse and search through all available icons. Click on any icon to see a preview and get the usage code.",
|
|
91
|
-
},
|
|
92
|
-
source: {
|
|
93
|
-
code: null, // This hides the source code
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
};
|