@iota/apps-ui-kit 0.0.0-dev-20251015065834

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 (243) hide show
  1. package/CHANGELOG.md +145 -0
  2. package/LICENSE +201 -0
  3. package/README.md +16 -0
  4. package/dist/index.d.ts +1911 -0
  5. package/dist/index.es.js +6486 -0
  6. package/dist/index.es.js.map +1 -0
  7. package/dist/index.umd.js +66 -0
  8. package/dist/index.umd.js.map +1 -0
  9. package/dist/style.css +1 -0
  10. package/package.json +80 -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 +110 -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 +24 -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 +124 -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/image/Image.tsx +32 -0
  36. package/src/lib/components/atoms/image/index.ts +4 -0
  37. package/src/lib/components/atoms/index.ts +26 -0
  38. package/src/lib/components/atoms/info-box/InfoBox.tsx +68 -0
  39. package/src/lib/components/atoms/info-box/index.ts +5 -0
  40. package/src/lib/components/atoms/info-box/infoBox.classes.ts +18 -0
  41. package/src/lib/components/atoms/info-box/infoBox.enums.ts +14 -0
  42. package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +157 -0
  43. package/src/lib/components/atoms/key-value-info/index.ts +6 -0
  44. package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
  45. package/src/lib/components/atoms/label-text/LabelText.tsx +92 -0
  46. package/src/lib/components/atoms/label-text/index.ts +5 -0
  47. package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
  48. package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
  49. package/src/lib/components/atoms/list-item/ListItem.tsx +88 -0
  50. package/src/lib/components/atoms/list-item/index.ts +4 -0
  51. package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
  52. package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
  53. package/src/lib/components/atoms/media-fallback/MediaFallback.tsx +12 -0
  54. package/src/lib/components/atoms/media-fallback/index.ts +4 -0
  55. package/src/lib/components/atoms/panel/Panel.tsx +28 -0
  56. package/src/lib/components/atoms/panel/index.ts +4 -0
  57. package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
  58. package/src/lib/components/atoms/placeholder/index.ts +4 -0
  59. package/src/lib/components/atoms/radio-button/RadioButton.tsx +64 -0
  60. package/src/lib/components/atoms/radio-button/index.ts +4 -0
  61. package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +29 -0
  62. package/src/lib/components/atoms/secondary-text/index.ts +4 -0
  63. package/src/lib/components/atoms/skeleton/Skeleton.tsx +30 -0
  64. package/src/lib/components/atoms/skeleton/index.ts +4 -0
  65. package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
  66. package/src/lib/components/atoms/snackbar/index.ts +5 -0
  67. package/src/lib/components/atoms/snackbar/snackbar.classes.ts +18 -0
  68. package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +9 -0
  69. package/src/lib/components/atoms/toggle/Toggle.tsx +140 -0
  70. package/src/lib/components/atoms/toggle/index.ts +6 -0
  71. package/src/lib/components/atoms/toggle/toggle.classes.ts +41 -0
  72. package/src/lib/components/atoms/toggle/toggle.enums.ts +12 -0
  73. package/src/lib/components/atoms/tooltip/Tooltip.tsx +139 -0
  74. package/src/lib/components/atoms/tooltip/index.ts +5 -0
  75. package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
  76. package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
  77. package/src/lib/components/atoms/video/Video.tsx +33 -0
  78. package/src/lib/components/atoms/video/index.ts +4 -0
  79. package/src/lib/components/atoms/video/video.constants.ts +31 -0
  80. package/src/lib/components/index.ts +6 -0
  81. package/src/lib/components/molecules/account/Account.tsx +195 -0
  82. package/src/lib/components/molecules/account/index.ts +4 -0
  83. package/src/lib/components/molecules/address/Address.tsx +101 -0
  84. package/src/lib/components/molecules/address/index.ts +4 -0
  85. package/src/lib/components/molecules/asset-media-renderer/AssetMediaRenderer.tsx +50 -0
  86. package/src/lib/components/molecules/asset-media-renderer/index.ts +4 -0
  87. package/src/lib/components/molecules/card/Card.tsx +70 -0
  88. package/src/lib/components/molecules/card/CardAction.tsx +78 -0
  89. package/src/lib/components/molecules/card/CardBody.tsx +73 -0
  90. package/src/lib/components/molecules/card/CardImage.tsx +43 -0
  91. package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
  92. package/src/lib/components/molecules/card/card.classes.ts +27 -0
  93. package/src/lib/components/molecules/card/card.enums.ts +26 -0
  94. package/src/lib/components/molecules/card/index.ts +8 -0
  95. package/src/lib/components/molecules/chip/Chip.tsx +146 -0
  96. package/src/lib/components/molecules/chip/chip.classes.ts +54 -0
  97. package/src/lib/components/molecules/chip/chip.enums.ts +15 -0
  98. package/src/lib/components/molecules/chip/index.ts +5 -0
  99. package/src/lib/components/molecules/display-stats/DisplayStats.tsx +142 -0
  100. package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
  101. package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
  102. package/src/lib/components/molecules/display-stats/index.ts +5 -0
  103. package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
  104. package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
  105. package/src/lib/components/molecules/dropdown/index.ts +5 -0
  106. package/src/lib/components/molecules/index.ts +19 -0
  107. package/src/lib/components/molecules/input/Input.tsx +261 -0
  108. package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
  109. package/src/lib/components/molecules/input/TextArea.tsx +148 -0
  110. package/src/lib/components/molecules/input/index.ts +8 -0
  111. package/src/lib/components/molecules/input/input.classes.ts +13 -0
  112. package/src/lib/components/molecules/input/input.enums.ts +14 -0
  113. package/src/lib/components/molecules/input/input.types.ts +29 -0
  114. package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +47 -0
  115. package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
  116. package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
  117. package/src/lib/components/molecules/navbar-item/index.ts +5 -0
  118. package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
  119. package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
  120. package/src/lib/components/molecules/search/Search.tsx +219 -0
  121. package/src/lib/components/molecules/search/index.ts +5 -0
  122. package/src/lib/components/molecules/search/search.classes.ts +20 -0
  123. package/src/lib/components/molecules/search/search.enums.ts +7 -0
  124. package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +38 -0
  125. package/src/lib/components/molecules/segmented-button/index.ts +6 -0
  126. package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
  127. package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
  128. package/src/lib/components/molecules/select/Select.tsx +235 -0
  129. package/src/lib/components/molecules/select/index.ts +5 -0
  130. package/src/lib/components/molecules/select/select.enums.ts +7 -0
  131. package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
  132. package/src/lib/components/molecules/table-cell/index.ts +4 -0
  133. package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +140 -0
  134. package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
  135. package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
  136. package/src/lib/components/molecules/title/Title.tsx +78 -0
  137. package/src/lib/components/molecules/title/index.ts +5 -0
  138. package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
  139. package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
  140. package/src/lib/components/molecules/visual-asset-card/VisualAssetCard.tsx +89 -0
  141. package/src/lib/components/molecules/visual-asset-card/index.ts +5 -0
  142. package/src/lib/components/molecules/visual-asset-card/visualAssetCard.enums.ts +7 -0
  143. package/src/lib/components/organisms/accordion/Accordion.tsx +108 -0
  144. package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
  145. package/src/lib/components/organisms/accordion/index.ts +4 -0
  146. package/src/lib/components/organisms/dialog/Dialog.tsx +157 -0
  147. package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
  148. package/src/lib/components/organisms/dialog/index.ts +5 -0
  149. package/src/lib/components/organisms/index.ts +7 -0
  150. package/src/lib/components/organisms/navbar/Navbar.tsx +101 -0
  151. package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +59 -0
  152. package/src/lib/components/organisms/navbar/index.ts +5 -0
  153. package/src/lib/components/organisms/table/Table.tsx +234 -0
  154. package/src/lib/components/organisms/table/TableContext.tsx +56 -0
  155. package/src/lib/components/organisms/table/index.ts +4 -0
  156. package/src/lib/constants/colors.constants.ts +239 -0
  157. package/src/lib/constants/index.ts +4 -0
  158. package/src/lib/enums/index.ts +5 -0
  159. package/src/lib/enums/screenSize.enums.ts +9 -0
  160. package/src/lib/enums/theme.enums.ts +8 -0
  161. package/src/lib/index.ts +10 -0
  162. package/src/lib/styles/base.css +144 -0
  163. package/src/lib/styles/components.css +735 -0
  164. package/src/lib/styles/fonts.css +7 -0
  165. package/src/lib/styles/index.css +18 -0
  166. package/src/lib/styles/utilities.css +61 -0
  167. package/src/lib/styles/variables/dark-variables.css +262 -0
  168. package/src/lib/styles/variables/general-variables.css +9 -0
  169. package/src/lib/styles/variables/light-variables.css +276 -0
  170. package/src/lib/styles/variables/names-variables.css +270 -0
  171. package/src/lib/tailwind/base.presets.ts +58 -0
  172. package/src/lib/tailwind/constants/customColors.constants.ts +13 -0
  173. package/src/lib/tailwind/constants/fontFamily.constants.ts +8 -0
  174. package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
  175. package/src/lib/tailwind/constants/gradients.constants.ts +6 -0
  176. package/src/lib/tailwind/constants/index.ts +7 -0
  177. package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
  178. package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
  179. package/src/lib/tailwind/helpers.ts +20 -0
  180. package/src/lib/tailwind/index.ts +5 -0
  181. package/src/lib/tailwind/plugins.ts +12 -0
  182. package/src/lib/tailwind/responsive.presets.ts +36 -0
  183. package/src/lib/tailwind/static.presets.ts +25 -0
  184. package/src/lib/tailwind/types.ts +6 -0
  185. package/src/lib/utils/format.ts +8 -0
  186. package/src/lib/utils/index.ts +4 -0
  187. package/src/storybook/blocks/Showcase.tsx +20 -0
  188. package/src/storybook/blocks/TypeSet.tsx +34 -0
  189. package/src/storybook/blocks/TypeSetItem.tsx +74 -0
  190. package/src/storybook/blocks/index.ts +6 -0
  191. package/src/storybook/constants/gradients.constants.ts +8 -0
  192. package/src/storybook/constants/index.ts +5 -0
  193. package/src/storybook/constants/typeset.constants.ts +39 -0
  194. package/src/storybook/constants/variableSpacing.constants.ts +6 -0
  195. package/src/storybook/helpers/formatGradientNames.ts +15 -0
  196. package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
  197. package/src/storybook/helpers/index.ts +4 -0
  198. package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
  199. package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
  200. package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
  201. package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
  202. package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
  203. package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
  204. package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
  205. package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
  206. package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
  207. package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
  208. package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
  209. package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
  210. package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
  211. package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
  212. package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
  213. package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
  214. package/src/storybook/stories/atoms/Snackbar.stories.tsx +43 -0
  215. package/src/storybook/stories/atoms/Toggle.stories.tsx +59 -0
  216. package/src/storybook/stories/atoms/Tooltip.stories.tsx +59 -0
  217. package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +57 -0
  218. package/src/storybook/stories/components/DocsSyncTheme.tsx +20 -0
  219. package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
  220. package/src/storybook/stories/components/index.ts +5 -0
  221. package/src/storybook/stories/design-tokens/colors.stories.mdx +44 -0
  222. package/src/storybook/stories/design-tokens/icons.stories.mdx +19 -0
  223. package/src/storybook/stories/design-tokens/typeset.stories.mdx +17 -0
  224. package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +11 -0
  225. package/src/storybook/stories/molecules/Account.stories.tsx +71 -0
  226. package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
  227. package/src/storybook/stories/molecules/Card.stories.tsx +112 -0
  228. package/src/storybook/stories/molecules/Chip.stories.tsx +127 -0
  229. package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
  230. package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
  231. package/src/storybook/stories/molecules/Input.stories.tsx +239 -0
  232. package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
  233. package/src/storybook/stories/molecules/Search.stories.tsx +101 -0
  234. package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +108 -0
  235. package/src/storybook/stories/molecules/Select.stories.tsx +103 -0
  236. package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
  237. package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
  238. package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
  239. package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
  240. package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
  241. package/src/storybook/stories/organisms/Dialog.stories.tsx +129 -0
  242. package/src/storybook/stories/organisms/Navbar.stories.tsx +78 -0
  243. package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
