@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,201 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ThemeConfig } from 'tailwindcss/types/config';
5
+
6
+ type TailwindFontSize = ThemeConfig['fontSize'];
7
+
8
+ export type TailwindFontSizeConfig = Partial<{
9
+ lineHeight: string;
10
+ letterSpacing: string;
11
+ fontWeight: string | number;
12
+ }>;
13
+
14
+ export type TailwindCustomFonts = Record<
15
+ string,
16
+ [
17
+ string,
18
+ Partial<{
19
+ lineHeight: string;
20
+ letterSpacing: string;
21
+ fontWeight: string | number;
22
+ }>,
23
+ ]
24
+ >;
25
+
26
+ export const TEXT_LABEL_CLASSES: TailwindCustomFonts = {
27
+ 'text-label-sm': [
28
+ '11px',
29
+ {
30
+ lineHeight: '16px',
31
+ letterSpacing: '0.2px',
32
+ fontWeight: 500,
33
+ },
34
+ ],
35
+ 'text-label-md': [
36
+ '12px',
37
+ {
38
+ lineHeight: '16px',
39
+ letterSpacing: '-0.1px',
40
+ fontWeight: 500,
41
+ },
42
+ ],
43
+ 'text-label-lg': [
44
+ '14px',
45
+ {
46
+ lineHeight: '20px',
47
+ letterSpacing: '-0.1px',
48
+ fontWeight: 500,
49
+ },
50
+ ],
51
+ } satisfies TailwindFontSize;
52
+
53
+ export const TEXT_BODY_CLASSES: TailwindCustomFonts = {
54
+ 'text-body-sm': [
55
+ '12px',
56
+ {
57
+ lineHeight: '16px',
58
+ letterSpacing: '0.1px',
59
+ fontWeight: 400,
60
+ },
61
+ ],
62
+ 'text-body-md': [
63
+ '14px',
64
+ {
65
+ lineHeight: '20px',
66
+ letterSpacing: '-0.1px',
67
+ fontWeight: 400,
68
+ },
69
+ ],
70
+ 'text-body-lg': [
71
+ '16px',
72
+ {
73
+ lineHeight: '24px',
74
+ letterSpacing: '0.1px',
75
+ fontWeight: 400,
76
+ },
77
+ ],
78
+ };
79
+
80
+ export const TEXT_BODY_DISAMBIGUOUS_CLASSES: TailwindCustomFonts = {
81
+ 'text-body-ds-sm': [
82
+ '12px',
83
+ {
84
+ lineHeight: '16px',
85
+ letterSpacing: '0.1px',
86
+ fontWeight: 400,
87
+ },
88
+ ],
89
+ 'text-body-ds-md': [
90
+ '14px',
91
+ {
92
+ lineHeight: '20px',
93
+ letterSpacing: '-0.1px',
94
+ fontWeight: 400,
95
+ },
96
+ ],
97
+ 'text-body-ds-lg': [
98
+ '16px',
99
+ {
100
+ lineHeight: '24px',
101
+ letterSpacing: '0.2px',
102
+ fontWeight: 400,
103
+ },
104
+ ],
105
+ };
106
+
107
+ export const TEXT_TITLE_CLASSES: TailwindCustomFonts = {
108
+ 'text-title-sm': [
109
+ '14px',
110
+ {
111
+ lineHeight: '120%',
112
+ letterSpacing: '-0.1px',
113
+ fontWeight: 500,
114
+ },
115
+ ],
116
+ 'text-title-md': [
117
+ '16px',
118
+ {
119
+ lineHeight: '120%',
120
+ letterSpacing: '-0.15px',
121
+ fontWeight: 500,
122
+ },
123
+ ],
124
+ 'text-title-lg': [
125
+ '20px',
126
+ {
127
+ lineHeight: '120%',
128
+ letterSpacing: '-0.4px',
129
+ fontWeight: 500,
130
+ },
131
+ ],
132
+ };
133
+
134
+ export const TEXT_HEADLINE_CLASSES: TailwindCustomFonts = {
135
+ 'text-headline-sm': [
136
+ '24px',
137
+ {
138
+ lineHeight: '120%',
139
+ letterSpacing: '-0.2px',
140
+ fontWeight: 500,
141
+ },
142
+ ],
143
+ 'text-headline-md': [
144
+ '28px',
145
+ {
146
+ lineHeight: '120%',
147
+ letterSpacing: '-0.4px',
148
+ fontWeight: 500,
149
+ },
150
+ ],
151
+ 'text-headline-lg': [
152
+ '32px',
153
+ {
154
+ lineHeight: '120%',
155
+ letterSpacing: '-0.4px',
156
+ fontWeight: 500,
157
+ },
158
+ ],
159
+ };
160
+
161
+ export const TEXT_DISPLAY_CLASSES: TailwindCustomFonts = {
162
+ 'text-display-sm': [
163
+ '36px',
164
+ {
165
+ lineHeight: '120%',
166
+ fontWeight: 500,
167
+ },
168
+ ],
169
+ 'text-display-md': [
170
+ '48px',
171
+ {
172
+ lineHeight: '120%',
173
+ fontWeight: 500,
174
+ },
175
+ ],
176
+ 'text-display-lg': [
177
+ '60px',
178
+ {
179
+ lineHeight: '120%',
180
+ fontWeight: 500,
181
+ },
182
+ ],
183
+ };
184
+
185
+ const CUSTOM_TEXT_CLASSES: TailwindCustomFonts = {
186
+ ...TEXT_LABEL_CLASSES,
187
+ ...TEXT_BODY_CLASSES,
188
+ ...TEXT_BODY_DISAMBIGUOUS_CLASSES,
189
+ ...TEXT_TITLE_CLASSES,
190
+ ...TEXT_HEADLINE_CLASSES,
191
+ ...TEXT_DISPLAY_CLASSES,
192
+ };
193
+
194
+ // Remove the 'text-' prefix from the keys to match the TailwindCSS font size keys
195
+ export const CUSTOM_FONT_SIZES: TailwindCustomFonts = Object.entries(CUSTOM_TEXT_CLASSES).reduce(
196
+ (acc, [className, properties]) => {
197
+ const key = className.startsWith('text-') ? className.replace('text-', '') : className;
198
+ return { ...acc, [key]: properties };
199
+ },
200
+ {},
201
+ );
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './scaling.constants';
5
+ export * from './fontSizes.constants';
6
+ export * from './variableSpacing.constants';
@@ -0,0 +1,41 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { pxToRem } from '../helpers';
5
+
6
+ type TailwindScale = Record<string, string> & { DEFAULT?: string };
7
+
8
+ export const BORDER_RADIUS: TailwindScale = {
9
+ none: pxToRem(0),
10
+ sm: pxToRem(2),
11
+ DEFAULT: pxToRem(4),
12
+ md: pxToRem(6),
13
+ lg: pxToRem(8),
14
+ xl: pxToRem(12),
15
+ '2xl': pxToRem(16),
16
+ '3xl': pxToRem(24),
17
+ full: pxToRem(120),
18
+ };
19
+
20
+ export const CUSTOM_SPACING: TailwindScale = {
21
+ none: pxToRem(0),
22
+ xxxs: pxToRem(2),
23
+ xxs: pxToRem(4),
24
+ xs: pxToRem(8),
25
+ sm: pxToRem(12),
26
+ md: pxToRem(16),
27
+ lg: pxToRem(24),
28
+ xl: pxToRem(32),
29
+ '2xl': pxToRem(48),
30
+ };
31
+
32
+ export const OPACITY: TailwindScale = {
33
+ 0: '0',
34
+ 8: '0.08',
35
+ 12: '0.12',
36
+ 16: '0.16',
37
+ 40: '0.4',
38
+ 60: '0.6',
39
+ 80: '0.8',
40
+ 100: '1',
41
+ };
@@ -0,0 +1,66 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ScreenSize } from '../../enums/screenSize.enums';
5
+
6
+ enum VariableSpacingClassPrefix {
7
+ Xs = 'xs--rs',
8
+ Sm = 'sm--rs',
9
+ Md = 'md--rs',
10
+ }
11
+
12
+ type DefaultValue = string;
13
+ type ScreenMdValue = string;
14
+ type ScreenLgValue = string;
15
+ type ScreenXlValue = string;
16
+
17
+ const VARIABLE_SPACING: Record<
18
+ VariableSpacingClassPrefix,
19
+ [DefaultValue, ScreenMdValue, ScreenLgValue?, ScreenXlValue?]
20
+ > = {
21
+ [VariableSpacingClassPrefix.Xs]: ['4px', '8px'],
22
+ [VariableSpacingClassPrefix.Sm]: ['8px', '12px'],
23
+ [VariableSpacingClassPrefix.Md]: ['16px', '24px'],
24
+ };
25
+
26
+ function getClampedSpacingValues(
27
+ key: VariableSpacingClassPrefix,
28
+ screens: Record<string, string>,
29
+ ): string {
30
+ const CUSTOM_SCREEN_SIZES: ScreenSize[] = [
31
+ ScreenSize.Sm,
32
+ ScreenSize.Md,
33
+ ScreenSize.Lg,
34
+ ScreenSize.Xl,
35
+ ];
36
+
37
+ const values = VARIABLE_SPACING[key];
38
+ // Use the first value as the default value, since it doesn't need to be clamped.
39
+ let clampValue = `${values[0]}`;
40
+ for (let i = 1; i < values.length; i++) {
41
+ if (values[i]) {
42
+ // Iterate the tailwind screens and check if desired the breakpoint exists.
43
+ const breakpoint = screens[CUSTOM_SCREEN_SIZES[i]];
44
+ if (breakpoint) {
45
+ // Clamp the spacing value using the screen breakpoint as reference.
46
+ clampValue = `clamp(${clampValue}, (100vw - ${breakpoint}) * 99, ${values[i]})`;
47
+ }
48
+ }
49
+ }
50
+
51
+ return clampValue;
52
+ }
53
+
54
+ export function generateVariableSpacing(tailwindScreens: Record<string, string>) {
55
+ const variableSpacing = Object.keys(VARIABLE_SPACING).reduce((acc, variableSpacingPrefix) => {
56
+ const clampedSpacing = getClampedSpacingValues(
57
+ variableSpacingPrefix as VariableSpacingClassPrefix,
58
+ tailwindScreens,
59
+ );
60
+ return {
61
+ ...acc,
62
+ [variableSpacingPrefix]: clampedSpacing,
63
+ };
64
+ }, {});
65
+ return variableSpacing;
66
+ }
@@ -0,0 +1,20 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ScreenSize } from '../enums';
5
+
6
+ export const pxToRem = (px: number, base: number = 16) => `${px / base}rem`;
7
+
8
+ export function getTailwindScreens(
9
+ breakpoints: Partial<Record<ScreenSize, number>>,
10
+ ): Record<string, string> {
11
+ const screens: Record<string, string> = Object.entries(breakpoints).reduce(
12
+ (acc, [key, value]) => {
13
+ acc[key] = `${value}px`;
14
+ return acc;
15
+ },
16
+ {} as Record<string, string>,
17
+ );
18
+
19
+ return screens;
20
+ }
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export { default as uiKitResponsivePreset } from './responsive.presets';
5
+ export { default as uiKitStaticPreset } from './static.presets';
@@ -0,0 +1,36 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Config } from 'tailwindcss';
5
+ import type { ScreenBreakpoints } from './types';
6
+ import { ScreenSize } from '../enums';
7
+ import { getTailwindScreens, pxToRem } from './helpers';
8
+ import { BASE_CONFIG } from './base.presets';
9
+ import merge from 'lodash.merge';
10
+
11
+ const BREAKPOINTS: ScreenBreakpoints = {
12
+ [ScreenSize.Sm]: 768,
13
+ [ScreenSize.Md]: 1024,
14
+ [ScreenSize.Lg]: 1400,
15
+ [ScreenSize.Xl]: 1920,
16
+ };
17
+
18
+ const screens = getTailwindScreens(BREAKPOINTS);
19
+
20
+ const responsivePreset: Config = merge({}, BASE_CONFIG, {
21
+ theme: {
22
+ screens,
23
+ container: {
24
+ center: true,
25
+ screens,
26
+ padding: {
27
+ DEFAULT: pxToRem(24),
28
+ md: pxToRem(48),
29
+ lg: pxToRem(120),
30
+ xl: pxToRem(240),
31
+ },
32
+ },
33
+ },
34
+ });
35
+
36
+ export default responsivePreset;
@@ -0,0 +1,25 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Config } from 'tailwindcss';
5
+ import type { ScreenBreakpoints } from './types';
6
+ import { getTailwindScreens } from './helpers';
7
+ import { BASE_CONFIG } from './base.presets';
8
+ import merge from 'lodash.merge';
9
+
10
+ const BREAKPOINTS: Partial<ScreenBreakpoints> & { default: number } = {
11
+ default: 0,
12
+ };
13
+
14
+ const screens = getTailwindScreens(BREAKPOINTS);
15
+
16
+ const staticPreset: Config = merge({}, BASE_CONFIG, {
17
+ theme: {
18
+ screens,
19
+ },
20
+ corePlugins: {
21
+ container: false,
22
+ },
23
+ });
24
+
25
+ export default staticPreset;
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { ScreenSize } from '../enums';
5
+
6
+ export type ScreenBreakpoints = Record<ScreenSize, number>;
@@ -0,0 +1,8 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export function truncate(value: string, startLength: number = 6, endLength: number = 6): string {
5
+ return value.length > startLength + endLength
6
+ ? `${value.slice(0, startLength)}...${value.slice(-endLength)}`
7
+ : value;
8
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './format';
@@ -0,0 +1,20 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ interface ShowcaseProps {
5
+ children?: React.ReactNode;
6
+ title: string;
7
+ }
8
+
9
+ export function Showcase({ children, title }: ShowcaseProps) {
10
+ return (
11
+ <div className="flex flex-col gap-2">
12
+ <code className="inline w-fit rounded-md bg-neutral-96 px-xxs">{title}</code>
13
+ <div className="flex">
14
+ <div className="flex flex-row items-center justify-center rounded-xl border border-neutral-70 p-md">
15
+ {children}
16
+ </div>
17
+ </div>
18
+ </div>
19
+ );
20
+ }
@@ -0,0 +1,34 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { TypeSetItem } from './TypeSetItem';
5
+ import { getFontSizeLabelFromClass } from '../helpers';
6
+ import { TailwindCustomFonts } from '@/lib/tailwind/constants';
7
+
8
+ export interface TypeSetProps {
9
+ typeset: TailwindCustomFonts;
10
+ label: string;
11
+ }
12
+
13
+ export function TypeSet({ typeset, label }: TypeSetProps) {
14
+ const textClasses = Object.entries(typeset);
15
+ return (
16
+ <div className="mt-4 flex flex-col gap-y-2 rounded-md border border-gray-200 px-xl py-lg shadow-md">
17
+ {textClasses.map(([fontClass, [_, fontConfig]], index) => {
18
+ const sizeText = getFontSizeLabelFromClass(fontClass);
19
+ return (
20
+ <>
21
+ <TypeSetItem
22
+ key={index}
23
+ sampleText={label}
24
+ fontClass={fontClass}
25
+ sizeText={sizeText}
26
+ {...fontConfig}
27
+ />
28
+ {index !== textClasses.length - 1 && <hr className="mb-sm mt-xxs" />}
29
+ </>
30
+ );
31
+ })}
32
+ </div>
33
+ );
34
+ }
@@ -0,0 +1,74 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { Fragment, useEffect, useRef, useState } from 'react';
5
+
6
+ enum FontStyleProperties {
7
+ FontSize = 'Font Size',
8
+ LetterSpacing = 'Letter Spacing',
9
+ FontWeight = 'Font Weight',
10
+ LineHeight = 'Line Height',
11
+ FontFamily = 'Font Family',
12
+ }
13
+
14
+ interface TypeSetItemProps {
15
+ sampleText: string;
16
+ fontClass?: string;
17
+ sizeText?: string;
18
+ }
19
+
20
+ type FontStyles = Record<FontStyleProperties, string>;
21
+
22
+ function getComputedFontStyles(element: HTMLDivElement): FontStyles {
23
+ const computedStyles = getComputedStyle(element);
24
+ return {
25
+ [FontStyleProperties.FontSize]: computedStyles.fontSize,
26
+ [FontStyleProperties.LetterSpacing]: computedStyles.letterSpacing,
27
+ [FontStyleProperties.FontWeight]: computedStyles.fontWeight,
28
+ [FontStyleProperties.LineHeight]: computedStyles.lineHeight,
29
+ [FontStyleProperties.FontFamily]: computedStyles.fontFamily,
30
+ };
31
+ }
32
+
33
+ export function TypeSetItem({ sampleText, sizeText, fontClass }: TypeSetItemProps) {
34
+ const [styles, setStyles] = useState<FontStyles | undefined>();
35
+ const ref = useRef<HTMLDivElement | null>(null);
36
+
37
+ useEffect(() => {
38
+ if (ref.current) {
39
+ const computedStyles = getComputedFontStyles(ref.current);
40
+ setStyles(computedStyles);
41
+ }
42
+ }, [ref.current]);
43
+
44
+ return (
45
+ <div className="flex flex-row items-start gap-x-md">
46
+ {styles && (
47
+ <div className="text-xs text-neutral-60">
48
+ {styles[FontStyleProperties.FontSize]}
49
+ </div>
50
+ )}
51
+ <div className="flex flex-col gap-y-sm">
52
+ <span ref={ref} className={fontClass}>
53
+ {sampleText} {sizeText}
54
+ </span>
55
+ {styles && (
56
+ <div className="flex flex-row gap-x-xs">
57
+ {Object.entries(styles)
58
+ .filter(([key]) => key !== FontStyleProperties.FontSize)
59
+ .map(([key, value], index) => (
60
+ <Fragment key={index}>
61
+ {index > 0 && (
62
+ <span className="text-xs text-neutral-60">|</span>
63
+ )}
64
+ <span className="text-xs text-neutral-60">
65
+ {key}: {value}
66
+ </span>
67
+ </Fragment>
68
+ ))}
69
+ </div>
70
+ )}
71
+ </div>
72
+ </div>
73
+ );
74
+ }
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './TypeSet';
5
+ export * from './TypeSetItem';
6
+ export * from './Showcase';
@@ -0,0 +1,5 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './typeset.constants';
5
+ export * from './variableSpacing.constants';
@@ -0,0 +1,39 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import {
5
+ TEXT_LABEL_CLASSES,
6
+ TEXT_BODY_CLASSES,
7
+ TEXT_BODY_DISAMBIGUOUS_CLASSES,
8
+ TEXT_TITLE_CLASSES,
9
+ TEXT_HEADLINE_CLASSES,
10
+ TEXT_DISPLAY_CLASSES,
11
+ } from '@/lib/tailwind/constants';
12
+ import type { TypeSetProps } from '../blocks';
13
+
14
+ export const TYPESETS: TypeSetProps[] = [
15
+ {
16
+ label: 'Label',
17
+ typeset: TEXT_LABEL_CLASSES,
18
+ },
19
+ {
20
+ label: 'Body',
21
+ typeset: TEXT_BODY_CLASSES,
22
+ },
23
+ {
24
+ label: 'Body Disambiguous',
25
+ typeset: TEXT_BODY_DISAMBIGUOUS_CLASSES,
26
+ },
27
+ {
28
+ label: 'Title',
29
+ typeset: TEXT_TITLE_CLASSES,
30
+ },
31
+ {
32
+ label: 'Headline',
33
+ typeset: TEXT_HEADLINE_CLASSES,
34
+ },
35
+ {
36
+ label: 'Display',
37
+ typeset: TEXT_DISPLAY_CLASSES,
38
+ },
39
+ ];
@@ -0,0 +1,6 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export const VARIABLE_GAP_CLASSES: string[] = ['gap-xs--rs', 'gap-sm--rs', 'gap-md--rs'];
5
+
6
+ export const VARIABLE_PADDING_CLASSES: string[] = ['p-xs--rs', 'p-sm--rs', 'p-md--rs'];
@@ -0,0 +1,15 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ const SIZE_TO_LABEL_MAP: Record<string, string> = {
5
+ sm: 'Small',
6
+ md: 'Medium',
7
+ lg: 'Large',
8
+ };
9
+
10
+ export function getFontSizeLabelFromClass(fontClass: string): string {
11
+ const fontClassSplit = fontClass.split('-');
12
+ const size = fontClassSplit[fontClassSplit.length - 1];
13
+ const label = SIZE_TO_LABEL_MAP[size];
14
+ return label;
15
+ }
@@ -0,0 +1,4 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ export * from './getFontSizeLabel';
@@ -0,0 +1,32 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import type { Meta, StoryObj } from '@storybook/react';
5
+ import { Badge, BadgeType } from '@/components';
6
+
7
+ const meta: Meta<typeof Badge> = {
8
+ component: Badge,
9
+ tags: ['autodocs'],
10
+ render: (props) => {
11
+ return <Badge {...props} />;
12
+ },
13
+ } satisfies Meta<typeof Badge>;
14
+
15
+ export default meta;
16
+
17
+ type Story = StoryObj<typeof meta>;
18
+
19
+ export const Default: Story = {
20
+ args: {
21
+ label: 'Badge',
22
+ type: BadgeType.PrimarySolid,
23
+ },
24
+ argTypes: {
25
+ type: {
26
+ control: {
27
+ type: 'select',
28
+ options: Object.values(BadgeType),
29
+ },
30
+ },
31
+ },
32
+ };