@inglorious/ui 0.1.0 → 1.0.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 (283) hide show
  1. package/README.md +45 -0
  2. package/package.json +190 -15
  3. package/src/all.css +7 -0
  4. package/src/controls/button/button.stories.js +35 -15
  5. package/src/controls/button/index.js +1 -3
  6. package/src/controls/button/style.css +80 -37
  7. package/src/controls/button/template.js +23 -26
  8. package/src/controls/button-group/button-group.stories.js +19 -15
  9. package/src/controls/button-group/index.js +1 -2
  10. package/src/controls/button-group/style.css +0 -7
  11. package/src/controls/button-group/template.js +46 -56
  12. package/src/controls/checkbox/checkbox.stories.js +16 -13
  13. package/src/controls/checkbox/index.js +1 -2
  14. package/src/controls/checkbox/style.css +23 -2
  15. package/src/controls/checkbox/template.js +20 -18
  16. package/src/controls/combobox/combobox.stories.js +92 -0
  17. package/src/controls/{select → combobox}/handlers.js +8 -5
  18. package/src/controls/combobox/helpers.js +91 -0
  19. package/src/controls/combobox/index.js +43 -0
  20. package/src/controls/combobox/style.css +203 -0
  21. package/src/controls/combobox/template.js +340 -0
  22. package/src/controls/controls.css +12 -0
  23. package/src/controls/fab/fab.stories.js +11 -11
  24. package/src/controls/fab/index.js +1 -2
  25. package/src/controls/fab/template.js +21 -19
  26. package/src/controls/icon-button/icon-button.stories.js +8 -10
  27. package/src/controls/icon-button/index.js +1 -2
  28. package/src/controls/icon-button/template.js +13 -19
  29. package/src/controls/input/index.js +1 -2
  30. package/src/controls/input/input.stories.js +24 -23
  31. package/src/controls/input/style.css +9 -7
  32. package/src/controls/input/template.js +28 -31
  33. package/src/controls/radio-group/index.js +1 -2
  34. package/src/controls/radio-group/radio-group.stories.js +11 -8
  35. package/src/controls/radio-group/style.css +22 -1
  36. package/src/controls/radio-group/template.js +20 -15
  37. package/src/controls/rating/index.js +1 -2
  38. package/src/controls/rating/rating.stories.js +7 -10
  39. package/src/controls/rating/style.css +1 -2
  40. package/src/controls/rating/template.js +20 -17
  41. package/src/controls/select/helpers.js +2 -21
  42. package/src/controls/select/index.js +1 -13
  43. package/src/controls/select/select.stories.js +68 -64
  44. package/src/controls/select/style.css +66 -189
  45. package/src/controls/select/template.js +77 -406
  46. package/src/controls/slider/index.js +1 -2
  47. package/src/controls/slider/slider.stories.js +15 -12
  48. package/src/controls/slider/style.css +24 -3
  49. package/src/controls/slider/template.js +30 -23
  50. package/src/controls/switch/index.js +1 -2
  51. package/src/controls/switch/style.css +23 -2
  52. package/src/controls/switch/switch.stories.js +14 -11
  53. package/src/controls/switch/template.js +18 -16
  54. package/src/data-display/avatar/avatar.stories.js +106 -0
  55. package/src/data-display/avatar/index.js +3 -0
  56. package/src/data-display/avatar/style.css +64 -0
  57. package/src/data-display/avatar/template.js +81 -0
  58. package/src/data-display/badge/badge.stories.js +64 -0
  59. package/src/data-display/badge/index.js +3 -0
  60. package/src/data-display/badge/style.css +84 -0
  61. package/src/data-display/badge/template.js +46 -0
  62. package/src/data-display/chip/chip.stories.js +57 -0
  63. package/src/data-display/chip/index.js +3 -0
  64. package/src/data-display/chip/style.css +84 -0
  65. package/src/data-display/chip/template.js +32 -0
  66. package/src/data-display/data-display.css +11 -0
  67. package/src/data-display/data-grid/base.css +58 -0
  68. package/src/data-display/data-grid/data-grid.stories.js +158 -0
  69. package/src/data-display/data-grid/filters/helpers.js +8 -0
  70. package/src/data-display/data-grid/filters/index.js +21 -0
  71. package/src/data-display/data-grid/filters/input.js +24 -0
  72. package/src/data-display/data-grid/filters/range.js +48 -0
  73. package/src/data-display/data-grid/filters/select.js +17 -0
  74. package/src/data-display/data-grid/handlers.js +523 -0
  75. package/src/data-display/data-grid/helpers.js +248 -0
  76. package/src/data-display/data-grid/index.js +64 -0
  77. package/src/data-display/data-grid/style.css +14 -0
  78. package/src/data-display/data-grid/template.js +458 -0
  79. package/src/data-display/data-grid/theme.css +148 -0
  80. package/src/data-display/divider/divider.stories.js +48 -0
  81. package/src/data-display/divider/index.js +3 -0
  82. package/src/data-display/divider/style.css +18 -0
  83. package/src/data-display/divider/template.js +17 -0
  84. package/src/data-display/icon/icon-implementations.mdx +160 -0
  85. package/src/data-display/icon/icon-utf8.stories.js +156 -0
  86. package/src/data-display/icon/icon.stories.js +38 -0
  87. package/src/data-display/icon/index.js +3 -0
  88. package/src/data-display/icon/style.css +17 -0
  89. package/src/data-display/icon/template.js +19 -0
  90. package/src/data-display/list/handlers.js +25 -0
  91. package/src/data-display/list/index.js +4 -0
  92. package/src/data-display/list/list.stories.js +187 -0
  93. package/src/data-display/list/style.css +119 -0
  94. package/src/data-display/list/template.js +302 -0
  95. package/src/data-display/material-icon/index.js +3 -0
  96. package/src/data-display/material-icon/material-icon.stories.js +99 -0
  97. package/src/data-display/material-icon/style.css +27 -0
  98. package/src/data-display/material-icon/template.js +21 -0
  99. package/src/data-display/table/index.js +1 -0
  100. package/src/data-display/table/style.css +42 -0
  101. package/src/data-display/table/table.stories.js +40 -0
  102. package/src/data-display/table/template.js +114 -0
  103. package/src/data-display/tooltip/index.js +3 -0
  104. package/src/data-display/tooltip/style.css +57 -0
  105. package/src/data-display/tooltip/template.js +58 -0
  106. package/src/data-display/tooltip/tooltip.stories.js +44 -0
  107. package/src/data-display/typography/index.js +3 -0
  108. package/src/data-display/typography/style.css +49 -0
  109. package/src/data-display/typography/template.js +110 -0
  110. package/src/data-display/typography/typography.stories.js +48 -0
  111. package/src/data-display/virtual-list/handlers.js +68 -0
  112. package/src/data-display/virtual-list/index.js +4 -0
  113. package/src/data-display/virtual-list/template.js +101 -0
  114. package/src/examples/dashboard/app-drawer.js +255 -0
  115. package/src/examples/dashboard/app-header.js +149 -0
  116. package/src/examples/dashboard/dashboard.js +85 -0
  117. package/src/examples/dashboard/dashboard.stories.js +47 -0
  118. package/src/examples/dashboard/data.js +205 -0
  119. package/src/examples/dashboard/mode.js +27 -0
  120. package/src/examples/dashboard/primitive-content.js +1325 -0
  121. package/src/examples/dashboard/primitive-section.js +158 -0
  122. package/src/examples/dashboard/router.js +13 -0
  123. package/src/examples/dashboard/social-card.js +73 -0
  124. package/src/examples/dashboard/stat-card.js +84 -0
  125. package/src/examples/dashboard/style.css +339 -0
  126. package/src/examples/dashboard/theme-utils.js +95 -0
  127. package/src/examples/dashboard/theme.js +27 -0
  128. package/src/examples/dashboard/traffic-card.js +108 -0
  129. package/src/examples/dashboard/traffic-sales-card.js +267 -0
  130. package/src/feedback/alert/alert.stories.js +70 -0
  131. package/src/feedback/alert/index.js +3 -0
  132. package/src/feedback/alert/style.css +98 -0
  133. package/src/feedback/alert/template.js +74 -0
  134. package/src/feedback/backdrop/backdrop.stories.js +21 -0
  135. package/src/feedback/backdrop/index.js +3 -0
  136. package/src/feedback/backdrop/style.css +25 -0
  137. package/src/feedback/backdrop/template.js +31 -0
  138. package/src/feedback/dialog/dialog.stories.js +27 -0
  139. package/src/feedback/dialog/index.js +3 -0
  140. package/src/feedback/dialog/style.css +68 -0
  141. package/src/feedback/dialog/template.js +64 -0
  142. package/src/feedback/feedback.css +6 -0
  143. package/src/feedback/progress/index.js +3 -0
  144. package/src/feedback/progress/progress.stories.js +54 -0
  145. package/src/feedback/progress/style.css +95 -0
  146. package/src/feedback/progress/template.js +88 -0
  147. package/src/feedback/skeleton/index.js +3 -0
  148. package/src/feedback/skeleton/skeleton.stories.js +44 -0
  149. package/src/feedback/skeleton/style.css +41 -0
  150. package/src/feedback/skeleton/template.js +48 -0
  151. package/src/feedback/snackbar/index.js +3 -0
  152. package/src/feedback/snackbar/snackbar.stories.js +25 -0
  153. package/src/feedback/snackbar/style.css +64 -0
  154. package/src/feedback/snackbar/template.js +55 -0
  155. package/src/index.js +32 -1
  156. package/src/layout/container/container.stories.js +105 -0
  157. package/src/layout/container/index.js +3 -0
  158. package/src/layout/container/style.css +34 -0
  159. package/src/layout/container/template.js +119 -0
  160. package/src/layout/flex/flex.stories.js +28 -10
  161. package/src/layout/flex/index.js +1 -2
  162. package/src/layout/flex/style.css +20 -0
  163. package/src/layout/flex/template.js +40 -13
  164. package/src/layout/grid/grid.stories.js +46 -30
  165. package/src/layout/grid/index.js +1 -2
  166. package/src/layout/grid/style.css +20 -0
  167. package/src/layout/grid/template.js +100 -20
  168. package/src/layout/layout.css +3 -0
  169. package/src/navigation/bottom-navigation/bottom-navigation.stories.js +33 -0
  170. package/src/navigation/bottom-navigation/index.js +1 -0
  171. package/src/navigation/bottom-navigation/style.css +32 -0
  172. package/src/navigation/bottom-navigation/template.js +74 -0
  173. package/src/navigation/breadcrumbs/breadcrumbs.stories.js +33 -0
  174. package/src/navigation/breadcrumbs/index.js +1 -0
  175. package/src/navigation/breadcrumbs/style.css +27 -0
  176. package/src/navigation/breadcrumbs/template.js +79 -0
  177. package/src/navigation/drawer/drawer.stories.js +60 -0
  178. package/src/navigation/drawer/index.js +3 -0
  179. package/src/navigation/drawer/style.css +125 -0
  180. package/src/navigation/drawer/template.js +131 -0
  181. package/src/navigation/link/index.js +3 -0
  182. package/src/navigation/link/link.stories.js +53 -0
  183. package/src/navigation/link/style.css +40 -0
  184. package/src/navigation/link/template.js +53 -0
  185. package/src/navigation/menu/index.js +1 -0
  186. package/src/navigation/menu/menu.stories.js +36 -0
  187. package/src/navigation/menu/style.css +44 -0
  188. package/src/navigation/menu/template.js +81 -0
  189. package/src/navigation/navigation.css +9 -0
  190. package/src/navigation/pagination/index.js +1 -0
  191. package/src/navigation/pagination/pagination.stories.js +61 -0
  192. package/src/navigation/pagination/style.css +29 -0
  193. package/src/navigation/pagination/template.js +140 -0
  194. package/src/navigation/speed-dial/index.js +1 -0
  195. package/src/navigation/speed-dial/speed-dial.stories.js +40 -0
  196. package/src/navigation/speed-dial/style.css +38 -0
  197. package/src/navigation/speed-dial/template.js +68 -0
  198. package/src/navigation/stepper/index.js +1 -0
  199. package/src/navigation/stepper/stepper.stories.js +35 -0
  200. package/src/navigation/stepper/style.css +49 -0
  201. package/src/navigation/stepper/template.js +61 -0
  202. package/src/navigation/tabs/index.js +1 -0
  203. package/src/navigation/tabs/style.css +35 -0
  204. package/src/navigation/tabs/tabs.stories.js +40 -0
  205. package/src/navigation/tabs/template.js +79 -0
  206. package/src/overview.mdx +39 -0
  207. package/src/stories/notifyStory.js +22 -25
  208. package/src/styles/base.css +2 -0
  209. package/src/styles/reset.css +15 -0
  210. package/src/{themes → styles/themes}/bootstrap.css +2 -0
  211. package/src/{themes → styles/themes}/inglorious.css +9 -1
  212. package/src/{themes → styles/themes}/material.css +2 -0
  213. package/src/{tokens/index.css → styles/tokens.css} +9 -0
  214. package/src/surfaces/accordion/accordion.stories.js +60 -0
  215. package/src/surfaces/accordion/index.js +1 -0
  216. package/src/surfaces/accordion/style.css +64 -0
  217. package/src/surfaces/accordion/template.js +85 -0
  218. package/src/surfaces/app-bar/app-bar.stories.js +109 -0
  219. package/src/surfaces/app-bar/index.js +3 -0
  220. package/src/surfaces/app-bar/style.css +109 -0
  221. package/src/surfaces/app-bar/template.js +78 -0
  222. package/src/surfaces/card/card.stories.js +108 -0
  223. package/src/surfaces/card/index.js +1 -0
  224. package/src/surfaces/card/style.css +107 -0
  225. package/src/surfaces/card/template.js +163 -0
  226. package/src/surfaces/paper/index.js +3 -0
  227. package/src/surfaces/paper/paper.stories.js +97 -0
  228. package/src/surfaces/paper/style.css +73 -0
  229. package/src/surfaces/paper/template.js +76 -0
  230. package/src/surfaces/surfaces.css +4 -0
  231. package/types/controls/button-group.d.ts +8 -7
  232. package/types/controls/button.d.ts +10 -7
  233. package/types/controls/checkbox.d.ts +8 -6
  234. package/types/controls/combobox.d.ts +66 -0
  235. package/types/controls/fab.d.ts +6 -5
  236. package/types/controls/icon-button.d.ts +8 -7
  237. package/types/controls/input.d.ts +18 -11
  238. package/types/controls/radio-group.d.ts +7 -5
  239. package/types/controls/rating.d.ts +6 -5
  240. package/types/controls/select.d.ts +11 -34
  241. package/types/controls/slider.d.ts +8 -6
  242. package/types/controls/switch.d.ts +7 -5
  243. package/types/data-display/avatar.d.ts +30 -0
  244. package/types/data-display/badge.d.ts +20 -0
  245. package/types/data-display/chip.d.ts +25 -0
  246. package/types/data-display/data-grid.d.ts +151 -0
  247. package/types/data-display/divider.d.ts +14 -0
  248. package/types/data-display/icon.d.ts +16 -0
  249. package/types/data-display/list.d.ts +66 -0
  250. package/types/data-display/material-icon.d.ts +15 -0
  251. package/types/data-display/table.d.ts +45 -0
  252. package/types/data-display/tooltip.d.ts +20 -0
  253. package/types/data-display/typography.d.ts +28 -0
  254. package/types/data-display/virtual-list.d.ts +94 -0
  255. package/types/feedback/alert.d.ts +22 -0
  256. package/types/feedback/backdrop.d.ts +17 -0
  257. package/types/feedback/dialog.d.ts +21 -0
  258. package/types/feedback/progress.d.ts +18 -0
  259. package/types/feedback/skeleton.d.ts +18 -0
  260. package/types/feedback/snackbar.d.ts +19 -0
  261. package/types/index.d.ts +92 -14
  262. package/types/layout/container.d.ts +28 -0
  263. package/types/layout/flex.d.ts +16 -5
  264. package/types/layout/grid.d.ts +15 -4
  265. package/types/navigation/bottom-navigation.d.ts +33 -0
  266. package/types/navigation/breadcrumbs.d.ts +29 -0
  267. package/types/navigation/drawer.d.ts +23 -0
  268. package/types/navigation/link.d.ts +22 -0
  269. package/types/navigation/menu.d.ts +32 -0
  270. package/types/navigation/pagination.d.ts +50 -0
  271. package/types/navigation/speed-dial.d.ts +35 -0
  272. package/types/navigation/stepper.d.ts +26 -0
  273. package/types/navigation/tabs.d.ts +31 -0
  274. package/types/surfaces/accordion.d.ts +32 -0
  275. package/types/surfaces/app-bar.d.ts +25 -0
  276. package/types/surfaces/card.d.ts +39 -0
  277. package/types/surfaces/paper.d.ts +28 -0
  278. package/src/shared/withRenderValidation.js +0 -19
  279. package/src/widgets/card/card.stories.js +0 -135
  280. package/src/widgets/card/index.js +0 -4
  281. package/src/widgets/card/style.css +0 -53
  282. package/src/widgets/card/template.js +0 -97
  283. package/types/widgets/card.d.ts +0 -21