@@ -0,0 +1,146 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ButtonUnstyled } from '@/components/atoms/button';
5
+ import { Close } from '@iota/apps-ui-icons';
6
+ import cx from 'classnames';
7
+ import {
8
+ BACKGROUND_CLASSES,
9
+ BG_SELECTED_OUTLINE,
10
+ BG_SELECTED_OVERLAY,
11
+ BORDER_CLASSES,
12
+ CLOSE_ICON_INTERACTIVE,
13
+ FOCUS_CLASSES,
14
+ ROUNDED_CLASS,
15
+ STATE_LAYER_CLASSES,
16
+ TEXT_COLOR,
17
+ TEXT_COLOR_SELECTED_OUTLINE,
18
+ } from './chip.classes';
19
+ import { ChipSize, ChipType } from './chip.enums';
20
+
21
+ interface ChipProps {
22
+ /**
23
+ * The label of the chip
24
+ */
25
+ label: string;
26
+ /**
27
+ * Whether to show the close icon
28
+ */
29
+ showClose?: boolean;
30
+ /**
31
+ * Whether the chip is selected
32
+ */
33
+ selected?: boolean;
34
+ /**
35
+ * Callback when the close icon is clicked
36
+ */
37
+ onClose?: () => void;
38
+ /**
39
+ * On Click handler for the chip
40
+ */
41
+ onClick?: () => void;
42
+ /**
43
+ * Avatar to show in the chip.
44
+ */
45
+ avatar?: React.JSX.Element;
46
+ /**
47
+ * Leading element to show in the chip.
48
+ */
49
+ leadingElement?: React.JSX.Element;
50
+ /**
51
+ * Trailing element to show in the chip.
52
+ */
53
+ trailingElement?: React.JSX.Element;
54
+ /**
55
+ * The button is disabled or not.
56
+ */
57
+ disabled?: boolean;
58
+ /**
59
+ * The type of the Chip
60
+ */
61
+ type?: ChipType;
62
+ /**
63
+ * The size of the chip.
64
+ */
65
+ size?: ChipSize;
66
+ }
67
+
68
+ export function Chip({
69
+ label,
70
+ type = ChipType.Outline,
71
+ selected,
72
+ showClose,
73
+ onClose,
74
+ onClick,
75
+ avatar,
76
+ leadingElement,
77
+ trailingElement,
78
+ disabled,
79
+ size = ChipSize.Default,
80
+ }: ChipProps) {
81
+ const isOutlineSelected = type === ChipType.Outline && selected;
82
+ const outlineStyle = selected
83
+ ? type === ChipType.Outline
84
+ ? 'outline-transparent names:outline-names-neutral-20'
85
+ : 'chip-outline-color'
86
+ : 'outline-transparent';
87
+
88
+ const focusOutlineStyle = cx(
89
+ 'group-focus:chip-outline-color-active',
90
+ type === ChipType.Outline && 'names:group-focus:outline-transparent',
91
+ );
92
+ const selectedOverlayBg =
93
+ selected && !disabled && type !== ChipType.Outline ? BG_SELECTED_OVERLAY : '';
94
+
95
+ return (
96
+ <ButtonUnstyled
97
+ onClick={onClick}
98
+ className={cx(
99
+ 'group border disabled:opacity-40',
100
+ ROUNDED_CLASS,
101
+ isOutlineSelected
102
+ ? BG_SELECTED_OUTLINE[ChipType.Outline]
103
+ : BACKGROUND_CLASSES[type],
104
+ selected ? 'border-transparent' : BORDER_CLASSES[type],
105
+ )}
106
+ disabled={disabled}
107
+ >
108
+ <span
109
+ className={cx(
110
+ 'flex h-full w-full flex-row items-center gap-x-2',
111
+ avatar ? 'py-xxs' : 'py-[6px]',
112
+ avatar ? 'pl-xxs' : leadingElement ? 'pl-xs' : 'pl-sm',
113
+ showClose ? 'pr-xs' : 'pr-sm',
114
+ ROUNDED_CLASS,
115
+ isOutlineSelected
116
+ ? TEXT_COLOR_SELECTED_OUTLINE[ChipType.Outline]
117
+ : TEXT_COLOR[type],
118
+ outlineStyle,
119
+ !disabled && focusOutlineStyle,
120
+ !disabled && STATE_LAYER_CLASSES,
121
+ FOCUS_CLASSES,
122
+ selectedOverlayBg,
123
+ )}
124
+ >
125
+ {avatar ?? leadingElement}
126
+ <span className={cx(size === ChipSize.Small ? 'text-label-md' : 'text-body-md')}>
127
+ {label}
128
+ </span>
129
+ {trailingElement}
130
+ {showClose && (
131
+ <div
132
+ onClick={onClose}
133
+ className={cx(disabled ? 'cursor-default' : 'cursor-pointer')}
134
+ >
135
+ <Close
136
+ className={cx(
137
+ 'h-4 w-4 transition-opacity duration-150',
138
+ disabled ? '' : selected ? 'opacity-100' : CLOSE_ICON_INTERACTIVE,
139
+ )}
140
+ />
141
+ </div>
142
+ )}
143
+ </span>
144
+ </ButtonUnstyled>
145
+ );
146
+ }
@@ -0,0 +1,54 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ChipType } from './chip.enums';
5
+
6
+ export const ROUNDED_CLASS = 'rounded-full';
7
+
8
+ export const BACKGROUND_CLASSES: Record<ChipType, string> = {
9
+ [ChipType.Outline]: 'bg-transparent',
10
+ [ChipType.Elevated]: 'chip-bg-elevated',
11
+ [ChipType.Success]: 'bg-success-surface',
12
+ [ChipType.Brand]: 'chip-bg-brand',
13
+ [ChipType.Error]: 'bg-error-surface',
14
+ };
15
+
16
+ export const STATE_LAYER_OUTLINE =
17
+ 'outline outline-1 hover:chip-outline-color-hover active:chip-outline-color-active';
18
+
19
+ export const STATE_LAYER_BG_CLASSES =
20
+ 'hover:chip-bg-color-hover active:chip-bg-color-active group-focus:chip-bg-color-focus';
21
+
22
+ export const STATE_LAYER_CLASSES = `${STATE_LAYER_OUTLINE} ${STATE_LAYER_BG_CLASSES}`;
23
+
24
+ export const BG_SELECTED_OUTLINE: Partial<Record<ChipType, string>> = {
25
+ [ChipType.Outline]: 'chip-bg-selected-outline',
26
+ };
27
+
28
+ export const BG_SELECTED_OVERLAY = 'chip-bg-selected-overlay';
29
+
30
+ export const TEXT_COLOR_SELECTED_OUTLINE: Partial<Record<ChipType, string>> = {
31
+ [ChipType.Outline]: 'chip-text-secondary',
32
+ };
33
+
34
+ export const BORDER_CLASSES: Record<ChipType, string> = {
35
+ [ChipType.Outline]: 'chip-border-default',
36
+ [ChipType.Elevated]: 'border-transparent',
37
+ [ChipType.Success]: 'border-success-surface',
38
+ [ChipType.Brand]: 'chip-border-color-brand',
39
+ [ChipType.Error]: 'border-error-surface',
40
+ };
41
+
42
+ export const TEXT_COLOR: Record<ChipType, string> = {
43
+ [ChipType.Outline]: 'chip-text-default',
44
+ [ChipType.Elevated]: 'chip-text-secondary',
45
+ [ChipType.Success]: 'chip-text-secondary',
46
+ [ChipType.Brand]: 'chip-text-brand',
47
+ [ChipType.Error]: 'chip-text-secondary',
48
+ };
49
+
50
+ export const FOCUS_CLASSES =
51
+ 'focus-visible:shadow-[0_0_0_2px] focus-visible:chip-focus-ring focus-visible:outline-none';
52
+
53
+ export const CLOSE_ICON_INTERACTIVE =
54
+ 'chip-close-icon-opacity group-hover:opacity-100 group-focus:opacity-100 group-active:opacity-100';
@@ -0,0 +1,15 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum ChipType {
5
+ Outline = 'outline',
6
+ Elevated = 'elevated',
7
+ Success = 'success',
8
+ Brand = 'brand',
9
+ Error = 'error',
10
+ }
11
+
12
+ export enum ChipSize {
13
+ Small = 'small',
14
+ Default = 'default',
15
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Chip';
5
+ export * from './chip.enums';
@@ -0,0 +1,142 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { ReactNode } from 'react';
5
+ import type { TooltipPosition } from '@/components/atoms';
6
+ import { ButtonUnstyled, Tooltip } from '@/components/atoms';
7
+ import { Copy, Info } from '@iota/apps-ui-icons';
8
+ import { DisplayStatsType, DisplayStatsSize } from './displayStats.enums';
9
+ import cx from 'classnames';
10
+ import {
11
+ BACKGROUND_CLASSES,
12
+ SIZE_CLASSES,
13
+ TEXT_CLASSES,
14
+ VALUE_TEXT_CLASSES,
15
+ SUPPORTING_LABEL_TEXT_CLASSES,
16
+ LABEL_TEXT_CLASSES,
17
+ } from './displayStats.classes';
18
+
19
+ interface DisplayStatsProps {
20
+ /**
21
+ * The label of the stats.
22
+ */
23
+ label: ReactNode;
24
+ /**
25
+ * The tooltip position.
26
+ */
27
+ tooltipPosition?: TooltipPosition;
28
+ /**
29
+ * The tooltip text.
30
+ */
31
+ tooltipText?: string;
32
+ /**
33
+ * The value of the stats.
34
+ */
35
+ value: ReactNode;
36
+ /**
37
+ * The supporting label of the stats (optional).
38
+ */
39
+ supportingLabel?: string;
40
+ /**
41
+ * The background color of the stats.
42
+ */
43
+ type?: DisplayStatsType;
44
+ /**
45
+ * The size of the stats.
46
+ */
47
+ size?: DisplayStatsSize;
48
+ /**
49
+ * Add icon to the right of the label.
50
+ */
51
+ icon?: React.ReactNode;
52
+ /**
53
+ * Text that need to be copied (optional).
54
+ */
55
+ copyText?: string;
56
+ /**
57
+ * The onCopySuccess event of the KeyValue (optional).
58
+ */
59
+ onCopySuccess?: (e: React.MouseEvent<HTMLButtonElement>, text: string) => void;
60
+ /**
61
+ * The onCopyError event of the KeyValue (optional).
62
+ */
63
+ onCopyError?: (e: unknown, text: string) => void;
64
+ }
65
+
66
+ export function DisplayStats({
67
+ label,
68
+ tooltipPosition,
69
+ tooltipText,
70
+ value,
71
+ supportingLabel,
72
+ type = DisplayStatsType.Default,
73
+ size = DisplayStatsSize.Default,
74
+ icon,
75
+ copyText,
76
+ onCopySuccess,
77
+ onCopyError,
78
+ }: DisplayStatsProps): React.JSX.Element {
79
+ const backgroundClass = BACKGROUND_CLASSES[type];
80
+ const sizeClass = SIZE_CLASSES[size];
81
+ const textClass = TEXT_CLASSES[type];
82
+ const valueClass = VALUE_TEXT_CLASSES[size];
83
+ const labelClass = LABEL_TEXT_CLASSES[size];
84
+ const supportingLabelTextClass = SUPPORTING_LABEL_TEXT_CLASSES[size];
85
+
86
+ async function handleCopyClick(event: React.MouseEvent<HTMLButtonElement>) {
87
+ if (!navigator.clipboard) {
88
+ return;
89
+ }
90
+
91
+ if (copyText) {
92
+ try {
93
+ await navigator.clipboard.writeText(copyText);
94
+ onCopySuccess?.(event, copyText);
95
+ } catch (error) {
96
+ console.error('Failed to copy:', error);
97
+ onCopyError?.(error, copyText);
98
+ }
99
+ }
100
+ }
101
+ return (
102
+ <div
103
+ className={cx(
104
+ 'flex h-full w-full flex-col justify-between rounded-2xl p-md--rs',
105
+ backgroundClass,
106
+ sizeClass,
107
+ textClass,
108
+ )}
109
+ >
110
+ <div
111
+ className={cx('flex flex-row items-center', {
112
+ 'w-full justify-between': icon,
113
+ })}
114
+ >
115
+ <div className="flex flex-row items-center gap-xxs">
116
+ <span className={cx(labelClass, 'whitespace-pre-line')}>{label}</span>
117
+ {tooltipText && (
118
+ <Tooltip text={tooltipText} position={tooltipPosition}>
119
+ <Info className="opacity-40" />
120
+ </Tooltip>
121
+ )}
122
+ </div>
123
+ {icon && <span className="display-stats-icon-color">{icon}</span>}
124
+ </div>
125
+ <div className="flex w-full flex-row items-baseline gap-xxs">
126
+ <span className={cx('break-all', valueClass)}>{value}</span>
127
+ {supportingLabel && (
128
+ <span className={cx('opacity-40', supportingLabelTextClass)}>
129
+ {supportingLabel}
130
+ </span>
131
+ )}
132
+ {copyText && (
133
+ <div className="self-center">
134
+ <ButtonUnstyled onClick={handleCopyClick}>
135
+ <Copy className="display-stats-copy-icon-color" />
136
+ </ButtonUnstyled>
137
+ </div>
138
+ )}
139
+ </div>
140
+ </div>
141
+ );
142
+ }
@@ -0,0 +1,36 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { DisplayStatsType, DisplayStatsSize } from './displayStats.enums';
5
+
6
+ export const BACKGROUND_CLASSES: Record<DisplayStatsType, string> = {
7
+ [DisplayStatsType.Default]: 'display-stats-bg-default',
8
+ [DisplayStatsType.Highlight]: 'display-stats-bg-highlight',
9
+ [DisplayStatsType.Secondary]: 'display-stats-bg-secondary',
10
+ };
11
+
12
+ export const TEXT_CLASSES: Record<DisplayStatsType, string> = {
13
+ [DisplayStatsType.Default]: 'display-stats-text-default',
14
+ [DisplayStatsType.Highlight]: 'display-stats-text-highlight',
15
+ [DisplayStatsType.Secondary]: 'display-stats-text-secondary',
16
+ };
17
+
18
+ export const SIZE_CLASSES: Record<DisplayStatsSize, string> = {
19
+ [DisplayStatsSize.Default]: 'gap-y-sm',
20
+ [DisplayStatsSize.Large]: 'gap-y-md',
21
+ };
22
+
23
+ export const VALUE_TEXT_CLASSES: Record<DisplayStatsSize, string> = {
24
+ [DisplayStatsSize.Default]: 'text-title-md',
25
+ [DisplayStatsSize.Large]: 'text-headline-sm',
26
+ };
27
+
28
+ export const SUPPORTING_LABEL_TEXT_CLASSES: Record<DisplayStatsSize, string> = {
29
+ [DisplayStatsSize.Default]: 'text-label-md',
30
+ [DisplayStatsSize.Large]: 'text-label-lg',
31
+ };
32
+
33
+ export const LABEL_TEXT_CLASSES: Record<DisplayStatsSize, string> = {
34
+ [DisplayStatsSize.Default]: 'text-label-sm',
35
+ [DisplayStatsSize.Large]: 'text-label-md',
36
+ };
@@ -0,0 +1,13 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum DisplayStatsType {
5
+ Default = 'default',
6
+ Highlight = 'highlight',
7
+ Secondary = 'secondary',
8
+ }
9
+
10
+ export enum DisplayStatsSize {
11
+ Default = 'default',
12
+ Large = 'large',
13
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './DisplayStats';
5
+ export * from './displayStats.enums';
@@ -0,0 +1,10 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export function Dropdown({ children }: React.PropsWithChildren): React.JSX.Element {
5
+ return (
6
+ <ul className="dropdown-bg dropdown-border-color list-none rounded-lg border py-xs">
7
+ {children}
8
+ </ul>
9
+ );
10
+ }
@@ -0,0 +1,7 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export enum DropdownPosition {
5
+ Top = 'top',
6
+ Bottom = 'bottom',
7
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './Dropdown';
5
+ export * from './dropdownPosition.enums';
@@ -0,0 +1,19 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './address';
5
+ export * from './asset-media-renderer';
6
+ export * from './chip';
7
+ export * from './segmented-button';
8
+ export * from './title';
9
+ export * from './input';
10
+ export * from './navbar-item';
11
+ export * from './account';
12
+ export * from './dropdown';
13
+ export * from './table-cell';
14
+ export * from './select';
15
+ export * from './table-header-cell';
16
+ export * from './search';
17
+ export * from './card';
18
+ export * from './display-stats';
19
+ export * from './visual-asset-card';