react-miui 0.20.0 → 0.21.0

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 (319) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/components/form/input/Input.css.d.ts +47 -0
  3. package/dist/components/form/input/Input.css.d.ts.map +1 -0
  4. package/dist/components/form/input/Input.css.js +52 -0
  5. package/dist/components/form/input/Input.css.js.map +1 -0
  6. package/dist/components/form/input/Input.styled.d.ts +68 -36
  7. package/dist/components/form/input/Input.styled.d.ts.map +1 -1
  8. package/dist/components/form/input/Input.styled.js +3 -48
  9. package/dist/components/form/input/Input.styled.js.map +1 -1
  10. package/dist/components/form/textarea/TextArea.d.ts.map +1 -0
  11. package/dist/components/form/{TextArea.js → textarea/TextArea.js} +3 -10
  12. package/dist/components/form/textarea/TextArea.js.map +1 -0
  13. package/dist/components/form/textarea/TextArea.stories.d.ts +8 -0
  14. package/dist/components/form/textarea/TextArea.stories.d.ts.map +1 -0
  15. package/dist/components/form/textarea/TextArea.stories.js +15 -0
  16. package/dist/components/form/textarea/TextArea.stories.js.map +1 -0
  17. package/dist/components/{layout/list/Value.styled.d.ts → form/textarea/TextArea.styled.d.ts} +24 -12
  18. package/dist/components/form/textarea/TextArea.styled.d.ts.map +1 -0
  19. package/dist/components/form/textarea/TextArea.styled.js +9 -0
  20. package/dist/components/form/textarea/TextArea.styled.js.map +1 -0
  21. package/dist/components/icons/Icon.js +1 -2
  22. package/dist/components/icons/Icon.js.map +1 -1
  23. package/dist/components/layout/list/Header.d.ts +174 -7
  24. package/dist/components/layout/list/Header.d.ts.map +1 -1
  25. package/dist/components/layout/list/Header.js +36 -11
  26. package/dist/components/layout/list/Header.js.map +1 -1
  27. package/dist/components/layout/list/Header.stories.d.ts +8 -0
  28. package/dist/components/layout/list/Header.stories.d.ts.map +1 -0
  29. package/dist/components/layout/list/Header.stories.js +33 -0
  30. package/dist/components/layout/list/Header.stories.js.map +1 -0
  31. package/dist/components/layout/list/Item.d.ts +88 -7
  32. package/dist/components/layout/list/Item.d.ts.map +1 -1
  33. package/dist/components/layout/list/Item.js +66 -33
  34. package/dist/components/layout/list/Item.js.map +1 -1
  35. package/dist/components/layout/list/Item.stories.d.ts +10 -0
  36. package/dist/components/layout/list/Item.stories.d.ts.map +1 -0
  37. package/dist/components/layout/list/Item.stories.js +65 -0
  38. package/dist/components/layout/list/Item.stories.js.map +1 -0
  39. package/dist/components/layout/list/Label.d.ts +83 -5
  40. package/dist/components/layout/list/Label.d.ts.map +1 -1
  41. package/dist/components/layout/list/Label.js +24 -6
  42. package/dist/components/layout/list/Label.js.map +1 -1
  43. package/dist/components/layout/list/Label.stories.d.ts +8 -0
  44. package/dist/components/layout/list/Label.stories.d.ts.map +1 -0
  45. package/dist/components/layout/list/Label.stories.js +35 -0
  46. package/dist/components/layout/list/Label.stories.js.map +1 -0
  47. package/dist/components/layout/list/List.d.ts +86 -7
  48. package/dist/components/layout/list/List.d.ts.map +1 -1
  49. package/dist/components/layout/list/List.js +15 -9
  50. package/dist/components/layout/list/List.js.map +1 -1
  51. package/dist/components/layout/list/List.stories.d.ts +9 -0
  52. package/dist/components/layout/list/List.stories.d.ts.map +1 -0
  53. package/dist/components/layout/list/List.stories.js +53 -0
  54. package/dist/components/layout/list/List.stories.js.map +1 -0
  55. package/dist/components/layout/list/Value.d.ts +81 -1
  56. package/dist/components/layout/list/Value.d.ts.map +1 -1
  57. package/dist/components/layout/list/Value.js +9 -2
  58. package/dist/components/layout/list/Value.js.map +1 -1
  59. package/dist/components/layout/list/Value.stories.d.ts +8 -0
  60. package/dist/components/layout/list/Value.stories.d.ts.map +1 -0
  61. package/dist/components/layout/list/Value.stories.js +29 -0
  62. package/dist/components/layout/list/Value.stories.js.map +1 -0
  63. package/dist/components/layout/section/Section.d.ts +83 -8
  64. package/dist/components/layout/section/Section.d.ts.map +1 -1
  65. package/dist/components/layout/section/Section.js +17 -15
  66. package/dist/components/layout/section/Section.js.map +1 -1
  67. package/dist/components/layout/section/Section.stories.d.ts +8 -0
  68. package/dist/components/layout/section/Section.stories.d.ts.map +1 -0
  69. package/dist/components/layout/section/Section.stories.js +37 -0
  70. package/dist/components/layout/section/Section.stories.js.map +1 -0
  71. package/dist/components/layout/section/SectionContainer.d.ts +80 -5
  72. package/dist/components/layout/section/SectionContainer.d.ts.map +1 -1
  73. package/dist/components/layout/section/SectionContainer.js +9 -8
  74. package/dist/components/layout/section/SectionContainer.js.map +1 -1
  75. package/dist/components/ui/message/Message.d.ts +17 -9
  76. package/dist/components/ui/message/Message.d.ts.map +1 -1
  77. package/dist/components/ui/message/Message.styled.d.ts +17 -9
  78. package/dist/components/ui/message/Message.styled.d.ts.map +1 -1
  79. package/dist/index.d.ts +2 -2
  80. package/dist/index.d.ts.map +1 -1
  81. package/dist/index.js +2 -2
  82. package/dist/index.js.map +1 -1
  83. package/dist/scrollbars.css.d.ts +4 -0
  84. package/dist/scrollbars.css.d.ts.map +1 -0
  85. package/dist/scrollbars.css.js +34 -0
  86. package/dist/scrollbars.css.js.map +1 -0
  87. package/dist/theme.d.ts +125 -69
  88. package/dist/theme.d.ts.map +1 -1
  89. package/dist/theme.js +2 -0
  90. package/dist/theme.js.map +1 -1
  91. package/docs/assets/search.js +1 -1
  92. package/docs/classes/Drawer.html +14 -16
  93. package/docs/classes/Pop.html +14 -16
  94. package/docs/classes/ToasterProvider.html +10 -12
  95. package/docs/enums/ICON.html +14 -16
  96. package/docs/functions/Action.html +6 -8
  97. package/docs/functions/Button.html +6 -8
  98. package/docs/functions/Card.html +6 -8
  99. package/docs/functions/Checkbox.html +6 -8
  100. package/docs/functions/Choice.html +7 -9
  101. package/docs/functions/CoveringLoader.html +6 -8
  102. package/docs/functions/DirectionPad.html +6 -8
  103. package/docs/functions/EqualActions.html +6 -8
  104. package/docs/functions/FullLoader.html +6 -8
  105. package/docs/functions/HandleEsc.html +6 -8
  106. package/docs/functions/Header.html +6 -8
  107. package/docs/functions/HeaderIconAction.html +6 -8
  108. package/docs/functions/Icon-1.html +6 -8
  109. package/docs/functions/If.html +6 -8
  110. package/docs/functions/Input.html +7 -9
  111. package/docs/functions/KeyValue.html +6 -8
  112. package/docs/functions/Label.html +6 -8
  113. package/docs/functions/List-1.html +18 -10
  114. package/docs/functions/Loader.html +6 -8
  115. package/docs/functions/Loading.html +6 -8
  116. package/docs/functions/Message.html +6 -8
  117. package/docs/functions/Modal-1.html +6 -8
  118. package/docs/functions/ModalButtons-1.html +6 -8
  119. package/docs/functions/PopLoader.html +6 -8
  120. package/docs/functions/PopOption.html +6 -8
  121. package/docs/functions/SearchContainer.html +6 -8
  122. package/docs/functions/Section.html +146 -0
  123. package/docs/functions/Select.html +6 -8
  124. package/docs/functions/Selector.html +7 -9
  125. package/docs/functions/Spacer.html +6 -8
  126. package/docs/functions/Stats.html +6 -8
  127. package/docs/functions/StickyHeader-1.html +6 -8
  128. package/docs/functions/StickyHeader.Content.html +5 -7
  129. package/docs/functions/Table.html +6 -8
  130. package/docs/functions/TextArea.html +6 -8
  131. package/docs/functions/Toggle.html +6 -8
  132. package/docs/functions/getCssText.html +6 -8
  133. package/docs/functions/styled.html +6 -8
  134. package/docs/functions/useToaster.html +7 -9
  135. package/docs/index.html +6 -8
  136. package/docs/modules/List.html +10 -9
  137. package/docs/modules/Modal.html +6 -8
  138. package/docs/modules/ModalButtons.html +6 -8
  139. package/docs/modules/StickyHeader.html +6 -8
  140. package/docs/modules.html +9 -13
  141. package/docs/pages/tutorials/Test.html +6 -8
  142. package/docs/types/ThemeCSS.html +7 -9
  143. package/docs/variables/List.Header.html +8 -9
  144. package/docs/variables/List.Item.html +54 -0
  145. package/docs/variables/Modal.NegateMargin.html +5 -7
  146. package/docs/variables/ModalButtons.Button.html +5 -7
  147. package/docs/variables/cssReset.html +7 -9
  148. package/docs/variables/miuiScrollbars.html +96 -0
  149. package/esm/components/form/input/Input.css.d.ts +47 -0
  150. package/esm/components/form/input/Input.css.d.ts.map +1 -0
  151. package/esm/components/form/input/Input.css.js +48 -0
  152. package/esm/components/form/input/Input.css.js.map +1 -0
  153. package/esm/components/form/input/Input.styled.d.ts +68 -36
  154. package/esm/components/form/input/Input.styled.d.ts.map +1 -1
  155. package/esm/components/form/input/Input.styled.js +4 -49
  156. package/esm/components/form/input/Input.styled.js.map +1 -1
  157. package/esm/components/form/textarea/TextArea.d.ts.map +1 -0
  158. package/esm/components/form/textarea/TextArea.js +16 -0
  159. package/esm/components/form/textarea/TextArea.js.map +1 -0
  160. package/esm/components/form/textarea/TextArea.stories.d.ts +8 -0
  161. package/esm/components/form/textarea/TextArea.stories.d.ts.map +1 -0
  162. package/esm/components/form/textarea/TextArea.stories.js +12 -0
  163. package/esm/components/form/textarea/TextArea.stories.js.map +1 -0
  164. package/esm/components/{layout/list/Value.styled.d.ts → form/textarea/TextArea.styled.d.ts} +24 -12
  165. package/esm/components/form/textarea/TextArea.styled.d.ts.map +1 -0
  166. package/esm/components/form/textarea/TextArea.styled.js +14 -0
  167. package/esm/components/form/textarea/TextArea.styled.js.map +1 -0
  168. package/esm/components/layout/list/Header.d.ts +174 -7
  169. package/esm/components/layout/list/Header.d.ts.map +1 -1
  170. package/esm/components/layout/list/Header.js +24 -11
  171. package/esm/components/layout/list/Header.js.map +1 -1
  172. package/esm/components/layout/list/Header.stories.d.ts +8 -0
  173. package/esm/components/layout/list/Header.stories.d.ts.map +1 -0
  174. package/esm/components/layout/list/Header.stories.js +27 -0
  175. package/esm/components/layout/list/Header.stories.js.map +1 -0
  176. package/esm/components/layout/list/Item.d.ts +88 -7
  177. package/esm/components/layout/list/Item.d.ts.map +1 -1
  178. package/esm/components/layout/list/Item.js +64 -33
  179. package/esm/components/layout/list/Item.js.map +1 -1
  180. package/esm/components/layout/list/Item.stories.d.ts +10 -0
  181. package/esm/components/layout/list/Item.stories.d.ts.map +1 -0
  182. package/esm/components/layout/list/Item.stories.js +57 -0
  183. package/esm/components/layout/list/Item.stories.js.map +1 -0
  184. package/esm/components/layout/list/Label.d.ts +83 -5
  185. package/esm/components/layout/list/Label.d.ts.map +1 -1
  186. package/esm/components/layout/list/Label.js +12 -6
  187. package/esm/components/layout/list/Label.js.map +1 -1
  188. package/esm/components/layout/list/Label.stories.d.ts +8 -0
  189. package/esm/components/layout/list/Label.stories.d.ts.map +1 -0
  190. package/esm/components/layout/list/Label.stories.js +29 -0
  191. package/esm/components/layout/list/Label.stories.js.map +1 -0
  192. package/esm/components/layout/list/List.d.ts +86 -7
  193. package/esm/components/layout/list/List.d.ts.map +1 -1
  194. package/esm/components/layout/list/List.js +15 -9
  195. package/esm/components/layout/list/List.js.map +1 -1
  196. package/esm/components/layout/list/List.stories.d.ts +9 -0
  197. package/esm/components/layout/list/List.stories.d.ts.map +1 -0
  198. package/esm/components/layout/list/List.stories.js +46 -0
  199. package/esm/components/layout/list/List.stories.js.map +1 -0
  200. package/esm/components/layout/list/Value.d.ts +81 -1
  201. package/esm/components/layout/list/Value.d.ts.map +1 -1
  202. package/esm/components/layout/list/Value.js +9 -1
  203. package/esm/components/layout/list/Value.js.map +1 -1
  204. package/esm/components/layout/list/Value.stories.d.ts +8 -0
  205. package/esm/components/layout/list/Value.stories.d.ts.map +1 -0
  206. package/esm/components/layout/list/Value.stories.js +23 -0
  207. package/esm/components/layout/list/Value.stories.js.map +1 -0
  208. package/esm/components/layout/section/Section.d.ts +83 -8
  209. package/esm/components/layout/section/Section.d.ts.map +1 -1
  210. package/esm/components/layout/section/Section.js +17 -12
  211. package/esm/components/layout/section/Section.js.map +1 -1
  212. package/esm/components/layout/section/Section.stories.d.ts +8 -0
  213. package/esm/components/layout/section/Section.stories.d.ts.map +1 -0
  214. package/esm/components/layout/section/Section.stories.js +31 -0
  215. package/esm/components/layout/section/Section.stories.js.map +1 -0
  216. package/esm/components/layout/section/SectionContainer.d.ts +80 -5
  217. package/esm/components/layout/section/SectionContainer.d.ts.map +1 -1
  218. package/esm/components/layout/section/SectionContainer.js +9 -5
  219. package/esm/components/layout/section/SectionContainer.js.map +1 -1
  220. package/esm/components/ui/message/Message.d.ts +17 -9
  221. package/esm/components/ui/message/Message.d.ts.map +1 -1
  222. package/esm/components/ui/message/Message.styled.d.ts +17 -9
  223. package/esm/components/ui/message/Message.styled.d.ts.map +1 -1
  224. package/esm/index.d.ts +2 -2
  225. package/esm/index.d.ts.map +1 -1
  226. package/esm/index.js +2 -2
  227. package/esm/index.js.map +1 -1
  228. package/esm/scrollbars.css.d.ts +4 -0
  229. package/esm/scrollbars.css.d.ts.map +1 -0
  230. package/esm/scrollbars.css.js +49 -0
  231. package/esm/scrollbars.css.js.map +1 -0
  232. package/esm/theme.d.ts +125 -69
  233. package/esm/theme.d.ts.map +1 -1
  234. package/esm/theme.js +2 -0
  235. package/esm/theme.js.map +1 -1
  236. package/package.json +7 -6
  237. package/src/components/form/input/Input.css.ts +60 -0
  238. package/src/components/form/input/Input.styled.ts +4 -52
  239. package/src/components/form/textarea/TextArea.stories.tsx +21 -0
  240. package/src/components/form/textarea/TextArea.styled.ts +19 -0
  241. package/src/components/form/{TextArea.tsx → textarea/TextArea.tsx} +10 -9
  242. package/src/components/layout/list/Header.stories.tsx +40 -0
  243. package/src/components/layout/list/Header.tsx +43 -26
  244. package/src/components/layout/list/Item.stories.tsx +69 -0
  245. package/src/components/layout/list/Item.tsx +118 -46
  246. package/src/components/layout/list/Label.stories.tsx +45 -0
  247. package/src/components/layout/list/Label.tsx +21 -12
  248. package/src/components/layout/list/List.stories.tsx +84 -0
  249. package/src/components/layout/list/List.tsx +34 -23
  250. package/src/components/layout/list/Value.stories.tsx +37 -0
  251. package/src/components/layout/list/Value.tsx +15 -1
  252. package/src/components/layout/section/Section.stories.tsx +54 -0
  253. package/src/components/layout/section/Section.tsx +27 -27
  254. package/src/components/layout/section/SectionContainer.tsx +10 -13
  255. package/src/demo/components/form/Choice.tsx +3 -3
  256. package/src/demo/components/form/Form.tsx +1 -1
  257. package/src/demo/components/form/Search.tsx +3 -1
  258. package/src/demo/components/form/Toggle.tsx +3 -1
  259. package/src/demo/components/layout/card/Card.tsx +3 -3
  260. package/src/demo/components/ui/icons/Icons.tsx +3 -1
  261. package/src/demo/components/ui/keyValue/KeyValue.tsx +1 -1
  262. package/src/demo/components/ui/modal/Modal.tsx +4 -2
  263. package/src/demo/components/ui/pop/Pop.tsx +1 -1
  264. package/src/demo/componentsMap.ts +0 -52
  265. package/src/index.ts +3 -2
  266. package/src/pages/_app.tsx +2 -0
  267. package/src/scrollbars.css.ts +56 -0
  268. package/src/theme.ts +5 -3
  269. package/dist/components/form/TextArea.d.ts.map +0 -1
  270. package/dist/components/form/TextArea.js.map +0 -1
  271. package/dist/components/layout/list/Header.module.scss +0 -8
  272. package/dist/components/layout/list/Item.module.scss +0 -46
  273. package/dist/components/layout/list/Label.module.scss +0 -9
  274. package/dist/components/layout/list/List.module.scss +0 -8
  275. package/dist/components/layout/list/Value.styled.d.ts.map +0 -1
  276. package/dist/components/layout/list/Value.styled.js +0 -13
  277. package/dist/components/layout/list/Value.styled.js.map +0 -1
  278. package/dist/components/layout/section/Section.module.scss +0 -24
  279. package/dist/components/layout/section/SectionContainer.module.scss +0 -4
  280. package/docs/functions/Item-1.html +0 -109
  281. package/docs/functions/Section-1.html +0 -109
  282. package/docs/modules/Item.html +0 -64
  283. package/docs/modules/Section.html +0 -61
  284. package/docs/variables/Item.Label.html +0 -56
  285. package/docs/variables/Item.Value.html +0 -56
  286. package/docs/variables/Section.Container.html +0 -55
  287. package/esm/components/form/TextArea.d.ts.map +0 -1
  288. package/esm/components/form/TextArea.js +0 -20
  289. package/esm/components/form/TextArea.js.map +0 -1
  290. package/esm/components/layout/list/Header.module.scss +0 -8
  291. package/esm/components/layout/list/Item.module.scss +0 -46
  292. package/esm/components/layout/list/Label.module.scss +0 -9
  293. package/esm/components/layout/list/List.module.scss +0 -8
  294. package/esm/components/layout/list/Value.styled.d.ts.map +0 -1
  295. package/esm/components/layout/list/Value.styled.js +0 -10
  296. package/esm/components/layout/list/Value.styled.js.map +0 -1
  297. package/esm/components/layout/section/Section.module.scss +0 -24
  298. package/esm/components/layout/section/SectionContainer.module.scss +0 -4
  299. package/src/components/layout/list/Header.module.scss +0 -8
  300. package/src/components/layout/list/Item.module.scss +0 -46
  301. package/src/components/layout/list/Label.module.scss +0 -9
  302. package/src/components/layout/list/List.module.scss +0 -8
  303. package/src/components/layout/list/Value.styled.ts +0 -13
  304. package/src/components/layout/section/Section.module.scss +0 -24
  305. package/src/components/layout/section/SectionContainer.module.scss +0 -4
  306. package/src/demo/components/form/Input.tsx +0 -28
  307. package/src/demo/components/layout/list/Header.tsx +0 -23
  308. package/src/demo/components/layout/list/Inset.tsx +0 -23
  309. package/src/demo/components/layout/list/ItemRatio.tsx +0 -20
  310. package/src/demo/components/layout/list/Label.tsx +0 -31
  311. package/src/demo/components/layout/list/List.Item.module.scss +0 -7
  312. package/src/demo/components/layout/list/List.Item.tsx +0 -24
  313. package/src/demo/components/layout/list/Selection.tsx +0 -16
  314. package/src/demo/components/layout/list/Value.module.scss +0 -4
  315. package/src/demo/components/layout/list/Value.tsx +0 -25
  316. package/src/demo/components/layout/section/Section.tsx +0 -33
  317. package/src/demo/components/ui/message/Message.tsx +0 -27
  318. /package/dist/components/form/{TextArea.d.ts → textarea/TextArea.d.ts} +0 -0
  319. /package/esm/components/form/{TextArea.d.ts → textarea/TextArea.d.ts} +0 -0
