@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
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @typedef {import('../../../types/feedback/alert').AlertProps} AlertProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html, ref } from "@inglorious/web"
7
+
8
+ import { applyElementProps } from "../../shared/applyElementProps.js"
9
+
10
+ /**
11
+ * @param {AlertProps} props
12
+ * @returns {TemplateResult}
13
+ */
14
+ export function render(props) {
15
+ const {
16
+ type, // eslint-disable-line no-unused-vars
17
+ title,
18
+ description,
19
+ children,
20
+ severity = "info",
21
+ variant = "filled",
22
+ icon,
23
+ action,
24
+ onClose,
25
+ className = "",
26
+ ...rest
27
+ } = props
28
+
29
+ const extraClasses = Object.fromEntries(
30
+ className
31
+ .split(/\s+/)
32
+ .filter(Boolean)
33
+ .map((name) => [name, true]),
34
+ )
35
+
36
+ const classes = {
37
+ "iw-alert": true,
38
+ [`iw-alert-${severity}`]: true,
39
+ [`iw-alert-${variant}`]: true,
40
+ ...extraClasses,
41
+ }
42
+
43
+ const content = description ?? children
44
+ const hasTrailing = !!action || !!onClose
45
+
46
+ return html`<div
47
+ class=${classMap(classes)}
48
+ role="alert"
49
+ ${ref((el) => applyElementProps(el, rest))}
50
+ >
51
+ ${icon ? html`<div class="iw-alert-icon">${icon}</div>` : null}
52
+ <div class="iw-alert-content">
53
+ ${title ? html`<div class="iw-alert-title">${title}</div>` : null}
54
+ ${content
55
+ ? html`<div class="iw-alert-description">${content}</div>`
56
+ : null}
57
+ </div>
58
+ ${hasTrailing
59
+ ? html`<div class="iw-alert-trailing">
60
+ ${action ? html`<div class="iw-alert-action">${action}</div>` : null}
61
+ ${onClose
62
+ ? html`<button
63
+ type="button"
64
+ class="iw-alert-close"
65
+ aria-label="Dismiss"
66
+ @click=${onClose}
67
+ >
68
+ ×
69
+ </button>`
70
+ : null}
71
+ </div>`
72
+ : null}
73
+ </div>`
74
+ }
@@ -0,0 +1,21 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import { createRender } from "../../stories/notifyStory.js"
4
+ import { backdrop } from "."
5
+
6
+ export default {
7
+ title: "Feedback/Backdrop",
8
+ tags: ["autodocs"],
9
+ render: createRender(backdrop),
10
+ argTypes: {
11
+ isOpen: { control: "boolean" },
12
+ onClick: { action: "onClick" },
13
+ },
14
+ }
15
+
16
+ export const Open = {
17
+ args: {
18
+ isOpen: true,
19
+ children: html`<div>Loading content…</div>`,
20
+ },
21
+ }
@@ -0,0 +1,3 @@
1
+ import { render } from "./template.js"
2
+
3
+ export const backdrop = { render }
@@ -0,0 +1,25 @@
1
+ .iw-backdrop {
2
+ position: fixed;
3
+ inset: 0;
4
+ background: color-mix(in srgb, var(--iw-color-black) 65%, transparent);
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ z-index: var(--iw-z-modal-backdrop, 1040);
9
+ color: var(--iw-color-white);
10
+ backdrop-filter: blur(3px);
11
+ padding: var(--iw-space-4);
12
+ }
13
+
14
+ .iw-backdrop-content {
15
+ max-width: min(28rem, 90vw);
16
+ padding: var(--iw-space-4) var(--iw-space-5);
17
+ border-radius: var(--iw-radius-md);
18
+ background: color-mix(
19
+ in srgb,
20
+ var(--iw-color-surface, #111) 88%,
21
+ transparent
22
+ );
23
+ border: 1px solid color-mix(in srgb, var(--iw-color-white) 14%, transparent);
24
+ box-shadow: var(--iw-shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.35));
25
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * @typedef {import('../../../types/feedback/backdrop').BackdropProps} BackdropProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html, when } from "@inglorious/web"
7
+
8
+ /**
9
+ * @param {BackdropProps} props
10
+ * @returns {TemplateResult | null}
11
+ */
12
+ export function render({ isOpen = false, className = "", onClick, children }) {
13
+ if (!isOpen) return null
14
+
15
+ const extraClasses = Object.fromEntries(
16
+ className
17
+ .split(/\s+/)
18
+ .filter(Boolean)
19
+ .map((name) => [name, true]),
20
+ )
21
+
22
+ return html`<div
23
+ class=${classMap({ "iw-backdrop": true, ...extraClasses })}
24
+ @click=${onClick}
25
+ >
26
+ ${when(
27
+ children,
28
+ () => html`<div class="iw-backdrop-content">${children}</div>`,
29
+ )}
30
+ </div>`
31
+ }
@@ -0,0 +1,27 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import { createRender } from "../../stories/notifyStory.js"
4
+ import { dialog } from "."
5
+
6
+ export default {
7
+ title: "Feedback/Dialog",
8
+ tags: ["autodocs"],
9
+ render: createRender(dialog),
10
+ argTypes: {
11
+ isOpen: { control: "boolean" },
12
+ title: { control: "text" },
13
+ description: { control: "text" },
14
+ onClose: { action: "onClose" },
15
+ },
16
+ }
17
+
18
+ export const Open = {
19
+ args: {
20
+ isOpen: true,
21
+ title: "Delete item",
22
+ description: "This action cannot be undone.",
23
+ children: html`<p>Are you sure you want to continue?</p>`,
24
+ actions: html`<button class="iw-button iw-button-outline">Cancel</button>
25
+ <button class="iw-button iw-button-primary">Confirm</button>`,
26
+ },
27
+ }
@@ -0,0 +1,3 @@
1
+ import { render } from "./template.js"
2
+
3
+ export const dialog = { render }
@@ -0,0 +1,68 @@
1
+ .iw-dialog-backdrop {
2
+ position: fixed;
3
+ inset: 0;
4
+ background: color-mix(in srgb, var(--iw-color-black) 55%, transparent);
5
+ display: flex;
6
+ align-items: center;
7
+ justify-content: center;
8
+ z-index: var(--iw-z-modal, 1050);
9
+ padding: var(--iw-space-4);
10
+ backdrop-filter: blur(2px);
11
+ }
12
+
13
+ .iw-dialog {
14
+ background: var(--iw-color-surface);
15
+ color: var(--iw-color-text);
16
+ border-radius: var(--iw-radius-md);
17
+ border: 1px solid color-mix(in srgb, var(--iw-color-border) 70%, transparent);
18
+ min-width: min(32rem, 90vw);
19
+ max-width: min(48rem, 90vw);
20
+ box-shadow: var(--iw-shadow-lg, 0 12px 40px rgba(0, 0, 0, 0.3));
21
+ padding: var(--iw-space-4);
22
+ }
23
+
24
+ .iw-dialog-header {
25
+ display: flex;
26
+ align-items: center;
27
+ justify-content: space-between;
28
+ gap: var(--iw-space-2);
29
+ }
30
+
31
+ .iw-dialog-title {
32
+ font-weight: var(--iw-font-weight-semibold);
33
+ font-size: 1.1rem;
34
+ }
35
+
36
+ .iw-dialog-close {
37
+ border: 0 none;
38
+ background: transparent;
39
+ width: 1.75rem;
40
+ height: 1.75rem;
41
+ border-radius: var(--iw-radius-sm);
42
+ display: inline-flex;
43
+ align-items: center;
44
+ justify-content: center;
45
+ cursor: pointer;
46
+ color: inherit;
47
+ }
48
+
49
+ .iw-dialog-close:hover {
50
+ background-color: color-mix(in srgb, currentColor 12%, transparent);
51
+ }
52
+
53
+ .iw-dialog-description {
54
+ margin-top: var(--iw-space-2);
55
+ color: var(--iw-color-text-muted, var(--iw-color-text));
56
+ }
57
+
58
+ .iw-dialog-body {
59
+ margin-top: var(--iw-space-3);
60
+ }
61
+
62
+ .iw-dialog-actions {
63
+ margin-top: var(--iw-space-4);
64
+ display: flex;
65
+ justify-content: flex-end;
66
+ flex-wrap: wrap;
67
+ gap: var(--iw-space-2);
68
+ }
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @typedef {import('../../../types/feedback/dialog').DialogProps} DialogProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html } from "@inglorious/web"
7
+
8
+ /**
9
+ * @param {DialogProps} props
10
+ * @returns {TemplateResult | null}
11
+ */
12
+ export function render(props) {
13
+ const {
14
+ isOpen = false,
15
+ title,
16
+ description,
17
+ children,
18
+ actions,
19
+ className = "",
20
+ onClose,
21
+ onBackdropClick,
22
+ } = props
23
+
24
+ if (!isOpen) return null
25
+
26
+ const extraClasses = Object.fromEntries(
27
+ className
28
+ .split(/\s+/)
29
+ .filter(Boolean)
30
+ .map((name) => [name, true]),
31
+ )
32
+
33
+ return html`<div
34
+ class=${classMap({ "iw-dialog-backdrop": true })}
35
+ @click=${onBackdropClick ?? onClose}
36
+ >
37
+ <div
38
+ class=${classMap({ "iw-dialog": true, ...extraClasses })}
39
+ role="dialog"
40
+ aria-modal="true"
41
+ @click=${(event) => event.stopPropagation()}
42
+ >
43
+ ${(title || onClose) &&
44
+ html`<div class="iw-dialog-header">
45
+ ${title ? html`<div class="iw-dialog-title">${title}</div>` : null}
46
+ ${onClose
47
+ ? html`<button
48
+ type="button"
49
+ class="iw-dialog-close"
50
+ aria-label="Close"
51
+ @click=${onClose}
52
+ >
53
+ ×
54
+ </button>`
55
+ : null}
56
+ </div>`}
57
+ ${description
58
+ ? html`<div class="iw-dialog-description">${description}</div>`
59
+ : null}
60
+ ${children ? html`<div class="iw-dialog-body">${children}</div>` : null}
61
+ ${actions ? html`<div class="iw-dialog-actions">${actions}</div>` : null}
62
+ </div>
63
+ </div>`
64
+ }
@@ -0,0 +1,6 @@
1
+ @import "./alert/style.css";
2
+ @import "./backdrop/style.css";
3
+ @import "./dialog/style.css";
4
+ @import "./progress/style.css";
5
+ @import "./skeleton/style.css";
6
+ @import "./snackbar/style.css";
@@ -0,0 +1,3 @@
1
+ import * as renderers from "./template.js"
2
+
3
+ export const progress = { ...renderers }
@@ -0,0 +1,54 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { progress } from "."
3
+
4
+ export default {
5
+ title: "Feedback/Progress",
6
+ tags: ["autodocs"],
7
+ render: createRender(progress),
8
+ argTypes: {
9
+ variant: { control: "select", options: ["linear", "circular"] },
10
+ value: { control: "number" },
11
+ size: { control: "number" },
12
+ thickness: { control: "number" },
13
+ color: {
14
+ control: "select",
15
+ options: [
16
+ "default",
17
+ "primary",
18
+ "secondary",
19
+ "success",
20
+ "warning",
21
+ "info",
22
+ ],
23
+ },
24
+ },
25
+ }
26
+
27
+ export const Linear = {
28
+ args: {
29
+ variant: "linear",
30
+ value: 40,
31
+ },
32
+ }
33
+
34
+ export const LinearIndeterminate = {
35
+ args: {
36
+ variant: "linear",
37
+ },
38
+ }
39
+
40
+ export const Circular = {
41
+ args: {
42
+ variant: "circular",
43
+ value: 65,
44
+ size: 48,
45
+ thickness: 4,
46
+ },
47
+ }
48
+
49
+ export const CircularIndeterminate = {
50
+ args: {
51
+ variant: "circular",
52
+ size: 48,
53
+ },
54
+ }
@@ -0,0 +1,95 @@
1
+ .iw-progress {
2
+ &.iw-progress-primary {
3
+ color: var(--iw-color-primary);
4
+ }
5
+
6
+ &.iw-progress-secondary {
7
+ color: var(--iw-color-secondary);
8
+ }
9
+
10
+ &.iw-progress-success {
11
+ color: var(--iw-color-success);
12
+ }
13
+
14
+ &.iw-progress-error {
15
+ color: var(--iw-color-error);
16
+ }
17
+
18
+ &.iw-progress-warning {
19
+ color: var(--iw-color-warning);
20
+ }
21
+
22
+ &.iw-progress-info {
23
+ color: var(--iw-color-info);
24
+ }
25
+ }
26
+
27
+ .iw-progress-linear {
28
+ width: 100%;
29
+ }
30
+
31
+ .iw-progress-linear-track {
32
+ width: 100%;
33
+ height: 8px;
34
+ background: color-mix(in srgb, currentColor 24%, transparent);
35
+ border-radius: var(--iw-radius-sm);
36
+ overflow: hidden;
37
+ }
38
+
39
+ .iw-progress-linear-bar {
40
+ display: block;
41
+ height: 100%;
42
+ background: linear-gradient(
43
+ 90deg,
44
+ color-mix(in srgb, currentColor 84%, white),
45
+ currentColor
46
+ );
47
+ transition: width 0.2s ease;
48
+ min-width: 8px;
49
+ }
50
+
51
+ .iw-progress-linear.iw-progress-indeterminate .iw-progress-linear-bar {
52
+ width: 30%;
53
+ animation: iw-progress-linear 1.4s ease-in-out infinite;
54
+ }
55
+
56
+ @keyframes iw-progress-linear {
57
+ 0% {
58
+ transform: translateX(-100%);
59
+ }
60
+ 100% {
61
+ transform: translateX(350%);
62
+ }
63
+ }
64
+
65
+ .iw-progress-circular svg {
66
+ width: 100%;
67
+ height: 100%;
68
+ transform: rotate(-90deg);
69
+ display: block;
70
+ }
71
+
72
+ .iw-progress-circular .iw-progress-track {
73
+ fill: none;
74
+ stroke: color-mix(in srgb, currentColor 20%, transparent);
75
+ }
76
+
77
+ .iw-progress-circular .iw-progress-value {
78
+ fill: none;
79
+ stroke: currentColor;
80
+ stroke-linecap: round;
81
+ transition: stroke-dashoffset 0.2s ease;
82
+ }
83
+
84
+ .iw-progress-circular.iw-progress-indeterminate {
85
+ animation: iw-progress-rotate 1.2s linear infinite;
86
+ }
87
+
88
+ @keyframes iw-progress-rotate {
89
+ 0% {
90
+ transform: rotate(0deg);
91
+ }
92
+ 100% {
93
+ transform: rotate(360deg);
94
+ }
95
+ }
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @typedef {import('../../../types/feedback/progress').ProgressProps} ProgressProps
3
+ * @typedef {import('@inglorious/web').TemplateResult} TemplateResult
4
+ */
5
+
6
+ import { classMap, html } from "@inglorious/web"
7
+
8
+ function clamp(value) {
9
+ return Math.max(0, Math.min(100, value))
10
+ }
11
+
12
+ /**
13
+ * @param {ProgressProps} props
14
+ * @returns {TemplateResult}
15
+ */
16
+ export function render(props) {
17
+ const {
18
+ variant = "linear",
19
+ value,
20
+ size = 40,
21
+ thickness = 4,
22
+ color = "default",
23
+ className = "",
24
+ } = props
25
+
26
+ const extraClasses = Object.fromEntries(
27
+ className
28
+ .split(/\s+/)
29
+ .filter(Boolean)
30
+ .map((name) => [name, true]),
31
+ )
32
+
33
+ if (variant === "circular") {
34
+ const radius = (size - thickness) / 2
35
+ const circumference = 2 * Math.PI * radius
36
+ const progress = value == null ? null : clamp(value)
37
+ const dashOffset =
38
+ progress == null ? null : circumference * (1 - progress / 100)
39
+
40
+ return html`<div
41
+ class=${classMap({
42
+ "iw-progress": true,
43
+ "iw-progress-circular": true,
44
+ "iw-progress-${color}": true,
45
+ "iw-progress-indeterminate": progress == null,
46
+ ...extraClasses,
47
+ })}
48
+ style=${`width: ${size}px; height: ${size}px;`}
49
+ >
50
+ <svg viewBox="0 0 ${size} ${size}">
51
+ <circle
52
+ class="iw-progress-track"
53
+ cx=${size / 2}
54
+ cy=${size / 2}
55
+ r=${radius}
56
+ stroke-width=${thickness}
57
+ ></circle>
58
+ <circle
59
+ class="iw-progress-value"
60
+ cx=${size / 2}
61
+ cy=${size / 2}
62
+ r=${radius}
63
+ stroke-width=${thickness}
64
+ stroke-dasharray=${circumference}
65
+ stroke-dashoffset=${dashOffset ?? circumference * 0.75}
66
+ ></circle>
67
+ </svg>
68
+ </div>`
69
+ }
70
+
71
+ const progress = value == null ? null : clamp(value)
72
+
73
+ return html`<div
74
+ class=${classMap({
75
+ "iw-progress": true,
76
+ "iw-progress-linear": true,
77
+ "iw-progress-indeterminate": progress == null,
78
+ ...extraClasses,
79
+ })}
80
+ >
81
+ <div class="iw-progress-linear-track">
82
+ <div
83
+ class="iw-progress-linear-bar"
84
+ style=${progress == null ? "" : `width: ${progress}%;`}
85
+ ></div>
86
+ </div>
87
+ </div>`
88
+ }
@@ -0,0 +1,3 @@
1
+ import { render } from "./template.js"
2
+
3
+ export const skeleton = { render }
@@ -0,0 +1,44 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { skeleton } from "."
3
+
4
+ export default {
5
+ title: "Feedback/Skeleton",
6
+ tags: ["autodocs"],
7
+ render: createRender(skeleton),
8
+ argTypes: {
9
+ variant: { control: "select", options: ["text", "rect", "circle"] },
10
+ width: { control: "text" },
11
+ height: { control: "text" },
12
+ lines: { control: "number" },
13
+ },
14
+ }
15
+
16
+ export const Text = {
17
+ args: {
18
+ variant: "text",
19
+ width: "60%",
20
+ },
21
+ }
22
+
23
+ export const Rect = {
24
+ args: {
25
+ variant: "rect",
26
+ width: 240,
27
+ height: 120,
28
+ },
29
+ }
30
+
31
+ export const Circle = {
32
+ args: {
33
+ variant: "circle",
34
+ width: 48,
35
+ height: 48,
36
+ },
37
+ }
38
+
39
+ export const MultiLine = {
40
+ args: {
41
+ lines: 3,
42
+ width: "100%",
43
+ },
44
+ }
@@ -0,0 +1,41 @@
1
+ .iw-skeleton {
2
+ background: color-mix(in srgb, var(--iw-color-text) 14%, transparent);
3
+ border-radius: var(--iw-radius-sm);
4
+ position: relative;
5
+ overflow: hidden;
6
+ height: 1em;
7
+ }
8
+
9
+ .iw-skeleton::after {
10
+ content: "";
11
+ position: absolute;
12
+ inset: 0;
13
+ transform: translateX(-100%);
14
+ background: linear-gradient(
15
+ 90deg,
16
+ transparent,
17
+ rgba(255, 255, 255, 0.35),
18
+ transparent
19
+ );
20
+ animation: iw-skeleton-shimmer 1.4s ease-in-out infinite;
21
+ }
22
+
23
+ @keyframes iw-skeleton-shimmer {
24
+ 100% {
25
+ transform: translateX(100%);
26
+ }
27
+ }
28
+
29
+ .iw-skeleton-rect {
30
+ border-radius: var(--iw-radius-sm);
31
+ }
32
+
33
+ .iw-skeleton-circle {
34
+ border-radius: 999px;
35
+ }
36
+
37
+ .iw-skeleton-stack {
38
+ display: flex;
39
+ flex-direction: column;
40
+ gap: var(--iw-space-2);
41
+ }