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
package/README.md
CHANGED
@@ -1,29 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# Lutra
|
2
2
|
|
3
|
-
|
3
|
+
UI library for Svelte 5.
|
4
4
|
|
5
|
-
|
5
|
+
## Installation
|
6
6
|
|
7
7
|
```bash
|
8
|
-
|
8
|
+
npm install --save lutra
|
9
9
|
```
|
10
|
-
|
11
|
-
### Rewriting props
|
12
|
-
|
13
|
-
When you edit a component's description or props, you need to regenerate `componentProps.ts`.
|
14
|
-
|
15
|
-
`read_props.js` reads all the library files and generates props to display in the docs from the AST. Running
|
16
|
-
|
17
|
-
```bash
|
18
|
-
pnpm props
|
19
|
-
```
|
20
|
-
|
21
|
-
will read the props and write `componentProps.ts`.
|
22
|
-
|
23
|
-
Running:
|
24
|
-
|
25
|
-
```bash
|
26
|
-
pnpm package
|
27
|
-
```
|
28
|
-
|
29
|
-
will write the props and generate the library Svelte files.
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Snippet } from "svelte";
|
3
|
+
let {
|
4
|
+
ratio = 16 / 9,
|
5
|
+
children
|
6
|
+
}: {
|
7
|
+
ratio?: number;
|
8
|
+
children: Snippet;
|
9
|
+
} = $props();
|
10
|
+
</script>
|
11
|
+
|
12
|
+
<div class="AspectRatio" style="--aspect-ratio: {ratio}">
|
13
|
+
{@render children()}
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<style>
|
17
|
+
@property --aspect-ratio {
|
18
|
+
syntax: "<number-percentage> / <number-percentage>";
|
19
|
+
inherits: false;
|
20
|
+
initial-value: 16 / 9;
|
21
|
+
}
|
22
|
+
.AspectRatio {
|
23
|
+
aspect-ratio: var(--aspect-ratio);
|
24
|
+
}
|
25
|
+
</style>
|
26
|
+
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { Snippet } from "svelte";
|
2
|
+
type $$ComponentProps = {
|
3
|
+
ratio?: number;
|
4
|
+
children: Snippet;
|
5
|
+
};
|
6
|
+
declare const AspectRatio: import("svelte").Component<$$ComponentProps, {}, "">;
|
7
|
+
type AspectRatio = ReturnType<typeof AspectRatio>;
|
8
|
+
export default AspectRatio;
|
@@ -0,0 +1,105 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Snippet } from 'svelte';
|
3
|
+
import { hexRelativeLuminance, stringToColor } from '../util/color.js';
|
4
|
+
import Image from './Image.svelte';
|
5
|
+
|
6
|
+
/**
|
7
|
+
* @description
|
8
|
+
* An avatar is a user profile photo or a logo. It can be a placeholder or a URL to an image. If there is no image, the first letter of the name will be used as a placeholder.
|
9
|
+
* You can pick from three crop styles: circle, square, or rounded. The color of the placeholder is based on the name, making each visually distinct from each other.
|
10
|
+
* @cssprop --border-radius - The border radius of the avatar when cropped as rounded.
|
11
|
+
* @cssprop --mask-image - Custom mask image to use for the avatar.
|
12
|
+
* @example
|
13
|
+
* <p>With picture:</p>
|
14
|
+
* <Avatar name="Auth70" shape="rounded" src="https://avatars.githubusercontent.com/u/122825113?s=200&v=4" --size="4rem" />
|
15
|
+
* <p>Without picture:</p>
|
16
|
+
* <Avatar name="Moxie" shape="square" />
|
17
|
+
* <Avatar name="Napoleon" shape="rounded" />
|
18
|
+
* <Avatar name="Byron" shape="circle" />
|
19
|
+
*/
|
20
|
+
let {
|
21
|
+
src,
|
22
|
+
srcset,
|
23
|
+
alt,
|
24
|
+
color,
|
25
|
+
size = '3rem',
|
26
|
+
name = "N/A",
|
27
|
+
shape = 'circle',
|
28
|
+
children,
|
29
|
+
}: {
|
30
|
+
src?: string;
|
31
|
+
srcset?: string;
|
32
|
+
alt?: string;
|
33
|
+
color?: string;
|
34
|
+
size?: string;
|
35
|
+
name?: string;
|
36
|
+
shape?: 'circle' | 'square' | 'rounded';
|
37
|
+
children?: Snippet;
|
38
|
+
} = $props();
|
39
|
+
|
40
|
+
const userColor = (src || srcset) ? '#666666' : color ?? stringToColor(name);
|
41
|
+
const luminance = hexRelativeLuminance(userColor);
|
42
|
+
const textColor = luminance < 0.5 ? 'rgba(255,255,255,0.85)' : 'rgba(0,0,0,0.85)';
|
43
|
+
const firstCharacter = [...name][0]; // supports multi-byte characters. name[0] would not.
|
44
|
+
</script>
|
45
|
+
|
46
|
+
<figure class="Avatar {shape}" style="--user-color: {userColor}; --text-color: {textColor}; --size: {size}">
|
47
|
+
{#if src}
|
48
|
+
<Image
|
49
|
+
src={src}
|
50
|
+
srcset={srcset}
|
51
|
+
alt={alt ?? name}
|
52
|
+
fit="cover"
|
53
|
+
--width={size}
|
54
|
+
--height={size}
|
55
|
+
/>
|
56
|
+
{:else}
|
57
|
+
<div class="Placeholder">
|
58
|
+
{#if children}
|
59
|
+
{@render children()}
|
60
|
+
{:else}
|
61
|
+
<span>{firstCharacter}</span>
|
62
|
+
{/if}
|
63
|
+
</div>
|
64
|
+
{/if}
|
65
|
+
</figure>
|
66
|
+
|
67
|
+
<style>
|
68
|
+
.Avatar {
|
69
|
+
display: flex;
|
70
|
+
align-items: center;
|
71
|
+
justify-content: center;
|
72
|
+
margin: 0;
|
73
|
+
block-size: var(--size, 3rem);
|
74
|
+
inline-size: var(--size, 3rem);
|
75
|
+
overflow: clip;
|
76
|
+
background-color: var(--user-color);
|
77
|
+
mask-image: var(--mask-image, none);
|
78
|
+
mask-size: 100% 100%;
|
79
|
+
mask-repeat: no-repeat;
|
80
|
+
-webkit-mask-image: var(--mask-image, none);
|
81
|
+
-webkit-mask-size: 100% 100%;
|
82
|
+
-webkit-mask-repeat: no-repeat;
|
83
|
+
}
|
84
|
+
.Avatar.circle { border-radius: 50%; }
|
85
|
+
.Avatar.square { border-radius: 0; }
|
86
|
+
.Avatar.rounded { border-radius: var(--border-radius); }
|
87
|
+
.Avatar img {
|
88
|
+
block-size: 100%;
|
89
|
+
inline-size: 100%;
|
90
|
+
object-fit: cover;
|
91
|
+
}
|
92
|
+
.Avatar .Placeholder {
|
93
|
+
display: flex;
|
94
|
+
align-items: center;
|
95
|
+
justify-content: center;
|
96
|
+
block-size: 100%;
|
97
|
+
inline-size: 100%;
|
98
|
+
background-color: var(--user-color);
|
99
|
+
color: var(--text-color);
|
100
|
+
user-select: none;
|
101
|
+
font-size: 1rem;
|
102
|
+
font-weight: 600;
|
103
|
+
user-select: none;
|
104
|
+
}
|
105
|
+
</style>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { Snippet } from 'svelte';
|
2
|
+
type $$ComponentProps = {
|
3
|
+
src?: string;
|
4
|
+
srcset?: string;
|
5
|
+
alt?: string;
|
6
|
+
color?: string;
|
7
|
+
size?: string;
|
8
|
+
name?: string;
|
9
|
+
shape?: 'circle' | 'square' | 'rounded';
|
10
|
+
children?: Snippet;
|
11
|
+
};
|
12
|
+
declare const Avatar: import("svelte").Component<$$ComponentProps, {}, "">;
|
13
|
+
type Avatar = ReturnType<typeof Avatar>;
|
14
|
+
export default Avatar;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
<script lang="ts">
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<script lang="ts">
|
2
|
+
let {
|
3
|
+
onclick,
|
4
|
+
position
|
5
|
+
}: {
|
6
|
+
onclick?: (e: MouseEvent) => void;
|
7
|
+
position?: "top left" | "top right" | "bottom left" | "bottom right";
|
8
|
+
} = $props();
|
5
9
|
</script>
|
6
10
|
|
7
|
-
<button class="Close {position}" {onclick}>
|
11
|
+
<button class="Close {position}" {onclick} aria-label="Close">
|
8
12
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
9
13
|
<line x1="18" y1="6" x2="6" y2="18"></line>
|
10
14
|
<line x1="6" y1="6" x2="18" y2="18"></line>
|
@@ -16,18 +20,32 @@
|
|
16
20
|
cursor: pointer;
|
17
21
|
padding: var(--close-padding, 0.5rem);
|
18
22
|
border-radius: 50%;
|
19
|
-
color: var(--text);
|
23
|
+
color: var(--text-color, light-dark(black, white));
|
20
24
|
cursor: pointer;
|
21
25
|
pointer-events: auto;
|
26
|
+
border: none;
|
27
|
+
}
|
28
|
+
|
29
|
+
button {
|
30
|
+
background-color: transparent;
|
31
|
+
border: none;
|
32
|
+
padding: 0;
|
33
|
+
margin: 0;
|
34
|
+
font: inherit;
|
35
|
+
color: inherit;
|
36
|
+
text-align: inherit;
|
37
|
+
display: inline-block;
|
22
38
|
}
|
23
39
|
|
24
40
|
svg {
|
41
|
+
display: block;
|
42
|
+
margin: 0;
|
25
43
|
width: max(1.5rem, 16px);
|
26
44
|
height: max(1.5rem, 16px);
|
27
45
|
}
|
28
46
|
|
29
47
|
.Close:hover {
|
30
|
-
color: var(--text-subtle);
|
48
|
+
color: var(--text-color-subtle, light-dark(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.5)));
|
31
49
|
}
|
32
50
|
|
33
51
|
.Close.top {
|
@@ -0,0 +1,7 @@
|
|
1
|
+
type $$ComponentProps = {
|
2
|
+
onclick?: (e: MouseEvent) => void;
|
3
|
+
position?: "top left" | "top right" | "bottom left" | "bottom right";
|
4
|
+
};
|
5
|
+
declare const Close: import("svelte").Component<$$ComponentProps, {}, "">;
|
6
|
+
type Close = ReturnType<typeof Close>;
|
7
|
+
export default Close;
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Snippet } from "svelte";
|
3
|
+
import Tooltip from "./Tooltip.svelte";
|
4
|
+
import Help from "../icons/IconHelp.svelte";
|
5
|
+
import Icon from "./Icon.svelte";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @description
|
9
|
+
* A component that displays a context tip.
|
10
|
+
* @example
|
11
|
+
* <ContextTip tip="This is a context tip" />
|
12
|
+
*/
|
13
|
+
let {
|
14
|
+
tip
|
15
|
+
}: {
|
16
|
+
tip: string | Snippet;
|
17
|
+
} = $props();
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<Tooltip {tip}>
|
21
|
+
<a href="#contexttip" onclick={(e) => { e.preventDefault(); e.stopPropagation(); }}>
|
22
|
+
<Icon icon={Help} --icon-width="16px" --icon-height="16px" --cursor="help" --vertical-align="baseline" />
|
23
|
+
</a>
|
24
|
+
</Tooltip>
|
25
|
+
|
26
|
+
<style>
|
27
|
+
a {
|
28
|
+
border-radius: 50%;
|
29
|
+
color: var(--overlay-color, light-dark(black, white));
|
30
|
+
height: 16px;
|
31
|
+
width: 16px;
|
32
|
+
padding: 0;
|
33
|
+
display: inline-flex;
|
34
|
+
align-items: center;
|
35
|
+
justify-content: center;
|
36
|
+
}
|
37
|
+
a:focus-visible {
|
38
|
+
color: var(--focus-ring-color);
|
39
|
+
outline-offset: 0px;
|
40
|
+
}
|
41
|
+
</style>
|
@@ -0,0 +1,78 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Snippet } from "svelte";
|
3
|
+
import { slidefade } from "../util/transitions.js";
|
4
|
+
|
5
|
+
/**
|
6
|
+
* @description
|
7
|
+
* A dialog component that follows the HTML dialog element spec.
|
8
|
+
* Provides a modal dialog with a backdrop and proper focus management.
|
9
|
+
*/
|
10
|
+
let {
|
11
|
+
open = $bindable(false),
|
12
|
+
title,
|
13
|
+
children,
|
14
|
+
onClose,
|
15
|
+
}: {
|
16
|
+
/** [Bindable] Whether the dialog is open */
|
17
|
+
open?: boolean;
|
18
|
+
/** The title of the dialog */
|
19
|
+
title?: string;
|
20
|
+
/** The content of the dialog */
|
21
|
+
children: Snippet;
|
22
|
+
/** Callback when the dialog is closed */
|
23
|
+
onClose?: () => void;
|
24
|
+
} = $props();
|
25
|
+
|
26
|
+
let dialog: HTMLDialogElement;
|
27
|
+
|
28
|
+
$effect(() => {
|
29
|
+
if (open && dialog) {
|
30
|
+
dialog.showModal();
|
31
|
+
} else if (dialog) {
|
32
|
+
dialog.close();
|
33
|
+
}
|
34
|
+
});
|
35
|
+
|
36
|
+
function handleClose() {
|
37
|
+
if (onClose) onClose();
|
38
|
+
}
|
39
|
+
|
40
|
+
</script>
|
41
|
+
|
42
|
+
<dialog
|
43
|
+
bind:this={dialog}
|
44
|
+
class="Dialog"
|
45
|
+
transition:slidefade
|
46
|
+
>
|
47
|
+
{#if title}
|
48
|
+
<header class="DialogHeader">
|
49
|
+
<h6>{title}</h6>
|
50
|
+
</header>
|
51
|
+
{/if}
|
52
|
+
<div class="DialogContent">
|
53
|
+
{@render children()}
|
54
|
+
</div>
|
55
|
+
</dialog>
|
56
|
+
|
57
|
+
<style>
|
58
|
+
.Dialog {
|
59
|
+
padding: 0;
|
60
|
+
border: var(--field-border-size) var(--field-border-style) var(--field-border-color);
|
61
|
+
border-radius: var(--field-radius);
|
62
|
+
background: var(--bg-surface);
|
63
|
+
color: var(--fg-surface);
|
64
|
+
max-width: min(calc(100vw - 2rem), 32rem);
|
65
|
+
max-height: min(calc(100vh - 2rem), 32rem);
|
66
|
+
}
|
67
|
+
.Dialog::backdrop {
|
68
|
+
background: var(--bg-scrim);
|
69
|
+
backdrop-filter: blur(2px);
|
70
|
+
}
|
71
|
+
.DialogHeader {
|
72
|
+
padding: var(--pad-m);
|
73
|
+
border-bottom: var(--field-border-size) var(--field-border-style) var(--field-border-color);
|
74
|
+
}
|
75
|
+
.DialogContent {
|
76
|
+
padding: var(--pad-m);
|
77
|
+
}
|
78
|
+
</style>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { Snippet } from "svelte";
|
2
|
+
type $$ComponentProps = {
|
3
|
+
/** [Bindable] Whether the dialog is open */
|
4
|
+
open?: boolean;
|
5
|
+
/** The title of the dialog */
|
6
|
+
title?: string;
|
7
|
+
/** The content of the dialog */
|
8
|
+
children: Snippet;
|
9
|
+
/** Callback when the dialog is closed */
|
10
|
+
onClose?: () => void;
|
11
|
+
};
|
12
|
+
declare const Dialog: import("svelte").Component<$$ComponentProps, {}, "open">;
|
13
|
+
type Dialog = ReturnType<typeof Dialog>;
|
14
|
+
export default Dialog;
|
@@ -0,0 +1,62 @@
|
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Component } from "svelte";
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @description
|
6
|
+
* A component that displays an icon. It can be an image url or a component. The icon will be centered in the container.
|
7
|
+
* @cssprop --icon-width - The width of the icon. (Default: var(--font-size, 1em))
|
8
|
+
* @cssprop --icon-height - The height of the icon. (Default: var(--font-size, 1em))
|
9
|
+
* @cssprop --icon-color - The color of the icon. (Default: var(--text-color, currentColor))
|
10
|
+
* @example
|
11
|
+
* <script>
|
12
|
+
* import Copy from 'lutra/Icons/Copy.svelte';
|
13
|
+
* import Link from 'lutra/Icons/Link.svelte';
|
14
|
+
* <\/script>
|
15
|
+
* <Icon icon={Link} alt="Link icon" />
|
16
|
+
* <Icon icon={Copy} alt="Copy icon" />
|
17
|
+
*/
|
18
|
+
|
19
|
+
let {
|
20
|
+
icon,
|
21
|
+
alt,
|
22
|
+
}: {
|
23
|
+
icon: string | Component;
|
24
|
+
alt?: string,
|
25
|
+
} = $props();
|
26
|
+
|
27
|
+
let Icon = icon as Component;
|
28
|
+
|
29
|
+
</script>
|
30
|
+
|
31
|
+
<span class="Icon" aria-label="icon">
|
32
|
+
{#if typeof icon === "string"}
|
33
|
+
<img src={icon} alt={alt ? alt : 'Icon'} width="100%" height="100%" />
|
34
|
+
{:else}
|
35
|
+
<Icon />
|
36
|
+
{/if}
|
37
|
+
</span>
|
38
|
+
|
39
|
+
<style>
|
40
|
+
.Icon {
|
41
|
+
display: inline-flex;
|
42
|
+
align-items: center;
|
43
|
+
justify-content: center;
|
44
|
+
font-size: 1em;
|
45
|
+
line-height: inherit;
|
46
|
+
width: max(
|
47
|
+
var(--icon-width,
|
48
|
+
var(--icon-height, 1rem)
|
49
|
+
), 16px);
|
50
|
+
height: max(var(--icon-height, auto), 16px);
|
51
|
+
color: var(--icon-color, currentColor);
|
52
|
+
overflow: clip;
|
53
|
+
vertical-align: var(--vertical-align, text-bottom);
|
54
|
+
cursor: var(--cursor, default);
|
55
|
+
}
|
56
|
+
img,
|
57
|
+
.Icon :global(svg) {
|
58
|
+
width: 100%;
|
59
|
+
height: auto;
|
60
|
+
display: block;
|
61
|
+
}
|
62
|
+
</style>
|
@@ -1,13 +1,42 @@
|
|
1
|
-
<script lang="ts">
|
2
|
-
import {
|
3
|
-
import
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
<script lang="ts">
|
2
|
+
import type { Component, Snippet } from "svelte";
|
3
|
+
import Icon from './Icon.svelte';
|
4
|
+
import { fly } from "svelte/transition";
|
5
|
+
import { popBezier, popBezierInverse } from "../util/transitions.js";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @description
|
9
|
+
* A component that displays an icon with a possible label. It can also have a click event.
|
10
|
+
* The button has a padding of 0.75em by default to make it easier to tap on mobile devices. The padding can be changed using the `--padding` CSS variable.
|
11
|
+
* Icon and text color will be inherited from the parent element.
|
12
|
+
* @cssprop --padding - The padding of the icon button. (Default: 0.75em)
|
13
|
+
* @example
|
14
|
+
* <script>
|
15
|
+
* import Copy from 'lutra/Icons/Copy.svelte';
|
16
|
+
* import Link from 'lutra/Icons/Link.svelte';
|
17
|
+
* <\/script>
|
18
|
+
* <IconButton icon={Link} onclick={() => alert('clicked')} />
|
19
|
+
* <IconButton icon={Copy} onclick={() => alert('clicked')}>Copy</IconButton>
|
20
|
+
*/
|
21
|
+
let {
|
22
|
+
icon,
|
23
|
+
disabled,
|
24
|
+
children,
|
25
|
+
onclick,
|
26
|
+
mask = true
|
27
|
+
}: {
|
28
|
+
/** The icon to display. */
|
29
|
+
icon: string | Component;
|
30
|
+
/** The children to display. */
|
31
|
+
children?: Snippet,
|
32
|
+
/** The onclick event. */
|
33
|
+
onclick?: (event: MouseEvent) => void,
|
34
|
+
/** Whether the button is disabled. */
|
35
|
+
disabled?: boolean,
|
36
|
+
/** Whether to mask the content. */
|
37
|
+
mask?: boolean
|
38
|
+
} = $props();
|
39
|
+
|
11
40
|
</script>
|
12
41
|
|
13
42
|
{#snippet inside()}
|
@@ -41,12 +70,12 @@ let {
|
|
41
70
|
align-items: stretch;
|
42
71
|
color: inherit;
|
43
72
|
opacity: 1;
|
44
|
-
background-color: var(--field-
|
73
|
+
background-color: var(--field-background-color, transparent);
|
45
74
|
transition: background-color 0.04s;
|
46
|
-
border-radius: var(--field-radius);
|
75
|
+
border-radius: var(--field-border-radius);
|
47
76
|
}
|
48
77
|
.IconButton:hover {
|
49
|
-
background-color: var(--menu-
|
78
|
+
background-color: var(--menu-background-color-hover);
|
50
79
|
}
|
51
80
|
.IconButton:active {
|
52
81
|
scale: 1;
|
@@ -55,7 +84,7 @@ let {
|
|
55
84
|
border: none;
|
56
85
|
background: none;
|
57
86
|
cursor: pointer;
|
58
|
-
color: var(--text);
|
87
|
+
color: var(--text-color-p, light-dark(black, white));
|
59
88
|
}
|
60
89
|
.IconMask {
|
61
90
|
height: 100%;
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { Component, Snippet } from "svelte";
|
2
|
+
type $$ComponentProps = {
|
3
|
+
/** The icon to display. */
|
4
|
+
icon: string | Component;
|
5
|
+
/** The children to display. */
|
6
|
+
children?: Snippet;
|
7
|
+
/** The onclick event. */
|
8
|
+
onclick?: (event: MouseEvent) => void;
|
9
|
+
/** Whether the button is disabled. */
|
10
|
+
disabled?: boolean;
|
11
|
+
/** Whether to mask the content. */
|
12
|
+
mask?: boolean;
|
13
|
+
};
|
14
|
+
declare const IconButton: Component<$$ComponentProps, {}, "">;
|
15
|
+
type IconButton = ReturnType<typeof IconButton>;
|
16
|
+
export default IconButton;
|