@iota/apps-ui-kit 0.0.0-experimental-20250613144451
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/CHANGELOG.md +106 -0
- package/LICENSE +201 -0
- package/README.md +16 -0
- package/dist/index.d.ts +1726 -0
- package/dist/index.es.js +6923 -0
- package/dist/index.es.js.map +1 -0
- package/dist/index.umd.js +118 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/style.css +1 -0
- package/package.json +75 -0
- package/src/lib/components/atoms/badge/Badge.tsx +37 -0
- package/src/lib/components/atoms/badge/badge.classes.ts +33 -0
- package/src/lib/components/atoms/badge/badge.enums.ts +11 -0
- package/src/lib/components/atoms/badge/index.ts +6 -0
- package/src/lib/components/atoms/button/Button.tsx +99 -0
- package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
- package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
- package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
- package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
- package/src/lib/components/atoms/button/button.classes.ts +53 -0
- package/src/lib/components/atoms/button/button.enums.ts +21 -0
- package/src/lib/components/atoms/button/index.ts +7 -0
- package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +98 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +45 -0
- package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
- package/src/lib/components/atoms/button-segment/index.ts +5 -0
- package/src/lib/components/atoms/checkbox/Checkbox.tsx +114 -0
- package/src/lib/components/atoms/checkbox/index.ts +4 -0
- package/src/lib/components/atoms/divider/Divider.tsx +48 -0
- package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
- package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
- package/src/lib/components/atoms/divider/index.ts +6 -0
- package/src/lib/components/atoms/header/Header.tsx +73 -0
- package/src/lib/components/atoms/header/index.ts +4 -0
- package/src/lib/components/atoms/index.ts +23 -0
- package/src/lib/components/atoms/info-box/InfoBox.tsx +74 -0
- package/src/lib/components/atoms/info-box/index.ts +5 -0
- package/src/lib/components/atoms/info-box/infoBox.classes.ts +19 -0
- package/src/lib/components/atoms/info-box/infoBox.enums.ts +14 -0
- package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +157 -0
- package/src/lib/components/atoms/key-value-info/index.ts +6 -0
- package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
- package/src/lib/components/atoms/label-text/LabelText.tsx +94 -0
- package/src/lib/components/atoms/label-text/index.ts +5 -0
- package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
- package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
- package/src/lib/components/atoms/list-item/ListItem.tsx +89 -0
- package/src/lib/components/atoms/list-item/index.ts +4 -0
- package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
- package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
- package/src/lib/components/atoms/panel/Panel.tsx +30 -0
- package/src/lib/components/atoms/panel/index.ts +4 -0
- package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
- package/src/lib/components/atoms/placeholder/index.ts +4 -0
- package/src/lib/components/atoms/radio-button/RadioButton.tsx +68 -0
- package/src/lib/components/atoms/radio-button/index.ts +4 -0
- package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
- package/src/lib/components/atoms/secondary-text/index.ts +4 -0
- package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -0
- package/src/lib/components/atoms/skeleton/index.ts +4 -0
- package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
- package/src/lib/components/atoms/snackbar/index.ts +5 -0
- package/src/lib/components/atoms/snackbar/snackbar.classes.ts +18 -0
- package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +9 -0
- package/src/lib/components/atoms/toggle/Toggle.tsx +140 -0
- package/src/lib/components/atoms/toggle/index.ts +6 -0
- package/src/lib/components/atoms/toggle/toggle.classes.ts +41 -0
- package/src/lib/components/atoms/toggle/toggle.enums.ts +12 -0
- package/src/lib/components/atoms/tooltip/Tooltip.tsx +138 -0
- package/src/lib/components/atoms/tooltip/index.ts +5 -0
- package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
- package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
- package/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx +101 -0
- package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
- package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
- package/src/lib/components/index.ts +8 -0
- package/src/lib/components/molecules/account/Account.tsx +192 -0
- package/src/lib/components/molecules/account/index.ts +4 -0
- package/src/lib/components/molecules/address/Address.tsx +101 -0
- package/src/lib/components/molecules/address/index.ts +4 -0
- package/src/lib/components/molecules/card/Card.tsx +70 -0
- package/src/lib/components/molecules/card/CardAction.tsx +80 -0
- package/src/lib/components/molecules/card/CardBody.tsx +72 -0
- package/src/lib/components/molecules/card/CardImage.tsx +43 -0
- package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
- package/src/lib/components/molecules/card/card.classes.ts +27 -0
- package/src/lib/components/molecules/card/card.enums.ts +26 -0
- package/src/lib/components/molecules/card/index.ts +8 -0
- package/src/lib/components/molecules/chip/Chip.tsx +105 -0
- package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
- package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
- package/src/lib/components/molecules/chip/index.ts +4 -0
- package/src/lib/components/molecules/display-stats/DisplayStats.tsx +142 -0
- package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
- package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
- package/src/lib/components/molecules/display-stats/index.ts +5 -0
- package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
- package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
- package/src/lib/components/molecules/dropdown/index.ts +5 -0
- package/src/lib/components/molecules/index.ts +17 -0
- package/src/lib/components/molecules/input/Input.tsx +246 -0
- package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
- package/src/lib/components/molecules/input/TextArea.tsx +150 -0
- package/src/lib/components/molecules/input/index.ts +8 -0
- package/src/lib/components/molecules/input/input.classes.ts +14 -0
- package/src/lib/components/molecules/input/input.enums.ts +14 -0
- package/src/lib/components/molecules/input/input.types.ts +29 -0
- package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +48 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
- package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
- package/src/lib/components/molecules/navbar-item/index.ts +5 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
- package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
- package/src/lib/components/molecules/search/Search.tsx +216 -0
- package/src/lib/components/molecules/search/index.ts +5 -0
- package/src/lib/components/molecules/search/search.classes.ts +20 -0
- package/src/lib/components/molecules/search/search.enums.ts +7 -0
- package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +38 -0
- package/src/lib/components/molecules/segmented-button/index.ts +6 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
- package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
- package/src/lib/components/molecules/select/Select.tsx +222 -0
- package/src/lib/components/molecules/select/index.ts +5 -0
- package/src/lib/components/molecules/select/select.enums.ts +7 -0
- package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
- package/src/lib/components/molecules/table-cell/index.ts +4 -0
- package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +140 -0
- package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
- package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
- package/src/lib/components/molecules/title/Title.tsx +78 -0
- package/src/lib/components/molecules/title/index.ts +5 -0
- package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
- package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
- package/src/lib/components/organisms/accordion/Accordion.tsx +109 -0
- package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
- package/src/lib/components/organisms/accordion/index.ts +4 -0
- package/src/lib/components/organisms/dialog/Dialog.tsx +142 -0
- package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
- package/src/lib/components/organisms/dialog/index.ts +5 -0
- package/src/lib/components/organisms/index.ts +7 -0
- package/src/lib/components/organisms/navbar/Navbar.tsx +101 -0
- package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +59 -0
- package/src/lib/components/organisms/navbar/index.ts +5 -0
- package/src/lib/components/organisms/table/Table.tsx +234 -0
- package/src/lib/components/organisms/table/TableContext.tsx +56 -0
- package/src/lib/components/organisms/table/index.ts +4 -0
- package/src/lib/constants/colors.constants.ts +133 -0
- package/src/lib/constants/index.ts +4 -0
- package/src/lib/enums/index.ts +4 -0
- package/src/lib/enums/screenSize.enums.ts +9 -0
- package/src/lib/index.ts +8 -0
- package/src/lib/styles/fonts.css +5 -0
- package/src/lib/styles/index.css +149 -0
- package/src/lib/tailwind/base.presets.ts +49 -0
- package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
- package/src/lib/tailwind/constants/index.ts +6 -0
- package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
- package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
- package/src/lib/tailwind/helpers.ts +20 -0
- package/src/lib/tailwind/index.ts +5 -0
- package/src/lib/tailwind/plugins.ts +8 -0
- package/src/lib/tailwind/responsive.presets.ts +36 -0
- package/src/lib/tailwind/static.presets.ts +25 -0
- package/src/lib/tailwind/types.ts +6 -0
- package/src/lib/utils/format.ts +8 -0
- package/src/lib/utils/index.ts +4 -0
- package/src/storybook/blocks/Showcase.tsx +20 -0
- package/src/storybook/blocks/TypeSet.tsx +34 -0
- package/src/storybook/blocks/TypeSetItem.tsx +74 -0
- package/src/storybook/blocks/index.ts +6 -0
- package/src/storybook/constants/index.ts +5 -0
- package/src/storybook/constants/typeset.constants.ts +39 -0
- package/src/storybook/constants/variableSpacing.constants.ts +6 -0
- package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
- package/src/storybook/helpers/index.ts +4 -0
- package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
- package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
- package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
- package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
- package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
- package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
- package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
- package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
- package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
- package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
- package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
- package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
- package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
- package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
- package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
- package/src/storybook/stories/atoms/Snackbar.stories.tsx +43 -0
- package/src/storybook/stories/atoms/Toggle.stories.tsx +59 -0
- package/src/storybook/stories/atoms/Tooltip.stories.tsx +57 -0
- package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
- package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
- package/src/storybook/stories/components/index.ts +4 -0
- package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
- package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
- package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
- package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
- package/src/storybook/stories/molecules/Account.stories.tsx +69 -0
- package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
- package/src/storybook/stories/molecules/Card.stories.tsx +112 -0
- package/src/storybook/stories/molecules/Chip.stories.tsx +122 -0
- package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
- package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
- package/src/storybook/stories/molecules/Input.stories.tsx +162 -0
- package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
- package/src/storybook/stories/molecules/Search.stories.tsx +101 -0
- package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +108 -0
- package/src/storybook/stories/molecules/Select.stories.tsx +103 -0
- package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
- package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
- package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
- package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
- package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
- package/src/storybook/stories/organisms/Dialog.stories.tsx +103 -0
- package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
- package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
package/package.json
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@iota/apps-ui-kit",
|
|
3
|
+
"version": "0.0.0-experimental-20250613144451",
|
|
4
|
+
"repository": {
|
|
5
|
+
"type": "git",
|
|
6
|
+
"url": "github.com:iotaledger/iota.git"
|
|
7
|
+
},
|
|
8
|
+
"license": "Apache-2.0",
|
|
9
|
+
"files": [
|
|
10
|
+
"CHANGELOG.md",
|
|
11
|
+
"LICENSE",
|
|
12
|
+
"src",
|
|
13
|
+
"dist"
|
|
14
|
+
],
|
|
15
|
+
"exports": {
|
|
16
|
+
".": {
|
|
17
|
+
"import": "./dist/index.es.js",
|
|
18
|
+
"require": "./dist/index.umd.js",
|
|
19
|
+
"types": "./dist/index.d.ts"
|
|
20
|
+
},
|
|
21
|
+
"./styles": "./dist/style.css"
|
|
22
|
+
},
|
|
23
|
+
"types": "./dist/index.d.ts",
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@fontsource/inter": "^5.0.17",
|
|
26
|
+
"@radix-ui/react-dialog": "^1.1.1",
|
|
27
|
+
"@radix-ui/react-visually-hidden": "^1.1.0",
|
|
28
|
+
"classnames": "^2.5.1",
|
|
29
|
+
"lodash.merge": "^4.6.2",
|
|
30
|
+
"react-number-format": "^5.2.2",
|
|
31
|
+
"@iota/apps-ui-icons": "0.0.0-experimental-20250613144451"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"react": "*"
|
|
35
|
+
},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"react": "^18.3.1",
|
|
38
|
+
"@chromatic-com/storybook": "^1.6.0",
|
|
39
|
+
"@storybook/addon-essentials": "^7.1.0",
|
|
40
|
+
"@storybook/addon-interactions": "^7.1.0",
|
|
41
|
+
"@storybook/addon-links": "^7.1.0",
|
|
42
|
+
"@storybook/blocks": "^7.1.0",
|
|
43
|
+
"@storybook/react": "^7.1.0",
|
|
44
|
+
"@storybook/react-vite": "^7.1.0",
|
|
45
|
+
"@types/lodash.merge": "^4.6.9",
|
|
46
|
+
"@types/node": "^20.14.10",
|
|
47
|
+
"@types/react": "^18.3.3",
|
|
48
|
+
"@types/react-dom": "^18.3.0",
|
|
49
|
+
"@vitejs/plugin-react-swc": "^3.3.2",
|
|
50
|
+
"autoprefixer": "^10.4.19",
|
|
51
|
+
"cross-env": "^7.0.3",
|
|
52
|
+
"memfs": "^4.11.1",
|
|
53
|
+
"postcss": "^8.4.31",
|
|
54
|
+
"storybook": "^7.1.0",
|
|
55
|
+
"storybook-dark-mode": "^4.0.2",
|
|
56
|
+
"tailwindcss": "^3.3.3",
|
|
57
|
+
"typescript": "^5.5.3",
|
|
58
|
+
"vite": "^5.4.12",
|
|
59
|
+
"vite-plugin-dts": "^4.3.0",
|
|
60
|
+
"vite-tsconfig-paths": "^4.2.0"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"prettier:check": "prettier -c --ignore-unknown --ignore-path=../../.prettierignore --ignore-path=.prettierignore .",
|
|
64
|
+
"prettier:fix": "prettier -w --ignore-unknown --ignore-path=../../.prettierignore --ignore-path=.prettierignore .",
|
|
65
|
+
"eslint:check": "eslint --max-warnings=0 .",
|
|
66
|
+
"eslint:fix": "pnpm run eslint:check --fix",
|
|
67
|
+
"lint": "pnpm run eslint:check && pnpm run prettier:check",
|
|
68
|
+
"lint:fix": "pnpm run eslint:fix && pnpm run prettier:fix",
|
|
69
|
+
"storybook": "storybook dev -p 6006",
|
|
70
|
+
"build-storybook": "storybook build",
|
|
71
|
+
"build-package": "tsc --project tsconfig.package.json && vite build",
|
|
72
|
+
"build": "cross-env BUILD_ENV=package pnpm run build-package",
|
|
73
|
+
"dev": "pnpm run storybook"
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import cx from 'classnames';
|
|
5
|
+
import type { BadgeType } from './badge.enums';
|
|
6
|
+
import { BACKGROUND_COLORS, BADGE_TEXT_CLASS, BORDER_COLORS, TEXT_COLORS } from './badge.classes';
|
|
7
|
+
|
|
8
|
+
interface BadgeProps {
|
|
9
|
+
/**
|
|
10
|
+
* The type of the badge.
|
|
11
|
+
*/
|
|
12
|
+
type: BadgeType;
|
|
13
|
+
/**
|
|
14
|
+
* The label of the badge.
|
|
15
|
+
*/
|
|
16
|
+
label?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function Badge({ type, label }: BadgeProps): React.JSX.Element {
|
|
20
|
+
const backgroundClasses = BACKGROUND_COLORS[type];
|
|
21
|
+
const textClasses = TEXT_COLORS[type];
|
|
22
|
+
const borderClasses = BORDER_COLORS[type];
|
|
23
|
+
const labelClasses = label ? 'px-xs py-xxs' : 'h-1.5 w-1.5';
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<div
|
|
27
|
+
className={cx(
|
|
28
|
+
'inline-flex items-center space-x-2 rounded-full border disabled:opacity-30',
|
|
29
|
+
backgroundClasses,
|
|
30
|
+
borderClasses,
|
|
31
|
+
labelClasses,
|
|
32
|
+
)}
|
|
33
|
+
>
|
|
34
|
+
<span className={cx(BADGE_TEXT_CLASS, textClasses)}>{label}</span>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { BadgeType } from './badge.enums';
|
|
5
|
+
|
|
6
|
+
export const BACKGROUND_COLORS = {
|
|
7
|
+
[BadgeType.PrimarySolid]: 'bg-primary-30',
|
|
8
|
+
[BadgeType.Neutral]: 'bg-neutral-92 dark:bg-neutral-12',
|
|
9
|
+
[BadgeType.PrimarySoft]: 'bg-primary-90 dark:bg-primary-10',
|
|
10
|
+
[BadgeType.Success]: 'bg-tertiary-90 dark:bg-tertiary-10',
|
|
11
|
+
[BadgeType.Warning]: 'bg-warning-90 dark:bg-warning-20',
|
|
12
|
+
[BadgeType.Error]: 'bg-error-90 dark:bg-error-10',
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export const TEXT_COLORS: Record<BadgeType, string> = {
|
|
16
|
+
[BadgeType.PrimarySolid]: 'text-primary-100',
|
|
17
|
+
[BadgeType.Neutral]: 'text-neutral-10 dark:text-neutral-92',
|
|
18
|
+
[BadgeType.PrimarySoft]: 'text-primary-20 dark:text-primary-90',
|
|
19
|
+
[BadgeType.Success]: 'text-tertiary-20 dark:text-tertiary-90',
|
|
20
|
+
[BadgeType.Warning]: 'text-warning-10 dark:text-warning-90',
|
|
21
|
+
[BadgeType.Error]: 'text-error-20 dark:text-error-90',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const BORDER_COLORS: Record<BadgeType, string> = {
|
|
25
|
+
[BadgeType.PrimarySolid]: 'border-primary-30',
|
|
26
|
+
[BadgeType.Neutral]: 'border-neutral-92 dark:border-neutral-12',
|
|
27
|
+
[BadgeType.PrimarySoft]: 'border-primary-90 dark:border-primary-10',
|
|
28
|
+
[BadgeType.Success]: 'border-tertiary-90 dark:border-tertiary-10',
|
|
29
|
+
[BadgeType.Warning]: 'border-warning-90 dark:border-warning-20',
|
|
30
|
+
[BadgeType.Error]: 'border-error-90 dark:border-error-10',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export const BADGE_TEXT_CLASS = 'text-label-md';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum BadgeType {
|
|
5
|
+
Neutral = 'neutral',
|
|
6
|
+
PrimarySolid = 'primary-solid',
|
|
7
|
+
PrimarySoft = 'primary-fill',
|
|
8
|
+
Success = 'success',
|
|
9
|
+
Warning = 'warning',
|
|
10
|
+
Error = 'error',
|
|
11
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType, ButtonSize, ButtonType } from './button.enums';
|
|
5
|
+
import {
|
|
6
|
+
PADDINGS,
|
|
7
|
+
PADDINGS_ONLY_ICON,
|
|
8
|
+
BACKGROUND_COLORS,
|
|
9
|
+
TEXT_COLORS,
|
|
10
|
+
TEXT_CLASSES,
|
|
11
|
+
TEXT_COLOR_DISABLED,
|
|
12
|
+
DISABLED_BACKGROUND_COLORS,
|
|
13
|
+
} from './button.classes';
|
|
14
|
+
import cx from 'classnames';
|
|
15
|
+
|
|
16
|
+
export interface ButtonProps {
|
|
17
|
+
/**
|
|
18
|
+
* The size of the button.
|
|
19
|
+
*/
|
|
20
|
+
size?: ButtonSize;
|
|
21
|
+
/**
|
|
22
|
+
* The type of the button
|
|
23
|
+
*/
|
|
24
|
+
type?: ButtonType;
|
|
25
|
+
/**
|
|
26
|
+
* The text of the button.
|
|
27
|
+
*/
|
|
28
|
+
text?: string;
|
|
29
|
+
/**
|
|
30
|
+
The icon of the button
|
|
31
|
+
*/
|
|
32
|
+
icon?: React.ReactNode;
|
|
33
|
+
/**
|
|
34
|
+
* Should the icon be after the text.
|
|
35
|
+
*/
|
|
36
|
+
iconAfterText?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The button is disabled or not.
|
|
39
|
+
*/
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* The onClick event of the button.
|
|
43
|
+
*/
|
|
44
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Whether the button should have the full width.
|
|
47
|
+
*/
|
|
48
|
+
fullWidth?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* The type of the button. Available options are 'button', 'submit', 'reset'.
|
|
51
|
+
*/
|
|
52
|
+
htmlType?: ButtonHtmlType;
|
|
53
|
+
/**
|
|
54
|
+
* The tab index of the button.
|
|
55
|
+
*/
|
|
56
|
+
tabIndex?: number;
|
|
57
|
+
/**
|
|
58
|
+
* The 'data-testid' attribute value (used in e2e tests)
|
|
59
|
+
*/
|
|
60
|
+
testId?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function Button({
|
|
64
|
+
icon,
|
|
65
|
+
text,
|
|
66
|
+
disabled,
|
|
67
|
+
onClick,
|
|
68
|
+
fullWidth,
|
|
69
|
+
htmlType = ButtonHtmlType.Button,
|
|
70
|
+
size = ButtonSize.Medium,
|
|
71
|
+
type = ButtonType.Primary,
|
|
72
|
+
iconAfterText = false,
|
|
73
|
+
tabIndex = 0,
|
|
74
|
+
testId,
|
|
75
|
+
}: ButtonProps): React.JSX.Element {
|
|
76
|
+
const paddingClasses = icon && !text ? PADDINGS_ONLY_ICON[size] : PADDINGS[size];
|
|
77
|
+
const textSizes = TEXT_CLASSES[size];
|
|
78
|
+
const backgroundColors = disabled ? DISABLED_BACKGROUND_COLORS[type] : BACKGROUND_COLORS[type];
|
|
79
|
+
const textColors = disabled ? TEXT_COLOR_DISABLED[type] : TEXT_COLORS[type];
|
|
80
|
+
return (
|
|
81
|
+
<button
|
|
82
|
+
onClick={onClick}
|
|
83
|
+
type={htmlType}
|
|
84
|
+
className={cx(
|
|
85
|
+
'state-layer relative flex items-center justify-center gap-2 rounded-full transition-all duration-150 ease-in disabled:cursor-not-allowed disabled:opacity-40',
|
|
86
|
+
paddingClasses,
|
|
87
|
+
backgroundColors,
|
|
88
|
+
fullWidth && 'w-full',
|
|
89
|
+
!iconAfterText ? 'flex-row' : 'flex-row-reverse',
|
|
90
|
+
)}
|
|
91
|
+
disabled={disabled}
|
|
92
|
+
tabIndex={tabIndex}
|
|
93
|
+
data-testid={testId}
|
|
94
|
+
>
|
|
95
|
+
{icon && <span className={cx(textColors)}>{icon}</span>}
|
|
96
|
+
{text && <span className={cx('font-inter', textColors, textSizes)}>{text}</span>}
|
|
97
|
+
</button>
|
|
98
|
+
);
|
|
99
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType } from '../button.enums';
|
|
5
|
+
import type { ButtonVariantProps } from './buttonVariants.types';
|
|
6
|
+
|
|
7
|
+
export function ButtonPill({
|
|
8
|
+
htmlType = ButtonHtmlType.Button,
|
|
9
|
+
children,
|
|
10
|
+
tabIndex = 0,
|
|
11
|
+
...buttonProps
|
|
12
|
+
}: Omit<ButtonVariantProps, 'className'>) {
|
|
13
|
+
return (
|
|
14
|
+
<button
|
|
15
|
+
className="flex items-center justify-center rounded-xl border border-neutral-70 px-sm text-body-md text-neutral-40 disabled:opacity-40 dark:border-neutral-40 dark:text-neutral-60"
|
|
16
|
+
type={htmlType}
|
|
17
|
+
tabIndex={tabIndex}
|
|
18
|
+
{...buttonProps}
|
|
19
|
+
>
|
|
20
|
+
{children}
|
|
21
|
+
</button>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonHtmlType } from '../button.enums';
|
|
5
|
+
import type { ButtonVariantProps } from './buttonVariants.types';
|
|
6
|
+
import cx from 'classnames';
|
|
7
|
+
|
|
8
|
+
export function ButtonUnstyled({
|
|
9
|
+
htmlType = ButtonHtmlType.Button,
|
|
10
|
+
children,
|
|
11
|
+
className,
|
|
12
|
+
tabIndex = 0,
|
|
13
|
+
testId,
|
|
14
|
+
...buttonProps
|
|
15
|
+
}: ButtonVariantProps): React.JSX.Element {
|
|
16
|
+
return (
|
|
17
|
+
<button
|
|
18
|
+
type={htmlType}
|
|
19
|
+
{...buttonProps}
|
|
20
|
+
className={cx('appearance-none', className)}
|
|
21
|
+
tabIndex={tabIndex}
|
|
22
|
+
data-testid={testId}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</button>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import type { ButtonProps } from '../Button';
|
|
5
|
+
|
|
6
|
+
type ButtonPickedProps = Pick<ButtonProps, 'htmlType' | 'testId'>;
|
|
7
|
+
type PropsFromButtonElement = Omit<React.HTMLProps<HTMLButtonElement>, 'type'>;
|
|
8
|
+
|
|
9
|
+
export interface ButtonVariantProps extends ButtonPickedProps, PropsFromButtonElement {
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ButtonSize, ButtonType } from './button.enums';
|
|
5
|
+
|
|
6
|
+
export const PADDINGS: Record<ButtonSize, string> = {
|
|
7
|
+
[ButtonSize.Small]: 'px-md py-xs',
|
|
8
|
+
[ButtonSize.Medium]: 'px-md py-sm',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const PADDINGS_ONLY_ICON: Record<ButtonSize, string> = {
|
|
12
|
+
[ButtonSize.Small]: 'p-xs',
|
|
13
|
+
[ButtonSize.Medium]: 'p-sm',
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export const BACKGROUND_COLORS: Record<ButtonType, string> = {
|
|
17
|
+
[ButtonType.Primary]: 'bg-primary-30',
|
|
18
|
+
[ButtonType.Secondary]: 'bg-neutral-90 dark:bg-neutral-20',
|
|
19
|
+
[ButtonType.Ghost]: 'bg-transparent',
|
|
20
|
+
[ButtonType.Outlined]: 'bg-transparent border border-neutral-50',
|
|
21
|
+
[ButtonType.Destructive]: 'bg-error-90 dark:bg-error-20',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const DISABLED_BACKGROUND_COLORS: Record<ButtonType, string> = {
|
|
25
|
+
[ButtonType.Primary]: 'bg-neutral-80 dark:bg-neutral-30',
|
|
26
|
+
[ButtonType.Secondary]: 'bg-neutral-90 dark:bg-neutral-20',
|
|
27
|
+
[ButtonType.Ghost]: 'bg-transparent',
|
|
28
|
+
[ButtonType.Outlined]: 'bg-transparent border border-neutral-50',
|
|
29
|
+
[ButtonType.Destructive]: 'bg-error-90 dark:bg-error-20',
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const DEFAULT_TEXT_COLORS: string = 'text-neutral-10 dark:text-neutral-92';
|
|
33
|
+
|
|
34
|
+
export const TEXT_COLORS: Record<ButtonType, string> = {
|
|
35
|
+
[ButtonType.Primary]: 'text-primary-100',
|
|
36
|
+
[ButtonType.Secondary]: DEFAULT_TEXT_COLORS,
|
|
37
|
+
[ButtonType.Ghost]: DEFAULT_TEXT_COLORS,
|
|
38
|
+
[ButtonType.Outlined]: DEFAULT_TEXT_COLORS,
|
|
39
|
+
[ButtonType.Destructive]: 'text-error-20 dark:text-error-90',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const TEXT_CLASSES: Record<ButtonSize, string> = {
|
|
43
|
+
[ButtonSize.Small]: 'text-label-md',
|
|
44
|
+
[ButtonSize.Medium]: 'text-label-lg',
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const TEXT_COLOR_DISABLED: Record<ButtonType, string> = {
|
|
48
|
+
[ButtonType.Primary]: DEFAULT_TEXT_COLORS,
|
|
49
|
+
[ButtonType.Secondary]: DEFAULT_TEXT_COLORS,
|
|
50
|
+
[ButtonType.Ghost]: DEFAULT_TEXT_COLORS,
|
|
51
|
+
[ButtonType.Outlined]: DEFAULT_TEXT_COLORS,
|
|
52
|
+
[ButtonType.Destructive]: 'text-error-20 dark:text-error-90',
|
|
53
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export enum ButtonSize {
|
|
5
|
+
Small = 'small',
|
|
6
|
+
Medium = 'medium',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export enum ButtonType {
|
|
10
|
+
Primary = 'primary',
|
|
11
|
+
Secondary = 'secondary',
|
|
12
|
+
Ghost = 'ghost',
|
|
13
|
+
Outlined = 'outlined',
|
|
14
|
+
Destructive = 'destructive',
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export enum ButtonHtmlType {
|
|
18
|
+
Button = 'button',
|
|
19
|
+
Submit = 'submit',
|
|
20
|
+
Reset = 'reset',
|
|
21
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
BACKGROUND_COLORS,
|
|
6
|
+
BACKGROUND_COLORS_SELECTED,
|
|
7
|
+
TEXT_COLORS,
|
|
8
|
+
TEXT_COLORS_SELECTED,
|
|
9
|
+
UNDERLINED,
|
|
10
|
+
UNDERLINED_SELECTED,
|
|
11
|
+
} from './buttonSegment.classes';
|
|
12
|
+
import cx from 'classnames';
|
|
13
|
+
import { ButtonSegmentType } from './buttonSegment.enums';
|
|
14
|
+
import { ButtonUnstyled } from '../button';
|
|
15
|
+
|
|
16
|
+
interface ButtonSegmentProps {
|
|
17
|
+
/**
|
|
18
|
+
* The label of the button.
|
|
19
|
+
*/
|
|
20
|
+
label: string;
|
|
21
|
+
/**
|
|
22
|
+
The icon of the button
|
|
23
|
+
*/
|
|
24
|
+
icon?: React.ReactNode;
|
|
25
|
+
/**
|
|
26
|
+
The selected flag of the button
|
|
27
|
+
*/
|
|
28
|
+
selected?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* The button is disabled or not.
|
|
31
|
+
*/
|
|
32
|
+
disabled?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* The onClick event of the button.
|
|
35
|
+
*/
|
|
36
|
+
onClick?: (e: React.MouseEvent<HTMLButtonElement>) => void;
|
|
37
|
+
/**
|
|
38
|
+
* The type of the button.
|
|
39
|
+
*/
|
|
40
|
+
type?: ButtonSegmentType;
|
|
41
|
+
/**
|
|
42
|
+
* If the button is nested inside a parent button.
|
|
43
|
+
*/
|
|
44
|
+
isNested?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function ButtonSegment({
|
|
48
|
+
icon,
|
|
49
|
+
label,
|
|
50
|
+
selected,
|
|
51
|
+
disabled,
|
|
52
|
+
onClick,
|
|
53
|
+
type = ButtonSegmentType.Rounded,
|
|
54
|
+
isNested = false,
|
|
55
|
+
}: ButtonSegmentProps): React.JSX.Element {
|
|
56
|
+
const isUnderlined = type === ButtonSegmentType.Underlined;
|
|
57
|
+
|
|
58
|
+
const backgroundColors = selected
|
|
59
|
+
? isUnderlined
|
|
60
|
+
? 'bg-transparent'
|
|
61
|
+
: BACKGROUND_COLORS_SELECTED
|
|
62
|
+
: BACKGROUND_COLORS;
|
|
63
|
+
|
|
64
|
+
const underlined = isUnderlined ? (selected ? UNDERLINED_SELECTED : UNDERLINED) : '';
|
|
65
|
+
const textColors = selected ? TEXT_COLORS_SELECTED : TEXT_COLORS;
|
|
66
|
+
const padding = isUnderlined ? (isNested ? 'px-md py-sm' : 'px-lg py-md') : 'px-sm py-[6px]';
|
|
67
|
+
const borderRadius = isUnderlined ? '' : 'rounded-full';
|
|
68
|
+
const textSize = isNested
|
|
69
|
+
? isUnderlined
|
|
70
|
+
? 'text-title-sm'
|
|
71
|
+
: 'text-label-md'
|
|
72
|
+
: isUnderlined
|
|
73
|
+
? 'text-title-md'
|
|
74
|
+
: 'text-label-lg';
|
|
75
|
+
|
|
76
|
+
return (
|
|
77
|
+
<ButtonUnstyled
|
|
78
|
+
onClick={onClick}
|
|
79
|
+
className={cx(
|
|
80
|
+
'enabled:state-layer relative flex items-center disabled:opacity-40',
|
|
81
|
+
backgroundColors,
|
|
82
|
+
textColors,
|
|
83
|
+
padding,
|
|
84
|
+
borderRadius,
|
|
85
|
+
underlined,
|
|
86
|
+
{
|
|
87
|
+
'pl-xs': !!icon && !isUnderlined,
|
|
88
|
+
},
|
|
89
|
+
)}
|
|
90
|
+
disabled={disabled}
|
|
91
|
+
>
|
|
92
|
+
<div className={cx('flex flex-row items-center justify-center gap-2', textSize)}>
|
|
93
|
+
{icon && <span>{icon}</span>}
|
|
94
|
+
<span className="shrink-0 font-inter">{label}</span>
|
|
95
|
+
</div>
|
|
96
|
+
</ButtonUnstyled>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// Copyright (c) 2024 IOTA Stiftung
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export const BACKGROUND_COLORS = 'bg-transparent';
|
|
5
|
+
export const BACKGROUND_COLORS_SELECTED = 'bg-primary-100 dark:bg-neutral-6';
|
|
6
|
+
|
|
7
|
+
const TEXT_COLOR = 'text-neutral-60 dark:text-neutral-40';
|
|
8
|
+
const TEXT_COLOR_HOVER = 'enabled:hover:text-neutral-40 enabled:dark:hover:text-neutral-60';
|
|
9
|
+
const TEXT_COLOR_FOCUSED = 'enabled:focused:text-neutral-40 enabled:dark:focused:text-neutral-60';
|
|
10
|
+
|
|
11
|
+
export const TEXT_COLORS = `${TEXT_COLOR} ${TEXT_COLOR_HOVER} ${TEXT_COLOR_FOCUSED}`;
|
|
12
|
+
export const TEXT_COLORS_SELECTED = 'text-neutral-10 dark:text-neutral-92';
|
|
13
|
+
|
|
14
|
+
export const UNDERLINED_SELECTED = `
|
|
15
|
+
relative
|
|
16
|
+
before:content-['']
|
|
17
|
+
border-b
|
|
18
|
+
border-shader-neutral-light-8
|
|
19
|
+
dark:border-shader-neutral-dark-8
|
|
20
|
+
before:block
|
|
21
|
+
before:w-full
|
|
22
|
+
before:border-b
|
|
23
|
+
before:absolute
|
|
24
|
+
before:bottom-[-0.8px]
|
|
25
|
+
before:left-0
|
|
26
|
+
enabled:before:w-[calc(100%-16px)]
|
|
27
|
+
enabled:before:left-2
|
|
28
|
+
enabled:before:border-primary-30
|
|
29
|
+
enabled:before:dark:border-primary-80`;
|
|
30
|
+
|
|
31
|
+
export const UNDERLINED = `
|
|
32
|
+
relative
|
|
33
|
+
before:content-['']
|
|
34
|
+
before:block
|
|
35
|
+
before:w-full
|
|
36
|
+
before:border-b
|
|
37
|
+
before:border-shader-neutral-light-8
|
|
38
|
+
before:dark:border-shader-neutral-dark-8
|
|
39
|
+
before:absolute
|
|
40
|
+
before:bottom-0
|
|
41
|
+
before:left-0
|
|
42
|
+
hover:before:w-[calc(100%-16px)]
|
|
43
|
+
hover:before:left-2
|
|
44
|
+
hover:before:border-neutral-70
|
|
45
|
+
hover:before:dark:border-neutral-40`;
|