@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.
Files changed (220) hide show
  1. package/CHANGELOG.md +106 -0
  2. package/LICENSE +201 -0
  3. package/README.md +16 -0
  4. package/dist/index.d.ts +1726 -0
  5. package/dist/index.es.js +6923 -0
  6. package/dist/index.es.js.map +1 -0
  7. package/dist/index.umd.js +118 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/style.css +1 -0
  10. package/package.json +75 -0
  11. package/src/lib/components/atoms/badge/Badge.tsx +37 -0
  12. package/src/lib/components/atoms/badge/badge.classes.ts +33 -0
  13. package/src/lib/components/atoms/badge/badge.enums.ts +11 -0
  14. package/src/lib/components/atoms/badge/index.ts +6 -0
  15. package/src/lib/components/atoms/button/Button.tsx +99 -0
  16. package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
  17. package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
  18. package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
  19. package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
  20. package/src/lib/components/atoms/button/button.classes.ts +53 -0
  21. package/src/lib/components/atoms/button/button.enums.ts +21 -0
  22. package/src/lib/components/atoms/button/index.ts +7 -0
  23. package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +98 -0
  24. package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +45 -0
  25. package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
  26. package/src/lib/components/atoms/button-segment/index.ts +5 -0
  27. package/src/lib/components/atoms/checkbox/Checkbox.tsx +114 -0
  28. package/src/lib/components/atoms/checkbox/index.ts +4 -0
  29. package/src/lib/components/atoms/divider/Divider.tsx +48 -0
  30. package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
  31. package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
  32. package/src/lib/components/atoms/divider/index.ts +6 -0
  33. package/src/lib/components/atoms/header/Header.tsx +73 -0
  34. package/src/lib/components/atoms/header/index.ts +4 -0
  35. package/src/lib/components/atoms/index.ts +23 -0
  36. package/src/lib/components/atoms/info-box/InfoBox.tsx +74 -0
  37. package/src/lib/components/atoms/info-box/index.ts +5 -0
  38. package/src/lib/components/atoms/info-box/infoBox.classes.ts +19 -0
  39. package/src/lib/components/atoms/info-box/infoBox.enums.ts +14 -0
  40. package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +157 -0
  41. package/src/lib/components/atoms/key-value-info/index.ts +6 -0
  42. package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
  43. package/src/lib/components/atoms/label-text/LabelText.tsx +94 -0
  44. package/src/lib/components/atoms/label-text/index.ts +5 -0
  45. package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
  46. package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
  47. package/src/lib/components/atoms/list-item/ListItem.tsx +89 -0
  48. package/src/lib/components/atoms/list-item/index.ts +4 -0
  49. package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
  50. package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
  51. package/src/lib/components/atoms/panel/Panel.tsx +30 -0
  52. package/src/lib/components/atoms/panel/index.ts +4 -0
  53. package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
  54. package/src/lib/components/atoms/placeholder/index.ts +4 -0
  55. package/src/lib/components/atoms/radio-button/RadioButton.tsx +68 -0
  56. package/src/lib/components/atoms/radio-button/index.ts +4 -0
  57. package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
  58. package/src/lib/components/atoms/secondary-text/index.ts +4 -0
  59. package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -0
  60. package/src/lib/components/atoms/skeleton/index.ts +4 -0
  61. package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
  62. package/src/lib/components/atoms/snackbar/index.ts +5 -0
  63. package/src/lib/components/atoms/snackbar/snackbar.classes.ts +18 -0
  64. package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +9 -0
  65. package/src/lib/components/atoms/toggle/Toggle.tsx +140 -0
  66. package/src/lib/components/atoms/toggle/index.ts +6 -0
  67. package/src/lib/components/atoms/toggle/toggle.classes.ts +41 -0
  68. package/src/lib/components/atoms/toggle/toggle.enums.ts +12 -0
  69. package/src/lib/components/atoms/tooltip/Tooltip.tsx +138 -0
  70. package/src/lib/components/atoms/tooltip/index.ts +5 -0
  71. package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
  72. package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
  73. package/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx +101 -0
  74. package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
  75. package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
  76. package/src/lib/components/index.ts +8 -0
  77. package/src/lib/components/molecules/account/Account.tsx +192 -0
  78. package/src/lib/components/molecules/account/index.ts +4 -0
  79. package/src/lib/components/molecules/address/Address.tsx +101 -0
  80. package/src/lib/components/molecules/address/index.ts +4 -0
  81. package/src/lib/components/molecules/card/Card.tsx +70 -0
  82. package/src/lib/components/molecules/card/CardAction.tsx +80 -0
  83. package/src/lib/components/molecules/card/CardBody.tsx +72 -0
  84. package/src/lib/components/molecules/card/CardImage.tsx +43 -0
  85. package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
  86. package/src/lib/components/molecules/card/card.classes.ts +27 -0
  87. package/src/lib/components/molecules/card/card.enums.ts +26 -0
  88. package/src/lib/components/molecules/card/index.ts +8 -0
  89. package/src/lib/components/molecules/chip/Chip.tsx +105 -0
  90. package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
  91. package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
  92. package/src/lib/components/molecules/chip/index.ts +4 -0
  93. package/src/lib/components/molecules/display-stats/DisplayStats.tsx +142 -0
  94. package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
  95. package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
  96. package/src/lib/components/molecules/display-stats/index.ts +5 -0
  97. package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
  98. package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
  99. package/src/lib/components/molecules/dropdown/index.ts +5 -0
  100. package/src/lib/components/molecules/index.ts +17 -0
  101. package/src/lib/components/molecules/input/Input.tsx +246 -0
  102. package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
  103. package/src/lib/components/molecules/input/TextArea.tsx +150 -0
  104. package/src/lib/components/molecules/input/index.ts +8 -0
  105. package/src/lib/components/molecules/input/input.classes.ts +14 -0
  106. package/src/lib/components/molecules/input/input.enums.ts +14 -0
  107. package/src/lib/components/molecules/input/input.types.ts +29 -0
  108. package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +48 -0
  109. package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
  110. package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
  111. package/src/lib/components/molecules/navbar-item/index.ts +5 -0
  112. package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
  113. package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
  114. package/src/lib/components/molecules/search/Search.tsx +216 -0
  115. package/src/lib/components/molecules/search/index.ts +5 -0
  116. package/src/lib/components/molecules/search/search.classes.ts +20 -0
  117. package/src/lib/components/molecules/search/search.enums.ts +7 -0
  118. package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +38 -0
  119. package/src/lib/components/molecules/segmented-button/index.ts +6 -0
  120. package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
  121. package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
  122. package/src/lib/components/molecules/select/Select.tsx +222 -0
  123. package/src/lib/components/molecules/select/index.ts +5 -0
  124. package/src/lib/components/molecules/select/select.enums.ts +7 -0
  125. package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
  126. package/src/lib/components/molecules/table-cell/index.ts +4 -0
  127. package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +140 -0
  128. package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
  129. package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
  130. package/src/lib/components/molecules/title/Title.tsx +78 -0
  131. package/src/lib/components/molecules/title/index.ts +5 -0
  132. package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
  133. package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
  134. package/src/lib/components/organisms/accordion/Accordion.tsx +109 -0
  135. package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
  136. package/src/lib/components/organisms/accordion/index.ts +4 -0
  137. package/src/lib/components/organisms/dialog/Dialog.tsx +142 -0
  138. package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
  139. package/src/lib/components/organisms/dialog/index.ts +5 -0
  140. package/src/lib/components/organisms/index.ts +7 -0
  141. package/src/lib/components/organisms/navbar/Navbar.tsx +101 -0
  142. package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +59 -0
  143. package/src/lib/components/organisms/navbar/index.ts +5 -0
  144. package/src/lib/components/organisms/table/Table.tsx +234 -0
  145. package/src/lib/components/organisms/table/TableContext.tsx +56 -0
  146. package/src/lib/components/organisms/table/index.ts +4 -0
  147. package/src/lib/constants/colors.constants.ts +133 -0
  148. package/src/lib/constants/index.ts +4 -0
  149. package/src/lib/enums/index.ts +4 -0
  150. package/src/lib/enums/screenSize.enums.ts +9 -0
  151. package/src/lib/index.ts +8 -0
  152. package/src/lib/styles/fonts.css +5 -0
  153. package/src/lib/styles/index.css +149 -0
  154. package/src/lib/tailwind/base.presets.ts +49 -0
  155. package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
  156. package/src/lib/tailwind/constants/index.ts +6 -0
  157. package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
  158. package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
  159. package/src/lib/tailwind/helpers.ts +20 -0
  160. package/src/lib/tailwind/index.ts +5 -0
  161. package/src/lib/tailwind/plugins.ts +8 -0
  162. package/src/lib/tailwind/responsive.presets.ts +36 -0
  163. package/src/lib/tailwind/static.presets.ts +25 -0
  164. package/src/lib/tailwind/types.ts +6 -0
  165. package/src/lib/utils/format.ts +8 -0
  166. package/src/lib/utils/index.ts +4 -0
  167. package/src/storybook/blocks/Showcase.tsx +20 -0
  168. package/src/storybook/blocks/TypeSet.tsx +34 -0
  169. package/src/storybook/blocks/TypeSetItem.tsx +74 -0
  170. package/src/storybook/blocks/index.ts +6 -0
  171. package/src/storybook/constants/index.ts +5 -0
  172. package/src/storybook/constants/typeset.constants.ts +39 -0
  173. package/src/storybook/constants/variableSpacing.constants.ts +6 -0
  174. package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
  175. package/src/storybook/helpers/index.ts +4 -0
  176. package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
  177. package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
  178. package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
  179. package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
  180. package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
  181. package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
  182. package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
  183. package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
  184. package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
  185. package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
  186. package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
  187. package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
  188. package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
  189. package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
  190. package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
  191. package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
  192. package/src/storybook/stories/atoms/Snackbar.stories.tsx +43 -0
  193. package/src/storybook/stories/atoms/Toggle.stories.tsx +59 -0
  194. package/src/storybook/stories/atoms/Tooltip.stories.tsx +57 -0
  195. package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
  196. package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
  197. package/src/storybook/stories/components/index.ts +4 -0
  198. package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
  199. package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
  200. package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
  201. package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
  202. package/src/storybook/stories/molecules/Account.stories.tsx +69 -0
  203. package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
  204. package/src/storybook/stories/molecules/Card.stories.tsx +112 -0
  205. package/src/storybook/stories/molecules/Chip.stories.tsx +122 -0
  206. package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
  207. package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
  208. package/src/storybook/stories/molecules/Input.stories.tsx +162 -0
  209. package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
  210. package/src/storybook/stories/molecules/Search.stories.tsx +101 -0
  211. package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +108 -0
  212. package/src/storybook/stories/molecules/Select.stories.tsx +103 -0
  213. package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
  214. package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
  215. package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
  216. package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
  217. package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
  218. package/src/storybook/stories/organisms/Dialog.stories.tsx +103 -0
  219. package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
  220. 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,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { Badge } from './Badge';
5
+
6
+ export * from './badge.enums';
@@ -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,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './ButtonPill';
5
+ export * from './ButtonUnstyled';
@@ -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,7 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Button';
5
+ export * from './button-variants';
6
+
7
+ export * from './button.enums';
@@ -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`;
@@ -0,0 +1,7 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum ButtonSegmentType {
5
+ Rounded = 'rounded',
6
+ Underlined = 'underlined',
7
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './ButtonSegment';
5
+ export * from './buttonSegment.enums';