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.
- package/README.md +4 -24
- package/dist/components/AspectRatio.svelte +26 -0
- package/dist/components/AspectRatio.svelte.d.ts +8 -0
- package/dist/components/Avatar.svelte +105 -0
- package/dist/components/Avatar.svelte.d.ts +14 -0
- package/dist/{display → components}/Close.svelte +25 -7
- package/dist/components/Close.svelte.d.ts +7 -0
- package/dist/components/ContextTip.svelte +41 -0
- package/dist/components/ContextTip.svelte.d.ts +7 -0
- package/dist/components/Dialog.svelte +78 -0
- package/dist/components/Dialog.svelte.d.ts +14 -0
- package/dist/components/Icon.svelte +62 -0
- package/dist/components/Icon.svelte.d.ts +8 -0
- package/dist/{display → components}/IconButton.svelte +43 -14
- package/dist/components/IconButton.svelte.d.ts +16 -0
- package/dist/components/Image.svelte +172 -0
- package/dist/components/Image.svelte.d.ts +56 -0
- package/dist/{display → components}/Indicator.svelte +44 -9
- package/dist/components/Indicator.svelte.d.ts +12 -0
- package/dist/{display → components}/Inset.svelte +8 -3
- package/dist/components/Inset.svelte.d.ts +7 -0
- package/dist/components/Layout.svelte +33 -0
- package/dist/components/Layout.svelte.d.ts +11 -0
- package/dist/components/MenuDropdown.svelte +195 -0
- package/dist/components/MenuDropdown.svelte.d.ts +16 -0
- package/dist/{nav → components}/MenuItem.svelte +46 -38
- package/dist/components/MenuItem.svelte.d.ts +11 -0
- package/dist/components/MenuItemContent.svelte +25 -0
- package/dist/components/MenuItemContent.svelte.d.ts +10 -0
- package/dist/{nav → components}/MenuTypes.d.ts +19 -5
- package/dist/components/Modal.svelte +149 -0
- package/dist/components/Modal.svelte.d.ts +16 -0
- package/dist/{display → components}/Notification.svelte +33 -22
- package/dist/components/Notification.svelte.d.ts +12 -0
- package/dist/components/Overlay.svelte +31 -0
- package/dist/components/Overlay.svelte.d.ts +14 -0
- package/dist/{layout → components}/OverlayContainer.svelte +6 -3
- package/dist/{layout → components}/OverlayContainer.svelte.d.ts +4 -1
- package/dist/components/OverlayLayer.svelte +168 -0
- package/dist/components/OverlayLayer.svelte.d.ts +8 -0
- package/dist/components/PageContent.svelte +108 -0
- package/dist/components/PageContent.svelte.d.ts +38 -0
- package/dist/components/TabbedContent.svelte +74 -0
- package/dist/components/TabbedContent.svelte.d.ts +11 -0
- package/dist/components/TabbedContentItem.svelte +33 -0
- package/dist/components/TabbedContentItem.svelte.d.ts +10 -0
- package/dist/components/Table.svelte +41 -0
- package/dist/components/Table.svelte.d.ts +13 -0
- package/dist/{nav → components}/Tabs.svelte +99 -41
- package/dist/components/Tabs.svelte.d.ts +20 -0
- package/dist/components/Tag.svelte +120 -0
- package/dist/components/Tag.svelte.d.ts +21 -0
- package/dist/components/Theme.svelte +105 -0
- package/dist/components/Theme.svelte.d.ts +17 -0
- package/dist/{display → components}/Tooltip.svelte +41 -16
- package/dist/components/Tooltip.svelte.d.ts +12 -0
- package/dist/components/UIContent.svelte +19 -0
- package/dist/components/UIContent.svelte.d.ts +7 -0
- package/dist/components/index.d.ts +28 -0
- package/dist/components/index.js +29 -0
- package/dist/{display → components}/notifications.svelte.d.ts +1 -1
- package/dist/{display → components}/notifications.svelte.js +3 -4
- package/dist/{layout → components}/overlays.svelte.d.ts +4 -2
- package/dist/config.d.ts +30 -0
- package/dist/config.js +18 -0
- package/dist/css/1-props.css +440 -0
- package/dist/css/2-base.css +343 -0
- package/dist/css/3-typo.css +106 -0
- package/dist/css/4-layout.css +368 -0
- package/dist/css/5-media.css +116 -0
- package/dist/css/lutra.css +7 -0
- package/dist/css/themes/DefaultTheme.css +209 -0
- package/dist/form/Button.svelte +35 -16
- package/dist/form/Button.svelte.d.ts +8 -19
- package/dist/form/Datepicker.svelte +311 -0
- package/dist/form/Datepicker.svelte.d.ts +9 -0
- package/dist/form/FieldContent.svelte +69 -44
- package/dist/form/FieldContent.svelte.d.ts +7 -17
- package/dist/form/FieldError.svelte +16 -6
- package/dist/form/FieldError.svelte.d.ts +4 -15
- package/dist/form/Fieldset.svelte +48 -13
- package/dist/form/Fieldset.svelte.d.ts +5 -16
- package/dist/form/Form.svelte +158 -74
- package/dist/form/Form.svelte.d.ts +17 -17
- package/dist/form/{FieldActions.svelte → FormActions.svelte} +29 -17
- package/dist/form/FormActions.svelte.d.ts +9 -0
- package/dist/form/FormSection.svelte +96 -0
- package/dist/form/FormSection.svelte.d.ts +9 -0
- package/dist/form/ImageUpload.svelte +134 -94
- package/dist/form/ImageUpload.svelte.d.ts +5 -16
- package/dist/form/Input.svelte +254 -136
- package/dist/form/Input.svelte.d.ts +12 -21
- package/dist/form/InputLength.svelte +15 -5
- package/dist/form/InputLength.svelte.d.ts +4 -15
- package/dist/form/Label.svelte +55 -11
- package/dist/form/Label.svelte.d.ts +6 -15
- package/dist/form/LogoUpload.svelte +36 -21
- package/dist/form/LogoUpload.svelte.d.ts +4 -15
- package/dist/form/Select.svelte +100 -50
- package/dist/form/Select.svelte.d.ts +5 -16
- package/dist/form/Textarea.svelte +200 -98
- package/dist/form/Textarea.svelte.d.ts +11 -24
- package/dist/form/Toggle.svelte +3 -1
- package/dist/form/Toggle.svelte.d.ts +4 -1
- package/dist/form/client.svelte.d.ts +1 -0
- package/dist/form/client.svelte.js +6 -2
- package/dist/form/form.d.ts +10 -9
- package/dist/form/form.js +37 -32
- package/dist/form/index.d.ts +3 -4
- package/dist/form/index.js +3 -4
- package/dist/form/types.d.ts +9 -16
- package/dist/icons/IconAlert.svelte.d.ts +4 -1
- package/dist/icons/IconCopy.svelte.d.ts +4 -1
- package/dist/icons/IconDone.svelte.d.ts +4 -1
- package/dist/icons/IconError.svelte.d.ts +4 -1
- package/dist/icons/IconHelp.svelte.d.ts +4 -1
- package/dist/icons/IconHide.svelte.d.ts +4 -1
- package/dist/icons/IconInfo.svelte.d.ts +4 -1
- package/dist/icons/IconLink.svelte.d.ts +4 -1
- package/dist/icons/IconMenuBurger.svelte.d.ts +4 -1
- package/dist/icons/IconMenuDots.svelte.d.ts +4 -1
- package/dist/icons/IconSearch.svelte.d.ts +4 -1
- package/dist/icons/IconShow.svelte.d.ts +4 -1
- package/dist/icons/IconSuccess.svelte.d.ts +4 -1
- package/dist/icons/IconWarning.svelte.d.ts +4 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +3 -2
- package/dist/types.d.ts +39 -0
- package/dist/types.js +25 -0
- package/dist/util/StringOrComponent.svelte +20 -0
- package/dist/util/StringOrComponent.svelte.d.ts +8 -0
- package/dist/util/StringOrSnippet.svelte +16 -0
- package/dist/util/StringOrSnippet.svelte.d.ts +8 -0
- package/dist/{utils → util}/dom.js +1 -2
- package/dist/util/locale.d.ts +1 -0
- package/dist/util/locale.js +47 -0
- package/dist/util/settings.d.ts +4 -0
- package/package.json +35 -79
- package/dist/color.css +0 -0
- package/dist/display/Avatar.svelte +0 -61
- package/dist/display/Avatar.svelte.d.ts +0 -19
- package/dist/display/Badge.svelte +0 -91
- package/dist/display/Badge.svelte.d.ts +0 -30
- package/dist/display/Callout.svelte +0 -109
- package/dist/display/Callout.svelte.d.ts +0 -28
- package/dist/display/Close.svelte.d.ts +0 -18
- package/dist/display/Code.svelte +0 -190
- package/dist/display/Code.svelte.d.ts +0 -32
- package/dist/display/ContextTip.svelte +0 -23
- package/dist/display/ContextTip.svelte.d.ts +0 -18
- package/dist/display/DataList.svelte +0 -16
- package/dist/display/DataList.svelte.d.ts +0 -21
- package/dist/display/Details.svelte +0 -49
- package/dist/display/Details.svelte.d.ts +0 -27
- package/dist/display/Hero.svelte +0 -50
- package/dist/display/Hero.svelte.d.ts +0 -26
- package/dist/display/Icon.svelte +0 -39
- package/dist/display/Icon.svelte.d.ts +0 -19
- package/dist/display/IconButton.svelte.d.ts +0 -27
- package/dist/display/Image.svelte +0 -91
- package/dist/display/Image.svelte.d.ts +0 -26
- package/dist/display/Indicator.svelte.d.ts +0 -23
- package/dist/display/Inset.svelte.d.ts +0 -18
- package/dist/display/LineChart.svelte +0 -385
- package/dist/display/LineChart.svelte.d.ts +0 -24
- package/dist/display/LoadingIndicator.svelte +0 -33
- package/dist/display/LoadingIndicator.svelte.d.ts +0 -15
- package/dist/display/Modal.svelte +0 -116
- package/dist/display/Modal.svelte.d.ts +0 -27
- package/dist/display/Notification.svelte.d.ts +0 -23
- package/dist/display/Panel.svelte +0 -23
- package/dist/display/Panel.svelte.d.ts +0 -19
- package/dist/display/Popup.svelte +0 -111
- package/dist/display/Popup.svelte.d.ts +0 -25
- package/dist/display/Stat.svelte +0 -81
- package/dist/display/Stat.svelte.d.ts +0 -30
- package/dist/display/Table.svelte +0 -28
- package/dist/display/Table.svelte.d.ts +0 -24
- package/dist/display/TablePaginator.svelte +0 -51
- package/dist/display/TablePaginator.svelte.d.ts +0 -21
- package/dist/display/Tag.svelte +0 -90
- package/dist/display/Tag.svelte.d.ts +0 -32
- package/dist/display/Tooltip.svelte.d.ts +0 -23
- package/dist/display/chart.d.ts +0 -78
- package/dist/display/chart.js +0 -212
- package/dist/display/index.d.ts +0 -24
- package/dist/display/index.js +0 -24
- package/dist/form/FieldActions.svelte.d.ts +0 -20
- package/dist/form/FieldContainer.svelte +0 -37
- package/dist/form/FieldContainer.svelte.d.ts +0 -19
- package/dist/form/FieldSection.svelte +0 -86
- package/dist/form/FieldSection.svelte.d.ts +0 -20
- package/dist/layout/Layout.svelte +0 -47
- package/dist/layout/Layout.svelte.d.ts +0 -22
- package/dist/layout/LayoutFooter.svelte +0 -21
- package/dist/layout/LayoutFooter.svelte.d.ts +0 -18
- package/dist/layout/LayoutGrid.svelte +0 -51
- package/dist/layout/LayoutGrid.svelte.d.ts +0 -27
- package/dist/layout/LayoutHeader.svelte +0 -97
- package/dist/layout/LayoutHeader.svelte.d.ts +0 -34
- package/dist/layout/LayoutSideMenu.svelte +0 -55
- package/dist/layout/LayoutSideMenu.svelte.d.ts +0 -21
- package/dist/layout/LayoutTypes.d.ts +0 -15
- package/dist/layout/LayoutTypes.js +0 -9
- package/dist/layout/Overlay.svelte +0 -20
- package/dist/layout/Overlay.svelte.d.ts +0 -25
- package/dist/layout/OverlayLayer.svelte +0 -140
- package/dist/layout/OverlayLayer.svelte.d.ts +0 -19
- package/dist/layout/PageContent.svelte +0 -82
- package/dist/layout/PageContent.svelte.d.ts +0 -25
- package/dist/layout/Theme.svelte +0 -243
- package/dist/layout/Theme.svelte.d.ts +0 -19
- package/dist/layout/UIContent.svelte +0 -15
- package/dist/layout/UIContent.svelte.d.ts +0 -18
- package/dist/layout/index.d.ts +0 -11
- package/dist/layout/index.js +0 -11
- package/dist/nav/Breadcrumb.svelte +0 -82
- package/dist/nav/Breadcrumb.svelte.d.ts +0 -28
- package/dist/nav/Menu.svelte +0 -170
- package/dist/nav/Menu.svelte.d.ts +0 -27
- package/dist/nav/MenuItem.svelte.d.ts +0 -22
- package/dist/nav/NavMenu.svelte +0 -181
- package/dist/nav/NavMenu.svelte.d.ts +0 -19
- package/dist/nav/TabbedContent.svelte +0 -43
- package/dist/nav/TabbedContent.svelte.d.ts +0 -23
- package/dist/nav/Tabs.svelte.d.ts +0 -25
- package/dist/nav/index.d.ts +0 -7
- package/dist/nav/index.js +0 -6
- package/dist/style.css +0 -950
- package/dist/typo/Clamp.svelte +0 -25
- package/dist/typo/Clamp.svelte.d.ts +0 -24
- package/dist/typo/H.svelte +0 -52
- package/dist/typo/H.svelte.d.ts +0 -28
- package/dist/typo/H1.svelte +0 -14
- package/dist/typo/H1.svelte.d.ts +0 -26
- package/dist/typo/H2.svelte +0 -14
- package/dist/typo/H2.svelte.d.ts +0 -26
- package/dist/typo/H3.svelte +0 -14
- package/dist/typo/H3.svelte.d.ts +0 -26
- package/dist/typo/H4.svelte +0 -14
- package/dist/typo/H4.svelte.d.ts +0 -26
- package/dist/typo/H5.svelte +0 -14
- package/dist/typo/H5.svelte.d.ts +0 -26
- package/dist/typo/H6.svelte +0 -14
- package/dist/typo/H6.svelte.d.ts +0 -26
- package/dist/typo/P.svelte +0 -34
- package/dist/typo/P.svelte.d.ts +0 -26
- package/dist/typo/index.d.ts +0 -9
- package/dist/typo/index.js +0 -9
- package/dist/utils/StringOrComponent.svelte +0 -14
- package/dist/utils/StringOrComponent.svelte.d.ts +0 -19
- package/dist/utils/StringOrSnippet.svelte +0 -11
- package/dist/utils/StringOrSnippet.svelte.d.ts +0 -19
- package/dist/utils/defaults.d.ts +0 -4
- package/dist/utils/hooks.server.d.ts +0 -2
- package/dist/utils/hooks.server.js +0 -16
- package/dist/utils/id.d.ts +0 -1
- package/dist/utils/id.js +0 -3
- package/dist/utils/index.d.ts +0 -9
- package/dist/utils/index.js +0 -6
- package/dist/utils/isSnippet.d.ts +0 -3
- package/dist/utils/isSnippet.js +0 -11
- /package/dist/{nav → components}/MenuTypes.js +0 -0
- /package/dist/{layout → components}/overlays.svelte.js +0 -0
- /package/dist/{utils → util}/attr.d.ts +0 -0
- /package/dist/{utils → util}/attr.js +0 -0
- /package/dist/{utils → util}/color.d.ts +0 -0
- /package/dist/{utils → util}/color.js +0 -0
- /package/dist/{utils → util}/dom.d.ts +0 -0
- /package/dist/{utils → util}/keyboard.svelte.d.ts +0 -0
- /package/dist/{utils → util}/keyboard.svelte.js +0 -0
- /package/dist/{utils/defaults.js → util/settings.js} +0 -0
- /package/dist/{utils → util}/transitions.d.ts +0 -0
- /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">
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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(--
|
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(--
|
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(--
|
79
|
+
background-color: var(--tooltip-background);
|
55
80
|
padding: 0.35rem 0.5rem;
|
56
|
-
border-radius:
|
57
|
-
border-top: var(--border-
|
58
|
-
border-left: var(--border-
|
59
|
-
border-right: var(--border-
|
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(--
|
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,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,5 +1,4 @@
|
|
1
|
-
import {
|
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 =
|
15
|
+
const id = crypto.randomUUID();
|
17
16
|
addOverlay({
|
18
17
|
id,
|
19
18
|
z: 100,
|
20
|
-
|
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
|
-
|
14
|
-
|
13
|
+
text?: string;
|
14
|
+
snippet?: Snippet;
|
15
|
+
component?: Component;
|
16
|
+
props?: any;
|
15
17
|
layer?: string;
|
16
18
|
anchor?: HTMLElement;
|
17
19
|
transition?: TransitionOpts;
|
package/dist/config.d.ts
ADDED
@@ -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
|
+
};
|