@canonical/svelte-ds-app-launchpad 0.27.0 → 0.27.1-experimental.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/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/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 +1 -0
- package/dist/components/index.js +1 -0
- package/dist/transitions/cssControlledFade.d.ts +9 -0
- package/dist/transitions/cssControlledFade.js +39 -0
- package/package.json +11 -8
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
transition-property: background-color, border-color, outline-color;
|
|
70
70
|
transition-timing-function: var(--lp-transition-timing-ease-in);
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
&:not(:disabled) {
|
|
73
73
|
&:hover {
|
|
74
74
|
background-color: var(--color-background-select-input-hover);
|
|
75
75
|
}
|
|
@@ -140,17 +140,18 @@
|
|
|
140
140
|
}
|
|
141
141
|
|
|
142
142
|
&.base {
|
|
143
|
-
--
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
--
|
|
143
|
+
--color-background-select-input-hover: var(
|
|
144
|
+
--lp-color-background-neutral-hover
|
|
145
|
+
);
|
|
146
|
+
--color-background-select-input-active: var(
|
|
147
|
+
--lp-color-background-neutral-active
|
|
148
|
+
);
|
|
149
|
+
--color-background-select-input: transparent;
|
|
147
150
|
|
|
148
151
|
> select {
|
|
149
152
|
border: none;
|
|
150
|
-
}
|
|
151
153
|
|
|
152
|
-
|
|
153
|
-
> select {
|
|
154
|
+
&:not([multiple]) {
|
|
154
155
|
option {
|
|
155
156
|
/* FIXME(steciuk): Pt. 2 of the transparency workaround */
|
|
156
157
|
background-color: var(--lp-color-background-default);
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { cssControlledFade } from "../../transitions/cssControlledFade.js";
|
|
3
|
+
import "./styles.css";
|
|
4
|
+
import type { SideNavigationProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
const componentCssClassName = "ds side-navigation";
|
|
7
|
+
|
|
8
|
+
let {
|
|
9
|
+
class: className,
|
|
10
|
+
children,
|
|
11
|
+
logo,
|
|
12
|
+
footer,
|
|
13
|
+
expandToggle,
|
|
14
|
+
expanded = true,
|
|
15
|
+
...rest
|
|
16
|
+
}: SideNavigationProps = $props();
|
|
17
|
+
|
|
18
|
+
const navId = $props.id();
|
|
19
|
+
|
|
20
|
+
// We need to track if expanded has changed from its initial value to avoid animating on first render
|
|
21
|
+
let expandedChanged = $state(false);
|
|
22
|
+
// svelte-ignore state_referenced_locally
|
|
23
|
+
const initialExpanded = expanded;
|
|
24
|
+
$effect.pre(() => {
|
|
25
|
+
if (expanded !== initialExpanded) expandedChanged = true;
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
|
|
29
|
+
<header
|
|
30
|
+
class={[componentCssClassName, className]}
|
|
31
|
+
class:collapsed={!expanded}
|
|
32
|
+
class:expanded-changed={expandedChanged}
|
|
33
|
+
{...rest}
|
|
34
|
+
>
|
|
35
|
+
<div class="logo">
|
|
36
|
+
{@render logo()}
|
|
37
|
+
</div>
|
|
38
|
+
{@render expandToggle?.({
|
|
39
|
+
"aria-expanded": expanded,
|
|
40
|
+
"aria-controls": navId,
|
|
41
|
+
"aria-label": expanded ? "Collapse navigation" : "Expand navigation",
|
|
42
|
+
})}
|
|
43
|
+
{#if expanded}
|
|
44
|
+
<nav
|
|
45
|
+
id={navId}
|
|
46
|
+
transition:cssControlledFade={{
|
|
47
|
+
durationVar: "--transition-duration-side-navigation",
|
|
48
|
+
easingVar: "--transition-easing-side-navigation",
|
|
49
|
+
}}
|
|
50
|
+
>
|
|
51
|
+
{@render children?.()}
|
|
52
|
+
</nav>
|
|
53
|
+
{/if}
|
|
54
|
+
{#if footer}
|
|
55
|
+
<div class="footer">
|
|
56
|
+
{@render footer()}
|
|
57
|
+
</div>
|
|
58
|
+
{/if}
|
|
59
|
+
</header>
|
|
60
|
+
|
|
61
|
+
<!-- @component
|
|
62
|
+
`SideNavigation` is the primary navigation component containing links to navigate between different sections of an application. The component can be expanded or collapsed (depending on the `expanded` prop).
|
|
63
|
+
|
|
64
|
+
The component has two sections:
|
|
65
|
+
- main navigation area (children) - it is hidden when component is collapsed;
|
|
66
|
+
- footer area (footer) - if component is collapsed, only icons are shown.
|
|
67
|
+
|
|
68
|
+
## Example Usage
|
|
69
|
+
```svelte
|
|
70
|
+
<script lang="ts">
|
|
71
|
+
let expanded = $state(true);
|
|
72
|
+
</script>
|
|
73
|
+
|
|
74
|
+
<SideNavigation {expanded}>
|
|
75
|
+
{#snippet logo()}
|
|
76
|
+
<a href="/" aria-label="Home">
|
|
77
|
+
<Logo />
|
|
78
|
+
</a>
|
|
79
|
+
{/snippet}
|
|
80
|
+
{#snippet expandToggle(toggleProps)}
|
|
81
|
+
<SideNavigation.ExpandToggle
|
|
82
|
+
{...toggleProps}
|
|
83
|
+
onclick={() => (expanded = !expanded)}
|
|
84
|
+
/>
|
|
85
|
+
{/snippet}
|
|
86
|
+
<SideNavigation.NavigationItem href="/dashboard">
|
|
87
|
+
{#snippet icon()}
|
|
88
|
+
<Dashboard />
|
|
89
|
+
{/snippet}
|
|
90
|
+
Dashboard
|
|
91
|
+
</SideNavigation.NavigationItem>
|
|
92
|
+
<SideNavigation.NavigationItem href="/projects">
|
|
93
|
+
{#snippet icon()}
|
|
94
|
+
<Folder />
|
|
95
|
+
{/snippet}
|
|
96
|
+
Projects
|
|
97
|
+
</SideNavigation.NavigationItem>
|
|
98
|
+
{#snippet footer()}
|
|
99
|
+
<SideNavigation.NavigationItem onclick={doSomething}>
|
|
100
|
+
{#snippet icon()}
|
|
101
|
+
<ColorPalette />
|
|
102
|
+
{/snippet}
|
|
103
|
+
Theme
|
|
104
|
+
</SideNavigation.NavigationItem>
|
|
105
|
+
<SideNavigation.NavigationItem href="/profile">
|
|
106
|
+
{#snippet icon()}
|
|
107
|
+
<User />
|
|
108
|
+
{/snippet}
|
|
109
|
+
John Doe
|
|
110
|
+
</SideNavigation.NavigationItem>
|
|
111
|
+
<SideNavigation.NavigationItem onclick={doSomethingElse}>
|
|
112
|
+
{#snippet icon()}
|
|
113
|
+
<LogOut />
|
|
114
|
+
{/snippet}
|
|
115
|
+
Logout
|
|
116
|
+
</SideNavigation.NavigationItem>
|
|
117
|
+
{/snippet}
|
|
118
|
+
</SideNavigation>
|
|
119
|
+
```
|
|
120
|
+
-->
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import "./styles.css";
|
|
2
|
+
import type { SideNavigationProps } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* `SideNavigation` is the primary navigation component containing links to navigate between different sections of an application. The component can be expanded or collapsed (depending on the `expanded` prop).
|
|
5
|
+
*
|
|
6
|
+
* The component has two sections:
|
|
7
|
+
* - main navigation area (children) - it is hidden when component is collapsed;
|
|
8
|
+
* - footer area (footer) - if component is collapsed, only icons are shown.
|
|
9
|
+
*
|
|
10
|
+
* ## Example Usage
|
|
11
|
+
* ```svelte
|
|
12
|
+
* <script lang="ts">
|
|
13
|
+
* let expanded = $state(true);
|
|
14
|
+
* </script>
|
|
15
|
+
*
|
|
16
|
+
* <SideNavigation {expanded}>
|
|
17
|
+
* {#snippet logo()}
|
|
18
|
+
* <a href="/" aria-label="Home">
|
|
19
|
+
* <Logo />
|
|
20
|
+
* </a>
|
|
21
|
+
* {/snippet}
|
|
22
|
+
* {#snippet expandToggle(toggleProps)}
|
|
23
|
+
* <SideNavigation.ExpandToggle
|
|
24
|
+
* {...toggleProps}
|
|
25
|
+
* onclick={() => (expanded = !expanded)}
|
|
26
|
+
* />
|
|
27
|
+
* {/snippet}
|
|
28
|
+
* <SideNavigation.NavigationItem href="/dashboard">
|
|
29
|
+
* {#snippet icon()}
|
|
30
|
+
* <Dashboard />
|
|
31
|
+
* {/snippet}
|
|
32
|
+
* Dashboard
|
|
33
|
+
* </SideNavigation.NavigationItem>
|
|
34
|
+
* <SideNavigation.NavigationItem href="/projects">
|
|
35
|
+
* {#snippet icon()}
|
|
36
|
+
* <Folder />
|
|
37
|
+
* {/snippet}
|
|
38
|
+
* Projects
|
|
39
|
+
* </SideNavigation.NavigationItem>
|
|
40
|
+
* {#snippet footer()}
|
|
41
|
+
* <SideNavigation.NavigationItem onclick={doSomething}>
|
|
42
|
+
* {#snippet icon()}
|
|
43
|
+
* <ColorPalette />
|
|
44
|
+
* {/snippet}
|
|
45
|
+
* Theme
|
|
46
|
+
* </SideNavigation.NavigationItem>
|
|
47
|
+
* <SideNavigation.NavigationItem href="/profile">
|
|
48
|
+
* {#snippet icon()}
|
|
49
|
+
* <User />
|
|
50
|
+
* {/snippet}
|
|
51
|
+
* John Doe
|
|
52
|
+
* </SideNavigation.NavigationItem>
|
|
53
|
+
* <SideNavigation.NavigationItem onclick={doSomethingElse}>
|
|
54
|
+
* {#snippet icon()}
|
|
55
|
+
* <LogOut />
|
|
56
|
+
* {/snippet}
|
|
57
|
+
* Logout
|
|
58
|
+
* </SideNavigation.NavigationItem>
|
|
59
|
+
* {/snippet}
|
|
60
|
+
* </SideNavigation>
|
|
61
|
+
* ```
|
|
62
|
+
*/
|
|
63
|
+
declare const SideNavigation: import("svelte").Component<SideNavigationProps, {}, "">;
|
|
64
|
+
type SideNavigation = ReturnType<typeof SideNavigation>;
|
|
65
|
+
export default SideNavigation;
|
|
@@ -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 {};
|
|
@@ -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>
|
|
@@ -13,6 +13,7 @@ export * from "./Radio/index.js";
|
|
|
13
13
|
export * from "./RelativeDateTime/index.js";
|
|
14
14
|
export * from "./SearchBox/index.js";
|
|
15
15
|
export * from "./Select/index.js";
|
|
16
|
+
export * from "./SideNavigation/index.js";
|
|
16
17
|
export * from "./SidePanel/index.js";
|
|
17
18
|
export * from "./Spinner/index.js";
|
|
18
19
|
export * from "./Switch/index.js";
|
package/dist/components/index.js
CHANGED
|
@@ -13,6 +13,7 @@ export * from "./Radio/index.js";
|
|
|
13
13
|
export * from "./RelativeDateTime/index.js";
|
|
14
14
|
export * from "./SearchBox/index.js";
|
|
15
15
|
export * from "./Select/index.js";
|
|
16
|
+
export * from "./SideNavigation/index.js";
|
|
16
17
|
export * from "./SidePanel/index.js";
|
|
17
18
|
export * from "./Spinner/index.js";
|
|
18
19
|
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.27.0",
|
|
4
|
+
"version": "0.27.1-experimental.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.27.0",
|
|
66
|
+
"@canonical/biome-config": "^0.27.1-experimental.0",
|
|
64
67
|
"@canonical/design-tokens": "^0.6.0",
|
|
65
|
-
"@canonical/storybook-config": "^0.27.0",
|
|
66
|
-
"@canonical/storybook-helpers": "^0.27.0",
|
|
67
|
-
"@canonical/svelte-ssr-test": "^0.27.0",
|
|
68
|
-
"@canonical/typescript-config-svelte": "^0.27.0",
|
|
69
|
-
"@canonical/webarchitect": "^0.27.0",
|
|
68
|
+
"@canonical/storybook-config": "^0.27.1-experimental.0",
|
|
69
|
+
"@canonical/storybook-helpers": "^0.27.1-experimental.0",
|
|
70
|
+
"@canonical/svelte-ssr-test": "^0.27.1-experimental.0",
|
|
71
|
+
"@canonical/typescript-config-svelte": "^0.27.1-experimental.0",
|
|
72
|
+
"@canonical/webarchitect": "^0.27.1-experimental.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": "d3f5b9aab7bec07fce40a12b45097d28d3cf0201"
|
|
94
97
|
}
|