@@ -1,32 +1,49 @@
1
1
  import React from "react";
2
2
 
3
- import classnames from "classnames";
4
-
5
- import { makeVariants } from "../../../utils/index.js";
6
-
7
- import styles from "./Item.module.scss";
8
- import headerStyles from "./Header.module.scss";
9
-
10
- type Variant = "inset";
11
-
12
- interface Props {
13
- className?: string;
14
- variant?: Variant | Variant[];
15
- children: React.ReactNode;
16
- }
17
-
18
- const Header: React.FC<Props> = (props) => {
19
- const v = makeVariants(props.variant);
20
-
21
- const cls = classnames(props.className, styles.item, headerStyles.header, {
22
- [styles.inset]: v.includes("inset"),
23
- });
24
-
25
- // @TODO way to use h1, h2, h3 instead of div
3
+ import type { VariantProps } from "@stitches/react";
4
+
5
+ import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme.js";
6
+
7
+ import { Item, ItemInnerContainerClassName } from "./Item.js";
8
+
9
+ const StyledContent = styled("div", {});
10
+
11
+ const StyledHeader = styled(Item, {
12
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
13
+ paddingTop: dimensionsPxToRem(80),
14
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
15
+ paddingBottom: dimensionsPxToRem(40),
16
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
17
+ fontSize: fontPxToRem(26),
18
+ color: "$sub",
19
+ textTransform: "uppercase",
20
+
21
+ [`& ${ItemInnerContainerClassName}`]: {
22
+ minHeight: 0,
23
+ },
24
+
25
+ variants: {
26
+ inset: {
27
+ true: {
28
+ paddingLeft: 0,
29
+ paddingRight: 0,
30
+ },
31
+ },
32
+ },
33
+ });
34
+
35
+ type StyledHeaderProps = React.ComponentProps<typeof StyledHeader>;
36
+ type Variants = VariantProps<typeof StyledHeader>;
37
+
38
+ /**
39
+ * Use this to render a header within a `List`.
40
+ * Use `as` prop to define which tag to use.
41
+ */
42
+ const Header: React.FC<StyledHeaderProps & Variants & { as?: string }> = ({ as, ...props }) => {
26
43
  return (
27
- <li className={cls}>
28
- <div>{props.children}</div>
29
- </li>
44
+ <StyledHeader {...props}>
45
+ <StyledContent {...(as ? { as } : undefined)}>{props.children}</StyledContent>
46
+ </StyledHeader>
30
47
  );
31
48
  };
32
49
 
@@ -0,0 +1,69 @@
1
+ import React from "react";
2
+
3
+ import type { StoryObj, Meta } from "@storybook/react";
4
+
5
+ import { NextLink } from "../../../demo/NextLink.js";
6
+
7
+ import { Item } from "./Item.js";
8
+ import { List } from "./List.js";
9
+
10
+ const meta: Meta = {
11
+ title: "Components/Layout/List/Item",
12
+ component: Item,
13
+ tags: ["autodocs", "layout"],
14
+ argTypes: {
15
+ inset: {
16
+ type: "boolean",
17
+ },
18
+ Link: {
19
+ controls: "none",
20
+ },
21
+ },
22
+ };
23
+
24
+ type Story = StoryObj<typeof Item>;
25
+
26
+ const Primary: Story = {
27
+ args: {
28
+ children: "I am a list item",
29
+ inset: false,
30
+ Link: NextLink,
31
+ },
32
+ render: (args) => {
33
+ return <List><Item {...args} /></List>;
34
+ },
35
+ };
36
+
37
+ const Alignment: Story = {
38
+ args: {
39
+ children: [
40
+ <div key={"1st"}>first</div>,
41
+ <div key={"2nd"}>2nd</div>,
42
+ <div key={"3rd"}>last</div>,
43
+ ],
44
+ ratio: "1/2/1",
45
+ },
46
+ render: (args) => {
47
+ return <List><Item {...args} /></List>;
48
+ },
49
+ };
50
+
51
+ const OnClick: Story = {
52
+ args: {
53
+ children: "I am a list item, but I will render a button, click me",
54
+ onClick: () => {
55
+ alert("Clicked!");
56
+ },
57
+ },
58
+ render: (args) => {
59
+ return <List><Item {...args} /></List>;
60
+ },
61
+ };
62
+
63
+ export {
64
+ Primary,
65
+ Alignment,
66
+ OnClick,
67
+ };
68
+
69
+ export default meta;
@@ -1,11 +1,8 @@
1
1
  import React from "react";
2
2
 
3
- import classnames from "classnames";
4
-
5
- import { makeVariants } from "../../../utils/index.js";
6
3
  import { ICON, Icon } from "../../icons/Icon.js";
4
+ import { dimensionsPxToRem, fontPxToRem, pxToRem, styled } from "../../../theme.js";
7
5
 
8
- import styles from "./Item.module.scss";
9
6
  import { Value } from "./Value.js";
10
7
  import { Label } from "./Label.js";
11
8
 
@@ -14,18 +11,12 @@ interface LinkProps {
14
11
  children: React.ReactNode;
15
12
  }
16
13
 
17
- type Variant = "inset";
18
-
19
14
  interface Props {
20
15
  href?: string;
21
16
  to?: string;
22
17
  onClick?: () => void;
23
- className?: string;
24
18
  Link?: React.ComponentClass<LinkProps> | React.FC<LinkProps>;
25
19
  ratio?: string; // @TODO number/number/number/.. type?
26
- variant?: Variant | Variant[];
27
- selected?: boolean | undefined;
28
- children: React.ReactNode;
29
20
  }
30
21
 
31
22
  interface SubComponents {
@@ -33,32 +24,101 @@ interface SubComponents {
33
24
  Value: typeof Value;
34
25
  }
35
26
 
36
- const icon = <Icon className={styles.icon} name={ICON.forward} />;
37
- const noIcon = <span className={styles.icon} />;
38
-
39
- // eslint-disable-next-line max-statements,max-lines-per-function
40
- const Item: React.FC<Props> & SubComponents = (props) => {
41
- const { className, children, href, to, onClick, Link, ratio, variant, selected, ...restProps } = props;
42
- const v = makeVariants(variant);
43
- const cls = classnames(styles.item, className);
44
-
45
- const innerCls = classnames(styles.content, {
46
- [styles.inset]: v.includes("inset"),
47
- [styles.selected]: selected,
48
- });
27
+ const iconStyles = {
28
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
29
+ width: pxToRem(7),
30
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
31
+ marginRight: pxToRem(10),
32
+ display: "inline-block",
33
+ }; // TODO satisfies
34
+
35
+ const StyledIcon = styled(Icon, iconStyles);
36
+ const StyledNoIcon = styled("span", iconStyles);
37
+
38
+ const icon = <StyledIcon name={ICON.forward} />;
39
+ const noIcon = <StyledNoIcon />;
40
+
41
+ const StyledInnerContainer = styled("div", {
42
+ display: "flex",
43
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
44
+ minHeight: dimensionsPxToRem(174),
45
+ alignItems: "center",
46
+ gap: "1rem",
47
+
48
+ border: "none",
49
+ background: "none",
50
+ width: "100%",
51
+ textAlign: "left",
52
+ fontFamily: "inherit",
53
+ fontSize: "inherit",
54
+ });
55
+
56
+ const ItemInnerContainerClassName = StyledInnerContainer.toString();
57
+
58
+ const StyledItem = styled("li", {
59
+ "listStyleType": "none",
60
+ "margin": 0,
61
+ "padding": 0,
62
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
63
+ "fontSize": fontPxToRem(34),
64
+
65
+ "&:not(:first-child)": {
66
+ borderTop: "0.37px solid $headerBorder",
67
+ },
68
+
69
+ "> *": {
70
+ display: "block",
71
+ padding: 0,
72
+ textDecoration: "none",
73
+ },
74
+
75
+ "variants": {
76
+ inset: {
77
+ true: {
78
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
79
+ paddingLeft: dimensionsPxToRem(37),
80
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
81
+ paddingRight: dimensionsPxToRem(37),
82
+ },
83
+ },
84
+ selected: {
85
+ true: {
86
+ color: "$mainColor",
87
+ },
88
+ },
89
+ },
90
+ });
91
+
92
+ type StyledItemProps = React.ComponentProps<typeof StyledItem>;
93
+
94
+ /**
95
+ * Represents a single item in a list.
96
+ *
97
+ * It has two subcomponents:
98
+ * - `Label`: for rendering the label with sublabel (usually on the left)
99
+ * - `Value`: for rendering the value (usually on the right)
100
+ *
101
+ * It can be however used with any children, its children are rendered in a flexbox container, `ratio` prop can be used
102
+ * to set the flex ratio of each child.
103
+ *
104
+ * It has two variants:
105
+ * - `inset`: which adds padding to the left and right side of the item - it should be used when the list is inset (it's
106
+ * applied automatically if used within `List` component)
107
+ * - `selected`: which renders an arrow on the left side, useful when creating a radio-like list (please note that not
108
+ * sending `selected` is different from sending `false`)
109
+ *
110
+ * It accepts few more props:
111
+ * - `href`: if given it will render an anchor tag with the given href
112
+ * - `to`: if given it will render an anchor tag wrapped in a link using the given `Link` component
113
+ * - `onClick`: if given it will render a button tag with the given onClick handler (it can be passed with `href` too)
114
+ */
115
+ const Item: React.FC<StyledItemProps & Props> & SubComponents = ({ href, to, onClick, Link, ratio, ...props }) => {
116
+ const r = ratio ? ratio.split("/") : [];
49
117
 
50
- const pre = typeof selected === "boolean"
51
- ? (
52
- selected ? icon : noIcon
53
- )
118
+ const pre = typeof props.selected === "boolean"
119
+ ? (props.selected ? icon : noIcon)
54
120
  : null;
55
121
 
56
- const liProps = {
57
- className: cls,
58
- };
59
-
60
- const r = ratio ? ratio.split("/") : [];
61
-
62
122
  const ren = React.Children.map(props.children, (child, index) => {
63
123
  let flex = undefined;
64
124
  if (!r.length && child && typeof child === "object" && "type" in child && child.type === Value) {
@@ -75,28 +135,40 @@ const Item: React.FC<Props> & SubComponents = (props) => {
75
135
  throw new TypeError("`to` prop given without `Link` component");
76
136
  }
77
137
 
78
- return <li {...liProps}><Link href={to} {...restProps}><a className={innerCls}>{ren}</a></Link></li>;
138
+ return (
139
+ <StyledItem {...props}>
140
+ <Link href={to}><StyledInnerContainer as={"a"} href={to}>{ren}</StyledInnerContainer></Link>
141
+ </StyledItem>
142
+ );
79
143
  }
144
+
80
145
  if (href) {
81
- const aProps: typeof restProps & { onClick?: Props["onClick"] } = { ...restProps };
82
- if (onClick) {
83
- aProps.onClick = onClick;
84
- }
85
- return <li {...liProps}><a href={href} {...aProps} className={innerCls}>{ren}</a></li>;
146
+ return (
147
+ <StyledItem {...props}>
148
+ {/* eslint-disable-next-line react/jsx-handler-names */}
149
+ <StyledInnerContainer as={"a"} href={href} onClick={onClick}>{ren}</StyledInnerContainer>
150
+ </StyledItem>
151
+ );
86
152
  }
153
+
87
154
  if (onClick) {
88
155
  return (
89
- <li {...liProps}>
90
- <button className={classnames(styles.button, innerCls)} onClick={props.onClick} {...restProps}>
91
- {ren}
92
- </button>
93
- </li>
156
+ <StyledItem {...props}>
157
+ {/* eslint-disable-next-line react/jsx-handler-names */}
158
+ <StyledInnerContainer as={"button"} onClick={onClick}>{ren}</StyledInnerContainer>
159
+ </StyledItem>
94
160
  );
95
161
  }
96
- return <li {...liProps}><div {...restProps} className={innerCls}>{ren}</div></li>;
162
+
163
+ return <StyledItem {...props}><StyledInnerContainer>{ren}</StyledInnerContainer></StyledItem>;
97
164
  };
98
165
 
99
166
  Item.Label = Label;
100
167
  Item.Value = Value;
101
168
 
102
- export { Item };
169
+ export { Item, ItemInnerContainerClassName };
170
+
171
+ export type {
172
+ Props as ItemProps,
173
+ SubComponents as ItemSubComponents,
174
+ };
@@ -0,0 +1,45 @@
1
+ import React from "react";
2
+
3
+ import type { StoryObj, Meta } from "@storybook/react";
4
+
5
+ import { Label } from "./Label.js";
6
+ import { List } from "./List.js";
7
+ import { Item } from "./Item.js";
8
+
9
+ const meta: Meta = {
10
+ title: "Components/Layout/List/Label",
11
+ component: Label,
12
+ tags: ["autodocs", "layout"],
13
+ argTypes: {
14
+ sub: {
15
+ type: "string",
16
+ },
17
+ },
18
+ };
19
+
20
+ type Story = StoryObj<typeof Label>;
21
+
22
+ const Primary: Story = {
23
+ args: {
24
+ children: "I am a label",
25
+ sub: "Sub text",
26
+ },
27
+ render: (args) => {
28
+ return (
29
+ <List>
30
+ <Item>
31
+ <Label {...args} />
32
+ </Item>
33
+ <Item>
34
+ I am classic list item
35
+ </Item>
36
+ </List>
37
+ );
38
+ },
39
+ };
40
+
41
+ export {
42
+ Primary,
43
+ };
44
+
45
+ export default meta;
@@ -1,24 +1,33 @@
1
1
  import React from "react";
2
2
  import type { ReactNode } from "react";
3
3
 
4
- import classnames from "classnames";
4
+ import { dimensionsPxToRem, fontPxToRem, styled } from "../../../theme.js";
5
5
 
6
- import styles from "./Label.module.scss";
6
+ const SubLabel = styled("div", {
7
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
8
+ fontSize: fontPxToRem(27),
9
+ color: "$sub",
10
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
11
+ marginTop: fontPxToRem(27 / 3),
12
+ });
7
13
 
8
- interface Props {
9
- sub?: ReactNode;
10
- className?: string;
11
- children: React.ReactNode;
12
- }
14
+ const StyledLabel = styled("div", {
15
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
16
+ padding: `${dimensionsPxToRem(54)} 0`,
17
+ });
13
18
 
14
- const Label: React.FC<Props> = (props) => {
15
- const sub = props.sub ? <div className={styles.sub}>{props.sub}</div> : null;
19
+ type StyledLabelProps = React.ComponentProps<typeof StyledLabel>;
16
20
 
21
+ /**
22
+ * Use this to render a label within `Item`, optionally you can render a sublabel as well (with a tip message for
23
+ * example).
24
+ */
25
+ const Label: React.FC<StyledLabelProps & { sub?: ReactNode }> = ({ sub, ...props }) => {
17
26
  return (
18
- <div className={classnames(styles.root, props.className)}>
27
+ <StyledLabel {...props}>
19
28
  <div>{props.children}</div>
20
- {sub}
21
- </div>
29
+ {sub && <SubLabel>{sub}</SubLabel>}
30
+ </StyledLabel>
22
31
  );
23
32
  };
24
33
 
@@ -0,0 +1,84 @@
1
+ import React from "react";
2
+
3
+ import type { StoryObj, Meta } from "@storybook/react";
4
+
5
+ import { Icon, ICON } from "../../icons/Icon.js";
6
+
7
+ import { List } from "./List.js";
8
+
9
+ const meta: Meta = {
10
+ title: "Components/Layout/List/List",
11
+ component: List,
12
+ tags: ["autodocs", "layout"],
13
+ argTypes: {
14
+ inset: {
15
+ type: "boolean",
16
+ },
17
+ },
18
+ };
19
+
20
+ type Story = StoryObj<typeof List>;
21
+
22
+ const Primary: Story = {
23
+ args: {
24
+ inset: false,
25
+ },
26
+ render: (args) => {
27
+ return (
28
+ <List {...args}>
29
+ <List.Item>I am a list item</List.Item>
30
+ <List.Item>I am a list item</List.Item>
31
+ </List>
32
+ );
33
+ },
34
+ };
35
+
36
+ const FullFeaturedExample: Story = {
37
+ render: (args) => {
38
+ return (
39
+ <List>
40
+ <List.Header>GPS settings</List.Header>
41
+ <List.Item>
42
+ <List.Item.Label sub={"Higher precision means higher battery usage"}>
43
+ GPS precision
44
+ </List.Item.Label>
45
+ <List.Item.Value>
46
+ Low
47
+ </List.Item.Value>
48
+ <Icon name={ICON.forward} />
49
+ </List.Item>
50
+ <List.Item>
51
+ <List.Item>
52
+ Something
53
+ </List.Item>
54
+ </List.Item>
55
+ <List.Header>
56
+ Last trips
57
+ </List.Header>
58
+ <List.Item>
59
+ Portugal
60
+ </List.Item>
61
+ <List.Item>
62
+ <List.Item.Label sub={"Visited 2 times in last year"}>
63
+ Poland
64
+ </List.Item.Label>
65
+ </List.Item>
66
+ <List.Item>
67
+ Sweden
68
+ </List.Item>
69
+ <List.Header>
70
+ Choose one option
71
+ </List.Header>
72
+ <List.Item selected={true}>yes</List.Item>
73
+ <List.Item selected={false}>no</List.Item>
74
+ </List>
75
+ );
76
+ },
77
+ };
78
+
79
+ export {
80
+ Primary,
81
+ FullFeaturedExample,
82
+ };
83
+
84
+ export default meta;
@@ -1,47 +1,58 @@
1
1
  import React from "react";
2
2
 
3
- import classnames from "classnames";
4
-
5
- import { makeVariants } from "../../../utils/index.js";
3
+ import { pxToRem, styled } from "../../../theme.js";
6
4
 
7
5
  import { Header } from "./Header.js";
8
6
  import { Item } from "./Item.js";
9
- import styles from "./List.module.scss";
10
-
11
- type Variant = "inset";
12
-
13
- interface Props {
14
- className?: string;
15
- variant?: Variant | Variant[];
16
- children: React.ReactNode;
17
- }
18
7
 
19
8
  interface SubComponents {
20
9
  Header: typeof Header;
10
+ Item: typeof Item;
21
11
  }
22
12
 
23
- const List: React.FC<Props> & SubComponents = (props) => {
24
- const v = makeVariants(props.variant);
25
-
13
+ const StyledList = styled("ul", {
14
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
15
+ margin: `0 ${pxToRem(23)}`,
16
+ padding: 0,
17
+
18
+ variants: {
19
+ inset: {
20
+ true: {
21
+ margin: 0,
22
+ },
23
+ },
24
+ },
25
+ });
26
+
27
+ type StyledListProps = React.ComponentProps<typeof StyledList>;
28
+
29
+ /**
30
+ * Component for rendering menu lists.
31
+ *
32
+ * It has two subcomponents:
33
+ * - `Item`: for rendering list items
34
+ * - `Header`: for rendering list headers
35
+ *
36
+ * List has one variant: `inset`, which removes the margin from the list. If used it will be automatically applied to
37
+ * all children.
38
+ *
39
+ * See `Item` and `Header` for more information about their usage.
40
+ */
41
+ const List: React.FC<StyledListProps> & SubComponents = (props) => {
26
42
  const chld = React.Children.map(props.children, (child) => {
27
43
  if (child && typeof child === "object" && "type" in child && (child.type === Item || child.type === Header)) {
28
44
  return React.cloneElement(child, {
29
- // @TODO this will override but should merge?
30
- variant: props.variant,
45
+ inset: props.inset,
31
46
  });
32
47
  }
33
48
  return child;
34
49
  });
35
50
 
36
- const cls = classnames(props.className, styles.list, {
37
- [styles.inset]: v.includes("inset"),
38
- });
39
-
40
51
  return (
41
- <ul className={cls}>{chld}</ul>
52
+ <StyledList {...props}>{chld}</StyledList>
42
53
  );
43
54
  };
44
-
45
55
  List.Header = Header;
56
+ List.Item = Item;
46
57
 
47
58
  export { List };
@@ -0,0 +1,37 @@
1
+ import React from "react";
2
+
3
+ import type { StoryObj, Meta } from "@storybook/react";
4
+
5
+ import { Value } from "./Value.js";
6
+ import { List } from "./List.js";
7
+ import { Item } from "./Item.js";
8
+
9
+ const meta: Meta = {
10
+ title: "Components/Layout/List/Value",
11
+ component: Value,
12
+ tags: ["autodocs", "layout"],
13
+ };
14
+
15
+ type Story = StoryObj<typeof Value>;
16
+
17
+ const Primary: Story = {
18
+ args: {
19
+ children: "23,4*C",
20
+ },
21
+ render: (args) => {
22
+ return (
23
+ <List>
24
+ <Item>
25
+ <div>Some label</div>
26
+ <Value {...args} />
27
+ </Item>
28
+ </List>
29
+ );
30
+ },
31
+ };
32
+
33
+ export {
34
+ Primary,
35
+ };
36
+
37
+ export default meta;
@@ -1 +1,15 @@
1
- export { StyledValue as Value } from "./Value.styled.js";
1
+ import { fontPxToRem, styled } from "../../../theme.js";
2
+
3
+ /**
4
+ * Use this to render a value within `Item`. It's most useful when used with `Item.Label`.
5
+ */
6
+ const Value = styled("div", {
7
+ color: "$icon",
8
+ // eslint-disable-next-line @typescript-eslint/no-magic-numbers
9
+ fontSize: fontPxToRem(26),
10
+ display: "flex",
11
+ justifyContent: "flex-end",
12
+ flex: 1,
13
+ });
14
+
15
+ export { Value };