@@ -1,17 +1,13 @@
1
1
  import { html } from "@inglorious/web"
2
2
 
3
- import {
4
- makeStoryRender,
5
- notifyActionArgType,
6
- } from "../../stories/notifyStory.js"
3
+ import { createRender } from "../../stories/notifyStory.js"
7
4
  import { grid } from "."
8
5
 
9
6
  export default {
10
7
  title: "Layout/Grid",
11
8
  tags: ["autodocs"],
12
- render: makeStoryRender(grid, "story-grid"),
9
+ render: createRender(grid),
13
10
  argTypes: {
14
- ...notifyActionArgType,
15
11
  columns: {
16
12
  control: "number",
17
13
  description: "Fixed number of columns when auto-fit is not used.",
@@ -25,6 +21,25 @@ export default {
25
21
  options: ["none", "sm", "md", "lg", "xl"],
26
22
  description: "Spacing between grid cells.",
27
23
  },
24
+ padding: {
25
+ control: "select",
26
+ options: ["none", "sm", "md", "lg", "xl"],
27
+ description: "Inner padding for the grid container.",
28
+ },
29
+ element: {
30
+ control: "select",
31
+ options: [
32
+ "div",
33
+ "section",
34
+ "main",
35
+ "header",
36
+ "footer",
37
+ "nav",
38
+ "aside",
39
+ "article",
40
+ ],
41
+ description: "Semantic element for the container.",
42
+ },
28
43
  align: {
29
44
  control: "select",
30
45
  options: ["stretch", "start", "center", "end"],
@@ -35,7 +50,7 @@ export default {
35
50
  options: ["stretch", "start", "center", "end"],
36
51
  description: "Inline-axis alignment for cell content.",
37
52
  },
38
- fullWidth: {
53
+ isFullWidth: {
39
54
  control: "boolean",
40
55
  description: "Expands container width to 100%.",
41
56
  },
@@ -43,6 +58,7 @@ export default {
43
58
  control: "object",
44
59
  description: "Array of templates/content rendered as-is.",
45
60
  },
61
+ onClick: { action: "onClick" },
46
62
  },
47
63
  parameters: {
48
64
  docs: {
@@ -54,29 +70,29 @@ export default {
54
70
  },
55
71
  }
56
72
 
57
- export const Default = {}
58
- Default.args = {
59
- columns: 3,
60
- gap: "md",
61
- align: "stretch",
62
- justify: "stretch",
63
- fullWidth: false,
64
- children: [
65
- html`<div>Cell A</div>`,
66
- html`<div>Cell B</div>`,
67
- html`<div>Cell C</div>`,
68
- ],
73
+ export const Default = {
74
+ args: {
75
+ align: "stretch",
76
+ justify: "stretch",
77
+ isFullWidth: false,
78
+ gap: "md",
79
+ padding: "none",
80
+ element: "div",
81
+ children: [
82
+ html`<div>Product</div>`,
83
+ html`<div>Price</div>`,
84
+ html`<div>Status</div>`,
85
+ html`<div>Actions</div>`,
86
+ html`<div>Notes</div>`,
87
+ ],
88
+ columns: 3,
89
+ },
69
90
  }
70
91
 
71
- export const AutoFit = {}
72
- AutoFit.args = {
73
- ...Default.args,
74
- minColumnWidth: "180px",
75
- children: [
76
- html`<div>Product</div>`,
77
- html`<div>Price</div>`,
78
- html`<div>Status</div>`,
79
- html`<div>Actions</div>`,
80
- html`<div>Notes</div>`,
81
- ],
92
+ export const AutoFit = {
93
+ args: {
94
+ ...Default.args,
95
+ columns: 0,
96
+ minColumnWidth: "180px",
97
+ },
82
98
  }
@@ -1,4 +1,3 @@
1
- import { withRenderValidation } from "../../shared/withRenderValidation.js"
2
1
  import * as renderers from "./template.js"
3
2
 
4
- export const grid = [{ ...renderers }, withRenderValidation]
3
+ export const grid = { ...renderers }
@@ -26,6 +26,26 @@
26
26
  gap: var(--iw-space-8);
27
27
  }
28
28
 
29
+ .iw-grid.iw-grid-padding-none {
30
+ padding: 0;
31
+ }
32
+
33
+ .iw-grid.iw-grid-padding-sm {
34
+ padding: var(--iw-space-2);
35
+ }
36
+
37
+ .iw-grid.iw-grid-padding-md {
38
+ padding: var(--iw-space-4);
39
+ }
40
+
41
+ .iw-grid.iw-grid-padding-lg {
42
+ padding: var(--iw-space-6);
43
+ }
44
+
45
+ .iw-grid.iw-grid-padding-xl {
46
+ padding: var(--iw-space-8);
47
+ }
48
+
29
49
  .iw-grid.iw-grid-align-start {
30
50
  align-items: start;
31
51
  }
@@ -1,47 +1,127 @@
1
1
  /**
2
- * @typedef {import('../../../types/layout/grid').GridEntity} GridEntity
3
- * @typedef {import('@inglorious/web').Api} Api
2
+ * @typedef {import('../../../types/layout/grid').GridProps} GridProps
4
3
  * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
4
  */
6
5
 
7
6
  import { classMap, html, styleMap } from "@inglorious/web"
8
7
 
9
- const DEFAULT_COLUMNS = 2
10
-
11
8
  /**
12
9
  * Grid layout component for Inglorious Web.
13
10
  * Children are rendered as-is (templates/content composition).
14
11
  *
15
- * @param {GridEntity} entity
16
- * @param {Api} _api
12
+ * @param {GridProps} props
17
13
  * @returns {TemplateResult}
18
14
  */
19
- export function render(entity) {
15
+ export function render(props) {
20
16
  const {
21
- columns = DEFAULT_COLUMNS,
22
- minColumnWidth,
17
+ element = "div",
18
+ columns = 0,
19
+ minColumnWidth = 0,
23
20
  gap = "md",
21
+ padding = "none",
24
22
  align = "stretch",
25
23
  justify = "stretch",
26
- fullWidth = false,
24
+ isFullWidth = false,
25
+ className = "",
27
26
  children = [],
28
- } = entity
27
+ onClick,
28
+ } = props
29
+
30
+ const extraClasses = Object.fromEntries(
31
+ className
32
+ .split(/\s+/)
33
+ .filter(Boolean)
34
+ .map((name) => [name, true]),
35
+ )
29
36
 
30
37
  const classes = {
31
38
  "iw-grid": true,
32
- "iw-grid-full-width": fullWidth,
39
+ "iw-grid-full-width": isFullWidth,
33
40
  [`iw-grid-gap-${gap}`]: true,
41
+ [`iw-grid-padding-${padding}`]: true,
34
42
  [`iw-grid-align-${align}`]: align !== "stretch",
35
43
  [`iw-grid-justify-${justify}`]: justify !== "stretch",
44
+ ...extraClasses,
36
45
  }
37
46
 
38
- const styles = minColumnWidth
39
- ? {
40
- gridTemplateColumns: `repeat(auto-fit, minmax(${minColumnWidth}, 1fr))`,
41
- }
42
- : { gridTemplateColumns: `repeat(${columns}, minmax(0, 1fr))` }
47
+ const styles = {}
48
+ if (typeof columns !== "number") {
49
+ styles.gridTemplateColumns = columns
50
+ } else {
51
+ styles.gridTemplateColumns = `repeat(${columns || "auto-fit"}, minmax(${minColumnWidth}, 1fr))`
52
+ }
43
53
 
44
- return html`<div class=${classMap(classes)} style=${styleMap(styles)}>
45
- ${children}
46
- </div>`
54
+ return renderElement(element, classes, styles, onClick, children)
55
+ }
56
+
57
+ function renderElement(element, classes, styles, onClick, children) {
58
+ const classValue = classMap(classes)
59
+ const styleValue = styleMap(styles)
60
+
61
+ switch (element) {
62
+ case "section":
63
+ return html`<section
64
+ class=${classValue}
65
+ style=${styleValue}
66
+ @click=${onClick}
67
+ >
68
+ ${children}
69
+ </section>`
70
+ case "main":
71
+ return html`<main
72
+ class=${classValue}
73
+ style=${styleValue}
74
+ @click=${onClick}
75
+ >
76
+ ${children}
77
+ </main>`
78
+ case "header":
79
+ return html`<header
80
+ class=${classValue}
81
+ style=${styleValue}
82
+ @click=${onClick}
83
+ >
84
+ ${children}
85
+ </header>`
86
+ case "footer":
87
+ return html`<footer
88
+ class=${classValue}
89
+ style=${styleValue}
90
+ @click=${onClick}
91
+ >
92
+ ${children}
93
+ </footer>`
94
+ case "nav":
95
+ return html`<nav
96
+ class=${classValue}
97
+ style=${styleValue}
98
+ @click=${onClick}
99
+ >
100
+ ${children}
101
+ </nav>`
102
+ case "aside":
103
+ return html`<aside
104
+ class=${classValue}
105
+ style=${styleValue}
106
+ @click=${onClick}
107
+ >
108
+ ${children}
109
+ </aside>`
110
+ case "article":
111
+ return html`<article
112
+ class=${classValue}
113
+ style=${styleValue}
114
+ @click=${onClick}
115
+ >
116
+ ${children}
117
+ </article>`
118
+ default:
119
+ return html`<div
120
+ class=${classValue}
121
+ style=${styleValue}
122
+ @click=${onClick}
123
+ >
124
+ ${children}
125
+ </div>`
126
+ }
47
127
  }
@@ -0,0 +1,3 @@
1
+ @import "./container/style.css";
2
+ @import "./flex/style.css";
3
+ @import "./grid/style.css";
@@ -0,0 +1,33 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { bottomNavigation } from "."
3
+
4
+ export default {
5
+ title: "Navigation/Bottom Navigation",
6
+ tags: ["autodocs"],
7
+ render: createRender(bottomNavigation),
8
+ argTypes: {
9
+ actions: { control: "object", description: "Bottom navigation actions." },
10
+ value: { control: "text", description: "Currently selected action value." },
11
+ hasLabels: { control: "boolean", description: "Show labels below icons." },
12
+ onChange: { action: "onChange" },
13
+ },
14
+ parameters: {
15
+ docs: {
16
+ description: {
17
+ component:
18
+ "Bottom bar action navigation with overridable `renderAction`.",
19
+ },
20
+ },
21
+ },
22
+ }
23
+
24
+ export const Default = {
25
+ args: {
26
+ value: "recents",
27
+ actions: [
28
+ { value: "recents", label: "Recents", icon: "🕘" },
29
+ { value: "favorites", label: "Favorites", icon: "★" },
30
+ { value: "nearby", label: "Nearby", icon: "📍" },
31
+ ],
32
+ },
33
+ }
@@ -0,0 +1 @@
1
+ export { bottomNavigation } from "./template.js"
@@ -0,0 +1,32 @@
1
+ .iw-bottom-navigation {
2
+ display: flex;
3
+ align-items: stretch;
4
+ justify-content: space-around;
5
+ gap: var(--iw-space-2);
6
+ padding: var(--iw-space-2);
7
+ background: var(--iw-color-surface);
8
+ border-top: 1px solid var(--iw-color-border);
9
+ }
10
+
11
+ .iw-bottom-navigation-action {
12
+ flex: 1 1 0;
13
+ min-width: 0;
14
+ border: 0 none;
15
+ background: transparent;
16
+ color: var(--iw-color-text-muted, var(--iw-color-text));
17
+ display: inline-flex;
18
+ flex-direction: column;
19
+ align-items: center;
20
+ justify-content: center;
21
+ gap: var(--iw-space-1);
22
+ padding: var(--iw-space-2);
23
+ cursor: pointer;
24
+ }
25
+
26
+ .iw-bottom-navigation-action-selected {
27
+ color: var(--iw-color-primary);
28
+ }
29
+
30
+ .iw-bottom-navigation-label {
31
+ font-size: var(--iw-font-size-sm);
32
+ }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @typedef {import('../../../types/navigation/bottom-navigation').BottomNavigationProps} BottomNavigationProps
3
+ * @typedef {import('../../../types/navigation/bottom-navigation').BottomNavigationAction} BottomNavigationAction
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ */
6
+
7
+ import { classMap, html, ref } from "@inglorious/web"
8
+
9
+ import { applyElementProps } from "../../shared/applyElementProps.js"
10
+
11
+ export const bottomNavigation = {
12
+ /**
13
+ * @param {BottomNavigationProps} props
14
+ * @returns {TemplateResult}
15
+ */
16
+ render(props) {
17
+ const {
18
+ type, // eslint-disable-line no-unused-vars
19
+ actions = [],
20
+ value,
21
+ hasLabels = true,
22
+ className = "",
23
+ ...rest
24
+ } = props
25
+
26
+ const extraClasses = Object.fromEntries(
27
+ className
28
+ .split(/\s+/)
29
+ .filter(Boolean)
30
+ .map((name) => [name, true]),
31
+ )
32
+
33
+ return html`<nav
34
+ class=${classMap({ "iw-bottom-navigation": true, ...extraClasses })}
35
+ ${ref((el) => applyElementProps(el, rest))}
36
+ >
37
+ ${actions.map((action, index) =>
38
+ this.renderAction(action, index, { ...props, hasLabels, value }),
39
+ )}
40
+ </nav>`
41
+ },
42
+
43
+ /**
44
+ * @param {BottomNavigationAction} action
45
+ * @param {number} index
46
+ * @param {BottomNavigationProps} props
47
+ * @returns {TemplateResult}
48
+ */
49
+ renderAction(action, index, props) {
50
+ const currentValue = action.value ?? index
51
+ const selected = currentValue === props.value
52
+
53
+ return html`<button
54
+ type="button"
55
+ class=${classMap({
56
+ "iw-bottom-navigation-action": true,
57
+ "iw-bottom-navigation-action-selected": selected,
58
+ })}
59
+ aria-current=${selected ? "page" : null}
60
+ ?disabled=${action.isDisabled}
61
+ @click=${() => {
62
+ action.onClick?.(currentValue)
63
+ props.onChange?.(currentValue)
64
+ }}
65
+ >
66
+ ${action.icon
67
+ ? html`<span class="iw-bottom-navigation-icon">${action.icon}</span>`
68
+ : null}
69
+ ${props.hasLabels
70
+ ? html`<span class="iw-bottom-navigation-label">${action.label}</span>`
71
+ : null}
72
+ </button>`
73
+ },
74
+ }
@@ -0,0 +1,33 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { breadcrumbs } from "."
3
+
4
+ export default {
5
+ title: "Navigation/Breadcrumbs",
6
+ tags: ["autodocs"],
7
+ render: createRender(breadcrumbs),
8
+ argTypes: {
9
+ items: { control: "object", description: "Ordered breadcrumb path items." },
10
+ separator: {
11
+ control: "text",
12
+ description: "Separator rendered between items.",
13
+ },
14
+ },
15
+ parameters: {
16
+ docs: {
17
+ description: {
18
+ component:
19
+ "Hierarchical path navigation with overridable `renderItem`.",
20
+ },
21
+ },
22
+ },
23
+ }
24
+
25
+ export const Default = {
26
+ args: {
27
+ items: [
28
+ { label: "Home", href: "#" },
29
+ { label: "Library", href: "#" },
30
+ { label: "Data" },
31
+ ],
32
+ },
33
+ }
@@ -0,0 +1 @@
1
+ export { breadcrumbs } from "./template.js"
@@ -0,0 +1,27 @@
1
+ .iw-breadcrumbs-list {
2
+ display: flex;
3
+ align-items: center;
4
+ flex-wrap: wrap;
5
+ gap: var(--iw-space-2);
6
+ margin: 0;
7
+ padding: 0;
8
+ list-style: none;
9
+ }
10
+
11
+ .iw-breadcrumbs-link {
12
+ color: var(--iw-color-primary);
13
+ text-decoration: none;
14
+ }
15
+
16
+ .iw-breadcrumbs-link:hover {
17
+ text-decoration: underline;
18
+ }
19
+
20
+ .iw-breadcrumbs-separator {
21
+ color: var(--iw-color-text-muted, var(--iw-color-text));
22
+ }
23
+
24
+ .iw-breadcrumbs-current {
25
+ color: var(--iw-color-text-secondary, var(--iw-color-text));
26
+ font-weight: var(--iw-font-weight-normal);
27
+ }
@@ -0,0 +1,79 @@
1
+ /**
2
+ * @typedef {import('../../../types/navigation/breadcrumbs').BreadcrumbsProps} BreadcrumbsProps
3
+ * @typedef {import('../../../types/navigation/breadcrumbs').BreadcrumbItem} BreadcrumbItem
4
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
5
+ */
6
+
7
+ import { classMap, html, ref } from "@inglorious/web"
8
+
9
+ import { applyElementProps } from "../../shared/applyElementProps.js"
10
+
11
+ export const breadcrumbs = {
12
+ /**
13
+ * @param {BreadcrumbsProps} props
14
+ * @returns {TemplateResult}
15
+ */
16
+ render(props) {
17
+ const {
18
+ type, // eslint-disable-line no-unused-vars
19
+ items = [],
20
+ separator = "/",
21
+ className = "",
22
+ ...rest
23
+ } = props
24
+
25
+ const extraClasses = Object.fromEntries(
26
+ className
27
+ .split(/\s+/)
28
+ .filter(Boolean)
29
+ .map((name) => [name, true]),
30
+ )
31
+
32
+ return html`<nav
33
+ aria-label="Breadcrumb"
34
+ class=${classMap({ "iw-breadcrumbs": true, ...extraClasses })}
35
+ ${ref((el) => applyElementProps(el, rest))}
36
+ >
37
+ <ol class="iw-breadcrumbs-list">
38
+ ${items.map(
39
+ (item, index) =>
40
+ html`${this.renderItem(item, index, props)}${index <
41
+ items.length - 1
42
+ ? html`<li class="iw-breadcrumbs-separator" aria-hidden="true">
43
+ ${separator}
44
+ </li>`
45
+ : null}`,
46
+ )}
47
+ </ol>
48
+ </nav>`
49
+ },
50
+
51
+ /**
52
+ * @param {BreadcrumbItem} item
53
+ * @param {number} index
54
+ * @param {BreadcrumbsProps} props
55
+ * @returns {TemplateResult}
56
+ */
57
+ renderItem(item, index, props) {
58
+ const isLast = index === props.items.length - 1
59
+
60
+ return html`<li class="iw-breadcrumbs-item">
61
+ ${item.href && !isLast
62
+ ? html`<a
63
+ href=${item.href}
64
+ class="iw-breadcrumbs-link"
65
+ @click=${item.onClick ?? null}
66
+ >
67
+ ${item.label}
68
+ </a>`
69
+ : html`<span
70
+ class=${classMap({
71
+ "iw-breadcrumbs-current": isLast,
72
+ })}
73
+ aria-current=${isLast ? "page" : null}
74
+ >
75
+ ${item.label}
76
+ </span>`}
77
+ </li>`
78
+ },
79
+ }
@@ -0,0 +1,60 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import { createRender } from "../../stories/notifyStory.js"
4
+ import { drawer } from "."
5
+
6
+ export default {
7
+ title: "Navigation/Drawer",
8
+ tags: ["autodocs"],
9
+ render: createRender(drawer),
10
+ argTypes: {
11
+ isOpen: {
12
+ control: "boolean",
13
+ description: "Whether the drawer is visible.",
14
+ },
15
+ anchor: {
16
+ control: "select",
17
+ options: ["left", "right", "top", "bottom"],
18
+ description: "Edge from which the drawer appears.",
19
+ },
20
+ variant: {
21
+ control: "select",
22
+ options: ["temporary", "persistent", "permanent", "responsive"],
23
+ description: "Drawer behavior model.",
24
+ },
25
+ breakpoint: {
26
+ control: "select",
27
+ options: ["sm", "md", "lg", "xl"],
28
+ description: "Desktop breakpoint for responsive drawers.",
29
+ },
30
+ isCollapsed: {
31
+ control: "boolean",
32
+ description: "Whether a responsive drawer is collapsed on desktop.",
33
+ },
34
+ title: { control: "text", description: "Optional drawer header title." },
35
+ onClose: { action: "onClose" },
36
+ },
37
+ parameters: {
38
+ docs: {
39
+ description: {
40
+ component:
41
+ "Overlay or persistent navigation panel anchored to a viewport edge.",
42
+ },
43
+ },
44
+ },
45
+ }
46
+
47
+ export const Default = {
48
+ args: {
49
+ isOpen: true,
50
+ title: "Workspace",
51
+ children: html`<div>Navigation items</div>`,
52
+ },
53
+ }
54
+
55
+ export const Right = {
56
+ args: {
57
+ ...Default.args,
58
+ anchor: "right",
59
+ },
60
+ }
@@ -0,0 +1,3 @@
1
+ import * as renderers from "./template.js"
2
+
3
+ export const drawer = { ...renderers }