@canonical/svelte-ds-app-launchpad 0.25.0 → 0.26.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/SidePanel/SidePanel.svelte +34 -0
- package/dist/components/SidePanel/SidePanel.svelte.d.ts +13 -0
- package/dist/components/SidePanel/index.d.ts +72 -0
- package/dist/components/SidePanel/index.js +7 -0
- package/dist/components/SidePanel/styles.css +37 -0
- package/dist/components/SidePanel/types.d.ts +3 -0
- package/dist/components/SidePanel/types.js +2 -0
- package/dist/components/Table/Table.svelte +52 -0
- package/dist/components/Table/Table.svelte.d.ts +41 -0
- package/dist/components/Table/common/TH/TH.svelte +40 -0
- package/dist/components/Table/common/TH/TH.svelte.d.ts +5 -0
- package/dist/components/Table/common/TH/common/SortButton/SortButton.svelte +36 -0
- package/dist/components/Table/common/TH/common/SortButton/SortButton.svelte.d.ts +5 -0
- package/dist/components/Table/common/TH/common/SortButton/index.d.ts +2 -0
- package/dist/components/Table/common/TH/common/SortButton/index.js +3 -0
- package/dist/components/Table/common/TH/common/SortButton/styles.css +19 -0
- package/dist/components/Table/common/TH/common/SortButton/types.d.ts +10 -0
- package/dist/components/Table/common/TH/common/SortButton/types.js +2 -0
- package/dist/components/Table/common/TH/common/index.d.ts +1 -0
- package/dist/components/Table/common/TH/common/index.js +1 -0
- package/dist/components/Table/common/TH/context.d.ts +2 -0
- package/dist/components/Table/common/TH/context.js +2 -0
- package/dist/components/Table/common/TH/index.d.ts +10 -0
- package/dist/components/Table/common/TH/index.js +7 -0
- package/dist/components/Table/common/TH/styles.css +22 -0
- package/dist/components/Table/common/TH/types.d.ts +21 -0
- package/dist/components/Table/common/TH/types.js +2 -0
- package/dist/components/Table/common/index.d.ts +1 -0
- package/dist/components/Table/common/index.js +1 -0
- package/dist/components/Table/index.d.ts +21 -0
- package/dist/components/Table/index.js +6 -0
- package/dist/components/Table/styles.css +46 -0
- package/dist/components/Table/types.d.ts +2 -0
- package/dist/components/Table/types.js +2 -0
- package/dist/components/Timeline/Timeline.svelte +51 -0
- package/dist/components/Timeline/Timeline.svelte.d.ts +40 -0
- package/dist/components/Timeline/common/Event/Event.svelte +54 -0
- package/dist/components/Timeline/common/Event/Event.svelte.d.ts +5 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/TitleRow.svelte +32 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/TitleRow.svelte.d.ts +5 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/index.d.ts +2 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/index.js +3 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/styles.css +38 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/types.d.ts +18 -0
- package/dist/components/Timeline/common/Event/common/TitleRow/types.js +2 -0
- package/dist/components/Timeline/common/Event/common/index.d.ts +1 -0
- package/dist/components/Timeline/common/Event/common/index.js +1 -0
- package/dist/components/Timeline/common/Event/index.d.ts +20 -0
- package/dist/components/Timeline/common/Event/index.js +7 -0
- package/dist/components/Timeline/common/Event/styles.css +115 -0
- package/dist/components/Timeline/common/Event/types.d.ts +25 -0
- package/dist/components/Timeline/common/Event/types.js +2 -0
- package/dist/components/Timeline/common/HiddenEvents/HiddenEvents.svelte +24 -0
- package/dist/components/Timeline/common/HiddenEvents/HiddenEvents.svelte.d.ts +5 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/Link.svelte +15 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/Link.svelte.d.ts +6 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/index.d.ts +2 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/index.js +3 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/styles.css +9 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/types.d.ts +2 -0
- package/dist/components/Timeline/common/HiddenEvents/common/Link/types.js +2 -0
- package/dist/components/Timeline/common/HiddenEvents/common/index.d.ts +1 -0
- package/dist/components/Timeline/common/HiddenEvents/common/index.js +1 -0
- package/dist/components/Timeline/common/HiddenEvents/index.d.ts +17 -0
- package/dist/components/Timeline/common/HiddenEvents/index.js +7 -0
- package/dist/components/Timeline/common/HiddenEvents/styles.css +42 -0
- package/dist/components/Timeline/common/HiddenEvents/types.d.ts +9 -0
- package/dist/components/Timeline/common/HiddenEvents/types.js +2 -0
- package/dist/components/Timeline/common/index.d.ts +2 -0
- package/dist/components/Timeline/common/index.js +2 -0
- package/dist/components/Timeline/index.d.ts +39 -0
- package/dist/components/Timeline/index.js +8 -0
- package/dist/components/Timeline/styles.css +12 -0
- package/dist/components/Timeline/types.d.ts +2 -0
- package/dist/components/Timeline/types.js +2 -0
- package/dist/components/UserAvatar/UserAvatar.svelte +63 -0
- package/dist/components/UserAvatar/UserAvatar.svelte.d.ts +17 -0
- package/dist/components/UserAvatar/index.d.ts +2 -0
- package/dist/components/UserAvatar/index.js +3 -0
- package/dist/components/UserAvatar/styles.css +66 -0
- package/dist/components/UserAvatar/types.d.ts +12 -0
- package/dist/components/UserAvatar/types.js +2 -0
- package/dist/components/UserAvatar/utils/getInitials.d.ts +1 -0
- package/dist/components/UserAvatar/utils/getInitials.js +8 -0
- package/dist/components/UserAvatar/utils/index.d.ts +1 -0
- package/dist/components/UserAvatar/utils/index.js +1 -0
- package/dist/components/icons/SortIcon.svelte +25 -0
- package/dist/components/icons/SortIcon.svelte.d.ts +4 -0
- package/dist/components/icons/index.d.ts +1 -0
- package/dist/components/icons/index.js +2 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/type-utils/DistributiveOmit.d.ts +4 -0
- package/dist/type-utils/DistributiveOmit.js +1 -0
- package/dist/type-utils/index.d.ts +1 -0
- package/dist/type-utils/index.js +1 -0
- package/package.json +8 -8
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
/* @canonical/generator-ds 0.9.0-experimental.22 */
|
|
3
|
+
import { UserIcon } from "@canonical/svelte-icons";
|
|
4
|
+
import type { UserAvatarProps } from "./types.js";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
import { getInitials } from "./utils/index.js";
|
|
7
|
+
|
|
8
|
+
const componentCssClassName = "ds user-avatar";
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
class: classProp,
|
|
12
|
+
userName: userNameProp,
|
|
13
|
+
userAvatarUrl,
|
|
14
|
+
size = "medium",
|
|
15
|
+
alt,
|
|
16
|
+
...rest
|
|
17
|
+
}: UserAvatarProps = $props();
|
|
18
|
+
|
|
19
|
+
const className = $derived([componentCssClassName, size, classProp]);
|
|
20
|
+
const userName = $derived(userNameProp?.trim() || null);
|
|
21
|
+
const userInitials = $derived(userName ? getInitials(userName) : null);
|
|
22
|
+
|
|
23
|
+
let imageError = $state(false);
|
|
24
|
+
|
|
25
|
+
// Reset image error state when the avatar URL changes
|
|
26
|
+
$effect.pre(() => {
|
|
27
|
+
userAvatarUrl;
|
|
28
|
+
imageError = false;
|
|
29
|
+
});
|
|
30
|
+
</script>
|
|
31
|
+
|
|
32
|
+
{#if userAvatarUrl && !imageError}
|
|
33
|
+
<img
|
|
34
|
+
class={className}
|
|
35
|
+
src={userAvatarUrl}
|
|
36
|
+
{alt}
|
|
37
|
+
title={userName || undefined}
|
|
38
|
+
data-initials={userInitials}
|
|
39
|
+
onerror={() => (imageError = true)}
|
|
40
|
+
{...rest}
|
|
41
|
+
/>
|
|
42
|
+
{:else if userName}
|
|
43
|
+
<abbr class={className} title={userName} {...rest}>
|
|
44
|
+
{userInitials}
|
|
45
|
+
</abbr>
|
|
46
|
+
{:else}
|
|
47
|
+
<div class={className} {...rest}>
|
|
48
|
+
<UserIcon />
|
|
49
|
+
</div>
|
|
50
|
+
{/if}
|
|
51
|
+
|
|
52
|
+
<!-- @component
|
|
53
|
+
`UserAvatar` A component that displays a user's avatar.
|
|
54
|
+
|
|
55
|
+
The avatar will display the user's image if available and able to be loaded, otherwise it will display the first two initials. If neither is available, it will display a default icon placeholder.
|
|
56
|
+
|
|
57
|
+
In case JavaScript is disabled, and the image at `userAvatarUrl` fails to load, the component will provide a fallback: displaying the user's initials when `userName` is provided, or `?` when it is not.
|
|
58
|
+
|
|
59
|
+
## Example Usage
|
|
60
|
+
```svelte
|
|
61
|
+
<UserAvatar userName="John Doe" userAvatarUrl="https://example.com/avatar.png" />
|
|
62
|
+
```
|
|
63
|
+
-->
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { UserAvatarProps } from "./types.js";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/**
|
|
4
|
+
* `UserAvatar` A component that displays a user's avatar.
|
|
5
|
+
*
|
|
6
|
+
* The avatar will display the user's image if available and able to be loaded, otherwise it will display the first two initials. If neither is available, it will display a default icon placeholder.
|
|
7
|
+
*
|
|
8
|
+
* In case JavaScript is disabled, and the image at `userAvatarUrl` fails to load, the component will provide a fallback: displaying the user's initials when `userName` is provided, or `?` when it is not.
|
|
9
|
+
*
|
|
10
|
+
* ## Example Usage
|
|
11
|
+
* ```svelte
|
|
12
|
+
* <UserAvatar userName="John Doe" userAvatarUrl="https://example.com/avatar.png" />
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
declare const UserAvatar: import("svelte").Component<UserAvatarProps, {}, "">;
|
|
16
|
+
type UserAvatar = ReturnType<typeof UserAvatar>;
|
|
17
|
+
export default UserAvatar;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
.ds.user-avatar {
|
|
2
|
+
display: inline-grid;
|
|
3
|
+
flex: none;
|
|
4
|
+
|
|
5
|
+
border: var(--lp-dimension-stroke-thickness-default) solid
|
|
6
|
+
var(--lp-color-border-default);
|
|
7
|
+
background-color: var(--lp-color-background-alt);
|
|
8
|
+
color: var(--lp-color-text-default);
|
|
9
|
+
|
|
10
|
+
width: var(--lp-dimension-size-m);
|
|
11
|
+
height: var(--lp-dimension-size-m);
|
|
12
|
+
font: var(--lp-typography-paragraph-default-strong);
|
|
13
|
+
|
|
14
|
+
&.small {
|
|
15
|
+
width: var(--lp-dimension-size-s);
|
|
16
|
+
height: var(--lp-dimension-size-s);
|
|
17
|
+
font: var(--lp-typography-paragraph-s-strong);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&.large {
|
|
21
|
+
width: var(--lp-dimension-size-l);
|
|
22
|
+
height: var(--lp-dimension-size-l);
|
|
23
|
+
font: var(--lp-typography-h5);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
&:is(img) {
|
|
27
|
+
object-fit: cover;
|
|
28
|
+
position: relative;
|
|
29
|
+
overflow: hidden;
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
A fallback for when there is no JS and the image cannot be loaded.
|
|
33
|
+
|
|
34
|
+
When userName is provided, the initials are displayed. When userName is not provided, a "?" is displayed.
|
|
35
|
+
Ideally this would be a user icon instead of "?", but that would require either
|
|
36
|
+
- a base64 encoded SVG, that would bloat CSS (rather unnecessarily, for the rare case of no userName and image load failure),
|
|
37
|
+
- or a url to a static asset (difficult to achieve for a component library without making assumptions on the hosting app's bundler and asset management).
|
|
38
|
+
*/
|
|
39
|
+
&::after {
|
|
40
|
+
position: absolute;
|
|
41
|
+
inset: 0;
|
|
42
|
+
background-color: inherit;
|
|
43
|
+
display: grid;
|
|
44
|
+
place-content: center;
|
|
45
|
+
text-transform: uppercase;
|
|
46
|
+
user-select: none;
|
|
47
|
+
|
|
48
|
+
content: "?";
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
&[data-initials]::after {
|
|
52
|
+
content: attr(data-initials);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
&:is(abbr) {
|
|
57
|
+
user-select: none;
|
|
58
|
+
place-content: center;
|
|
59
|
+
text-transform: uppercase;
|
|
60
|
+
text-decoration: none;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
&:is(div) {
|
|
64
|
+
place-content: center;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { HTMLAttributes } from "svelte/elements";
|
|
2
|
+
export type UserOptions = {
|
|
3
|
+
/** The user's name */
|
|
4
|
+
userName?: string;
|
|
5
|
+
/** The URL of the user's avatar image */
|
|
6
|
+
userAvatarUrl?: string;
|
|
7
|
+
};
|
|
8
|
+
export interface UserAvatarProps extends Omit<HTMLAttributes<HTMLElement>, "children">, UserOptions {
|
|
9
|
+
size?: "small" | "medium" | "large";
|
|
10
|
+
/** The alt text for the avatar image, if available */
|
|
11
|
+
alt?: string;
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getInitials(userName: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getInitials.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./getInitials.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
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="sort" {...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
|
|
17
|
+
d="M10.5303 1.46973L9.25 2.00006V14.5001H10.75V3.81072L13.4697 6.53039L14.5303 5.46973L10.5303 1.46973Z"
|
|
18
|
+
fill="currentColor"
|
|
19
|
+
></path>
|
|
20
|
+
<path
|
|
21
|
+
d="M5.46967 14.5303L6.75 13.9999V1.49994H5.25V12.1893L2.53033 9.46961L1.46967 10.5303L5.46967 14.5303Z"
|
|
22
|
+
fill="currentColor"
|
|
23
|
+
></path>
|
|
24
|
+
</svg>
|
|
25
|
+
</IconBase>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as SortIcon } from "./SortIcon.svelte";
|
|
@@ -11,7 +11,11 @@ export * from "./NumberInput/index.js";
|
|
|
11
11
|
export * from "./Popover/index.js";
|
|
12
12
|
export * from "./Radio/index.js";
|
|
13
13
|
export * from "./RelativeDateTime/index.js";
|
|
14
|
+
export * from "./SidePanel/index.js";
|
|
14
15
|
export * from "./Spinner/index.js";
|
|
15
16
|
export * from "./Switch/index.js";
|
|
17
|
+
export * from "./Table/index.js";
|
|
16
18
|
export * from "./Textarea/index.js";
|
|
17
19
|
export * from "./TextInput/index.js";
|
|
20
|
+
export * from "./Timeline/index.js";
|
|
21
|
+
export * from "./UserAvatar/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -11,7 +11,11 @@ export * from "./NumberInput/index.js";
|
|
|
11
11
|
export * from "./Popover/index.js";
|
|
12
12
|
export * from "./Radio/index.js";
|
|
13
13
|
export * from "./RelativeDateTime/index.js";
|
|
14
|
+
export * from "./SidePanel/index.js";
|
|
14
15
|
export * from "./Spinner/index.js";
|
|
15
16
|
export * from "./Switch/index.js";
|
|
17
|
+
export * from "./Table/index.js";
|
|
16
18
|
export * from "./Textarea/index.js";
|
|
17
19
|
export * from "./TextInput/index.js";
|
|
20
|
+
export * from "./Timeline/index.js";
|
|
21
|
+
export * from "./UserAvatar/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type * from "./DistributiveOmit.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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.26.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
@@ -60,13 +60,13 @@
|
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@biomejs/biome": "2.4.9",
|
|
63
|
-
"@canonical/biome-config": "^0.
|
|
63
|
+
"@canonical/biome-config": "^0.26.0",
|
|
64
64
|
"@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.
|
|
65
|
+
"@canonical/storybook-config": "^0.26.0",
|
|
66
|
+
"@canonical/storybook-helpers": "^0.26.0",
|
|
67
|
+
"@canonical/svelte-ssr-test": "^0.26.0",
|
|
68
|
+
"@canonical/typescript-config-svelte": "^0.26.0",
|
|
69
|
+
"@canonical/webarchitect": "^0.26.0",
|
|
70
70
|
"@storybook/addon-docs": "^10.3.1",
|
|
71
71
|
"@storybook/addon-svelte-csf": "^5.0.11",
|
|
72
72
|
"@sveltejs/package": "^2.5.7",
|
|
@@ -90,5 +90,5 @@
|
|
|
90
90
|
"peerDependencies": {
|
|
91
91
|
"svelte": "^5.47.1"
|
|
92
92
|
},
|
|
93
|
-
"gitHead": "
|
|
93
|
+
"gitHead": "55fece1380dba8dcd3a88af443dd509d9aaaccb2"
|
|
94
94
|
}
|