@iota/apps-ui-kit 0.2.0 → 0.2.1

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 (212) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/index.d.ts +1622 -0
  3. package/dist/index.es.js +8805 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.umd.js +198 -0
  6. package/dist/index.umd.js.map +1 -0
  7. package/dist/style.css +1 -0
  8. package/package.json +5 -2
  9. package/src/lib/components/atoms/badge/Badge.tsx +37 -0
  10. package/src/lib/components/atoms/badge/badge.classes.ts +24 -0
  11. package/src/lib/components/atoms/badge/badge.enums.ts +8 -0
  12. package/src/lib/components/atoms/badge/index.ts +6 -0
  13. package/src/lib/components/atoms/button/Button.tsx +99 -0
  14. package/src/lib/components/atoms/button/button-variants/ButtonPill.tsx +23 -0
  15. package/src/lib/components/atoms/button/button-variants/ButtonUnstyled.tsx +27 -0
  16. package/src/lib/components/atoms/button/button-variants/buttonVariants.types.ts +11 -0
  17. package/src/lib/components/atoms/button/button-variants/index.ts +5 -0
  18. package/src/lib/components/atoms/button/button.classes.ts +53 -0
  19. package/src/lib/components/atoms/button/button.enums.ts +21 -0
  20. package/src/lib/components/atoms/button/index.ts +7 -0
  21. package/src/lib/components/atoms/button-segment/ButtonSegment.tsx +86 -0
  22. package/src/lib/components/atoms/button-segment/buttonSegment.classes.ts +45 -0
  23. package/src/lib/components/atoms/button-segment/buttonSegment.enums.ts +7 -0
  24. package/src/lib/components/atoms/button-segment/index.ts +5 -0
  25. package/src/lib/components/atoms/checkbox/Checkbox.tsx +114 -0
  26. package/src/lib/components/atoms/checkbox/index.ts +4 -0
  27. package/src/lib/components/atoms/divider/Divider.tsx +48 -0
  28. package/src/lib/components/atoms/divider/divider.classes.ts +11 -0
  29. package/src/lib/components/atoms/divider/divider.enums.ts +7 -0
  30. package/src/lib/components/atoms/divider/index.ts +6 -0
  31. package/src/lib/components/atoms/header/Header.tsx +73 -0
  32. package/src/lib/components/atoms/header/index.ts +4 -0
  33. package/src/lib/components/atoms/index.ts +22 -0
  34. package/src/lib/components/atoms/info-box/InfoBox.tsx +73 -0
  35. package/src/lib/components/atoms/info-box/index.ts +5 -0
  36. package/src/lib/components/atoms/info-box/infoBox.classes.ts +14 -0
  37. package/src/lib/components/atoms/info-box/infoBox.enums.ts +12 -0
  38. package/src/lib/components/atoms/key-value-info/KeyValueInfo.tsx +156 -0
  39. package/src/lib/components/atoms/key-value-info/index.ts +6 -0
  40. package/src/lib/components/atoms/key-value-info/keyValue.enums.ts +7 -0
  41. package/src/lib/components/atoms/label-text/LabelText.tsx +93 -0
  42. package/src/lib/components/atoms/label-text/index.ts +5 -0
  43. package/src/lib/components/atoms/label-text/labelText.classes.ts +22 -0
  44. package/src/lib/components/atoms/label-text/labelText.enums.ts +8 -0
  45. package/src/lib/components/atoms/list-item/ListItem.tsx +89 -0
  46. package/src/lib/components/atoms/list-item/index.ts +4 -0
  47. package/src/lib/components/atoms/loading-indicator/LoadingIndicator.tsx +38 -0
  48. package/src/lib/components/atoms/loading-indicator/index.ts +4 -0
  49. package/src/lib/components/atoms/panel/Panel.tsx +30 -0
  50. package/src/lib/components/atoms/panel/index.ts +4 -0
  51. package/src/lib/components/atoms/placeholder/Placeholder.tsx +27 -0
  52. package/src/lib/components/atoms/placeholder/index.ts +4 -0
  53. package/src/lib/components/atoms/radio-button/RadioButton.tsx +68 -0
  54. package/src/lib/components/atoms/radio-button/index.ts +4 -0
  55. package/src/lib/components/atoms/secondary-text/SecondaryText.tsx +28 -0
  56. package/src/lib/components/atoms/secondary-text/index.ts +4 -0
  57. package/src/lib/components/atoms/skeleton/Skeleton.tsx +47 -0
  58. package/src/lib/components/atoms/skeleton/index.ts +4 -0
  59. package/src/lib/components/atoms/snackbar/Snackbar.tsx +69 -0
  60. package/src/lib/components/atoms/snackbar/index.ts +5 -0
  61. package/src/lib/components/atoms/snackbar/snackbar.classes.ts +14 -0
  62. package/src/lib/components/atoms/snackbar/snackbar.enums.tsx +7 -0
  63. package/src/lib/components/atoms/tooltip/Tooltip.tsx +34 -0
  64. package/src/lib/components/atoms/tooltip/index.ts +5 -0
  65. package/src/lib/components/atoms/tooltip/tooltip.classes.ts +11 -0
  66. package/src/lib/components/atoms/tooltip/tooltip.enums.ts +9 -0
  67. package/src/lib/components/atoms/visual-asset-card/VisualAssetCard.tsx +93 -0
  68. package/src/lib/components/atoms/visual-asset-card/index.ts +5 -0
  69. package/src/lib/components/atoms/visual-asset-card/visualAssetCard.enums.ts +7 -0
  70. package/src/lib/components/index.ts +8 -0
  71. package/src/lib/components/molecules/account/Account.tsx +174 -0
  72. package/src/lib/components/molecules/account/index.ts +4 -0
  73. package/src/lib/components/molecules/address/Address.tsx +101 -0
  74. package/src/lib/components/molecules/address/index.ts +4 -0
  75. package/src/lib/components/molecules/card/Card.tsx +70 -0
  76. package/src/lib/components/molecules/card/CardAction.tsx +78 -0
  77. package/src/lib/components/molecules/card/CardBody.tsx +61 -0
  78. package/src/lib/components/molecules/card/CardImage.tsx +43 -0
  79. package/src/lib/components/molecules/card/CardImagePlaceholder.tsx +146 -0
  80. package/src/lib/components/molecules/card/card.classes.ts +26 -0
  81. package/src/lib/components/molecules/card/card.enums.ts +25 -0
  82. package/src/lib/components/molecules/card/index.ts +8 -0
  83. package/src/lib/components/molecules/chip/Chip.tsx +105 -0
  84. package/src/lib/components/molecules/chip/chip.classes.ts +32 -0
  85. package/src/lib/components/molecules/chip/chip.enums.ts +7 -0
  86. package/src/lib/components/molecules/chip/index.ts +4 -0
  87. package/src/lib/components/molecules/display-stats/DisplayStats.tsx +104 -0
  88. package/src/lib/components/molecules/display-stats/displayStats.classes.ts +36 -0
  89. package/src/lib/components/molecules/display-stats/displayStats.enums.ts +13 -0
  90. package/src/lib/components/molecules/display-stats/index.ts +5 -0
  91. package/src/lib/components/molecules/dropdown/Dropdown.tsx +10 -0
  92. package/src/lib/components/molecules/dropdown/dropdownPosition.enums.ts +7 -0
  93. package/src/lib/components/molecules/dropdown/index.ts +5 -0
  94. package/src/lib/components/molecules/index.ts +17 -0
  95. package/src/lib/components/molecules/input/Input.tsx +245 -0
  96. package/src/lib/components/molecules/input/InputWrapper.tsx +97 -0
  97. package/src/lib/components/molecules/input/TextArea.tsx +149 -0
  98. package/src/lib/components/molecules/input/index.ts +8 -0
  99. package/src/lib/components/molecules/input/input.classes.ts +14 -0
  100. package/src/lib/components/molecules/input/input.enums.ts +14 -0
  101. package/src/lib/components/molecules/input/input.types.ts +29 -0
  102. package/src/lib/components/molecules/navbar-item/NavbarItem.tsx +48 -0
  103. package/src/lib/components/molecules/navbar-item/NavbarItemHorizontal.tsx +65 -0
  104. package/src/lib/components/molecules/navbar-item/NavbarItemVertical.tsx +54 -0
  105. package/src/lib/components/molecules/navbar-item/index.ts +5 -0
  106. package/src/lib/components/molecules/navbar-item/navbarItem.classes.ts +16 -0
  107. package/src/lib/components/molecules/navbar-item/navbarItem.enums.ts +7 -0
  108. package/src/lib/components/molecules/search/Search.tsx +189 -0
  109. package/src/lib/components/molecules/search/index.ts +5 -0
  110. package/src/lib/components/molecules/search/search.classes.ts +20 -0
  111. package/src/lib/components/molecules/search/search.enums.ts +7 -0
  112. package/src/lib/components/molecules/segmented-button/SegmentedButton.tsx +34 -0
  113. package/src/lib/components/molecules/segmented-button/index.ts +6 -0
  114. package/src/lib/components/molecules/segmented-button/segmentedButton.classes.ts +12 -0
  115. package/src/lib/components/molecules/segmented-button/segmentedButton.enums.ts +8 -0
  116. package/src/lib/components/molecules/select/Select.tsx +223 -0
  117. package/src/lib/components/molecules/select/index.ts +5 -0
  118. package/src/lib/components/molecules/select/select.enums.ts +7 -0
  119. package/src/lib/components/molecules/table-cell/TableCell.tsx +62 -0
  120. package/src/lib/components/molecules/table-cell/index.ts +4 -0
  121. package/src/lib/components/molecules/table-header-cell/TableHeaderCell.tsx +126 -0
  122. package/src/lib/components/molecules/table-header-cell/index.ts +5 -0
  123. package/src/lib/components/molecules/table-header-cell/tableHeaderCell.enums.ts +7 -0
  124. package/src/lib/components/molecules/title/Title.tsx +69 -0
  125. package/src/lib/components/molecules/title/index.ts +5 -0
  126. package/src/lib/components/molecules/title/titleClasses.constants.ts +14 -0
  127. package/src/lib/components/molecules/title/titleSize.enums.ts +7 -0
  128. package/src/lib/components/organisms/accordion/Accordion.tsx +111 -0
  129. package/src/lib/components/organisms/accordion/accordion.classes.ts +4 -0
  130. package/src/lib/components/organisms/accordion/index.ts +4 -0
  131. package/src/lib/components/organisms/dialog/Dialog.tsx +122 -0
  132. package/src/lib/components/organisms/dialog/dialog.enums.ts +7 -0
  133. package/src/lib/components/organisms/dialog/index.ts +5 -0
  134. package/src/lib/components/organisms/index.ts +7 -0
  135. package/src/lib/components/organisms/navbar/Navbar.tsx +100 -0
  136. package/src/lib/components/organisms/navbar/NavbarSlideout.tsx +58 -0
  137. package/src/lib/components/organisms/navbar/index.ts +5 -0
  138. package/src/lib/components/organisms/table/Table.tsx +224 -0
  139. package/src/lib/components/organisms/table/TableContext.tsx +55 -0
  140. package/src/lib/components/organisms/table/index.ts +4 -0
  141. package/src/lib/constants/colors.constants.ts +127 -0
  142. package/src/lib/constants/index.ts +4 -0
  143. package/src/lib/enums/index.ts +4 -0
  144. package/src/lib/enums/screenSize.enums.ts +9 -0
  145. package/src/lib/index.ts +8 -0
  146. package/src/lib/styles/fonts.css +5 -0
  147. package/src/lib/styles/index.css +136 -0
  148. package/src/lib/tailwind/base.presets.ts +47 -0
  149. package/src/lib/tailwind/constants/fontSizes.constants.ts +201 -0
  150. package/src/lib/tailwind/constants/index.ts +6 -0
  151. package/src/lib/tailwind/constants/scaling.constants.ts +41 -0
  152. package/src/lib/tailwind/constants/variableSpacing.constants.ts +66 -0
  153. package/src/lib/tailwind/helpers.ts +20 -0
  154. package/src/lib/tailwind/index.ts +5 -0
  155. package/src/lib/tailwind/responsive.presets.ts +36 -0
  156. package/src/lib/tailwind/static.presets.ts +25 -0
  157. package/src/lib/tailwind/types.ts +6 -0
  158. package/src/lib/utils/format.ts +8 -0
  159. package/src/lib/utils/index.ts +4 -0
  160. package/src/storybook/blocks/Showcase.tsx +20 -0
  161. package/src/storybook/blocks/TypeSet.tsx +34 -0
  162. package/src/storybook/blocks/TypeSetItem.tsx +74 -0
  163. package/src/storybook/blocks/index.ts +6 -0
  164. package/src/storybook/constants/index.ts +5 -0
  165. package/src/storybook/constants/typeset.constants.ts +39 -0
  166. package/src/storybook/constants/variableSpacing.constants.ts +6 -0
  167. package/src/storybook/helpers/getFontSizeLabel.ts +15 -0
  168. package/src/storybook/helpers/index.ts +4 -0
  169. package/src/storybook/stories/atoms/Badge.stories.tsx +32 -0
  170. package/src/storybook/stories/atoms/Button.stories.tsx +45 -0
  171. package/src/storybook/stories/atoms/ButtonSegment.stories.tsx +45 -0
  172. package/src/storybook/stories/atoms/Checkbox.stories.tsx +34 -0
  173. package/src/storybook/stories/atoms/CustomScrollbar.stories.tsx +22 -0
  174. package/src/storybook/stories/atoms/Divider.stories.tsx +41 -0
  175. package/src/storybook/stories/atoms/Header.stories.tsx +58 -0
  176. package/src/storybook/stories/atoms/InfoBox.stories.tsx +67 -0
  177. package/src/storybook/stories/atoms/KeyValueInfo.stories.tsx +59 -0
  178. package/src/storybook/stories/atoms/LabelText.stories.tsx +55 -0
  179. package/src/storybook/stories/atoms/ListItem.stories.tsx +41 -0
  180. package/src/storybook/stories/atoms/LoadingIndicator.stories.tsx +32 -0
  181. package/src/storybook/stories/atoms/Panel.stories.tsx +36 -0
  182. package/src/storybook/stories/atoms/Placeholder.stories.tsx +33 -0
  183. package/src/storybook/stories/atoms/RadioButton.stories.tsx +51 -0
  184. package/src/storybook/stories/atoms/Skeleton.stories.tsx +33 -0
  185. package/src/storybook/stories/atoms/Snackbar.stories.tsx +42 -0
  186. package/src/storybook/stories/atoms/Tooltip.stories.tsx +57 -0
  187. package/src/storybook/stories/atoms/VisualAssetCard.stories.tsx +56 -0
  188. package/src/storybook/stories/components/VariableSpacingShowcase.tsx +46 -0
  189. package/src/storybook/stories/components/index.ts +4 -0
  190. package/src/storybook/stories/design-tokens/colors.stories.mdx +23 -0
  191. package/src/storybook/stories/design-tokens/icons.stories.mdx +17 -0
  192. package/src/storybook/stories/design-tokens/typeset.stories.mdx +15 -0
  193. package/src/storybook/stories/design-tokens/variable-spacing.stories.mdx +10 -0
  194. package/src/storybook/stories/molecules/Account.stories.tsx +69 -0
  195. package/src/storybook/stories/molecules/Address.stories.tsx +39 -0
  196. package/src/storybook/stories/molecules/Card.stories.tsx +115 -0
  197. package/src/storybook/stories/molecules/Chip.stories.tsx +122 -0
  198. package/src/storybook/stories/molecules/DisplayStats.stories.tsx +63 -0
  199. package/src/storybook/stories/molecules/Dropdown.stories.tsx +38 -0
  200. package/src/storybook/stories/molecules/Input.stories.tsx +161 -0
  201. package/src/storybook/stories/molecules/NavbarItem.stories.tsx +45 -0
  202. package/src/storybook/stories/molecules/Search.stories.tsx +100 -0
  203. package/src/storybook/stories/molecules/SegmentedButton.stories.tsx +107 -0
  204. package/src/storybook/stories/molecules/Select.stories.tsx +102 -0
  205. package/src/storybook/stories/molecules/TableCell.stories.tsx +46 -0
  206. package/src/storybook/stories/molecules/TableHeaderCell.stories.tsx +34 -0
  207. package/src/storybook/stories/molecules/TextArea.stories.tsx +80 -0
  208. package/src/storybook/stories/molecules/Title.stories.tsx +76 -0
  209. package/src/storybook/stories/organisms/Accordion.stories.tsx +70 -0
  210. package/src/storybook/stories/organisms/Dialog.stories.tsx +103 -0
  211. package/src/storybook/stories/organisms/Navbar.stories.tsx +77 -0
  212. package/src/storybook/stories/organisms/Table.stories.tsx +154 -0
