@inglorious/ui 0.1.0 → 1.0.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 (283) hide show
  1. package/README.md +45 -0
  2. package/package.json +191 -16
  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,95 @@
1
+ const DEFAULT_THEME = "inglorious"
2
+ const DEFAULT_MODE = "auto"
3
+ const THEME_CYCLE = ["inglorious", "material", "bootstrap"]
4
+ const MODE_CYCLE = ["auto", "light", "dark"]
5
+
6
+ let currentTheme = DEFAULT_THEME
7
+ let currentMode = DEFAULT_MODE
8
+ let systemMedia
9
+ let systemListener
10
+
11
+ export function applyTheme(theme = currentTheme, mode = currentMode) {
12
+ if (typeof document === "undefined") return
13
+
14
+ currentTheme = theme ?? DEFAULT_THEME
15
+ currentMode = mode ?? DEFAULT_MODE
16
+ ensureSystemListener()
17
+
18
+ const resolvedMode = resolveMode(currentMode)
19
+ const themeClass = `iw-theme-${currentTheme}`
20
+ const modeClass =
21
+ resolvedMode === "light" ? "iw-theme-light" : "iw-theme-dark"
22
+
23
+ document.body.className = document.body.className.replace(
24
+ /iw-theme-(\w+)/g,
25
+ "",
26
+ )
27
+ document.body.classList.add(themeClass, modeClass)
28
+ document.body.dataset.iwThemeMode = currentMode
29
+ document.body.dataset.iwTheme = currentTheme
30
+ document.documentElement.style.colorScheme = resolvedMode
31
+
32
+ const background =
33
+ getComputedStyle(document.body).getPropertyValue("--iw-color-bg").trim() ||
34
+ (resolvedMode === "dark" ? "#111827" : "#ffffff")
35
+ const foreground =
36
+ getComputedStyle(document.body)
37
+ .getPropertyValue("--iw-color-text")
38
+ .trim() || (resolvedMode === "dark" ? "#f9fafb" : "#111827")
39
+
40
+ document.body.style.backgroundColor = background
41
+ document.body.style.color = foreground
42
+ }
43
+
44
+ export function getTheme() {
45
+ return currentTheme
46
+ }
47
+
48
+ export function getMode() {
49
+ return currentMode
50
+ }
51
+
52
+ export function nextTheme(theme) {
53
+ const index = THEME_CYCLE.indexOf(theme)
54
+ if (index === -1) return THEME_CYCLE[0]
55
+ return THEME_CYCLE[(index + 1) % THEME_CYCLE.length]
56
+ }
57
+
58
+ export function nextMode(mode) {
59
+ const index = MODE_CYCLE.indexOf(mode)
60
+ if (index === -1) return MODE_CYCLE[0]
61
+ return MODE_CYCLE[(index + 1) % MODE_CYCLE.length]
62
+ }
63
+
64
+ function resolveMode(mode) {
65
+ if (mode !== "auto") return mode
66
+ return getSystemMode()
67
+ }
68
+
69
+ function getSystemMode() {
70
+ if (typeof window === "undefined") return "light"
71
+ systemMedia ??= window.matchMedia("(prefers-color-scheme: dark)")
72
+ return systemMedia.matches ? "dark" : "light"
73
+ }
74
+
75
+ function ensureSystemListener() {
76
+ if (typeof window === "undefined") return
77
+ systemMedia ??= window.matchMedia("(prefers-color-scheme: dark)")
78
+ if (systemListener) return
79
+
80
+ systemListener = () => {
81
+ if (currentMode !== "auto") return
82
+ applyTheme(currentTheme, currentMode)
83
+ }
84
+
85
+ if (typeof systemMedia.addEventListener === "function") {
86
+ systemMedia.addEventListener("change", systemListener)
87
+ } else if (typeof systemMedia.addListener === "function") {
88
+ systemMedia.addListener(systemListener)
89
+ }
90
+ }
91
+
92
+ export const DEFAULTS = {
93
+ theme: DEFAULT_THEME,
94
+ mode: DEFAULT_MODE,
95
+ }
@@ -0,0 +1,27 @@
1
+ import {
2
+ applyTheme,
3
+ DEFAULTS,
4
+ getMode,
5
+ getTheme,
6
+ nextTheme,
7
+ } from "./theme-utils.js"
8
+
9
+ export const theme = {
10
+ create(entity) {
11
+ entity.theme ??= DEFAULTS.theme
12
+ applyTheme(entity.theme, getMode())
13
+ },
14
+
15
+ set(entity, payload = {}) {
16
+ const next = payload.theme ?? entity.theme ?? DEFAULTS.theme
17
+ entity.theme = next
18
+ applyTheme(next, getMode())
19
+ },
20
+
21
+ toggle(entity) {
22
+ const activeTheme = entity.theme ?? getTheme()
23
+ const next = nextTheme(activeTheme)
24
+ entity.theme = next
25
+ applyTheme(next, getMode())
26
+ },
27
+ }
@@ -0,0 +1,108 @@
1
+ import { chart } from "@inglorious/charts"
2
+ import { html } from "@inglorious/web"
3
+
4
+ import { button } from "../../controls/button"
5
+ import { buttonGroup } from "../../controls/button-group"
6
+ import { materialIcon } from "../../data-display/material-icon"
7
+ import { typography } from "../../data-display/typography"
8
+ import { progress } from "../../feedback/progress"
9
+ import { flex } from "../../layout/flex"
10
+ import { grid } from "../../layout/grid"
11
+ import { card } from "../../surfaces/card"
12
+ import { trafficSeries, trafficSummary } from "./data"
13
+
14
+ export const trafficCard = {
15
+ render(entity, api) {
16
+ return card.render({
17
+ header: flex.render({
18
+ justify: "between",
19
+ align: "start",
20
+ gap: "md",
21
+ children: [
22
+ html`<div>
23
+ ${typography.render({ variant: "h3", children: "Traffic" })}
24
+ ${typography.render({
25
+ variant: "caption",
26
+ children: "January - July 2023",
27
+ color: "var(--iw-color-text-secondary)",
28
+ })}
29
+ </div>`,
30
+ flex.render({
31
+ gap: "md",
32
+ children: [
33
+ buttonGroup.render({
34
+ value: "month",
35
+ variant: "outline",
36
+ color: "secondary",
37
+ size: "md",
38
+ buttons: [
39
+ { id: "day", label: "Day" },
40
+ { id: "month", label: "Month" },
41
+ { id: "year", label: "Year" },
42
+ ],
43
+ }),
44
+ button.render({
45
+ size: "md",
46
+ color: "primary",
47
+ children: materialIcon.render({ name: "download" }),
48
+ "aria-label": "Download report",
49
+ }),
50
+ ],
51
+ }),
52
+ ],
53
+ }),
54
+ body: html`
55
+ <div class="iw-dashboard-traffic-chart">
56
+ ${this.renderTrafficChart(entity, api)}
57
+ </div>
58
+ `,
59
+ footer: grid.render({
60
+ minColumnWidth: "17rem",
61
+ gap: "lg",
62
+ children: [
63
+ trafficSummary.map((item) =>
64
+ flex.render({
65
+ direction: "column",
66
+ align: "center",
67
+ gap: "sm",
68
+ children: [
69
+ typography.render({
70
+ children: item.label,
71
+ color: "var(--iw-color-text-secondary)",
72
+ }),
73
+ typography.render({ children: item.value, weight: 600 }),
74
+ progress.render({
75
+ value: item.progress,
76
+ className: `iw-progress-${item.color}`,
77
+ }),
78
+ ],
79
+ }),
80
+ ),
81
+ ],
82
+ }),
83
+ })
84
+ },
85
+
86
+ renderTrafficChart(_, api) {
87
+ return chart.renderAreaChart(
88
+ { id: "traffic", type: "area", data: trafficSeries },
89
+ {
90
+ width: 1400,
91
+ height: 320,
92
+ dataKeys: ["visits", "unique"],
93
+ children: [
94
+ chart.CartesianGrid({
95
+ stroke: "rgba(255,255,255,0.08)",
96
+ strokeDasharray: "4 4",
97
+ }),
98
+ chart.XAxis({ dataKey: "month" }),
99
+ chart.YAxis({ width: "auto" }),
100
+ chart.Area({ dataKey: "visits", stroke: "#39a2f1", strokeWidth: 3 }),
101
+ chart.Area({ dataKey: "unique", stroke: "#2eb85c", strokeWidth: 3 }),
102
+ chart.Tooltip({}),
103
+ ],
104
+ },
105
+ api,
106
+ )
107
+ },
108
+ }
@@ -0,0 +1,267 @@
1
+ import { html } from "@inglorious/web"
2
+
3
+ import { button } from "../../controls/button"
4
+ import { avatar } from "../../data-display/avatar"
5
+ import { badge } from "../../data-display/badge"
6
+ import { icon } from "../../data-display/icon"
7
+ import { materialIcon } from "../../data-display/material-icon"
8
+ import { table } from "../../data-display/table"
9
+ import { typography } from "../../data-display/typography"
10
+ import { progress } from "../../feedback/progress"
11
+ import { flex } from "../../layout/flex"
12
+ import { grid } from "../../layout/grid"
13
+ import { card } from "../../surfaces/card"
14
+ import { clientBars, sourceBars, userRows } from "./data"
15
+
16
+ export const trafficSalesCard = {
17
+ render(entity, api) {
18
+ return card.render({
19
+ title: "Traffic & Sales",
20
+ body: html`
21
+ ${grid.render({
22
+ columns: 2,
23
+ gap: "lg",
24
+ className: "iw-dashboard-sales-layout",
25
+ children: [
26
+ html`
27
+ <div>
28
+ ${grid.render({
29
+ columns: 2,
30
+ gap: "lg",
31
+ className: "iw-dashboard-kpi-grid",
32
+ children: [
33
+ this.renderKpi(
34
+ entity,
35
+ {
36
+ label: "New Clients",
37
+ value: "9.123",
38
+ color: "#39a2f1",
39
+ },
40
+ api,
41
+ ),
42
+ this.renderKpi(
43
+ entity,
44
+ {
45
+ label: "Recurring Clients",
46
+ value: "22.643",
47
+ color: "#e55353",
48
+ },
49
+ api,
50
+ ),
51
+ ],
52
+ })}
53
+ <hr class="iw-dashboard-divider" />
54
+ ${flex.render({
55
+ direction: "column",
56
+ gap: "lg",
57
+ className: "iw-dashboard-progress-list",
58
+ children: clientBars.map(([day, first, second]) =>
59
+ grid.render({
60
+ columns: "6rem 1fr",
61
+ gap: "lg",
62
+ align: "center",
63
+ className: "iw-dashboard-progress-row",
64
+ children: [
65
+ html`<span>${day}</span>`,
66
+ flex.render({
67
+ direction: "column",
68
+ gap: "sm",
69
+ children: [
70
+ progress.render({
71
+ value: first,
72
+ className: "iw-progress-info",
73
+ }),
74
+ progress.render({
75
+ value: second,
76
+ className: "iw-progress-error",
77
+ }),
78
+ ],
79
+ }),
80
+ ],
81
+ }),
82
+ ),
83
+ })}
84
+ </div>
85
+ `,
86
+ html`
87
+ <div>
88
+ ${grid.render({
89
+ columns: 2,
90
+ gap: "lg",
91
+ className: "iw-dashboard-kpi-grid",
92
+ children: [
93
+ this.renderKpi(
94
+ entity,
95
+ {
96
+ label: "Pageviews",
97
+ value: "78.623",
98
+ color: "#f5a524",
99
+ },
100
+ api,
101
+ ),
102
+ this.renderKpi(
103
+ entity,
104
+ { label: "Organic", value: "49.123", color: "#2eb85c" },
105
+ api,
106
+ ),
107
+ ],
108
+ })}
109
+ <hr class="iw-dashboard-divider" />
110
+ ${flex.render({
111
+ direction: "column",
112
+ gap: "lg",
113
+ className: "iw-dashboard-progress-list",
114
+ children: sourceBars.map(
115
+ ([label, value, iconName, tone, metric, suffix]) => html`
116
+ <div>
117
+ ${flex.render({
118
+ align: "center",
119
+ justify: "between",
120
+ gap: "lg",
121
+ children: [
122
+ flex.render({
123
+ align: "center",
124
+ gap: "sm",
125
+ children: [
126
+ materialIcon.render({
127
+ name: iconName,
128
+ size: "lg",
129
+ }),
130
+ html`<span>${label}</span>`,
131
+ ],
132
+ }),
133
+ flex.render({
134
+ align: "center",
135
+ gap: "sm",
136
+ className: "iw-dashboard-progress-meta",
137
+ children: metric
138
+ ? [
139
+ html`<span>${metric}</span>`,
140
+ html`<span>${suffix}</span>`,
141
+ ]
142
+ : [html`<span>${value}%</span>`],
143
+ }),
144
+ ],
145
+ })}
146
+ ${progress.render({
147
+ value,
148
+ className: `iw-progress-${tone}`,
149
+ })}
150
+ </div>
151
+ `,
152
+ ),
153
+ })}
154
+ </div>
155
+ `,
156
+ ],
157
+ })}
158
+
159
+ <div style="height: var(--iw-space-5)"></div>
160
+
161
+ ${table.render({
162
+ columns: [
163
+ { id: "user", title: "User" },
164
+ { id: "country", title: "Country" },
165
+ { id: "usage", title: "Usage" },
166
+ { id: "payment", title: "Payment Method" },
167
+ { id: "activity", title: "Activity" },
168
+ { id: "menu", title: "" },
169
+ ],
170
+ rows: userRows.map((row) => ({
171
+ user: html`
172
+ ${flex.render({
173
+ align: "center",
174
+ gap: "lg",
175
+ children: [
176
+ html`<span class="iw-dashboard-avatar">
177
+ ${avatar.render({
178
+ size: "lg",
179
+ color: "auto",
180
+ initials: row.initials,
181
+ })}
182
+ ${badge.render({
183
+ shape: "circle",
184
+ ringWidth: "1px",
185
+ color: row.status,
186
+ className: "iw-dashboard-avatar-badge",
187
+ children: "",
188
+ })}
189
+ </span>`,
190
+ html`<div>
191
+ <div>${row.name}</div>
192
+ <div class="iw-dashboard-user-subtitle">
193
+ ${row.subtitle}
194
+ </div>
195
+ </div>`,
196
+ ],
197
+ })}
198
+ `,
199
+ country: html`<div class="iw-dashboard-country">
200
+ ${row.country}
201
+ </div>`,
202
+ usage: html`
203
+ ${flex.render({
204
+ direction: "column",
205
+ gap: "sm",
206
+ children: [
207
+ flex.render({
208
+ justify: "between",
209
+ gap: "sm",
210
+ children: [
211
+ html`<span>${row.usage}%</span>`,
212
+ html`<span class="iw-dashboard-user-subtitle"
213
+ >${row.range}</span
214
+ >`,
215
+ ],
216
+ }),
217
+ progress.render({
218
+ value: row.usage,
219
+ className: `iw-progress-${row.status}`,
220
+ }),
221
+ ],
222
+ })}
223
+ `,
224
+ payment: html`<div class="iw-dashboard-payment">
225
+ ${icon.render({
226
+ size: "lg",
227
+ children: html`<i
228
+ class="fa-brands fa-${row.payment}"
229
+ aria-hidden="true"
230
+ ></i>`,
231
+ })}
232
+ </div>`,
233
+ activity: html`
234
+ <div>
235
+ <div class="iw-dashboard-user-subtitle">Last login</div>
236
+ <div>${row.activity}</div>
237
+ </div>
238
+ `,
239
+ menu: html`
240
+ <div class="iw-dashboard-menu-cell">
241
+ ${button.render({
242
+ variant: "ghost",
243
+ color: "secondary",
244
+ children: materialIcon.render({ name: "more_vert" }),
245
+ "aria-label": "Row actions",
246
+ })}
247
+ </div>
248
+ `,
249
+ })),
250
+ })}
251
+ `,
252
+ })
253
+ },
254
+
255
+ renderKpi(_, { label, value, color }) {
256
+ return html`
257
+ <div class="iw-dashboard-kpi" style=${`color: ${color};`}>
258
+ ${typography.render({
259
+ variant: "caption",
260
+ children: label,
261
+ color: "var(--iw-color-text-secondary)",
262
+ })}
263
+ ${typography.render({ variant: "h3", children: value })}
264
+ </div>
265
+ `
266
+ },
267
+ }
@@ -0,0 +1,70 @@
1
+ import { createRender } from "../../stories/notifyStory.js"
2
+ import { alert } from "."
3
+
4
+ export default {
5
+ title: "Feedback/Alert",
6
+ tags: ["autodocs"],
7
+ render: createRender(alert),
8
+ argTypes: {
9
+ title: { control: "text" },
10
+ description: { control: "text" },
11
+ severity: {
12
+ control: "select",
13
+ options: ["info", "success", "warning", "error"],
14
+ },
15
+ variant: { control: "select", options: ["filled", "outlined"] },
16
+ icon: { control: "text" },
17
+ onClose: { action: "onClose" },
18
+ },
19
+ }
20
+
21
+ export const Info = {
22
+ args: {
23
+ title: "Info",
24
+ description: "This is an informational alert.",
25
+ severity: "info",
26
+ },
27
+ }
28
+
29
+ export const Success = {
30
+ args: {
31
+ title: "Success",
32
+ description: "Your changes have been saved.",
33
+ severity: "success",
34
+ },
35
+ }
36
+
37
+ export const Warning = {
38
+ args: {
39
+ title: "Warning",
40
+ description: "Please double-check your entries.",
41
+ severity: "warning",
42
+ },
43
+ }
44
+
45
+ export const Error = {
46
+ args: {
47
+ title: "Error",
48
+ description: "Something went wrong.",
49
+ severity: "error",
50
+ },
51
+ }
52
+
53
+ export const Outlined = {
54
+ args: {
55
+ title: "Outlined Alert",
56
+ description: "This alert uses the outlined variant.",
57
+ variant: "outlined",
58
+ severity: "info",
59
+ },
60
+ }
61
+
62
+ export const Actionable = {
63
+ args: {
64
+ title: "Saved",
65
+ description: "Your draft was saved.",
66
+ severity: "success",
67
+ action: "Undo",
68
+ onClose: () => {},
69
+ },
70
+ }
@@ -0,0 +1,3 @@
1
+ import { render } from "./template.js"
2
+
3
+ export const alert = { render }
@@ -0,0 +1,98 @@
1
+ .iw-alert {
2
+ display: flex;
3
+ align-items: flex-start;
4
+ gap: var(--iw-space-3);
5
+ padding: var(--iw-space-3);
6
+ border-radius: var(--iw-alert-radius, var(--iw-radius-md));
7
+ background: var(--iw-color-surface);
8
+ color: var(--iw-color-text);
9
+ border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
10
+ box-shadow: var(--iw-alert-shadow, none);
11
+ }
12
+
13
+ .iw-alert-icon {
14
+ display: inline-flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ margin-top: 0.1em;
18
+ color: var(--iw-alert-color, currentColor);
19
+ }
20
+
21
+ .iw-alert-content {
22
+ display: flex;
23
+ flex-direction: column;
24
+ gap: var(--iw-space-1);
25
+ flex: 1 1 auto;
26
+ }
27
+
28
+ .iw-alert-title {
29
+ font-weight: var(--iw-font-weight-semibold);
30
+ }
31
+
32
+ .iw-alert-description {
33
+ color: color-mix(in srgb, currentColor 88%, transparent);
34
+ }
35
+
36
+ .iw-alert-trailing {
37
+ margin-left: auto;
38
+ display: inline-flex;
39
+ align-items: center;
40
+ gap: var(--iw-space-2);
41
+ }
42
+
43
+ .iw-alert-action {
44
+ display: inline-flex;
45
+ align-items: center;
46
+ gap: var(--iw-space-2);
47
+ }
48
+
49
+ .iw-alert-close {
50
+ border: 0 none;
51
+ background: transparent;
52
+ cursor: pointer;
53
+ width: 1.75rem;
54
+ height: 1.75rem;
55
+ border-radius: var(--iw-radius-sm);
56
+ display: inline-flex;
57
+ align-items: center;
58
+ justify-content: center;
59
+ line-height: 1;
60
+ color: inherit;
61
+ font-size: 1rem;
62
+ }
63
+
64
+ .iw-alert-close:hover {
65
+ background: color-mix(in srgb, currentColor 12%, transparent);
66
+ }
67
+
68
+ .iw-alert-info {
69
+ --iw-alert-color: var(--iw-color-info, #2f7ef7);
70
+ }
71
+
72
+ .iw-alert-success {
73
+ --iw-alert-color: var(--iw-color-success, #2e8b57);
74
+ }
75
+
76
+ .iw-alert-warning {
77
+ --iw-alert-color: var(--iw-color-warning, #c79500);
78
+ }
79
+
80
+ .iw-alert-error {
81
+ --iw-alert-color: var(--iw-color-error, #d14343);
82
+ }
83
+
84
+ .iw-alert-outlined {
85
+ background: transparent;
86
+ border-color: color-mix(in srgb, var(--iw-alert-color) 55%, transparent);
87
+ color: var(--iw-alert-color);
88
+ }
89
+
90
+ .iw-alert-filled {
91
+ background: color-mix(
92
+ in srgb,
93
+ var(--iw-alert-color) 18%,
94
+ var(--iw-color-surface)
95
+ );
96
+ border-color: color-mix(in srgb, var(--iw-alert-color) 45%, transparent);
97
+ color: color-mix(in srgb, var(--iw-alert-color) 72%, var(--iw-color-text));
98
+ }