@agility/plenum-ui 2.0.0-rc6 → 2.0.0-rc61
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/README.md +104 -31
- package/build.js +30 -25
- package/dist/index.d.ts +446 -320
- package/dist/index.js +1 -6108
- package/dist/index.js.map +4 -4
- package/dist/{lib/tailwind.css → tailwind.css} +3735 -8122
- package/dist/types/stories/atoms/buttons/Button/Alternative/Alternative.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Button.d.ts +3 -7
- package/dist/types/stories/atoms/buttons/Button/Danger/Danger.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Primary/Primary.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Button/Secondary/Secondary.stories.d.ts +1 -0
- package/dist/types/stories/atoms/buttons/Capsule/Capsule.d.ts +1 -1
- package/dist/types/stories/atoms/icons/DynamicIcon.d.ts +2 -2
- package/dist/types/stories/atoms/icons/TablerIcon.d.ts +1 -1
- package/dist/types/stories/index.d.ts +4 -4
- package/dist/types/stories/molecules/index.d.ts +3 -3
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +8 -8
- package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +1 -1
- package/dist/types/stories/molecules/inputs/index.d.ts +4 -4
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +4 -2
- package/dist/types/stories/molecules/inputs/textArea/TextArea.d.ts +34 -21
- package/dist/types/stories/molecules/inputs/textArea/TextArea.stories.d.ts +4 -4
- package/dist/types/stories/molecules/inputs/textArea/index.d.ts +3 -3
- package/dist/types/stories/molecules/inputs/toggleSwitch/ToggleSwitch.d.ts +10 -7
- package/dist/types/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.d.ts +5 -5
- package/dist/types/stories/organisms/AnimatedLabelInput/index.d.ts +1 -1
- package/dist/types/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.d.ts +12 -0
- package/dist/types/stories/organisms/AnimatedLabelTextArea/index.d.ts +3 -0
- package/dist/types/stories/organisms/ButtonDropdown/ButtonDropdown.d.ts +1 -0
- package/dist/types/stories/organisms/DropdownComponent/DropdownComponent.d.ts +24 -13
- package/dist/types/stories/organisms/DropdownComponent/index.d.ts +2 -2
- package/dist/types/stories/organisms/EmptySectionPlaceholder/index.d.ts +1 -1
- package/dist/types/stories/organisms/TextInputSelect/InputSelect.d.ts +16 -0
- package/dist/types/stories/organisms/TextInputSelect/TextInputSelect.d.ts +48 -0
- package/dist/types/stories/organisms/TextInputSelect/index.d.ts +3 -0
- package/dist/types/stories/organisms/index.d.ts +5 -3
- package/local.sh +100 -0
- package/package.json +35 -18
- package/rollup.config.mjs +42 -0
- package/stories/atoms/badges/Badge.tsx +1 -1
- package/stories/atoms/buttons/Button/Alternative/Alternative.stories.ts +10 -0
- package/stories/atoms/buttons/Button/Button.tsx +111 -25
- package/stories/atoms/buttons/Button/Danger/Danger.stories.ts +14 -2
- package/stories/atoms/buttons/Button/Primary/Primary.stories.ts +14 -2
- package/stories/atoms/buttons/Button/Secondary/Secondary.stories.ts +13 -1
- package/stories/atoms/buttons/Button/defaultArgs.ts +1 -1
- package/stories/atoms/buttons/Capsule/Capsule.tsx +2 -1
- package/stories/atoms/icons/DynamicIcon.stories.ts +1 -1
- package/stories/atoms/icons/DynamicIcon.tsx +7 -7
- package/stories/atoms/icons/IconWithShadow.stories.ts +3 -3
- package/stories/atoms/icons/TablerIcon.tsx +1 -1
- package/stories/atoms/loaders/Loader.tsx +12 -6
- package/stories/atoms/loaders/NProgress/RadialProgress.tsx +0 -2
- package/stories/index.ts +18 -10
- package/stories/molecules/index.ts +6 -4
- package/stories/molecules/inputs/InputCounter/InputCounter.tsx +2 -2
- package/stories/molecules/inputs/InputField/InputField.tsx +32 -29
- package/stories/molecules/inputs/TextInput/TextInput.tsx +7 -4
- package/stories/molecules/inputs/checkbox/Checkbox.stories.ts +1 -1
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -2
- package/stories/molecules/inputs/combobox/ComboBox.tsx +126 -135
- package/stories/molecules/inputs/index.ts +5 -4
- package/stories/molecules/inputs/radio/Radio.stories.ts +2 -2
- package/stories/molecules/inputs/select/Select.tsx +10 -2
- package/stories/molecules/inputs/textArea/TextArea.stories.ts +7 -5
- package/stories/molecules/inputs/textArea/TextArea.tsx +139 -48
- package/stories/molecules/inputs/textArea/index.ts +3 -3
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.stories.tsx +15 -16
- package/stories/molecules/inputs/toggleSwitch/ToggleSwitch.tsx +63 -57
- package/stories/molecules/tabs/index.tsx +2 -3
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.stories.tsx +10 -1
- package/stories/organisms/AnimatedLabelInput/AnimatedLabelInput.tsx +53 -37
- package/stories/organisms/AnimatedLabelInput/index.tsx +1 -1
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.stories.tsx +26 -0
- package/stories/organisms/AnimatedLabelTextArea/AnimatedLabelTextArea.tsx +61 -0
- package/stories/organisms/AnimatedLabelTextArea/index.tsx +3 -0
- package/stories/organisms/ButtonDropdown/ButtonDropdown.stories.tsx +65 -58
- package/stories/organisms/ButtonDropdown/ButtonDropdown.tsx +42 -30
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +26 -2
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +225 -179
- package/stories/organisms/DropdownComponent/dropdownItems.ts +30 -9
- package/stories/organisms/DropdownComponent/index.ts +2 -2
- package/stories/organisms/EmptySectionPlaceholder/EmptySectionPlaceholder.stories.tsx +3 -3
- package/stories/organisms/EmptySectionPlaceholder/index.tsx +2 -1
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.stories.tsx +1 -1
- package/stories/organisms/FormInputWithAddons/FormInputWithAddons.tsx +7 -2
- package/stories/organisms/TextInputSelect/InputSelect.tsx +59 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.stories.tsx +33 -0
- package/stories/organisms/TextInputSelect/TextInputSelect.tsx +186 -0
- package/stories/organisms/TextInputSelect/index.tsx +3 -0
- package/stories/organisms/index.ts +15 -4
- package/tailwind.config.js +81 -37
- package/tsconfig.lib.json +13 -6
- package/watch.js +49 -0
- package/.yarnrc.yml +0 -1
- package/dist/types/stories/layouts/index.d.ts +0 -0
- package/stories/layouts/CardLayout/CardLayout.stories.tsx +0 -18
- package/stories/layouts/CardLayout/CardLayout.tsx +0 -22
- package/stories/layouts/CardLayout/index.tsx +0 -3
- package/stories/layouts/ModalLayout/ModalLayout.stories.tsx +0 -18
- package/stories/layouts/ModalLayout/ModalLayout.tsx +0 -22
- package/stories/layouts/ModalLayout/index.tsx +0 -3
- package/stories/layouts/index.ts +0 -0
- package/stories/organisms/DropdownComponent/Dropdown.test.tsx +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agility/plenum-ui",
|
|
3
|
-
"version": "2.0.0-
|
|
3
|
+
"version": "2.0.0-rc61",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -17,19 +17,35 @@
|
|
|
17
17
|
"storybook:tw": "tailwindcss -o ./lib/tailwind.css -w ",
|
|
18
18
|
"storybook": "npm-run-all -p \"storybook:*\" ",
|
|
19
19
|
"dev": "yarn storybook",
|
|
20
|
-
"build:tw": "tailwindcss -o ./dist/
|
|
20
|
+
"build:tw": "tailwindcss -o ./dist/tailwind.css",
|
|
21
21
|
"build:tsc": "yarn node build.js",
|
|
22
22
|
"prepare": "yarn build",
|
|
23
|
-
"build": "
|
|
23
|
+
"build": "yarn clean && npm-run-all -s \"build:*\" ",
|
|
24
24
|
"clean": "rimraf dist",
|
|
25
|
-
"create-component": "node scripts/create-component.js"
|
|
25
|
+
"create-component": "node scripts/create-component.js",
|
|
26
|
+
"start:local": "bash ./local.sh",
|
|
27
|
+
"start:watch": "yarn node watch.js"
|
|
26
28
|
},
|
|
27
|
-
"
|
|
29
|
+
"dependencies": {
|
|
28
30
|
"@floating-ui/react": "^0.25.0",
|
|
29
31
|
"@headlessui/react": "^1.7.10",
|
|
30
32
|
"@headlessui/tailwindcss": "^0.1.2",
|
|
31
33
|
"@heroicons/react": "^1.0.5",
|
|
32
34
|
"@next/font": "^13.4.12",
|
|
35
|
+
"@tabler/icons": "^2.26.0",
|
|
36
|
+
"@tabler/icons-react": "^2.27.0",
|
|
37
|
+
"@tailwindcss/forms": "^0.5.3",
|
|
38
|
+
"@tailwindcss/typography": "^0.5.9",
|
|
39
|
+
"classnames": "^2.3.2",
|
|
40
|
+
"concurrently": "^7.6.0",
|
|
41
|
+
"next": "13.1.6",
|
|
42
|
+
"npm-dts": "^1.3.12",
|
|
43
|
+
"npm-run-all": "^4.1.5",
|
|
44
|
+
"postcss": "^8.4.21",
|
|
45
|
+
"tailwindcss": "^3.2.4",
|
|
46
|
+
"typescript": "^5.1.6"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
33
49
|
"@storybook/addon-designs": "^7.0.1",
|
|
34
50
|
"@storybook/addon-essentials": "^7.1.1",
|
|
35
51
|
"@storybook/addon-interactions": "^7.1.1",
|
|
@@ -40,27 +56,28 @@
|
|
|
40
56
|
"@storybook/react": "^7.1.1",
|
|
41
57
|
"@storybook/testing-library": "^0.2.0",
|
|
42
58
|
"@storybook/theming": "^7.1.1",
|
|
43
|
-
"@tabler/icons": "^2.26.0",
|
|
44
|
-
"@tabler/icons-react": "^2.27.0",
|
|
45
|
-
"@tailwindcss/forms": "^0.5.3",
|
|
46
|
-
"@tailwindcss/typography": "^0.5.9",
|
|
47
59
|
"@types/node": "18.11.18",
|
|
48
60
|
"autoprefixer": "^10.4.13",
|
|
49
|
-
"classnames": "^2.3.2",
|
|
50
|
-
"concurrently": "^7.6.0",
|
|
51
61
|
"esbuild": "^0.18.19",
|
|
52
62
|
"eslint": "8.32.0",
|
|
53
63
|
"eslint-config-next": "13.1.6",
|
|
54
64
|
"eslint-plugin-storybook": "^0.6.13",
|
|
55
|
-
"next": "13.1.6",
|
|
56
|
-
"npm-dts": "^1.3.12",
|
|
57
|
-
"npm-run-all": "^4.1.5",
|
|
58
|
-
"postcss": "^8.4.21",
|
|
59
65
|
"react": "18.2.0",
|
|
60
66
|
"react-dom": "18.2.0",
|
|
61
67
|
"react-icons": "^4.10.1",
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
68
|
+
"rimraf": "^5.0.1",
|
|
69
|
+
"storybook": "^7.1.1"
|
|
70
|
+
},
|
|
71
|
+
"peerDependencies": {
|
|
72
|
+
"@floating-ui/react": "^0.25.0",
|
|
73
|
+
"@headlessui/react": "^1.7.10",
|
|
74
|
+
"@headlessui/tailwindcss": "^0.1.2",
|
|
75
|
+
"@heroicons/react": "^1.0.5",
|
|
76
|
+
"@tabler/icons": "^2.26.0",
|
|
77
|
+
"@tabler/icons-react": "^2.27.0",
|
|
78
|
+
"classnames": "^2.3.2",
|
|
79
|
+
"react": "18.2.0",
|
|
80
|
+
"react-dom": "18.2.0",
|
|
81
|
+
"react-icons": "^4.10.1"
|
|
65
82
|
}
|
|
66
83
|
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import peerDepsExternal from 'rollup-plugin-peer-deps-external';
|
|
2
|
+
import resolve from '@rollup/plugin-node-resolve';
|
|
3
|
+
import commonjs from '@rollup/plugin-commonjs';
|
|
4
|
+
import typescript from '@rollup/plugin-typescript';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const config = [
|
|
8
|
+
{
|
|
9
|
+
|
|
10
|
+
input: 'stories/index.ts',
|
|
11
|
+
|
|
12
|
+
output: [
|
|
13
|
+
{
|
|
14
|
+
file: "lib/index.js",
|
|
15
|
+
format: 'cjs',
|
|
16
|
+
sourcemap: true
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
file: "lib/index.esm.js",
|
|
20
|
+
format: 'esm',
|
|
21
|
+
sourcemap: true
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
external: ["react", "react-dom"],
|
|
25
|
+
plugins: [
|
|
26
|
+
peerDepsExternal(),
|
|
27
|
+
resolve(),
|
|
28
|
+
commonjs(),
|
|
29
|
+
typescript({
|
|
30
|
+
tsconfig: "./tsconfig.lib.json",
|
|
31
|
+
})
|
|
32
|
+
]
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
input: "lib/esm/types/index.d.ts",
|
|
36
|
+
output: [{ file: "dist/index.d.ts", format: "esm" }],
|
|
37
|
+
plugins: [dts()],
|
|
38
|
+
external: ["react", "react-dom"],
|
|
39
|
+
},
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
export default config;
|
|
@@ -117,7 +117,7 @@ const Badge: React.FC<IBadgeProps> = ({
|
|
|
117
117
|
className: `${removeButton?.className || ""} group outline-0 `
|
|
118
118
|
}}
|
|
119
119
|
>
|
|
120
|
-
<DynamicIcon {...{ icon: "
|
|
120
|
+
<DynamicIcon {...{ icon: "IconX", className: removeButtonStyles }} />
|
|
121
121
|
</button>
|
|
122
122
|
)}
|
|
123
123
|
</div>
|
|
@@ -22,6 +22,16 @@ export const Alternative: Story = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
export const AlternativeDisabled: Story = {
|
|
26
|
+
args: {
|
|
27
|
+
actionType: "alternative",
|
|
28
|
+
label: "Button",
|
|
29
|
+
disabled: true,
|
|
30
|
+
onClick: () => {
|
|
31
|
+
window.alert("Button clicked!")
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
25
35
|
export const AlternativeTrailingIcon: Story = {
|
|
26
36
|
args: {
|
|
27
37
|
...Alternative.args,
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import Loader from "stories/atoms/loaders/Loader"
|
|
2
2
|
import { default as cn } from "classnames"
|
|
3
|
-
import { HTMLAttributeAnchorTarget } from "react"
|
|
3
|
+
import React, { HTMLAttributeAnchorTarget, forwardRef } from "react"
|
|
4
4
|
import { DynamicIcon, UnifiedIconName, IDynamicIconProps } from "../../icons"
|
|
5
5
|
|
|
6
6
|
// import Loader from "../loaders/loader/Loader"
|
|
7
7
|
|
|
8
8
|
export type BTNActionType = "primary" | "secondary" | "alternative" | "danger"
|
|
9
|
-
|
|
9
|
+
|
|
10
|
+
export interface IButtonProps
|
|
11
|
+
extends Omit<React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, "ref"> {
|
|
10
12
|
/** Is the button a Primary CTA, alternative or danger button? */
|
|
11
13
|
actionType?: BTNActionType
|
|
12
14
|
/** How lg should the button be? - Defaults to 'base'. */
|
|
@@ -31,30 +33,31 @@ export interface IButtonProps extends React.ComponentPropsWithoutRef<"button"> {
|
|
|
31
33
|
isLoading?: boolean
|
|
32
34
|
className?: string
|
|
33
35
|
iconObj?: React.ReactNode
|
|
34
|
-
ref?: React.LegacyRef<HTMLButtonElement>
|
|
35
36
|
}
|
|
36
37
|
/**
|
|
37
38
|
* Primary UI component for user interaction
|
|
38
39
|
*/
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}: IButtonProps
|
|
40
|
+
const _Button = (
|
|
41
|
+
{
|
|
42
|
+
actionType = "primary",
|
|
43
|
+
size = "sm",
|
|
44
|
+
label,
|
|
45
|
+
icon,
|
|
46
|
+
iconObj,
|
|
47
|
+
CustomSVGIcon,
|
|
48
|
+
fullWidth = false,
|
|
49
|
+
iconPosition = "leading",
|
|
50
|
+
asLink,
|
|
51
|
+
isLoading = false,
|
|
52
|
+
className,
|
|
53
|
+
...props
|
|
54
|
+
}: IButtonProps,
|
|
55
|
+
ref: React.LegacyRef<HTMLButtonElement>
|
|
56
|
+
) => {
|
|
54
57
|
const iconStyles = cn(
|
|
55
58
|
{ "text-white h-5 w-5": actionType === "primary" || actionType === "danger" },
|
|
56
59
|
{ "text-purple-700 h-5 w-5 ": actionType === "secondary" },
|
|
57
|
-
{ "text-gray-
|
|
60
|
+
{ "text-gray-400 h-5 w-5": actionType === "alternative" }
|
|
58
61
|
)
|
|
59
62
|
const loaderColors = cn(
|
|
60
63
|
{ "border-r-white": actionType === "primary" },
|
|
@@ -64,11 +67,91 @@ const Button = ({
|
|
|
64
67
|
)
|
|
65
68
|
const loaderSize = cn({ "h-4 w-4": size === "sm" }, { "h-5 w-5": size === "md" }, { "h-6 w-6 ": size === "lg" })
|
|
66
69
|
|
|
67
|
-
return (
|
|
70
|
+
return asLink ? (
|
|
71
|
+
//@ts-ignore
|
|
72
|
+
<a
|
|
73
|
+
{...{
|
|
74
|
+
href: asLink.href,
|
|
75
|
+
target: asLink.target,
|
|
76
|
+
title: asLink.title,
|
|
77
|
+
className: cn(
|
|
78
|
+
"inline-flex items-center justify-center gap-x-2 font-medium rounded-[3px] !ring-offset-white outline-none focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2 transition-all",
|
|
79
|
+
{ "w-full": fullWidth },
|
|
80
|
+
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
81
|
+
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
82
|
+
{ "px-[17px] py-[9px] text-sm": size === "md" },
|
|
83
|
+
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
84
|
+
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
85
|
+
{
|
|
86
|
+
"bg-violet-800 text-white hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0":
|
|
87
|
+
actionType === "primary"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
" bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0":
|
|
91
|
+
actionType === "secondary"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300 disabled:bg-gray-50 disabled:text-gray-300 disabled:focus-visible:ring-0":
|
|
95
|
+
actionType === "alternative"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 disabled:bg-red-400 disabled:text-gray-50 disabled:focus-visible:ring-0":
|
|
99
|
+
actionType === "danger"
|
|
100
|
+
},
|
|
101
|
+
className ? className : ""
|
|
102
|
+
),
|
|
103
|
+
onClick: props.onClick
|
|
104
|
+
}}
|
|
105
|
+
>
|
|
106
|
+
{" "}
|
|
107
|
+
{CustomSVGIcon &&
|
|
108
|
+
(isLoading ? (
|
|
109
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
110
|
+
) : (
|
|
111
|
+
<i>{CustomSVGIcon}</i>
|
|
112
|
+
))}
|
|
113
|
+
{iconObj &&
|
|
114
|
+
iconPosition === "leading" &&
|
|
115
|
+
(!isLoading ? (
|
|
116
|
+
<>{iconObj}</>
|
|
117
|
+
) : (
|
|
118
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
119
|
+
))}
|
|
120
|
+
{icon &&
|
|
121
|
+
iconPosition === "leading" &&
|
|
122
|
+
(isLoading ? (
|
|
123
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
124
|
+
) : typeof icon === "string" ? (
|
|
125
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
126
|
+
) : (
|
|
127
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
128
|
+
))}
|
|
129
|
+
{!icon && !CustomSVGIcon && isLoading && (
|
|
130
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
131
|
+
)}
|
|
132
|
+
{label}
|
|
133
|
+
{icon &&
|
|
134
|
+
iconPosition === "trailing" &&
|
|
135
|
+
(isLoading ? (
|
|
136
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
137
|
+
) : typeof icon === "string" ? (
|
|
138
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
139
|
+
) : (
|
|
140
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
141
|
+
))}
|
|
142
|
+
{iconObj &&
|
|
143
|
+
iconPosition === "trailing" &&
|
|
144
|
+
(!isLoading ? (
|
|
145
|
+
<>{iconObj}</>
|
|
146
|
+
) : (
|
|
147
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
148
|
+
))}
|
|
149
|
+
</a>
|
|
150
|
+
) : (
|
|
68
151
|
<button
|
|
69
152
|
type="button"
|
|
70
153
|
className={cn(
|
|
71
|
-
"inline-flex items-center justify-center gap-x-2 font-medium
|
|
154
|
+
"inline-flex items-center justify-center gap-x-2 font-medium rounded-[3px] !ring-offset-white outline-none focus-visible:ring-2 focus-visible:ring-purple-600 focus-visible:ring-offset-2 focus-within:ring-2 focus-within:ring-purple-600 focus-within:ring-offset-2 focus:ring-2 focus:ring-purple-600 focus:ring-offset-2 active:ring-2 active:ring-purple-600 active:ring-offset-2 transition-all",
|
|
72
155
|
{ "w-full": fullWidth },
|
|
73
156
|
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
74
157
|
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
@@ -76,18 +159,19 @@ const Button = ({
|
|
|
76
159
|
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
77
160
|
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
78
161
|
{
|
|
79
|
-
"bg-
|
|
162
|
+
"bg-violet-800 text-violet-100 hover:border-violet-700 hover:bg-violet-700 disabled:bg-violet-400 disabled:focus-visible:ring-0":
|
|
163
|
+
actionType === "primary"
|
|
80
164
|
},
|
|
81
165
|
{
|
|
82
|
-
" bg-purple-50 text-purple-700 hover:bg-purple-
|
|
166
|
+
" bg-purple-50 border-purple-400 border hover:border-purple-500 text-purple-700 hover:bg-purple-100 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100 disabled:bg-purple-50 disabled:text-purple-300 disabled:focus-visible:ring-0":
|
|
83
167
|
actionType === "secondary"
|
|
84
168
|
},
|
|
85
169
|
{
|
|
86
|
-
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300":
|
|
170
|
+
"border-gray-300 bg-white border text-gray-700 hover:bg-gray-50 focus-visible:!border-gray-300 focus-within:!border-gray-300 focus:!border-gray-300 active:!border-gray-300 disabled:bg-gray-50 disabled:text-gray-300 disabled:focus-visible:ring-0":
|
|
87
171
|
actionType === "alternative"
|
|
88
172
|
},
|
|
89
173
|
{
|
|
90
|
-
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 ":
|
|
174
|
+
" bg-red-600 text-white hover:bg-red-700 <focus-visible:!></focus-visible:!>ring-red-500 focus:!ring-red-500 active:!ring-red-500 focus-within:!ring-red-500 disabled:bg-red-400 disabled:text-gray-50 disabled:focus-visible:ring-0":
|
|
91
175
|
actionType === "danger"
|
|
92
176
|
},
|
|
93
177
|
className ? className : ""
|
|
@@ -143,4 +227,6 @@ const Button = ({
|
|
|
143
227
|
)
|
|
144
228
|
}
|
|
145
229
|
|
|
230
|
+
const Button = forwardRef<HTMLButtonElement, IButtonProps>(_Button)
|
|
231
|
+
|
|
146
232
|
export default Button
|
|
@@ -22,12 +22,24 @@ export const Danger: Story = {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
+
|
|
26
|
+
export const DangerDisabled: Story = {
|
|
27
|
+
args: {
|
|
28
|
+
actionType: "danger",
|
|
29
|
+
label: "Danger Zone!",
|
|
30
|
+
disabled: true,
|
|
31
|
+
onClick: () => {
|
|
32
|
+
window.alert("Button clicked!")
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
25
37
|
export const DangerTrailingIcon: Story = {
|
|
26
38
|
args: {
|
|
27
39
|
...Danger.args,
|
|
28
40
|
icon: {
|
|
29
41
|
...defaultIcon,
|
|
30
|
-
icon: "
|
|
42
|
+
icon: "IconTrash"
|
|
31
43
|
},
|
|
32
44
|
iconPosition: "trailing"
|
|
33
45
|
}
|
|
@@ -41,7 +53,7 @@ export const DangerLeadingIcon: Story = {
|
|
|
41
53
|
export const DangerSimpleIconName: Story = {
|
|
42
54
|
args: {
|
|
43
55
|
...Danger.args,
|
|
44
|
-
icon: "
|
|
56
|
+
icon: "IconTrash",
|
|
45
57
|
iconPosition: "leading"
|
|
46
58
|
}
|
|
47
59
|
}
|
|
@@ -28,12 +28,24 @@ export const Primary: Story = {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export const PrimaryDisabled: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
actionType: "primary",
|
|
35
|
+
label: "Button",
|
|
36
|
+
disabled: true,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
window.alert("Button clicked!")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
export const PrimaryLeadingIcon: Story = {
|
|
32
44
|
args: {
|
|
33
45
|
...Primary.args,
|
|
34
46
|
icon: {
|
|
35
47
|
...defaultIcon,
|
|
36
|
-
icon: "
|
|
48
|
+
icon: "IconCheck",
|
|
37
49
|
outline: false
|
|
38
50
|
},
|
|
39
51
|
iconPosition: "leading"
|
|
@@ -42,7 +54,7 @@ export const PrimaryLeadingIcon: Story = {
|
|
|
42
54
|
export const PrimarySimpleIconName: Story = {
|
|
43
55
|
args: {
|
|
44
56
|
...Primary.args,
|
|
45
|
-
icon: "
|
|
57
|
+
icon: "IconCheck",
|
|
46
58
|
iconPosition: "leading"
|
|
47
59
|
}
|
|
48
60
|
}
|
|
@@ -28,6 +28,18 @@ export const Secondary: Story = {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
}
|
|
31
|
+
|
|
32
|
+
export const SecondaryDisabled: Story = {
|
|
33
|
+
args: {
|
|
34
|
+
actionType: "secondary",
|
|
35
|
+
label: "Button",
|
|
36
|
+
disabled: true,
|
|
37
|
+
onClick: () => {
|
|
38
|
+
window.alert("Button clicked!")
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
export const SecondaryTrailingIcon: Story = {
|
|
32
44
|
args: {
|
|
33
45
|
...Secondary.args,
|
|
@@ -44,7 +56,7 @@ export const SecondaryLeadingIcon: Story = {
|
|
|
44
56
|
export const SecondarySimpleIconName: Story = {
|
|
45
57
|
args: {
|
|
46
58
|
...Secondary.args,
|
|
47
|
-
icon: "
|
|
59
|
+
icon: "IconBell",
|
|
48
60
|
iconPosition: "leading"
|
|
49
61
|
}
|
|
50
62
|
}
|
|
@@ -6,7 +6,8 @@ import { UnifiedIconName } from "../../icons/DynamicIcon"
|
|
|
6
6
|
/**
|
|
7
7
|
* Capsule Style Button
|
|
8
8
|
*/
|
|
9
|
-
export interface ICapsuleProps
|
|
9
|
+
export interface ICapsuleProps
|
|
10
|
+
extends React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement> {
|
|
10
11
|
/** Is the button a Primary CTA, alternative or danger button? */
|
|
11
12
|
actionType: BTNActionType
|
|
12
13
|
/** How lg should the button be? - Defaults to 'base'. */
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
// TODO: Fix heroicons support
|
|
2
|
+
// TODO: Fix heroicons support
|
|
3
3
|
import * as SolidIcons from "@heroicons/react/solid"
|
|
4
4
|
import * as OutlineIcons from "@heroicons/react/outline"
|
|
5
|
-
import * as TablerIconComponents from "@tabler/icons-react"
|
|
6
5
|
import * as FA from "react-icons/fa"
|
|
7
6
|
import { tablerIconNames, TablerIconName } from "./tablerIconNames"
|
|
8
7
|
import { default as cn } from "classnames"
|
|
9
8
|
|
|
10
|
-
import TablerIcon from "./TablerIcon"
|
|
11
9
|
import { ClassNameWithAutocomplete } from "@/utils/types"
|
|
10
|
+
import TablerIcon from "./TablerIcon"
|
|
12
11
|
|
|
13
12
|
export type IconName = keyof typeof SolidIcons | keyof typeof OutlineIcons
|
|
14
|
-
|
|
15
13
|
export type FAIconName = keyof typeof FA
|
|
16
14
|
|
|
17
|
-
export type UnifiedIconName =
|
|
15
|
+
export type UnifiedIconName = TablerIconName | IconName | FAIconName
|
|
18
16
|
|
|
19
17
|
export function isHeroIcon(name: UnifiedIconName): name is keyof typeof SolidIcons | keyof typeof OutlineIcons {
|
|
20
18
|
return name in SolidIcons || name in OutlineIcons
|
|
@@ -27,11 +25,12 @@ export function isTablerIcon(name: UnifiedIconName): name is TablerIconName {
|
|
|
27
25
|
export function isFAIcon(name: UnifiedIconName): name is keyof typeof FA {
|
|
28
26
|
return name in FA
|
|
29
27
|
}
|
|
28
|
+
|
|
30
29
|
export function isUnifiedIconName(name: UnifiedIconName): name is UnifiedIconName {
|
|
31
|
-
return isTablerIcon(name) || isFAIcon(name)
|
|
30
|
+
return isTablerIcon(name) // || isHeroIcon(name) || isFAIcon(name)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
export interface IDynamicIconProps extends React.
|
|
33
|
+
export interface IDynamicIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
35
34
|
icon: UnifiedIconName
|
|
36
35
|
className?: ClassNameWithAutocomplete
|
|
37
36
|
outline?: boolean
|
|
@@ -62,6 +61,7 @@ export const DynamicIcon = ({
|
|
|
62
61
|
/>
|
|
63
62
|
)
|
|
64
63
|
}
|
|
64
|
+
|
|
65
65
|
if (isFAIcon(icon)) {
|
|
66
66
|
const Icon = FA[icon]
|
|
67
67
|
return (
|
|
@@ -11,13 +11,13 @@ type Story = StoryObj<typeof IconWithShadow>
|
|
|
11
11
|
|
|
12
12
|
export const HeroIconSolid: Story = {
|
|
13
13
|
args: {
|
|
14
|
-
icon: "
|
|
14
|
+
icon: "IconCube",
|
|
15
15
|
outline: false
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
export const HeroIconOutline: Story = {
|
|
19
19
|
args: {
|
|
20
|
-
icon: "
|
|
20
|
+
icon: "IconCube",
|
|
21
21
|
outline: true
|
|
22
22
|
}
|
|
23
23
|
}
|
|
@@ -35,7 +35,7 @@ export const TablerIconOutline: Story = {
|
|
|
35
35
|
}
|
|
36
36
|
export const FAIcon: Story = {
|
|
37
37
|
args: {
|
|
38
|
-
icon: "
|
|
38
|
+
icon: "IconBrandGithub",
|
|
39
39
|
outline: true
|
|
40
40
|
}
|
|
41
41
|
}
|
|
@@ -3,7 +3,7 @@ import { TablerIconName } from "./tablerIconNames"
|
|
|
3
3
|
import * as TablerIcons from "@tabler/icons-react"
|
|
4
4
|
import { ClassNameWithAutocomplete } from "@/utils/types"
|
|
5
5
|
|
|
6
|
-
export interface ITablerIconProps extends React.
|
|
6
|
+
export interface ITablerIconProps extends React.DetailedHTMLProps<React.HTMLAttributes<HTMLElement>, HTMLElement> {
|
|
7
7
|
icon: TablerIconName
|
|
8
8
|
className?: ClassNameWithAutocomplete
|
|
9
9
|
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import React from "react"
|
|
2
|
-
import
|
|
2
|
+
import { default as cn } from "classnames"
|
|
3
3
|
|
|
4
4
|
export interface ILoaderProps {
|
|
5
5
|
className?: string
|
|
6
6
|
}
|
|
7
7
|
const Loader: React.FC<ILoaderProps> = ({ className }) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
return (
|
|
9
|
+
<>
|
|
10
|
+
<i
|
|
11
|
+
className={cn(
|
|
12
|
+
"rounded-full w-16 h-16 inline-block border-8 animate-spin m-auto",
|
|
13
|
+
className ? className : "border-purple-700 border-r-gray-200"
|
|
14
|
+
)}
|
|
15
|
+
role="status"
|
|
16
|
+
/>
|
|
17
|
+
</>
|
|
18
|
+
)
|
|
13
19
|
}
|
|
14
20
|
|
|
15
21
|
export default Loader
|
|
@@ -31,8 +31,6 @@ const RadialProgress: React.FC<IRadialProgressProps> = ({
|
|
|
31
31
|
}
|
|
32
32
|
const drawPercentage = useMemo(() => {
|
|
33
33
|
const roundCircum = Math.round(2 * r * Math.PI)
|
|
34
|
-
console.log(roundCircum, "circumference")
|
|
35
|
-
console.log(inputValue, "input value")
|
|
36
34
|
return (inputValue * roundCircum) / 50
|
|
37
35
|
}, [inputValue, r])
|
|
38
36
|
|