@canonical/svelte-ds-app-launchpad 0.27.0 → 0.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Log/Log.svelte +80 -0
- package/dist/components/Log/Log.svelte.d.ts +29 -0
- package/dist/components/Log/common/Line/Line.svelte +44 -0
- package/dist/components/Log/common/Line/Line.svelte.d.ts +5 -0
- package/dist/components/Log/common/Line/index.d.ts +2 -0
- package/dist/components/Log/common/Line/index.js +3 -0
- package/dist/components/Log/common/Line/styles.css +76 -0
- package/dist/components/Log/common/Line/types.d.ts +18 -0
- package/dist/components/Log/common/Line/types.js +2 -0
- package/dist/components/Log/common/index.d.ts +1 -0
- package/dist/components/Log/common/index.js +1 -0
- package/dist/components/Log/context.d.ts +2 -0
- package/dist/components/Log/context.js +2 -0
- package/dist/components/Log/index.d.ts +23 -0
- package/dist/components/Log/index.js +6 -0
- package/dist/components/Log/styles.css +18 -0
- package/dist/components/Log/types.d.ts +57 -0
- package/dist/components/Log/types.js +2 -0
- package/dist/components/Log/utils/useDefaultTimestampFormatter.svelte.d.ts +10 -0
- package/dist/components/Log/utils/useDefaultTimestampFormatter.svelte.js +45 -0
- package/dist/components/Select/styles.css +9 -8
- package/dist/components/SideNavigation/SideNavigation.svelte +120 -0
- package/dist/components/SideNavigation/SideNavigation.svelte.d.ts +65 -0
- package/dist/components/SideNavigation/common/ExpandToggle/ExpandToggle.svelte +14 -0
- package/dist/components/SideNavigation/common/ExpandToggle/ExpandToggle.svelte.d.ts +5 -0
- package/dist/components/SideNavigation/common/ExpandToggle/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/index.js +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/styles.css +14 -0
- package/dist/components/SideNavigation/common/ExpandToggle/types.d.ts +2 -0
- package/dist/components/SideNavigation/common/ExpandToggle/types.js +1 -0
- package/dist/components/SideNavigation/common/NavigationItem/NavigationItem.svelte +33 -0
- package/dist/components/SideNavigation/common/NavigationItem/NavigationItem.svelte.d.ts +5 -0
- package/dist/components/SideNavigation/common/NavigationItem/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/NavigationItem/index.js +2 -0
- package/dist/components/SideNavigation/common/NavigationItem/styles.css +52 -0
- package/dist/components/SideNavigation/common/NavigationItem/types.d.ts +16 -0
- package/dist/components/SideNavigation/common/NavigationItem/types.js +1 -0
- package/dist/components/SideNavigation/common/index.d.ts +2 -0
- package/dist/components/SideNavigation/common/index.js +2 -0
- package/dist/components/SideNavigation/index.d.ts +15 -0
- package/dist/components/SideNavigation/index.js +7 -0
- package/dist/components/SideNavigation/styles.css +124 -0
- package/dist/components/SideNavigation/types.d.ts +39 -0
- package/dist/components/SideNavigation/types.js +2 -0
- package/dist/components/UserAvatar/UserAvatar.svelte +13 -2
- package/dist/components/UserAvatar/UserAvatar.svelte.d.ts +11 -0
- package/dist/components/UserAvatar/types.d.ts +8 -3
- package/dist/components/icons/ExpandRightIcon.svelte +22 -0
- package/dist/components/icons/ExpandRightIcon.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/components/icons/index.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +2 -0
- package/dist/transitions/cssControlledFade.d.ts +9 -0
- package/dist/transitions/cssControlledFade.js +39 -0
- package/package.json +11 -8
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ButtonPrimitive } from "../../../common/ButtonPrimitive/index.js";
|
|
3
|
+
import { ExpandRightIcon } from "../../../icons/index.js";
|
|
4
|
+
import "./styles.css";
|
|
5
|
+
import type { ExpandToggleProps } from "./types.js";
|
|
6
|
+
|
|
7
|
+
const componentCssClassName = "ds side-navigation-expand-toggle";
|
|
8
|
+
|
|
9
|
+
let { class: className, ...rest }: ExpandToggleProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<ButtonPrimitive class={[componentCssClassName, className]} {...rest}>
|
|
13
|
+
<ExpandRightIcon class="expand-icon" />
|
|
14
|
+
</ButtonPrimitive>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
.ds.side-navigation-expand-toggle.button-primitive {
|
|
2
|
+
display: grid;
|
|
3
|
+
place-items: center;
|
|
4
|
+
box-sizing: content-box;
|
|
5
|
+
&[aria-expanded="true"] .expand-icon {
|
|
6
|
+
transform: rotate(180deg);
|
|
7
|
+
}
|
|
8
|
+
&[aria-expanded="false"] {
|
|
9
|
+
min-height: 1lh;
|
|
10
|
+
--dimension-padding-block-button: var(
|
|
11
|
+
--dimension-padding-block-side-navigation-item
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { ButtonPrimitive } from "../../../common/ButtonPrimitive/index.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
import type { NavigationItemProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
const componentCssClassName = "ds navigation-item";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
icon,
|
|
12
|
+
selected,
|
|
13
|
+
...rest
|
|
14
|
+
}: NavigationItemProps = $props();
|
|
15
|
+
|
|
16
|
+
const labelId = $props.id();
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<ButtonPrimitive
|
|
20
|
+
class={[componentCssClassName, className, { selected }]}
|
|
21
|
+
aria-labelledby={labelId}
|
|
22
|
+
{...rest}
|
|
23
|
+
>
|
|
24
|
+
{#if icon}
|
|
25
|
+
<div class="icon">
|
|
26
|
+
{@render icon()}
|
|
27
|
+
</div>
|
|
28
|
+
{/if}
|
|
29
|
+
<!-- using labeled-by exposes the contents to a11y tree even if the label is visually hidden -->
|
|
30
|
+
<div id={labelId} class="label">
|
|
31
|
+
{@render children()}
|
|
32
|
+
</div>
|
|
33
|
+
</ButtonPrimitive>
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
.ds.navigation-item.button-primitive {
|
|
2
|
+
display: grid;
|
|
3
|
+
position: relative;
|
|
4
|
+
grid-column: 1 / -1;
|
|
5
|
+
border: none;
|
|
6
|
+
|
|
7
|
+
--dimension-padding-inline-button: 0;
|
|
8
|
+
--dimension-padding-block-button: var(--lp-dimension-spacing-block-xxs);
|
|
9
|
+
--dimension-padding-inline-start-button-label: var(
|
|
10
|
+
--lp-dimension-spacing-inline-xs
|
|
11
|
+
);
|
|
12
|
+
--color-background-button-selected: var(
|
|
13
|
+
--tmp-color-background-neutral-active
|
|
14
|
+
);
|
|
15
|
+
--dimension-width-button-selected-indicator: var(
|
|
16
|
+
--lp-dimension-stroke-thickness-large
|
|
17
|
+
);
|
|
18
|
+
--color-background-button-selected-indicator: var(
|
|
19
|
+
--tmp-color-border-highlight
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
grid-template-columns: subgrid;
|
|
23
|
+
|
|
24
|
+
> .icon {
|
|
25
|
+
grid-column: logo;
|
|
26
|
+
place-self: center;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
> .label {
|
|
30
|
+
grid-column: expanded-start / content-end;
|
|
31
|
+
text-align: left;
|
|
32
|
+
white-space: nowrap;
|
|
33
|
+
overflow: hidden;
|
|
34
|
+
text-overflow: ellipsis;
|
|
35
|
+
padding-inline-start: var(--dimension-padding-inline-start-button-label);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
&.selected {
|
|
39
|
+
--color-background-button: var(--color-background-button-selected);
|
|
40
|
+
--color-background-button-hover: var(--color-background-button-selected);
|
|
41
|
+
--color-background-button-active: var(--color-background-button-selected);
|
|
42
|
+
|
|
43
|
+
&::before {
|
|
44
|
+
content: "";
|
|
45
|
+
position: absolute;
|
|
46
|
+
height: 100%;
|
|
47
|
+
width: var(--dimension-width-button-selected-indicator);
|
|
48
|
+
inset-inline-start: 0;
|
|
49
|
+
background-color: var(--color-background-button-selected-indicator);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { ButtonPrimitiveProps } from "../../../common/index.js";
|
|
3
|
+
export type NavigationItemProps = ButtonPrimitiveProps & {
|
|
4
|
+
/**
|
|
5
|
+
* Whether the item should appear selected.
|
|
6
|
+
*/
|
|
7
|
+
selected?: boolean;
|
|
8
|
+
/**
|
|
9
|
+
* An optional icon to be displayed alongside the item text.
|
|
10
|
+
*/
|
|
11
|
+
icon?: Snippet<[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Content to be displayed inside the item.
|
|
14
|
+
*/
|
|
15
|
+
children: Snippet<[]>;
|
|
16
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ExpandToggle, NavigationItem } from "./common/index.js";
|
|
2
|
+
import { default as SideNavigationRoot } from "./SideNavigation.svelte";
|
|
3
|
+
declare const SideNavigation: typeof SideNavigationRoot & {
|
|
4
|
+
/**
|
|
5
|
+
* `SideNavigation.NavigationItem` A clickable button item within the side navigation.
|
|
6
|
+
*/
|
|
7
|
+
NavigationItem: typeof NavigationItem;
|
|
8
|
+
/**
|
|
9
|
+
* `SideNavigation.ExpandToggle` A button to toggle the expansion of the side navigation.
|
|
10
|
+
*/
|
|
11
|
+
ExpandToggle: typeof ExpandToggle;
|
|
12
|
+
};
|
|
13
|
+
export type { NavigationItemProps as SideNavigationItemProps } from "./common/index.js";
|
|
14
|
+
export type { ExpandToggleProps as SideNavigationExpandToggleProps, SideNavigationProps, } from "./types.js";
|
|
15
|
+
export { SideNavigation };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/* @canonical/generator-ds 0.17.1 */
|
|
2
|
+
import { ExpandToggle, NavigationItem } from "./common/index.js";
|
|
3
|
+
import { default as SideNavigationRoot } from "./SideNavigation.svelte";
|
|
4
|
+
const SideNavigation = SideNavigationRoot;
|
|
5
|
+
SideNavigation.NavigationItem = NavigationItem;
|
|
6
|
+
SideNavigation.ExpandToggle = ExpandToggle;
|
|
7
|
+
export { SideNavigation };
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
.ds.side-navigation {
|
|
2
|
+
--color-background-side-navigation: var(--lp-color-background-alt);
|
|
3
|
+
--transition-duration-side-navigation: var(--lp-transition-duration-brisk);
|
|
4
|
+
--transition-easing-side-navigation: var(--lp-transition-timing-ease-out);
|
|
5
|
+
--dimension-padding-side-navigation: var(--lp-dimension-spacing-inline-s);
|
|
6
|
+
--dimension-width-side-navigation-logo-column: 21px;
|
|
7
|
+
--dimension-width-side-navigation-expanded: 240px;
|
|
8
|
+
--dimension-padding-block-start-side-navigation-nav: 40px;
|
|
9
|
+
--dimension-padding-block-end-side-navigation-footer: var(
|
|
10
|
+
--lp-dimension-spacing-block-xs
|
|
11
|
+
);
|
|
12
|
+
--dimension-padding-block-end-side-navigation-nav: var(
|
|
13
|
+
--lp-dimension-spacing-block-xxl
|
|
14
|
+
);
|
|
15
|
+
--dimension-padding-block-side-navigation-item: var(
|
|
16
|
+
--lp-dimension-spacing-block-xxs
|
|
17
|
+
);
|
|
18
|
+
--typography-side-navigation: var(--lp-typography-paragraph-default);
|
|
19
|
+
|
|
20
|
+
width: var(--dimension-width-side-navigation-expanded);
|
|
21
|
+
background-color: var(--color-background-side-navigation);
|
|
22
|
+
|
|
23
|
+
position: sticky;
|
|
24
|
+
top: 0;
|
|
25
|
+
height: 100dvh;
|
|
26
|
+
display: grid;
|
|
27
|
+
overflow: hidden;
|
|
28
|
+
font: var(--typography-side-navigation);
|
|
29
|
+
grid-template-columns:
|
|
30
|
+
var(--dimension-padding-side-navigation)
|
|
31
|
+
[logo-start content-start] var(
|
|
32
|
+
--dimension-width-side-navigation-logo-column
|
|
33
|
+
)
|
|
34
|
+
[logo-end expanded-start] minmax(0, 1fr)
|
|
35
|
+
[expanded-end] auto [content-end] var(--dimension-padding-side-navigation);
|
|
36
|
+
grid-template-rows: [header-start] auto [header-end nav-start] 1fr [nav-end
|
|
37
|
+
footer-start] auto [footer-end];
|
|
38
|
+
|
|
39
|
+
transition: width var(--transition-duration-side-navigation)
|
|
40
|
+
var(--transition-easing-side-navigation);
|
|
41
|
+
|
|
42
|
+
& > .logo {
|
|
43
|
+
grid-column: logo-start / expanded-end;
|
|
44
|
+
min-width: max-content;
|
|
45
|
+
grid-row: header;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
& > nav {
|
|
49
|
+
grid-row: nav;
|
|
50
|
+
grid-column: 1 / -1;
|
|
51
|
+
overflow-y: auto;
|
|
52
|
+
overflow-x: hidden;
|
|
53
|
+
display: grid;
|
|
54
|
+
grid-template-columns: subgrid;
|
|
55
|
+
place-content: start stretch;
|
|
56
|
+
|
|
57
|
+
margin-block-start: var(
|
|
58
|
+
--dimension-padding-block-start-side-navigation-nav
|
|
59
|
+
);
|
|
60
|
+
padding-block-end: var(--dimension-padding-block-end-side-navigation-nav);
|
|
61
|
+
mask-image: linear-gradient(
|
|
62
|
+
to top,
|
|
63
|
+
transparent,
|
|
64
|
+
black var(--dimension-padding-block-end-side-navigation-nav)
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
& > .footer {
|
|
69
|
+
grid-row: footer;
|
|
70
|
+
grid-column: 1 / -1;
|
|
71
|
+
display: grid;
|
|
72
|
+
grid-template-columns: subgrid;
|
|
73
|
+
|
|
74
|
+
padding-block-end: var(
|
|
75
|
+
--dimension-padding-block-end-side-navigation-footer
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
& .ds.side-navigation-expand-toggle {
|
|
80
|
+
grid-row: header;
|
|
81
|
+
grid-column: expanded-end / content-end;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/* Collapsed state */
|
|
85
|
+
|
|
86
|
+
&.collapsed {
|
|
87
|
+
width: calc(
|
|
88
|
+
var(--dimension-width-side-navigation-logo-column) +
|
|
89
|
+
var(--dimension-padding-side-navigation) *
|
|
90
|
+
2
|
|
91
|
+
);
|
|
92
|
+
|
|
93
|
+
& .ds.side-navigation-expand-toggle {
|
|
94
|
+
grid-row: nav;
|
|
95
|
+
grid-column: 1 / -1;
|
|
96
|
+
|
|
97
|
+
grid-template-columns: subgrid;
|
|
98
|
+
align-self: self-start;
|
|
99
|
+
|
|
100
|
+
margin-block-start: var(--lp-dimension-spacing-block-m);
|
|
101
|
+
|
|
102
|
+
& .expand-icon {
|
|
103
|
+
grid-column: logo;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/* Footer items fade */
|
|
109
|
+
|
|
110
|
+
> .footer .navigation-item > .label {
|
|
111
|
+
transition: opacity var(--transition-duration-side-navigation)
|
|
112
|
+
var(--transition-easing-side-navigation);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
&.expanded-changed > .footer .navigation-item > .label {
|
|
116
|
+
@starting-style {
|
|
117
|
+
opacity: 0;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
&.collapsed > .footer .navigation-item > .label {
|
|
122
|
+
opacity: 0;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { SvelteHTMLElements } from "svelte/elements";
|
|
3
|
+
export type ExpandToggleProps = {
|
|
4
|
+
"aria-expanded": boolean;
|
|
5
|
+
"aria-controls": string;
|
|
6
|
+
"aria-label": string;
|
|
7
|
+
};
|
|
8
|
+
type BaseProps = SvelteHTMLElements["header"];
|
|
9
|
+
export interface SideNavigationProps extends BaseProps {
|
|
10
|
+
/**
|
|
11
|
+
* A snippet containing the logo to be displayed at the top of the side navigation.
|
|
12
|
+
*/
|
|
13
|
+
logo: Snippet<[]>;
|
|
14
|
+
/**
|
|
15
|
+
* A snippet containing a button to toggle the expansion of the side navigation.
|
|
16
|
+
*
|
|
17
|
+
* Snippet arguments:
|
|
18
|
+
* - `expandToggleProps`: Props that should be spread on the button element to provide accessibility information:
|
|
19
|
+
* - `aria-expanded`: A boolean indicating whether the side navigation is expanded or collapsed;
|
|
20
|
+
* - `aria-controls`: The id of the side navigation's `nav` element;
|
|
21
|
+
* - `aria-label`: A label describing the action of the button.
|
|
22
|
+
*/
|
|
23
|
+
expandToggle?: Snippet<[expandToggleProps: ExpandToggleProps]>;
|
|
24
|
+
/**
|
|
25
|
+
* A snippet containing content to be displayed at the bottom of the side navigation, below the navigation items. The icons of the items in the footer will always be visible, even when the side navigation is collapsed.
|
|
26
|
+
*/
|
|
27
|
+
footer?: Snippet<[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the side navigation is expanded or collapsed.
|
|
30
|
+
*
|
|
31
|
+
* @default true
|
|
32
|
+
*/
|
|
33
|
+
expanded?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Main page navigation items.
|
|
36
|
+
*/
|
|
37
|
+
children: Snippet<[]>;
|
|
38
|
+
}
|
|
39
|
+
export {};
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
userName: userNameProp,
|
|
13
13
|
userAvatarUrl,
|
|
14
14
|
size = "medium",
|
|
15
|
-
|
|
15
|
+
imageAttributes,
|
|
16
16
|
...rest
|
|
17
17
|
}: UserAvatarProps = $props();
|
|
18
18
|
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
<img
|
|
34
34
|
class={className}
|
|
35
35
|
src={userAvatarUrl}
|
|
36
|
-
{alt}
|
|
37
36
|
title={userName || undefined}
|
|
38
37
|
data-initials={userInitials}
|
|
39
38
|
onerror={() => (imageError = true)}
|
|
40
39
|
{...rest}
|
|
40
|
+
{...imageAttributes}
|
|
41
41
|
/>
|
|
42
42
|
{:else if userName}
|
|
43
43
|
<abbr class={className} title={userName} {...rest}>
|
|
@@ -60,4 +60,15 @@ In case JavaScript is disabled, and the image at `userAvatarUrl` fails to load,
|
|
|
60
60
|
```svelte
|
|
61
61
|
<UserAvatar userName="John Doe" userAvatarUrl="https://example.com/avatar.png" />
|
|
62
62
|
```
|
|
63
|
+
|
|
64
|
+
`<img>`-specific attributes (such as `alt` or `loading`) can be passed via `imageAttributes`.
|
|
65
|
+
They only take effect when the avatar renders as an image.
|
|
66
|
+
|
|
67
|
+
```svelte
|
|
68
|
+
<UserAvatar
|
|
69
|
+
userName="John Doe"
|
|
70
|
+
userAvatarUrl="https://example.com/avatar.png"
|
|
71
|
+
imageAttributes={{ alt: "John Doe's avatar", loading: "lazy" }}
|
|
72
|
+
/>
|
|
73
|
+
```
|
|
63
74
|
-->
|
|
@@ -11,6 +11,17 @@ import "./styles.css";
|
|
|
11
11
|
* ```svelte
|
|
12
12
|
* <UserAvatar userName="John Doe" userAvatarUrl="https://example.com/avatar.png" />
|
|
13
13
|
* ```
|
|
14
|
+
*
|
|
15
|
+
* `<img>`-specific attributes (such as `alt` or `loading`) can be passed via `imageAttributes`.
|
|
16
|
+
* They only take effect when the avatar renders as an image.
|
|
17
|
+
*
|
|
18
|
+
* ```svelte
|
|
19
|
+
* <UserAvatar
|
|
20
|
+
* userName="John Doe"
|
|
21
|
+
* userAvatarUrl="https://example.com/avatar.png"
|
|
22
|
+
* imageAttributes={{ alt: "John Doe's avatar", loading: "lazy" }}
|
|
23
|
+
* />
|
|
24
|
+
* ```
|
|
14
25
|
*/
|
|
15
26
|
declare const UserAvatar: import("svelte").Component<UserAvatarProps, {}, "">;
|
|
16
27
|
type UserAvatar = ReturnType<typeof UserAvatar>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { HTMLAttributes } from "svelte/elements";
|
|
1
|
+
import type { HTMLAttributes, HTMLImgAttributes } from "svelte/elements";
|
|
2
|
+
type ImageOnlyAttributes = Omit<HTMLImgAttributes, keyof HTMLAttributes<HTMLElement> | "bind:naturalWidth" | "bind:naturalHeight" | "children" | "src">;
|
|
2
3
|
export type UserOptions = {
|
|
3
4
|
/** The user's name */
|
|
4
5
|
userName?: string;
|
|
@@ -7,6 +8,10 @@ export type UserOptions = {
|
|
|
7
8
|
};
|
|
8
9
|
export interface UserAvatarProps extends Omit<HTMLAttributes<HTMLElement>, "children">, UserOptions {
|
|
9
10
|
size?: "small" | "medium" | "large";
|
|
10
|
-
/**
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* `<img>`-specific attributes (e.g. `alt`, `loading`, `fetchpriority`) for the avatar image.
|
|
13
|
+
* Only applied when the avatar renders as an image — i.e. `userAvatarUrl` is set and the image has not failed to load.
|
|
14
|
+
*/
|
|
15
|
+
imageAttributes?: ImageOnlyAttributes;
|
|
12
16
|
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { IconProps } from "@canonical/svelte-icons";
|
|
3
|
+
import { IconBase } from "@canonical/svelte-icons";
|
|
4
|
+
|
|
5
|
+
const props: IconProps = $props();
|
|
6
|
+
</script>
|
|
7
|
+
|
|
8
|
+
<IconBase iconName="expand-right" {...props}>
|
|
9
|
+
<svg
|
|
10
|
+
width="16"
|
|
11
|
+
height="16"
|
|
12
|
+
viewBox="0 0 16 16"
|
|
13
|
+
fill="none"
|
|
14
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
15
|
+
>
|
|
16
|
+
<path d="M3 1L3 15H1.5L1.5 1H3Z" fill="currentColor"></path>
|
|
17
|
+
<path
|
|
18
|
+
d="M8.91555 11.6844L11.8779 8.72209L4.9 8.72209V7.22209L11.8778 7.22209L8.91555 4.25982L9.97621 3.19916L14.7492 7.97213L9.97621 12.7451L8.91555 11.6844Z"
|
|
19
|
+
fill="currentColor"
|
|
20
|
+
></path>
|
|
21
|
+
</svg>
|
|
22
|
+
</IconBase>
|
|
@@ -6,6 +6,7 @@ export * from "./Chip/index.js";
|
|
|
6
6
|
export * from "./DateTime/index.js";
|
|
7
7
|
export * from "./DescriptionList/index.js";
|
|
8
8
|
export * from "./Link/index.js";
|
|
9
|
+
export * from "./Log/index.js";
|
|
9
10
|
export * from "./Modal/index.js";
|
|
10
11
|
export * from "./NumberInput/index.js";
|
|
11
12
|
export * from "./Popover/index.js";
|
|
@@ -13,6 +14,7 @@ export * from "./Radio/index.js";
|
|
|
13
14
|
export * from "./RelativeDateTime/index.js";
|
|
14
15
|
export * from "./SearchBox/index.js";
|
|
15
16
|
export * from "./Select/index.js";
|
|
17
|
+
export * from "./SideNavigation/index.js";
|
|
16
18
|
export * from "./SidePanel/index.js";
|
|
17
19
|
export * from "./Spinner/index.js";
|
|
18
20
|
export * from "./Switch/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -6,6 +6,7 @@ export * from "./Chip/index.js";
|
|
|
6
6
|
export * from "./DateTime/index.js";
|
|
7
7
|
export * from "./DescriptionList/index.js";
|
|
8
8
|
export * from "./Link/index.js";
|
|
9
|
+
export * from "./Log/index.js";
|
|
9
10
|
export * from "./Modal/index.js";
|
|
10
11
|
export * from "./NumberInput/index.js";
|
|
11
12
|
export * from "./Popover/index.js";
|
|
@@ -13,6 +14,7 @@ export * from "./Radio/index.js";
|
|
|
13
14
|
export * from "./RelativeDateTime/index.js";
|
|
14
15
|
export * from "./SearchBox/index.js";
|
|
15
16
|
export * from "./Select/index.js";
|
|
17
|
+
export * from "./SideNavigation/index.js";
|
|
16
18
|
export * from "./SidePanel/index.js";
|
|
17
19
|
export * from "./Spinner/index.js";
|
|
18
20
|
export * from "./Switch/index.js";
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TransitionConfig } from "svelte/transition";
|
|
2
|
+
/**
|
|
3
|
+
* A Svelte transition that fades an element's opacity.
|
|
4
|
+
* The duration and easing are controlled by CSS custom properties on the element.
|
|
5
|
+
*/
|
|
6
|
+
export declare function cssControlledFade(node: HTMLElement | SVGElement, params: {
|
|
7
|
+
durationVar: `--${string}`;
|
|
8
|
+
easingVar: `--${string}`;
|
|
9
|
+
}): TransitionConfig;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// TODO(in-JS-tokens): This would not be necessary if we had in-JS design tokens.
|
|
2
|
+
/**
|
|
3
|
+
* A Svelte transition that fades an element's opacity.
|
|
4
|
+
* The duration and easing are controlled by CSS custom properties on the element.
|
|
5
|
+
*/
|
|
6
|
+
export function cssControlledFade(node, params) {
|
|
7
|
+
const style = getComputedStyle(node);
|
|
8
|
+
const opacity = Number(style.opacity);
|
|
9
|
+
const durationMs = parseCssDuration(style.getPropertyValue(params.durationVar));
|
|
10
|
+
const easingValue = style.getPropertyValue(params.easingVar).trim();
|
|
11
|
+
// We directly set the animation-timing-function on the element so that we don't have to parse the easing function string.
|
|
12
|
+
if (easingValue) {
|
|
13
|
+
node.style.animationTimingFunction = easingValue;
|
|
14
|
+
}
|
|
15
|
+
return {
|
|
16
|
+
duration: durationMs,
|
|
17
|
+
css: (t) => `opacity: ${t * opacity}`,
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Parses a CSS duration string (e.g., "500ms", "0.8s") into a number of milliseconds.
|
|
22
|
+
* @param durationCSS The duration string from the CSS custom property.
|
|
23
|
+
* @returns The duration in milliseconds.
|
|
24
|
+
*/
|
|
25
|
+
function parseCssDuration(durationCSS) {
|
|
26
|
+
durationCSS = durationCSS.trim();
|
|
27
|
+
if (!durationCSS)
|
|
28
|
+
return 0; // A sensible default duration
|
|
29
|
+
const time = parseFloat(durationCSS);
|
|
30
|
+
if (Number.isNaN(time) || time < 0)
|
|
31
|
+
return 0;
|
|
32
|
+
if (durationCSS.endsWith("ms")) {
|
|
33
|
+
return time;
|
|
34
|
+
}
|
|
35
|
+
if (durationCSS.endsWith("s")) {
|
|
36
|
+
return time * 1000;
|
|
37
|
+
}
|
|
38
|
+
return 0;
|
|
39
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canonical/svelte-ds-app-launchpad",
|
|
3
3
|
"description": "Launchpad-specific components for the Pragma design system.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.28.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -37,6 +37,9 @@
|
|
|
37
37
|
"url": "https://github.com/canonical/pragma/issues"
|
|
38
38
|
},
|
|
39
39
|
"homepage": "https://github.com/canonical/pragma/tree/main/packages/svelte/ds-app-launchpad#readme",
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
40
43
|
"scripts": {
|
|
41
44
|
"build:all": "bun run build",
|
|
42
45
|
"build": "svelte-package -o dist -i src/lib --tsconfig ./tsconfig.build.json",
|
|
@@ -60,13 +63,13 @@
|
|
|
60
63
|
},
|
|
61
64
|
"devDependencies": {
|
|
62
65
|
"@biomejs/biome": "2.4.9",
|
|
63
|
-
"@canonical/biome-config": "^0.
|
|
66
|
+
"@canonical/biome-config": "^0.28.0",
|
|
64
67
|
"@canonical/design-tokens": "^0.6.0",
|
|
65
|
-
"@canonical/storybook-config": "^0.
|
|
66
|
-
"@canonical/storybook-helpers": "^0.
|
|
67
|
-
"@canonical/svelte-ssr-test": "^0.
|
|
68
|
-
"@canonical/typescript-config-svelte": "^0.
|
|
69
|
-
"@canonical/webarchitect": "^0.
|
|
68
|
+
"@canonical/storybook-config": "^0.28.0",
|
|
69
|
+
"@canonical/storybook-helpers": "^0.28.0",
|
|
70
|
+
"@canonical/svelte-ssr-test": "^0.28.0",
|
|
71
|
+
"@canonical/typescript-config-svelte": "^0.28.0",
|
|
72
|
+
"@canonical/webarchitect": "^0.28.0",
|
|
70
73
|
"@storybook/addon-docs": "^10.3.1",
|
|
71
74
|
"@storybook/addon-svelte-csf": "^5.0.11",
|
|
72
75
|
"@sveltejs/package": "^2.5.7",
|
|
@@ -90,5 +93,5 @@
|
|
|
90
93
|
"peerDependencies": {
|
|
91
94
|
"svelte": "^5.47.1"
|
|
92
95
|
},
|
|
93
|
-
"gitHead": "
|
|
96
|
+
"gitHead": "8297d72122bcba903f7e8833cb23ccbaa164ed56"
|
|
94
97
|
}
|