@@ -0,0 +1,80 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { TextArea } from '@/lib/components/molecules/input';
6
+ import { useEffect, useState } from 'react';
7
+ import { Button } from '@/lib';
8
+
9
+ const meta: Meta<typeof TextArea> = {
10
+ component: TextArea,
11
+ tags: ['autodocs'],
12
+ } satisfies Meta<typeof TextArea>;
13
+
14
+ export default meta;
15
+
16
+ type Story = StoryObj<typeof meta>;
17
+
18
+ export const Default: Story = {
19
+ args: {
20
+ label: 'Label',
21
+ caption: 'Caption',
22
+ },
23
+ argTypes: {
24
+ amountCounter: {
25
+ control: {
26
+ type: 'text',
27
+ },
28
+ },
29
+ rows: {
30
+ control: {
31
+ type: 'number',
32
+ },
33
+ },
34
+ maxLength: {
35
+ control: {
36
+ type: 'number',
37
+ },
38
+ },
39
+ minLength: {
40
+ control: {
41
+ type: 'number',
42
+ },
43
+ },
44
+ autoFocus: {
45
+ control: {
46
+ type: 'boolean',
47
+ },
48
+ },
49
+ },
50
+ render: (props) => {
51
+ const { onChange, value, ...storyProps } = props;
52
+ const [inputValue, setInputValue] = useState(props.value ?? '');
53
+
54
+ useEffect(() => {
55
+ setInputValue(props.value ?? '');
56
+ }, [props.value]);
57
+
58
+ function onSubmit() {
59
+ alert(inputValue);
60
+ }
61
+
62
+ function handleOnChange(e: React.ChangeEvent<HTMLTextAreaElement>) {
63
+ setInputValue(e.target.value);
64
+ }
65
+
66
+ return (
67
+ <div className="w-[300px]">
68
+ <TextArea
69
+ onChange={handleOnChange}
70
+ value={inputValue}
71
+ isVisibilityToggleEnabled
72
+ {...storyProps}
73
+ />
74
+ <div className="flex w-full justify-end">
75
+ <Button onClick={() => onSubmit()} text="Submit" />
76
+ </div>
77
+ </div>
78
+ );
79
+ },
80
+ };
@@ -0,0 +1,76 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import * as ButtonStory from '../atoms/Button.stories';
6
+ import * as BadgeStory from '../atoms/Badge.stories';
7
+ import { Badge, BadgeType, Button, Title, TooltipPosition } from '@/lib/components';
8
+
9
+ const meta: Meta<typeof Title> = {
10
+ component: Title,
11
+ tags: ['autodocs'],
12
+ render: (props) => {
13
+ return <Title {...props} />;
14
+ },
15
+ } satisfies Meta<typeof Title>;
16
+
17
+ export default meta;
18
+
19
+ type Story = StoryObj<typeof meta>;
20
+
21
+ export const Default: Story = {
22
+ args: {
23
+ title: 'Title',
24
+ subtitle: 'Subtitle',
25
+ },
26
+ argTypes: {
27
+ title: {
28
+ control: 'text',
29
+ },
30
+ subtitle: {
31
+ control: 'text',
32
+ },
33
+ tooltipText: {
34
+ control: 'text',
35
+ },
36
+ tooltipPosition: {
37
+ control: {
38
+ type: 'select',
39
+ options: Object.values(TooltipPosition),
40
+ },
41
+ },
42
+ },
43
+ };
44
+
45
+ export const WithTooltip: Story = {
46
+ args: {
47
+ title: 'Title',
48
+ subtitle: 'Subtitle',
49
+ tooltipText: 'Tooltip',
50
+ tooltipPosition: TooltipPosition.Top,
51
+ },
52
+ };
53
+
54
+ export const WithButton: Story = {
55
+ args: {
56
+ title: 'Title',
57
+ subtitle: 'Subtitle',
58
+ },
59
+ render: (props) => {
60
+ return <Title {...props} trailingElement={<Button {...ButtonStory.Default.args} />} />;
61
+ },
62
+ };
63
+
64
+ export const WithSupportingElement: Story = {
65
+ args: {
66
+ title: 'Title',
67
+ },
68
+ render: (props) => {
69
+ return (
70
+ <Title
71
+ {...props}
72
+ supportingElement={<Badge {...BadgeStory.Default.args} type={BadgeType.Neutral} />}
73
+ />
74
+ );
75
+ },
76
+ };
@@ -0,0 +1,70 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { useState } from 'react';
5
+ import type { Meta, StoryFn, StoryObj } from '@storybook/react';
6
+ import {
7
+ Accordion,
8
+ AccordionContent,
9
+ AccordionHeader,
10
+ Badge,
11
+ BadgeType,
12
+ KeyValueInfo,
13
+ Title,
14
+ } from '@/components';
15
+
16
+ interface CustomStoryProps {
17
+ title: string;
18
+ badgeType: BadgeType;
19
+ badgeLabel: string;
20
+ isExpanded: boolean;
21
+ }
22
+
23
+ const Template: StoryFn<CustomStoryProps> = (args) => {
24
+ const [isExpanded, setIsExpanded] = useState(args.isExpanded);
25
+
26
+ const onToggle = () => {
27
+ setIsExpanded(!isExpanded);
28
+ };
29
+
30
+ return (
31
+ <Accordion>
32
+ <AccordionHeader isExpanded={isExpanded} onToggle={onToggle}>
33
+ <Title
34
+ title={args.title}
35
+ supportingElement={<Badge type={args.badgeType} label={args.badgeLabel} />}
36
+ />
37
+ </AccordionHeader>
38
+ <AccordionContent isExpanded={isExpanded}>
39
+ <div className="flex flex-col gap-2">
40
+ <KeyValueInfo keyText={'Label'} value="Value" />
41
+ <KeyValueInfo keyText={'Label'} value="Value" />
42
+ <KeyValueInfo keyText={'Label'} value="Value" />
43
+ </div>
44
+ </AccordionContent>
45
+ </Accordion>
46
+ );
47
+ };
48
+
49
+ const meta: Meta<CustomStoryProps> = {
50
+ title: 'Organisms/Accordion',
51
+ tags: ['autodocs'],
52
+ argTypes: {
53
+ title: { control: 'text' },
54
+ badgeType: { control: 'select', options: Object.values(BadgeType) },
55
+ badgeLabel: { control: 'text' },
56
+ isExpanded: { control: 'boolean' },
57
+ },
58
+ } satisfies Meta<CustomStoryProps>;
59
+
60
+ export default meta;
61
+
62
+ export const Default: StoryObj<CustomStoryProps> = {
63
+ render: Template,
64
+ args: {
65
+ title: 'Default Title',
66
+ badgeType: BadgeType.Neutral,
67
+ badgeLabel: 'New',
68
+ isExpanded: true,
69
+ },
70
+ };
@@ -0,0 +1,103 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+ import { ButtonSize, DialogPosition } from '@/lib/components';
4
+
5
+ import type { Meta, StoryObj } from '@storybook/react';
6
+
7
+ import { Button, ButtonType, Header, Dialog, DialogContent, DialogBody } from '@/components';
8
+ import { useState } from 'react';
9
+
10
+ const meta = {
11
+ component: Dialog,
12
+ tags: ['autodocs'],
13
+ render: () => {
14
+ const [open, setOpen] = useState(false);
15
+ return (
16
+ <div className="flex">
17
+ <Button size={ButtonSize.Small} text="Open Dialog" onClick={() => setOpen(true)} />
18
+ <Dialog open={open} onOpenChange={setOpen}>
19
+ <DialogContent showCloseOnOverlay>
20
+ <Header
21
+ title="Connect Ledger Wallet"
22
+ titleCentered
23
+ onClose={() => setOpen(false)}
24
+ onBack={() => setOpen(false)}
25
+ />
26
+ <DialogBody>
27
+ <div className="flex flex-col items-center gap-2">
28
+ <div className="mt-4.5">Logo</div>
29
+ <div className="mt-4.5 break-words text-center">
30
+ Connect your ledger to your computer, unlock it, and launch the
31
+ IOTA app. Click Continue when done.
32
+ </div>
33
+ <div className="mt-4.5"> Need more help? View tutorial.</div>
34
+ </div>
35
+ </DialogBody>
36
+ <div className="flex w-full flex-row justify-center gap-2 px-md--rs pb-md--rs pt-sm--rs">
37
+ <Button
38
+ size={ButtonSize.Small}
39
+ type={ButtonType.Outlined}
40
+ text="Cancel"
41
+ onClick={() => setOpen(false)}
42
+ />
43
+ <Button size={ButtonSize.Small} text="Connect" />
44
+ </div>
45
+ </DialogContent>
46
+ </Dialog>
47
+ </div>
48
+ );
49
+ },
50
+ } satisfies Meta<typeof Dialog>;
51
+
52
+ export default meta;
53
+
54
+ type Story = StoryObj<typeof meta>;
55
+
56
+ export const Default: Story = {};
57
+
58
+ export const RightDialog: Story = {
59
+ render: () => {
60
+ const [open, setOpen] = useState(false);
61
+ return (
62
+ <div className="flex">
63
+ <Button size={ButtonSize.Small} text="Open Dialog" onClick={() => setOpen(true)} />
64
+ <Dialog open={open} onOpenChange={setOpen}>
65
+ <DialogContent showCloseOnOverlay position={DialogPosition.Right}>
66
+ <div className="h-full w-full">
67
+ <Header
68
+ title="Connect Ledger Wallet"
69
+ titleCentered
70
+ onClose={() => setOpen(false)}
71
+ onBack={() => setOpen(false)}
72
+ />
73
+ <div className="flex h-full w-full flex-col items-center justify-center">
74
+ <DialogBody>
75
+ <div className="flex flex-col items-center gap-2">
76
+ <div className="mt-4.5">Logo</div>
77
+ <div className="mt-4.5 break-words text-center">
78
+ Connect your ledger to your computer, unlock it, and
79
+ launch the IOTA app. Click Continue when done.
80
+ </div>
81
+ <div className="mt-4.5">
82
+ {' '}
83
+ Need more help? View tutorial.
84
+ </div>
85
+ </div>
86
+ </DialogBody>
87
+ <div className="flex w-full flex-row justify-center gap-2 px-md--rs pb-md--rs pt-sm--rs">
88
+ <Button
89
+ size={ButtonSize.Small}
90
+ type={ButtonType.Outlined}
91
+ text="Cancel"
92
+ onClick={() => setOpen(false)}
93
+ />
94
+ <Button size={ButtonSize.Small} text="Connect" />
95
+ </div>
96
+ </div>
97
+ </div>
98
+ </DialogContent>
99
+ </Dialog>
100
+ </div>
101
+ );
102
+ },
103
+ };
@@ -0,0 +1,77 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { Activity, Apps, Assets, Home } from '@iota/apps-ui-icons';
6
+ import { Navbar, NavbarSlideout, NavbarItemWithId, NavbarProps } from '@/components';
7
+ import { useState } from 'react';
8
+
9
+ const NAVBAR_ITEMS: NavbarItemWithId[] = [
10
+ { id: 'home', icon: <Home /> },
11
+ { id: 'assets', icon: <Assets /> },
12
+ { id: 'apps', icon: <Apps /> },
13
+ { id: 'activity', icon: <Activity /> },
14
+ ];
15
+ const NAVBAR_ITEMS_WITH_TEXT: NavbarItemWithId[] = [
16
+ { id: 'home', icon: <Home />, text: 'Home' },
17
+ { id: 'assets', icon: <Assets />, text: 'Assets' },
18
+ { id: 'apps', icon: <Apps />, text: 'Apps' },
19
+ { id: 'activity', icon: <Activity />, text: 'Activity' },
20
+ ];
21
+
22
+ type NavbarCustomProps = NavbarProps & {
23
+ isOpen: boolean;
24
+ };
25
+
26
+ const meta: Meta<NavbarCustomProps> = {
27
+ component: Navbar,
28
+ tags: ['autodocs'],
29
+ render: () => {
30
+ const [activeId, setActiveId] = useState<string>(NAVBAR_ITEMS[0].id);
31
+
32
+ return (
33
+ <div className="flex">
34
+ <Navbar
35
+ items={NAVBAR_ITEMS}
36
+ activeId={activeId}
37
+ onClickItem={(id) => setActiveId(id)}
38
+ />
39
+ </div>
40
+ );
41
+ },
42
+ } satisfies Meta<typeof Navbar>;
43
+
44
+ export default meta;
45
+
46
+ type Story = StoryObj<typeof meta>;
47
+
48
+ export const Default: Story = {};
49
+
50
+ export const Collapsable: Story = {
51
+ args: {},
52
+ argTypes: {},
53
+ render: (args) => {
54
+ const [activeId, setActiveId] = useState<string>(NAVBAR_ITEMS[0].id);
55
+ const [isOpen, setIsOpen] = useState<boolean>(false);
56
+
57
+ return (
58
+ <div className="flex h-96">
59
+ <Navbar
60
+ isCollapsable
61
+ items={NAVBAR_ITEMS}
62
+ activeId={activeId}
63
+ onClickItem={(id) => setActiveId(id)}
64
+ isOpen={isOpen}
65
+ onToggleNavbar={() => setIsOpen(!isOpen)}
66
+ />
67
+ <NavbarSlideout
68
+ items={NAVBAR_ITEMS_WITH_TEXT}
69
+ activeId={activeId}
70
+ onClickItem={(id) => setActiveId(id)}
71
+ isOpen={isOpen}
72
+ onToggleNavbar={() => setIsOpen(!isOpen)}
73
+ />
74
+ </div>
75
+ );
76
+ },
77
+ };
@@ -0,0 +1,154 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import {
6
+ TableHeaderCell,
7
+ Table,
8
+ TableBody,
9
+ TableHeader,
10
+ TableRow,
11
+ TableRowCheckbox,
12
+ TableCellText,
13
+ TableActionButton,
14
+ TableHeaderCheckbox,
15
+ } from '@/lib';
16
+ import { useState } from 'react';
17
+
18
+ const HEADERS = [
19
+ {
20
+ label: 'Name',
21
+ columnKey: 2,
22
+ hasSort: true,
23
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
24
+ },
25
+ {
26
+ label: 'Age',
27
+ columnKey: 3,
28
+ hasSort: true,
29
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
30
+ },
31
+ {
32
+ label: 'Occupation',
33
+ columnKey: 4,
34
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
35
+ },
36
+ {
37
+ label: 'Email',
38
+ columnKey: 5,
39
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
40
+ },
41
+ {
42
+ label: 'Start Date',
43
+ columnKey: 6,
44
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
45
+ },
46
+ {
47
+ label: 'End Date',
48
+ columnKey: 7,
49
+ cell: ({ text }: { text: string }) => <TableCellText>{text}</TableCellText>,
50
+ },
51
+ ];
52
+
53
+ const DATA = [
54
+ {
55
+ name: 'Jon Doe',
56
+ age: 30,
57
+ occupation: 'Software Engineer',
58
+ email: 'test@acme.com',
59
+ startDate: '10.04.2016',
60
+ endDate: '12.03.2019',
61
+ },
62
+ ];
63
+
64
+ const meta = {
65
+ component: Table,
66
+ tags: ['autodocs'],
67
+ render: (props) => {
68
+ const [selectedRows, setSelectedRows] = useState<Set<number>>(new Set());
69
+ return (
70
+ <div className="container mx-auto p-4">
71
+ <Table {...props} selectedRowIndexes={selectedRows}>
72
+ <TableHeader>
73
+ <TableRow
74
+ leading={
75
+ <TableHeaderCheckbox
76
+ onCheckboxChange={(checked) => {
77
+ if (checked) {
78
+ setSelectedRows(new Set(props.rowIndexes));
79
+ } else {
80
+ setSelectedRows(new Set());
81
+ }
82
+ }}
83
+ />
84
+ }
85
+ >
86
+ {HEADERS.map((header, index) => (
87
+ <TableHeaderCell key={index} {...header} />
88
+ ))}
89
+ </TableRow>
90
+ </TableHeader>
91
+ <TableBody>
92
+ {DATA.map((row, rowIndex) => (
93
+ <TableRow
94
+ key={rowIndex}
95
+ leading={
96
+ <TableRowCheckbox
97
+ rowIndex={rowIndex}
98
+ onCheckboxChange={(checked) => {
99
+ setSelectedRows((selectedRows) => {
100
+ if (checked) {
101
+ selectedRows.add(rowIndex);
102
+ } else {
103
+ selectedRows.delete(rowIndex);
104
+ }
105
+
106
+ console.log(
107
+ 'Checked checkbox at index:',
108
+ rowIndex,
109
+ 'with value:',
110
+ checked,
111
+ 'table values:',
112
+ selectedRows,
113
+ );
114
+
115
+ return new Set(selectedRows);
116
+ });
117
+ }}
118
+ />
119
+ }
120
+ >
121
+ {Object.entries(row).map((cell, columnIndex) => {
122
+ const Cell = HEADERS[columnIndex].cell;
123
+ return (
124
+ <td key={columnIndex}>
125
+ <Cell text={cell[1].toString()} />
126
+ </td>
127
+ );
128
+ })}
129
+ </TableRow>
130
+ ))}
131
+ </TableBody>
132
+ </Table>
133
+ </div>
134
+ );
135
+ },
136
+ } satisfies Meta<typeof Table>;
137
+
138
+ export default meta;
139
+
140
+ type Story = StoryObj<typeof meta>;
141
+
142
+ export const Default: Story = {
143
+ args: {
144
+ supportingLabel: '10.7k records',
145
+ paginationOptions: {
146
+ onFirst: () => console.log('First'),
147
+ onNext: () => console.log('Next'),
148
+ hasFirst: true,
149
+ hasNext: false,
150
+ },
151
+ action: <TableActionButton text="Action" />,
152
+ rowIndexes: [0, 1, 2],
153
+ },
154
+ };