@agility/plenum-ui 2.0.0-rc4 → 2.0.0-rc41
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 +278 -89
- package/dist/index.js +1 -5980
- package/dist/index.js.map +4 -4
- package/dist/tailwind.css +63599 -0
- 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/InputCounter/InputCounter.d.ts +10 -0
- package/dist/types/stories/molecules/inputs/InputCounter/index.d.ts +2 -0
- package/dist/types/stories/molecules/inputs/InputField/InputField.d.ts +6 -4
- package/dist/types/stories/molecules/inputs/TextInput/TextInput.d.ts +39 -0
- package/dist/types/stories/molecules/inputs/TextInput/index.d.ts +4 -0
- package/dist/types/stories/molecules/inputs/index.d.ts +5 -4
- package/dist/types/stories/molecules/inputs/select/Select.d.ts +2 -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 +3 -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/DropdownComponent/DropdownComponent.d.ts +21 -12
- 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 +36 -19
- package/rollup.config.mjs +42 -0
- package/stories/Introduction.mdx +1 -1
- 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 +108 -24
- 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/index.ts +22 -10
- package/stories/molecules/index.ts +22 -6
- package/stories/molecules/inputs/InputField/InputField.tsx +10 -9
- package/stories/molecules/inputs/TextInput/TextInput.tsx +6 -3
- package/stories/molecules/inputs/TextInput/index.tsx +4 -2
- package/stories/molecules/inputs/checkbox/Checkbox.tsx +1 -2
- package/stories/molecules/inputs/combobox/ComboBox.tsx +126 -135
- package/stories/molecules/inputs/index.ts +18 -4
- package/stories/molecules/inputs/select/Select.tsx +1 -1
- 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.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 +43 -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 +26 -21
- package/stories/organisms/DropdownComponent/Dropdown.stories.tsx +2 -2
- package/stories/organisms/DropdownComponent/DropdownComponent.tsx +213 -178
- 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/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/local.sh
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#! /usr/bin/bash
|
|
2
|
+
|
|
3
|
+
# ANSI escape codes for formatting
|
|
4
|
+
GREEN_BOLD='\033[1;32m'
|
|
5
|
+
ORANGE_BOLD='\033[1;33m'
|
|
6
|
+
RED_BOLD='\033[1;31m'
|
|
7
|
+
BLUE_BOLD='\033[1;34m'
|
|
8
|
+
RESET='\033[0m'
|
|
9
|
+
DIR="$PWD"
|
|
10
|
+
|
|
11
|
+
# The required yarn version to use this script
|
|
12
|
+
REQUIRED_YARN_VERSION="1.22.19"
|
|
13
|
+
|
|
14
|
+
# Get the installed Yarn version
|
|
15
|
+
INSTALLED_YARN_VERSION=$(yarn --version 2>/dev/null)
|
|
16
|
+
|
|
17
|
+
unlink_package() {
|
|
18
|
+
local package_name="${1:-@agility/plenum-ui}"
|
|
19
|
+
if [ -z "$1" ]; then
|
|
20
|
+
yarn unlink
|
|
21
|
+
else
|
|
22
|
+
cd "$DIR/node_modules/$package_name"
|
|
23
|
+
yarn unlink
|
|
24
|
+
fi
|
|
25
|
+
unlink_exit_code=$?
|
|
26
|
+
if [ $unlink_exit_code -ne 0 ]; then
|
|
27
|
+
echo -e "${ORANGE_BOLD}agility-cms-manager-app-react:warning${RESET} yarn unlink for '$package_name' encountered an error, but script will continue. \n"
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
cd "$DIR"
|
|
31
|
+
echo -e "\n"
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
link_package() {
|
|
35
|
+
local package_name="${1:-@agility/plenum-ui}"
|
|
36
|
+
if [ -z "$1" ]; then
|
|
37
|
+
yarn link
|
|
38
|
+
else
|
|
39
|
+
cd "$DIR/node_modules/$package_name"
|
|
40
|
+
yarn link
|
|
41
|
+
fi
|
|
42
|
+
unlink_exit_code=$?
|
|
43
|
+
if [ $unlink_exit_code -ne 0 ]; then
|
|
44
|
+
echo -e "${RED_BOLD}agility-cms-manager-app-react:error${RESET} yarn link for '$package_name' failed. Script cannot continue, exiting script."
|
|
45
|
+
exit 1
|
|
46
|
+
else
|
|
47
|
+
echo -e "${GREEN_BOLD}@agility/plenum-ui:success${RESET} yarn link for '$package_name' successful\n"
|
|
48
|
+
fi
|
|
49
|
+
|
|
50
|
+
cd "$DIR"
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
check_yarn_version() {
|
|
54
|
+
# Check if Yarn is installed and compare the version
|
|
55
|
+
if [ -n "$INSTALLED_YARN_VERSION" ] && [ "$INSTALLED_YARN_VERSION" != "$REQUIRED_YARN_VERSION" ]; then
|
|
56
|
+
echo -e "${RED_BOLD}error${RESET} Yarn version $required_version is required, but found version $INSTALLED_YARN_VERSION."
|
|
57
|
+
exit 1
|
|
58
|
+
fi
|
|
59
|
+
|
|
60
|
+
echo -e "${BLUE_BOLD}info${RESET} Yarn version is $INSTALLED_YARN_VERSION. Proceeding with the script...\n"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
### START SCRIPT
|
|
64
|
+
|
|
65
|
+
check_yarn_version
|
|
66
|
+
|
|
67
|
+
echo -e "Starting @agility/plenum-ui local watch script \n"
|
|
68
|
+
echo -e "${BLUE_BOLD}@agility/plenum-ui:info${RESET} unlinking existing symlink"
|
|
69
|
+
yarn unlink
|
|
70
|
+
if [ $? -ne 0 ]; then
|
|
71
|
+
echo "yarn unlink for @agility/plenum-ui encountered an error, but script will continue. \n"
|
|
72
|
+
fi
|
|
73
|
+
|
|
74
|
+
if [ ! -d "node_modules" ] || [ ! -d "node_modules/react" ] || [ ! -d "node_modules/react-dom" ]; then
|
|
75
|
+
echo -e "${ORANGE_BOLD}@agility/plenum-ui:warning${RESET} Could not find node_modules."
|
|
76
|
+
echo -e "${BLUE_BOLD}@agility/plenum-ui:info${RESET} installing dependencies...\n"
|
|
77
|
+
|
|
78
|
+
yarn install
|
|
79
|
+
|
|
80
|
+
if [ $? -eq 0 ]; then
|
|
81
|
+
echo -e "${GREEN_BOLD}@agility/plenum-ui:success${RESET} Finished installing dependencies"
|
|
82
|
+
else
|
|
83
|
+
echo -e "${RED_BOLD}@agility/plenum-ui:error${RESET} Couldn't install dependencies. Exiting script."
|
|
84
|
+
exit 1
|
|
85
|
+
fi
|
|
86
|
+
fi
|
|
87
|
+
|
|
88
|
+
echo -e "${BLUE_BOLD}@agility/plenum-ui:info${RESET} unlinking existing symlinks"
|
|
89
|
+
unlink_package react
|
|
90
|
+
unlink_package react-dom
|
|
91
|
+
unlink_package
|
|
92
|
+
|
|
93
|
+
echo -e "${BLUE_BOLD}@agility/plenum-ui:info${RESET} setting up symlinks...\n"
|
|
94
|
+
|
|
95
|
+
link_package react
|
|
96
|
+
link_package react-dom
|
|
97
|
+
link_package
|
|
98
|
+
|
|
99
|
+
echo -e "${GREEN_BOLD}@agility/plenum-ui:success${RESET} You can now run 'yarn start-cms:local' in agility-cms-manager-app-react\n"
|
|
100
|
+
yarn start:watch
|
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-rc41",
|
|
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 ./
|
|
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;
|
package/stories/Introduction.mdx
CHANGED
|
@@ -143,7 +143,7 @@ In your app entry point (i.e. \`_app.tsx\`), import the \`globals.css\` file fro
|
|
|
143
143
|
|
|
144
144
|
```jsx
|
|
145
145
|
import "<RELATIVE_PATH>/globals.css";
|
|
146
|
-
import "@agility/plenum-ui/lib/tailwind.css";
|
|
146
|
+
import "@agility/plenum-ui/dist/lib/tailwind.css";
|
|
147
147
|
```
|
|
148
148
|
|
|
149
149
|
Make sure to add any additional styles before these two import statements to prevent overwriting the Plenum styling.
|
|
@@ -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,26 +33,27 @@ 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" },
|
|
@@ -64,11 +67,89 @@ 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
|
+
<a
|
|
72
|
+
{...{
|
|
73
|
+
href: asLink.href,
|
|
74
|
+
target: asLink.target,
|
|
75
|
+
title: asLink.title,
|
|
76
|
+
className: cn(
|
|
77
|
+
"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",
|
|
78
|
+
{ "w-full": fullWidth },
|
|
79
|
+
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
80
|
+
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
81
|
+
{ "px-[17px] py-[9px] text-sm": size === "md" },
|
|
82
|
+
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
83
|
+
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
84
|
+
{
|
|
85
|
+
"bg-purple-600 text-white hover:border-purple-700 hover:bg-purple-700 disabled:bg-purple-400 disabled:focus-visible:ring-0":
|
|
86
|
+
actionType === "primary"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
" bg-purple-50 text-purple-700 hover:bg-purple-200 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":
|
|
90
|
+
actionType === "secondary"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"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":
|
|
94
|
+
actionType === "alternative"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
" 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":
|
|
98
|
+
actionType === "danger"
|
|
99
|
+
},
|
|
100
|
+
className ? className : ""
|
|
101
|
+
)
|
|
102
|
+
}}
|
|
103
|
+
>
|
|
104
|
+
{" "}
|
|
105
|
+
{CustomSVGIcon &&
|
|
106
|
+
(isLoading ? (
|
|
107
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
108
|
+
) : (
|
|
109
|
+
<i>{CustomSVGIcon}</i>
|
|
110
|
+
))}
|
|
111
|
+
{iconObj &&
|
|
112
|
+
iconPosition === "leading" &&
|
|
113
|
+
(!isLoading ? (
|
|
114
|
+
<>{iconObj}</>
|
|
115
|
+
) : (
|
|
116
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
117
|
+
))}
|
|
118
|
+
{icon &&
|
|
119
|
+
iconPosition === "leading" &&
|
|
120
|
+
(isLoading ? (
|
|
121
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
122
|
+
) : typeof icon === "string" ? (
|
|
123
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
124
|
+
) : (
|
|
125
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
126
|
+
))}
|
|
127
|
+
{!icon && !CustomSVGIcon && isLoading && (
|
|
128
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
129
|
+
)}
|
|
130
|
+
{label}
|
|
131
|
+
{icon &&
|
|
132
|
+
iconPosition === "trailing" &&
|
|
133
|
+
(isLoading ? (
|
|
134
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
135
|
+
) : typeof icon === "string" ? (
|
|
136
|
+
<DynamicIcon {...{ icon: icon, className: iconStyles }} />
|
|
137
|
+
) : (
|
|
138
|
+
<DynamicIcon {...{ ...icon, className: iconStyles }} />
|
|
139
|
+
))}
|
|
140
|
+
{iconObj &&
|
|
141
|
+
iconPosition === "trailing" &&
|
|
142
|
+
(!isLoading ? (
|
|
143
|
+
<>{iconObj}</>
|
|
144
|
+
) : (
|
|
145
|
+
<div className={cn("h-4 rounded-full w-4 border-2 m-0 animate-spin", loaderColors, loaderSize)} />
|
|
146
|
+
))}
|
|
147
|
+
</a>
|
|
148
|
+
) : (
|
|
68
149
|
<button
|
|
69
150
|
type="button"
|
|
70
151
|
className={cn(
|
|
71
|
-
"inline-flex items-center justify-center gap-x-2 font-medium
|
|
152
|
+
"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
153
|
{ "w-full": fullWidth },
|
|
73
154
|
{ "px-[11px] py-[7px] text-xs": size === "xs" },
|
|
74
155
|
{ "px-[13px] py-[9px] text-sm": size === "sm" },
|
|
@@ -76,18 +157,19 @@ const Button = ({
|
|
|
76
157
|
{ "px-[17px] py-[9px] text-base": size === "lg" },
|
|
77
158
|
{ "px-[25px] py-[13px] text-base": size === "xl" },
|
|
78
159
|
{
|
|
79
|
-
"bg-purple-600 text-white hover:border-purple-700 hover:bg-purple-700
|
|
160
|
+
"bg-purple-600 text-white hover:border-purple-700 hover:bg-purple-700 disabled:bg-purple-400 disabled:focus-visible:ring-0":
|
|
161
|
+
actionType === "primary"
|
|
80
162
|
},
|
|
81
163
|
{
|
|
82
|
-
" bg-purple-50 text-purple-700 hover:bg-purple-200 focus-within:bg-purple-100 focus-visible:bg-purple-100 focus:bg-purple-100 active:bg-purple-100":
|
|
164
|
+
" bg-purple-50 text-purple-700 hover:bg-purple-200 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
165
|
actionType === "secondary"
|
|
84
166
|
},
|
|
85
167
|
{
|
|
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":
|
|
168
|
+
"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
169
|
actionType === "alternative"
|
|
88
170
|
},
|
|
89
171
|
{
|
|
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 ":
|
|
172
|
+
" 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
173
|
actionType === "danger"
|
|
92
174
|
},
|
|
93
175
|
className ? className : ""
|
|
@@ -143,4 +225,6 @@ const Button = ({
|
|
|
143
225
|
)
|
|
144
226
|
}
|
|
145
227
|
|
|
228
|
+
const Button = forwardRef<HTMLButtonElement, IButtonProps>(_Button)
|
|
229
|
+
|
|
146
230
|
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
|
}
|