lutra 0.0.33 → 0.1.4

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 (274) hide show
  1. package/README.md +4 -24
  2. package/dist/components/AspectRatio.svelte +26 -0
  3. package/dist/components/AspectRatio.svelte.d.ts +8 -0
  4. package/dist/components/Avatar.svelte +105 -0
  5. package/dist/components/Avatar.svelte.d.ts +14 -0
  6. package/dist/{display → components}/Close.svelte +25 -7
  7. package/dist/components/Close.svelte.d.ts +7 -0
  8. package/dist/components/ContextTip.svelte +41 -0
  9. package/dist/components/ContextTip.svelte.d.ts +7 -0
  10. package/dist/components/Dialog.svelte +78 -0
  11. package/dist/components/Dialog.svelte.d.ts +14 -0
  12. package/dist/components/Icon.svelte +62 -0
  13. package/dist/components/Icon.svelte.d.ts +8 -0
  14. package/dist/{display → components}/IconButton.svelte +43 -14
  15. package/dist/components/IconButton.svelte.d.ts +16 -0
  16. package/dist/components/Image.svelte +172 -0
  17. package/dist/components/Image.svelte.d.ts +56 -0
  18. package/dist/{display → components}/Indicator.svelte +44 -9
  19. package/dist/components/Indicator.svelte.d.ts +12 -0
  20. package/dist/{display → components}/Inset.svelte +8 -3
  21. package/dist/components/Inset.svelte.d.ts +7 -0
  22. package/dist/components/Layout.svelte +33 -0
  23. package/dist/components/Layout.svelte.d.ts +11 -0
  24. package/dist/components/MenuDropdown.svelte +195 -0
  25. package/dist/components/MenuDropdown.svelte.d.ts +16 -0
  26. package/dist/{nav → components}/MenuItem.svelte +46 -38
  27. package/dist/components/MenuItem.svelte.d.ts +11 -0
  28. package/dist/components/MenuItemContent.svelte +25 -0
  29. package/dist/components/MenuItemContent.svelte.d.ts +10 -0
  30. package/dist/{nav → components}/MenuTypes.d.ts +19 -5
  31. package/dist/components/Modal.svelte +149 -0
  32. package/dist/components/Modal.svelte.d.ts +16 -0
  33. package/dist/{display → components}/Notification.svelte +33 -22
  34. package/dist/components/Notification.svelte.d.ts +12 -0
  35. package/dist/components/Overlay.svelte +31 -0
  36. package/dist/components/Overlay.svelte.d.ts +14 -0
  37. package/dist/{layout → components}/OverlayContainer.svelte +6 -3
  38. package/dist/{layout → components}/OverlayContainer.svelte.d.ts +4 -1
  39. package/dist/components/OverlayLayer.svelte +168 -0
  40. package/dist/components/OverlayLayer.svelte.d.ts +8 -0
  41. package/dist/components/PageContent.svelte +108 -0
  42. package/dist/components/PageContent.svelte.d.ts +38 -0
  43. package/dist/components/TabbedContent.svelte +74 -0
  44. package/dist/components/TabbedContent.svelte.d.ts +11 -0
  45. package/dist/components/TabbedContentItem.svelte +33 -0
  46. package/dist/components/TabbedContentItem.svelte.d.ts +10 -0
  47. package/dist/components/Table.svelte +41 -0
  48. package/dist/components/Table.svelte.d.ts +13 -0
  49. package/dist/{nav → components}/Tabs.svelte +99 -41
  50. package/dist/components/Tabs.svelte.d.ts +20 -0
  51. package/dist/components/Tag.svelte +120 -0
  52. package/dist/components/Tag.svelte.d.ts +21 -0
  53. package/dist/components/Theme.svelte +105 -0
  54. package/dist/components/Theme.svelte.d.ts +17 -0
  55. package/dist/{display → components}/Tooltip.svelte +41 -16
  56. package/dist/components/Tooltip.svelte.d.ts +12 -0
  57. package/dist/components/UIContent.svelte +19 -0
  58. package/dist/components/UIContent.svelte.d.ts +7 -0
  59. package/dist/components/index.d.ts +28 -0
  60. package/dist/components/index.js +29 -0
  61. package/dist/{display → components}/notifications.svelte.d.ts +1 -1
  62. package/dist/{display → components}/notifications.svelte.js +3 -4
  63. package/dist/{layout → components}/overlays.svelte.d.ts +4 -2
  64. package/dist/config.d.ts +30 -0
  65. package/dist/config.js +18 -0
  66. package/dist/css/1-props.css +440 -0
  67. package/dist/css/2-base.css +343 -0
  68. package/dist/css/3-typo.css +106 -0
  69. package/dist/css/4-layout.css +368 -0
  70. package/dist/css/5-media.css +116 -0
  71. package/dist/css/lutra.css +7 -0
  72. package/dist/css/themes/DefaultTheme.css +209 -0
  73. package/dist/form/Button.svelte +35 -16
  74. package/dist/form/Button.svelte.d.ts +8 -19
  75. package/dist/form/Datepicker.svelte +311 -0
  76. package/dist/form/Datepicker.svelte.d.ts +9 -0
  77. package/dist/form/FieldContent.svelte +69 -44
  78. package/dist/form/FieldContent.svelte.d.ts +7 -17
  79. package/dist/form/FieldError.svelte +16 -6
  80. package/dist/form/FieldError.svelte.d.ts +4 -15
  81. package/dist/form/Fieldset.svelte +48 -13
  82. package/dist/form/Fieldset.svelte.d.ts +5 -16
  83. package/dist/form/Form.svelte +158 -74
  84. package/dist/form/Form.svelte.d.ts +17 -17
  85. package/dist/form/{FieldActions.svelte → FormActions.svelte} +29 -17
  86. package/dist/form/FormActions.svelte.d.ts +9 -0
  87. package/dist/form/FormSection.svelte +96 -0
  88. package/dist/form/FormSection.svelte.d.ts +9 -0
  89. package/dist/form/ImageUpload.svelte +134 -94
  90. package/dist/form/ImageUpload.svelte.d.ts +5 -16
  91. package/dist/form/Input.svelte +254 -136
  92. package/dist/form/Input.svelte.d.ts +12 -21
  93. package/dist/form/InputLength.svelte +15 -5
  94. package/dist/form/InputLength.svelte.d.ts +4 -15
  95. package/dist/form/Label.svelte +55 -11
  96. package/dist/form/Label.svelte.d.ts +6 -15
  97. package/dist/form/LogoUpload.svelte +36 -21
  98. package/dist/form/LogoUpload.svelte.d.ts +4 -15
  99. package/dist/form/Select.svelte +100 -50
  100. package/dist/form/Select.svelte.d.ts +5 -16
  101. package/dist/form/Textarea.svelte +200 -98
  102. package/dist/form/Textarea.svelte.d.ts +11 -24
  103. package/dist/form/Toggle.svelte +3 -1
  104. package/dist/form/Toggle.svelte.d.ts +4 -1
  105. package/dist/form/client.svelte.d.ts +1 -0
  106. package/dist/form/client.svelte.js +6 -2
  107. package/dist/form/form.d.ts +10 -9
  108. package/dist/form/form.js +37 -32
  109. package/dist/form/index.d.ts +3 -4
  110. package/dist/form/index.js +3 -4
  111. package/dist/form/types.d.ts +9 -16
  112. package/dist/icons/IconAlert.svelte.d.ts +4 -1
  113. package/dist/icons/IconCopy.svelte.d.ts +4 -1
  114. package/dist/icons/IconDone.svelte.d.ts +4 -1
  115. package/dist/icons/IconError.svelte.d.ts +4 -1
  116. package/dist/icons/IconHelp.svelte.d.ts +4 -1
  117. package/dist/icons/IconHide.svelte.d.ts +4 -1
  118. package/dist/icons/IconInfo.svelte.d.ts +4 -1
  119. package/dist/icons/IconLink.svelte.d.ts +4 -1
  120. package/dist/icons/IconMenuBurger.svelte.d.ts +4 -1
  121. package/dist/icons/IconMenuDots.svelte.d.ts +4 -1
  122. package/dist/icons/IconSearch.svelte.d.ts +4 -1
  123. package/dist/icons/IconShow.svelte.d.ts +4 -1
  124. package/dist/icons/IconSuccess.svelte.d.ts +4 -1
  125. package/dist/icons/IconWarning.svelte.d.ts +4 -1
  126. package/dist/index.d.ts +3 -1
  127. package/dist/index.js +3 -2
  128. package/dist/types.d.ts +39 -0
  129. package/dist/types.js +25 -0
  130. package/dist/util/StringOrComponent.svelte +20 -0
  131. package/dist/util/StringOrComponent.svelte.d.ts +8 -0
  132. package/dist/util/StringOrSnippet.svelte +16 -0
  133. package/dist/util/StringOrSnippet.svelte.d.ts +8 -0
  134. package/dist/{utils → util}/dom.js +1 -2
  135. package/dist/util/locale.d.ts +1 -0
  136. package/dist/util/locale.js +47 -0
  137. package/dist/util/settings.d.ts +4 -0
  138. package/package.json +35 -79
  139. package/dist/color.css +0 -0
  140. package/dist/display/Avatar.svelte +0 -61
  141. package/dist/display/Avatar.svelte.d.ts +0 -19
  142. package/dist/display/Badge.svelte +0 -91
  143. package/dist/display/Badge.svelte.d.ts +0 -30
  144. package/dist/display/Callout.svelte +0 -109
  145. package/dist/display/Callout.svelte.d.ts +0 -28
  146. package/dist/display/Close.svelte.d.ts +0 -18
  147. package/dist/display/Code.svelte +0 -190
  148. package/dist/display/Code.svelte.d.ts +0 -32
  149. package/dist/display/ContextTip.svelte +0 -23
  150. package/dist/display/ContextTip.svelte.d.ts +0 -18
  151. package/dist/display/DataList.svelte +0 -16
  152. package/dist/display/DataList.svelte.d.ts +0 -21
  153. package/dist/display/Details.svelte +0 -49
  154. package/dist/display/Details.svelte.d.ts +0 -27
  155. package/dist/display/Hero.svelte +0 -50
  156. package/dist/display/Hero.svelte.d.ts +0 -26
  157. package/dist/display/Icon.svelte +0 -39
  158. package/dist/display/Icon.svelte.d.ts +0 -19
  159. package/dist/display/IconButton.svelte.d.ts +0 -27
  160. package/dist/display/Image.svelte +0 -91
  161. package/dist/display/Image.svelte.d.ts +0 -26
  162. package/dist/display/Indicator.svelte.d.ts +0 -23
  163. package/dist/display/Inset.svelte.d.ts +0 -18
  164. package/dist/display/LineChart.svelte +0 -385
  165. package/dist/display/LineChart.svelte.d.ts +0 -24
  166. package/dist/display/LoadingIndicator.svelte +0 -33
  167. package/dist/display/LoadingIndicator.svelte.d.ts +0 -15
  168. package/dist/display/Modal.svelte +0 -116
  169. package/dist/display/Modal.svelte.d.ts +0 -27
  170. package/dist/display/Notification.svelte.d.ts +0 -23
  171. package/dist/display/Panel.svelte +0 -23
  172. package/dist/display/Panel.svelte.d.ts +0 -19
  173. package/dist/display/Popup.svelte +0 -111
  174. package/dist/display/Popup.svelte.d.ts +0 -25
  175. package/dist/display/Stat.svelte +0 -81
  176. package/dist/display/Stat.svelte.d.ts +0 -30
  177. package/dist/display/Table.svelte +0 -28
  178. package/dist/display/Table.svelte.d.ts +0 -24
  179. package/dist/display/TablePaginator.svelte +0 -51
  180. package/dist/display/TablePaginator.svelte.d.ts +0 -21
  181. package/dist/display/Tag.svelte +0 -90
  182. package/dist/display/Tag.svelte.d.ts +0 -32
  183. package/dist/display/Tooltip.svelte.d.ts +0 -23
  184. package/dist/display/chart.d.ts +0 -78
  185. package/dist/display/chart.js +0 -212
  186. package/dist/display/index.d.ts +0 -24
  187. package/dist/display/index.js +0 -24
  188. package/dist/form/FieldActions.svelte.d.ts +0 -20
  189. package/dist/form/FieldContainer.svelte +0 -37
  190. package/dist/form/FieldContainer.svelte.d.ts +0 -19
  191. package/dist/form/FieldSection.svelte +0 -86
  192. package/dist/form/FieldSection.svelte.d.ts +0 -20
  193. package/dist/layout/Layout.svelte +0 -47
  194. package/dist/layout/Layout.svelte.d.ts +0 -22
  195. package/dist/layout/LayoutFooter.svelte +0 -21
  196. package/dist/layout/LayoutFooter.svelte.d.ts +0 -18
  197. package/dist/layout/LayoutGrid.svelte +0 -51
  198. package/dist/layout/LayoutGrid.svelte.d.ts +0 -27
  199. package/dist/layout/LayoutHeader.svelte +0 -97
  200. package/dist/layout/LayoutHeader.svelte.d.ts +0 -34
  201. package/dist/layout/LayoutSideMenu.svelte +0 -55
  202. package/dist/layout/LayoutSideMenu.svelte.d.ts +0 -21
  203. package/dist/layout/LayoutTypes.d.ts +0 -15
  204. package/dist/layout/LayoutTypes.js +0 -9
  205. package/dist/layout/Overlay.svelte +0 -20
  206. package/dist/layout/Overlay.svelte.d.ts +0 -25
  207. package/dist/layout/OverlayLayer.svelte +0 -140
  208. package/dist/layout/OverlayLayer.svelte.d.ts +0 -19
  209. package/dist/layout/PageContent.svelte +0 -82
  210. package/dist/layout/PageContent.svelte.d.ts +0 -25
  211. package/dist/layout/Theme.svelte +0 -243
  212. package/dist/layout/Theme.svelte.d.ts +0 -19
  213. package/dist/layout/UIContent.svelte +0 -15
  214. package/dist/layout/UIContent.svelte.d.ts +0 -18
  215. package/dist/layout/index.d.ts +0 -11
  216. package/dist/layout/index.js +0 -11
  217. package/dist/nav/Breadcrumb.svelte +0 -82
  218. package/dist/nav/Breadcrumb.svelte.d.ts +0 -28
  219. package/dist/nav/Menu.svelte +0 -170
  220. package/dist/nav/Menu.svelte.d.ts +0 -27
  221. package/dist/nav/MenuItem.svelte.d.ts +0 -22
  222. package/dist/nav/NavMenu.svelte +0 -181
  223. package/dist/nav/NavMenu.svelte.d.ts +0 -19
  224. package/dist/nav/TabbedContent.svelte +0 -43
  225. package/dist/nav/TabbedContent.svelte.d.ts +0 -23
  226. package/dist/nav/Tabs.svelte.d.ts +0 -25
  227. package/dist/nav/index.d.ts +0 -7
  228. package/dist/nav/index.js +0 -6
  229. package/dist/style.css +0 -950
  230. package/dist/typo/Clamp.svelte +0 -25
  231. package/dist/typo/Clamp.svelte.d.ts +0 -24
  232. package/dist/typo/H.svelte +0 -52
  233. package/dist/typo/H.svelte.d.ts +0 -28
  234. package/dist/typo/H1.svelte +0 -14
  235. package/dist/typo/H1.svelte.d.ts +0 -26
  236. package/dist/typo/H2.svelte +0 -14
  237. package/dist/typo/H2.svelte.d.ts +0 -26
  238. package/dist/typo/H3.svelte +0 -14
  239. package/dist/typo/H3.svelte.d.ts +0 -26
  240. package/dist/typo/H4.svelte +0 -14
  241. package/dist/typo/H4.svelte.d.ts +0 -26
  242. package/dist/typo/H5.svelte +0 -14
  243. package/dist/typo/H5.svelte.d.ts +0 -26
  244. package/dist/typo/H6.svelte +0 -14
  245. package/dist/typo/H6.svelte.d.ts +0 -26
  246. package/dist/typo/P.svelte +0 -34
  247. package/dist/typo/P.svelte.d.ts +0 -26
  248. package/dist/typo/index.d.ts +0 -9
  249. package/dist/typo/index.js +0 -9
  250. package/dist/utils/StringOrComponent.svelte +0 -14
  251. package/dist/utils/StringOrComponent.svelte.d.ts +0 -19
  252. package/dist/utils/StringOrSnippet.svelte +0 -11
  253. package/dist/utils/StringOrSnippet.svelte.d.ts +0 -19
  254. package/dist/utils/defaults.d.ts +0 -4
  255. package/dist/utils/hooks.server.d.ts +0 -2
  256. package/dist/utils/hooks.server.js +0 -16
  257. package/dist/utils/id.d.ts +0 -1
  258. package/dist/utils/id.js +0 -3
  259. package/dist/utils/index.d.ts +0 -9
  260. package/dist/utils/index.js +0 -6
  261. package/dist/utils/isSnippet.d.ts +0 -3
  262. package/dist/utils/isSnippet.js +0 -11
  263. /package/dist/{nav → components}/MenuTypes.js +0 -0
  264. /package/dist/{layout → components}/overlays.svelte.js +0 -0
  265. /package/dist/{utils → util}/attr.d.ts +0 -0
  266. /package/dist/{utils → util}/attr.js +0 -0
  267. /package/dist/{utils → util}/color.d.ts +0 -0
  268. /package/dist/{utils → util}/color.js +0 -0
  269. /package/dist/{utils → util}/dom.d.ts +0 -0
  270. /package/dist/{utils → util}/keyboard.svelte.d.ts +0 -0
  271. /package/dist/{utils → util}/keyboard.svelte.js +0 -0
  272. /package/dist/{utils/defaults.js → util/settings.js} +0 -0
  273. /package/dist/{utils → util}/transitions.d.ts +0 -0
  274. /package/dist/{utils → util}/transitions.js +0 -0
@@ -0,0 +1,120 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ import { isStatusColor } from '../util/color.js';
4
+ import type { StatusColorOrString } from '../util/color.js';
5
+ /**
6
+ * @description
7
+ * A tag is a small piece of information that can be used to categorize or label an item. You can pick between `rounded`, `pill` or `rectangle` shapes. The font size and padding are relative to the parent element by default.
8
+ * Changing the font size without changing the padding will cause padding to be scaled with the font size. This can be changed by setting the `--padding` CSS prop.
9
+ * You can pass a `href` to make the tag a link, or an `onclick` function to make it a button. If you pass a `href`, you can also pass a `target` to specify the target of the link.
10
+ * @cssprop --font-size - The font size of the tag. (Default: 1em)
11
+ * @cssprop --font-weight - The font weight of the tag. (Default: 500)
12
+ * @cssprop --padding - The padding of the tag. (Default: 0.25em 0.5em)
13
+ * @cssprop --vertical-align - The vertical alignment of the tag. (Default: baseline)
14
+ * @example
15
+ * <Tag href="https://google.com" target="_blank" --font-size="1.5rem" color="alert">Tag with a link</Tag>
16
+ * <Tag --padding="0.5em 1em" color="warn" onclick={() => { alert("Hi!"); }}>Warning</Tag>
17
+ * <Tag color="ok">Status OK</Tag>
18
+ * <Tag color="info">Informational</Tag>
19
+ * <p>Here's an inline <Tag code>code tag</Tag> in some text</p>
20
+ */
21
+ let {
22
+ code,
23
+ color = "default",
24
+ shape = "pill",
25
+ onclick,
26
+ href,
27
+ target,
28
+ children,
29
+ }: {
30
+ /** Use a mono-spaced font for the tag. */
31
+ code?: boolean;
32
+ /** The color of the tag. */
33
+ color?: StatusColorOrString;
34
+ /** The shape of the tag. */
35
+ shape?: "rounded" | "pill" | "rectangle";
36
+ /** A function to run when the tag is clicked. */
37
+ onclick?: (event: MouseEvent) => void;
38
+ /** A URL to link to. */
39
+ href?: string;
40
+ /** The target of the link. */
41
+ target?: string;
42
+ /** The content of the tag. */
43
+ children: Snippet;
44
+ } = $props();
45
+ let isSet = $derived(color ? isStatusColor(color) : true);
46
+ </script>
47
+
48
+ {#snippet content()}
49
+ <em>
50
+ {@render children()}
51
+ </em>
52
+ {/snippet}
53
+
54
+ {#if href}
55
+ <a {href} {target} class:code class="Tag Link {shape}" style="--bgColor: {!isSet ? color : 'var(--status-'+color+'-background)'}; --textColor: {!isSet ? color : 'var(--status-'+color+'-color)'};" onclick={onclick}>
56
+ {@render content()}
57
+ </a>
58
+ {:else if onclick}
59
+ <button type="button" class:code class="Tag {shape}" style="--bgColor: {!isSet ? color : 'var(--status-'+color+'-background)'}; --textColor: {!isSet ? color : 'var(--status-'+color+'-color)'};" onclick={onclick}>
60
+ {@render content()}
61
+ </button>
62
+ {:else}
63
+ <span class:code class="Tag {shape}" style="--bgColor: {!isSet ? color : 'var(--status-'+color+'-background)'}; --textColor: {!isSet ? color : 'var(--status-'+color+'-color)'};">
64
+ {@render content()}
65
+ </span>
66
+ {/if}
67
+
68
+ <style>
69
+ .Tag {
70
+ display: inline-flex;
71
+ padding: var(--padding, 0.5em 0.5em);
72
+ font-weight: var(--font-weight, 500);
73
+ background: var(--bgColor);
74
+ border-radius: var(--border-radius);
75
+ font-size: var(--font-size, 0.85em);
76
+ vertical-align: var(--vertical-align, baseline);
77
+ border: 1px solid color-mix(in srgb, var(--bgColor) 95%, var(--mix-target, black) 5%);
78
+ }
79
+ .Tag.rectangle {
80
+ border-radius: 0;
81
+ }
82
+ .Tag.pill {
83
+ border-radius: 99999px;
84
+ }
85
+ .Tag.code {
86
+ font-family: var(--font-family-mono);
87
+ padding: var(--padding, 0.15em 0.35em);
88
+ font-size: 1em;
89
+ line-height: 1em;
90
+ background: var(--bg, var(--bg-subtle));
91
+ color: var(--textColor);
92
+ border: var(--border, var(--border-subtle));
93
+ }
94
+ em {
95
+ font-style: normal;
96
+ left: 50%;
97
+ text-box: trim-both cap alphabetic;
98
+ position: relative;
99
+ display: block;
100
+ transform: translateX(-50%);
101
+ }
102
+ a:hover, button:hover {
103
+ --bgColor2: color-mix(in srgb, var(--bgColor) 87%, white 13%);
104
+ background-color: var(--bgColor2);
105
+ cursor: pointer;
106
+ }
107
+ @media (prefers-contrast: more) {
108
+ .Tag {
109
+ border: 1px solid color-mix(in srgb, var(--bgColor) 50%, var(--mix-target, black) 50%);
110
+ }
111
+ em {
112
+ opacity: 0.99;
113
+ }
114
+ }
115
+ @media (prefers-contrast: less) {
116
+ em {
117
+ opacity: 0.65;
118
+ }
119
+ }
120
+ </style>
@@ -0,0 +1,21 @@
1
+ import type { Snippet } from "svelte";
2
+ import type { StatusColorOrString } from '../util/color.js';
3
+ type $$ComponentProps = {
4
+ /** Use a mono-spaced font for the tag. */
5
+ code?: boolean;
6
+ /** The color of the tag. */
7
+ color?: StatusColorOrString;
8
+ /** The shape of the tag. */
9
+ shape?: "rounded" | "pill" | "rectangle";
10
+ /** A function to run when the tag is clicked. */
11
+ onclick?: (event: MouseEvent) => void;
12
+ /** A URL to link to. */
13
+ href?: string;
14
+ /** The target of the link. */
15
+ target?: string;
16
+ /** The content of the tag. */
17
+ children: Snippet;
18
+ };
19
+ declare const Tag: import("svelte").Component<$$ComponentProps, {}, "">;
20
+ type Tag = ReturnType<typeof Tag>;
21
+ export default Tag;
@@ -0,0 +1,105 @@
1
+ <script lang="ts">
2
+ import { browser } from "$app/environment";
3
+ import { onMount, setContext, type Snippet } from "svelte";
4
+ import { defaultConfig, type LutraConfig, type LutraRootConfig } from "../config.js";
5
+ import { getContextItem, LutraContext, type LutraTheme } from "../types.js";
6
+
7
+ /**
8
+ * @description
9
+ * A theme component. It is used to set the theme of the app in the root of the layout. You can also use it to set the theme of a specific section of the app.
10
+ */
11
+
12
+ // Destructuring props with default values
13
+ let {
14
+ theme,
15
+ config,
16
+ children
17
+ }: {
18
+ /**
19
+ * The theme to use. Leave undefined to use the system theme.
20
+ */
21
+ theme?: LutraTheme;
22
+ /**
23
+ * Lutra config. Leave undefined to use the default config.
24
+ */
25
+ config?: LutraRootConfig;
26
+ children: Snippet
27
+ } = $props();
28
+
29
+ // Determine if this is the root theme context
30
+ const root = getContextItem(LutraContext.Theme) === undefined;
31
+
32
+ // Retrieve existing configuration from context if available
33
+ const existingConfig = getContextItem(LutraContext.Config);
34
+
35
+ let _theme = $state(theme);
36
+
37
+ // If no config is provided, use the existing one from context or default to the defaultConfig
38
+ if(!config) {
39
+ config = existingConfig || defaultConfig;
40
+ }
41
+
42
+ // Set the configuration in the context for child components to access
43
+ setContext(LutraContext.Config, config);
44
+
45
+ // Retrieve existing theme from context if available
46
+ let existingTheme = getContextItem(LutraContext.Theme);
47
+
48
+ function getTheme() {
49
+ if(browser) {
50
+ return localStorage.getItem('lutra.theme') || (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
51
+ }
52
+ // TODO: Implement Sec-CH-Prefers-Color-Scheme header getting from context
53
+ return getContextItem(LutraContext.SecChPrefersColorScheme) || 'light';
54
+ }
55
+
56
+ // If no theme is provided, determine it from localStorage or system preferences
57
+ if(!theme) {
58
+ _theme = existingTheme || getTheme();
59
+ } else if(theme === 'invert') {
60
+ _theme = (existingTheme || getTheme()) === 'light' ? 'dark' : 'light';
61
+ }
62
+
63
+ onMount(() => {
64
+ const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
65
+ mediaQuery.addEventListener('change', (e) => {
66
+ if(browser && root && !theme && !existingTheme && !localStorage.getItem('lutra.theme')) {
67
+ _theme = e.matches ? 'dark' : 'light';
68
+ } else if(root && theme === "invert") {
69
+ _theme = existingTheme === 'light' ? 'dark' : 'light';
70
+ existingTheme = getContextItem(LutraContext.Theme);
71
+ } else if(root && !theme) {
72
+ _theme = existingTheme || getTheme();
73
+ }
74
+ });
75
+ });
76
+
77
+ // Set the theme in the context for child components to access
78
+ setContext(LutraContext.Theme, theme);
79
+ </script>
80
+
81
+ <svelte:head>
82
+ {#if !root}
83
+ <meta name="theme-color" content="{theme === 'dark' ? (config?.themeColor?.dark || '#000') : (config?.themeColor?.light || '#fff')}" />
84
+ {/if}
85
+ </svelte:head>
86
+
87
+ <div class="Theme {_theme}" class:root>
88
+ {@render children()}
89
+ </div>
90
+
91
+ <style>
92
+ @layer base {
93
+ .Theme {
94
+ display: contents;
95
+ color-scheme: light dark;
96
+ }
97
+ .Theme.light {
98
+ color-scheme: light;
99
+ }
100
+ .Theme.dark {
101
+ color-scheme: dark;
102
+ }
103
+ }
104
+ </style>
105
+
@@ -0,0 +1,17 @@
1
+ import { type Snippet } from "svelte";
2
+ import { type LutraRootConfig } from "../config.js";
3
+ import { type LutraTheme } from "../types.js";
4
+ type $$ComponentProps = {
5
+ /**
6
+ * The theme to use. Leave undefined to use the system theme.
7
+ */
8
+ theme?: LutraTheme;
9
+ /**
10
+ * Lutra config. Leave undefined to use the default config.
11
+ */
12
+ config?: LutraRootConfig;
13
+ children: Snippet;
14
+ };
15
+ declare const Theme: import("svelte").Component<$$ComponentProps, {}, "">;
16
+ type Theme = ReturnType<typeof Theme>;
17
+ export default Theme;
@@ -1,11 +1,36 @@
1
- <script lang="ts">import Theme from "../layout/Theme.svelte";
2
- let {
3
- children,
4
- tip,
5
- open
6
- } = $props();
7
- const id = `tt-${Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)}`;
8
- let offsetX = $state(0);
1
+ <script lang="ts">
2
+ import Theme from "./Theme.svelte";
3
+ import type { Snippet } from "svelte";
4
+
5
+ /**
6
+ * @description
7
+ * A tooltip component that displays a tooltip when hovering or focusing on the trigger element.
8
+ * When hovering, the tooltip will fade in with a default delay of 0.5s (can be changed with the `--delay` CSS prop). With a keyboard focus, the tooltip will fade in immediately.
9
+ * @supports prefers-reduced-motion
10
+ * @supports hover
11
+ * @aria role="tooltip"
12
+ * @aria aria-describedby=""
13
+ * @cssprop --delay - The delay of the tooltip fade in animation. (Default: 0.5s)
14
+ * @example
15
+ * <h3>Tooltip example</h3>
16
+ * <p>Lorem ipsum <Tooltip tip="This is a tooltip"><a href="#">dolor sit amet</a></Tooltip></p>
17
+ */
18
+ let {
19
+ children,
20
+ tip,
21
+ open,
22
+ }: {
23
+ /** Content to trigger the tooltip */
24
+ children: Snippet;
25
+ /** The content of the tooltip */
26
+ tip: string | Snippet;
27
+ /** Open the tooltip on render (cannot be closed) */
28
+ open?: boolean;
29
+ } = $props();
30
+
31
+ const id = `tt-${Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)}`;
32
+ let offsetX = $state(0);
33
+
9
34
  </script>
10
35
 
11
36
  <span class="Tooltip" class:open>
@@ -20,7 +45,7 @@ let offsetX = $state(0);
20
45
  </span>
21
46
  <svg width="12" height="8" viewBox="0 0 12 8" version="1.1">
22
47
  <g transform="matrix(0.75,0,0,1,0,0)">
23
- <path d="M16,0L0,0L8,8L16,0Z" fill="var(--bg-app)"/>
48
+ <path d="M16,0L0,0L8,8L16,0Z" fill="var(--tooltip-background)"/>
24
49
  </g>
25
50
  </svg>
26
51
  </Theme>
@@ -46,22 +71,22 @@ let offsetX = $state(0);
46
71
  display: flex;
47
72
  flex-direction: column;
48
73
  align-items: center;
49
- filter: drop-shadow(0px 2px 5px var(--border-subtle-color));
74
+ filter: drop-shadow(0px 2px 5px var(--tooltip-shadow-color));
50
75
  opacity: 0;
51
76
  pointer-events: none;
52
77
  }
53
78
  .TooltipContent {
54
- background-color: var(--bg-app);
79
+ background-color: var(--tooltip-background);
55
80
  padding: 0.35rem 0.5rem;
56
- border-radius: calc(var(--border-radius));
57
- border-top: var(--border-subtle);
58
- border-left: var(--border-subtle);
59
- border-right: var(--border-subtle);
81
+ border-radius: var(--tooltip-border-radius);
82
+ border-top: var(--tooltip-border-size);
83
+ border-left: var(--tooltip-border-size);
84
+ border-right: var(--tooltip-border-size);
60
85
  display: block;
61
86
  font-size: max(0.75rem, 11px);
62
87
  line-height: 1.35;
63
88
  font-weight: 500;
64
- color: var(--text-heading);
89
+ color: var(--tooltip-color);
65
90
  max-width: clamp(25ch, 100%, 25ch);
66
91
  width: max-content;
67
92
  }
@@ -0,0 +1,12 @@
1
+ import type { Snippet } from "svelte";
2
+ type $$ComponentProps = {
3
+ /** Content to trigger the tooltip */
4
+ children: Snippet;
5
+ /** The content of the tooltip */
6
+ tip: string | Snippet;
7
+ /** Open the tooltip on render (cannot be closed) */
8
+ open?: boolean;
9
+ };
10
+ declare const Tooltip: import("svelte").Component<$$ComponentProps, {}, "">;
11
+ type Tooltip = ReturnType<typeof Tooltip>;
12
+ export default Tooltip;
@@ -0,0 +1,19 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from "svelte";
3
+ let {
4
+ children,
5
+ }: {
6
+ children: Snippet;
7
+ } = $props();
8
+ </script>
9
+
10
+ <div class="UIContent">
11
+ {@render children()}
12
+ </div>
13
+
14
+ <style>
15
+ .UIContent {
16
+ display: contents;
17
+ --isPage: 0;
18
+ }
19
+ </style>
@@ -0,0 +1,7 @@
1
+ import type { Snippet } from "svelte";
2
+ type $$ComponentProps = {
3
+ children: Snippet;
4
+ };
5
+ declare const UiContent: import("svelte").Component<$$ComponentProps, {}, "">;
6
+ type UiContent = ReturnType<typeof UiContent>;
7
+ export default UiContent;
@@ -0,0 +1,28 @@
1
+ export { default as AspectRatio } from './AspectRatio.svelte';
2
+ export { default as Avatar } from './Avatar.svelte';
3
+ export { default as Close } from './Close.svelte';
4
+ export { default as ContextTip } from './ContextTip.svelte';
5
+ export { default as Dialog } from './Dialog.svelte';
6
+ export { default as Icon } from './Icon.svelte';
7
+ export { default as IconButton } from './IconButton.svelte';
8
+ export { default as Image } from './Image.svelte';
9
+ export { default as Indicator } from './Indicator.svelte';
10
+ export { default as Inset } from './Inset.svelte';
11
+ export { default as Layout } from './Layout.svelte';
12
+ export { default as MenuDropdown } from './MenuDropdown.svelte';
13
+ export { default as MenuItem } from './MenuItem.svelte';
14
+ export { default as MenuItemContent } from './MenuItemContent.svelte';
15
+ export { default as Modal } from './Modal.svelte';
16
+ export { default as Notification } from './Notification.svelte';
17
+ export { default as Overlay } from './Overlay.svelte';
18
+ export { default as OverlayContainer } from './OverlayContainer.svelte';
19
+ export { default as OverlayLayer } from './OverlayLayer.svelte';
20
+ export { default as PageContent } from './PageContent.svelte';
21
+ export { default as Tag } from './Tag.svelte';
22
+ export { default as Table } from './Table.svelte';
23
+ export { default as Theme } from './Theme.svelte';
24
+ export { default as Tooltip } from './Tooltip.svelte';
25
+ export { default as UIContent } from './UIContent.svelte';
26
+ export * from './MenuTypes.js';
27
+ export * from './notifications.svelte.js';
28
+ export * from './overlays.svelte.js';
@@ -0,0 +1,29 @@
1
+ export { default as AspectRatio } from './AspectRatio.svelte';
2
+ export { default as Avatar } from './Avatar.svelte';
3
+ export { default as Close } from './Close.svelte';
4
+ export { default as ContextTip } from './ContextTip.svelte';
5
+ export { default as Dialog } from './Dialog.svelte';
6
+ export { default as Icon } from './Icon.svelte';
7
+ export { default as IconButton } from './IconButton.svelte';
8
+ export { default as Image } from './Image.svelte';
9
+ export { default as Indicator } from './Indicator.svelte';
10
+ export { default as Inset } from './Inset.svelte';
11
+ export { default as Layout } from './Layout.svelte';
12
+ export { default as MenuDropdown } from './MenuDropdown.svelte';
13
+ export { default as MenuItem } from './MenuItem.svelte';
14
+ export { default as MenuItemContent } from './MenuItemContent.svelte';
15
+ export { default as Modal } from './Modal.svelte';
16
+ export { default as Notification } from './Notification.svelte';
17
+ export { default as Overlay } from './Overlay.svelte';
18
+ export { default as OverlayContainer } from './OverlayContainer.svelte';
19
+ export { default as OverlayLayer } from './OverlayLayer.svelte';
20
+ export { default as PageContent } from './PageContent.svelte';
21
+ export { default as Tag } from './Tag.svelte';
22
+ export { default as Table } from './Table.svelte';
23
+ export { default as Theme } from './Theme.svelte';
24
+ export { default as Tooltip } from './Tooltip.svelte';
25
+ export { default as UIContent } from './UIContent.svelte';
26
+ // Export TypeScript files and stores
27
+ export * from './MenuTypes.js';
28
+ export * from './notifications.svelte.js';
29
+ export * from './overlays.svelte.js';
@@ -1,4 +1,4 @@
1
- import { type OverlayPosition } from "../layout/overlays.svelte.js";
1
+ import { type OverlayPosition } from "./overlays.svelte.js";
2
2
  import type { Component, Snippet } from "svelte";
3
3
  /**
4
4
  * Add a notification to the screen.
@@ -1,5 +1,4 @@
1
- import { createId } from "../utils/id.js";
2
- import { addOverlay, removeOverlay } from "../layout/overlays.svelte.js";
1
+ import { addOverlay, removeOverlay } from "./overlays.svelte.js";
3
2
  import NotificationSvelte from "./Notification.svelte";
4
3
  /**
5
4
  * Add a notification to the screen.
@@ -13,11 +12,11 @@ import NotificationSvelte from "./Notification.svelte";
13
12
  * @returns {void}
14
13
  */
15
14
  export function addNotification(opts) {
16
- const id = createId();
15
+ const id = crypto.randomUUID();
17
16
  addOverlay({
18
17
  id,
19
18
  z: 100,
20
- content: NotificationSvelte,
19
+ component: NotificationSvelte,
21
20
  props: { id, ...opts },
22
21
  stack: opts.stack,
23
22
  position: opts.position || "bottom right",
@@ -10,8 +10,10 @@ export type TransitionOpts = {
10
10
  export type OverlayItem = {
11
11
  id: string;
12
12
  z?: number;
13
- content: string | Snippet | Component;
14
- props?: Record<string, any>;
13
+ text?: string;
14
+ snippet?: Snippet;
15
+ component?: Component;
16
+ props?: any;
15
17
  layer?: string;
16
18
  anchor?: HTMLElement;
17
19
  transition?: TransitionOpts;
@@ -0,0 +1,30 @@
1
+ export interface LutraConfig {
2
+ /**
3
+ * Whether to show a background color or image on the components.
4
+ */
5
+ background?: boolean;
6
+ /**
7
+ * Whether to use a contained layout (with borders and rounded corners).
8
+ */
9
+ contained?: boolean;
10
+ }
11
+ export interface LutraRootConfig extends LutraConfig {
12
+ /**
13
+ * The default theme to use.
14
+ */
15
+ theme?: 'light' | 'dark' | 'auto' | 'inherit';
16
+ /**
17
+ * Theme color for the theme-color meta tag. Only used in the root theme.
18
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name/theme-color
19
+ */
20
+ themeColor?: {
21
+ light?: string;
22
+ dark?: string;
23
+ };
24
+ }
25
+ /**
26
+ * Default Lutra config.
27
+ */
28
+ export declare const defaultConfig: LutraConfig;
29
+ export declare const defaultRootConfig: LutraRootConfig;
30
+ export declare const setConfig: (config: Partial<LutraConfig>) => void;
package/dist/config.js ADDED
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Default Lutra config.
3
+ */
4
+ export const defaultConfig = {
5
+ background: true,
6
+ contained: true,
7
+ };
8
+ export const defaultRootConfig = {
9
+ theme: 'auto',
10
+ themeColor: {
11
+ light: '#fff',
12
+ dark: '#000',
13
+ },
14
+ ...defaultConfig,
15
+ };
16
+ export const setConfig = (config) => {
17
+ Object.assign(config, config);
18
+ };