@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,80 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.10.0-experimental.5 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { setLogContext } from "./context.js";
|
|
5
|
+
import type { LogProps } from "./types.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
import { useDefaultTimestampFormatter } from "./utils/useDefaultTimestampFormatter.svelte.js";
|
|
8
|
+
|
|
9
|
+
const componentCssClassName = "ds log";
|
|
10
|
+
|
|
11
|
+
let {
|
|
12
|
+
class: className,
|
|
13
|
+
children,
|
|
14
|
+
hideTimestamps = false,
|
|
15
|
+
wrapLines = false,
|
|
16
|
+
timeZone = "UTC",
|
|
17
|
+
timestampFormatter,
|
|
18
|
+
caption,
|
|
19
|
+
...rest
|
|
20
|
+
}: LogProps = $props();
|
|
21
|
+
|
|
22
|
+
const defaultFormatter = useDefaultTimestampFormatter(() => timeZone);
|
|
23
|
+
|
|
24
|
+
setLogContext({
|
|
25
|
+
get hideTimestamps() {
|
|
26
|
+
return hideTimestamps;
|
|
27
|
+
},
|
|
28
|
+
get wrapLines() {
|
|
29
|
+
return wrapLines;
|
|
30
|
+
},
|
|
31
|
+
get timestampFormatter() {
|
|
32
|
+
return timestampFormatter ?? defaultFormatter;
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<table class={[componentCssClassName, className]} {...rest}>
|
|
38
|
+
{#if caption}
|
|
39
|
+
<caption class="visually-hidden">{caption}</caption>
|
|
40
|
+
{/if}
|
|
41
|
+
|
|
42
|
+
<thead class="visually-hidden">
|
|
43
|
+
<tr>
|
|
44
|
+
<th scope="col" class="line-number">Line</th>
|
|
45
|
+
{#if !hideTimestamps}
|
|
46
|
+
<th scope="col" class="timestamp">Timestamp</th>
|
|
47
|
+
{/if}
|
|
48
|
+
<th scope="col" class="content">Content</th>
|
|
49
|
+
</tr>
|
|
50
|
+
</thead>
|
|
51
|
+
|
|
52
|
+
<tbody>
|
|
53
|
+
{@render children?.()}
|
|
54
|
+
</tbody>
|
|
55
|
+
</table>
|
|
56
|
+
|
|
57
|
+
<!-- @component
|
|
58
|
+
`Log` is used to display log entries in a structured table format.
|
|
59
|
+
|
|
60
|
+
## Example Usage
|
|
61
|
+
```svelte
|
|
62
|
+
<Log>
|
|
63
|
+
<Log.Line
|
|
64
|
+
line={1}
|
|
65
|
+
timestamp="2024-10-27T10:00:59.400Z"
|
|
66
|
+
>
|
|
67
|
+
Starting database connection...
|
|
68
|
+
</Log.Line>
|
|
69
|
+
<Log.Line
|
|
70
|
+
id="line-2"
|
|
71
|
+
timestamp="2024-10-27T10:05:12.300Z"
|
|
72
|
+
>
|
|
73
|
+
{#snippet line()}
|
|
74
|
+
<Link href="#line-2" soft>2</Link>
|
|
75
|
+
{/snippet}
|
|
76
|
+
Database connection failed: Connection timed out
|
|
77
|
+
</Log.Line>
|
|
78
|
+
</Log>
|
|
79
|
+
```
|
|
80
|
+
-->
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { LogProps } from "./types.js";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/**
|
|
4
|
+
* `Log` is used to display log entries in a structured table format.
|
|
5
|
+
*
|
|
6
|
+
* ## Example Usage
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <Log>
|
|
9
|
+
* <Log.Line
|
|
10
|
+
* line={1}
|
|
11
|
+
* timestamp="2024-10-27T10:00:59.400Z"
|
|
12
|
+
* >
|
|
13
|
+
* Starting database connection...
|
|
14
|
+
* </Log.Line>
|
|
15
|
+
* <Log.Line
|
|
16
|
+
* id="line-2"
|
|
17
|
+
* timestamp="2024-10-27T10:05:12.300Z"
|
|
18
|
+
* >
|
|
19
|
+
* {#snippet line()}
|
|
20
|
+
* <Link href="#line-2" soft>2</Link>
|
|
21
|
+
* {/snippet}
|
|
22
|
+
* Database connection failed: Connection timed out
|
|
23
|
+
* </Log.Line>
|
|
24
|
+
* </Log>
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
declare const Log: import("svelte").Component<LogProps, {}, "">;
|
|
28
|
+
type Log = ReturnType<typeof Log>;
|
|
29
|
+
export default Log;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.10.0-experimental.5 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { getLogContext } from "../../context.js";
|
|
5
|
+
import type { LineProps } from "./types.js";
|
|
6
|
+
import "./styles.css";
|
|
7
|
+
|
|
8
|
+
const componentCssClassName = "ds log-line";
|
|
9
|
+
|
|
10
|
+
let {
|
|
11
|
+
class: className,
|
|
12
|
+
line,
|
|
13
|
+
timestamp,
|
|
14
|
+
children,
|
|
15
|
+
...rest
|
|
16
|
+
}: LineProps = $props();
|
|
17
|
+
|
|
18
|
+
const logContext = getLogContext();
|
|
19
|
+
</script>
|
|
20
|
+
|
|
21
|
+
<tr class={[componentCssClassName, className]} {...rest}>
|
|
22
|
+
<th class="line-number" scope="row">
|
|
23
|
+
{#if typeof line === "number"}
|
|
24
|
+
{line}
|
|
25
|
+
{:else}
|
|
26
|
+
{@render line()}
|
|
27
|
+
{/if}
|
|
28
|
+
</th>
|
|
29
|
+
{#if !logContext.hideTimestamps}
|
|
30
|
+
<!-- If timestamps are hidden globally, don't render the timestamp column at all -->
|
|
31
|
+
<td class="timestamp">
|
|
32
|
+
<!-- If only this particular line doesn't have a timestamp, render the cell, but leave it empty -->
|
|
33
|
+
{#if timestamp !== undefined}
|
|
34
|
+
{@const timestampDate = new Date(timestamp)}
|
|
35
|
+
<time datetime={timestampDate.toISOString()}>
|
|
36
|
+
{logContext.timestampFormatter.format(timestampDate)}
|
|
37
|
+
</time>
|
|
38
|
+
{/if}
|
|
39
|
+
</td>
|
|
40
|
+
{/if}
|
|
41
|
+
<td class={["content", { wrap: logContext.wrapLines }]}
|
|
42
|
+
>{@render children()}</td
|
|
43
|
+
>
|
|
44
|
+
</tr>
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.ds.log-line {
|
|
2
|
+
vertical-align: top;
|
|
3
|
+
display: grid;
|
|
4
|
+
grid-column: 1 / -1;
|
|
5
|
+
grid-template-columns: subgrid;
|
|
6
|
+
font: var(--lp-typography-code-s);
|
|
7
|
+
color: var(--lp-color-text-default);
|
|
8
|
+
|
|
9
|
+
--log-line-background-color: var(--lp-color-background-alt);
|
|
10
|
+
--log-line-target-highlight-color: var(--lp-color-background-active);
|
|
11
|
+
--log-line-target-highlight-time: 5s;
|
|
12
|
+
|
|
13
|
+
> td,
|
|
14
|
+
> th {
|
|
15
|
+
padding-block: var(--lp-dimension-spacing-block-xxxs);
|
|
16
|
+
font-weight: var(--lp-typography-weight-regular);
|
|
17
|
+
background-color: var(--log-line-background-color);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:target {
|
|
21
|
+
> td,
|
|
22
|
+
> th {
|
|
23
|
+
animation:
|
|
24
|
+
target-highlight-hold var(--log-line-target-highlight-time) step-end
|
|
25
|
+
forwards,
|
|
26
|
+
target-highlight-fade var(--lp-transition-duration-sleepy) ease-out
|
|
27
|
+
var(--log-line-target-highlight-time) forwards;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
> .line-number {
|
|
32
|
+
grid-column: line-number;
|
|
33
|
+
text-align: right;
|
|
34
|
+
color: var(--lp-color-text-muted);
|
|
35
|
+
position: sticky;
|
|
36
|
+
left: 0;
|
|
37
|
+
padding-inline-start: var(--log-padding-inline);
|
|
38
|
+
padding-inline-end: var(--lp-dimension-spacing-inline-s);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
> .timestamp {
|
|
42
|
+
grid-column: timestamp;
|
|
43
|
+
white-space: nowrap;
|
|
44
|
+
|
|
45
|
+
padding-inline-end: var(--lp-dimension-spacing-inline-m);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
> .content {
|
|
49
|
+
grid-column: content;
|
|
50
|
+
white-space: pre;
|
|
51
|
+
|
|
52
|
+
&.wrap {
|
|
53
|
+
white-space: pre-wrap;
|
|
54
|
+
word-break: break-word;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* TODO: Implement level-based styling when designs ready */
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@keyframes target-highlight-hold {
|
|
62
|
+
from,
|
|
63
|
+
to {
|
|
64
|
+
background-color: var(--log-line-target-highlight-color);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@keyframes target-highlight-fade {
|
|
69
|
+
from {
|
|
70
|
+
background-color: var(--log-line-target-highlight-color);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
to {
|
|
74
|
+
background-color: var(--log-line-background-color);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { SvelteHTMLElements } from "svelte/elements";
|
|
3
|
+
type BaseProps = SvelteHTMLElements["tr"];
|
|
4
|
+
export interface LineProps extends BaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* The line number of the log entry.
|
|
7
|
+
*/
|
|
8
|
+
line: number | Snippet<[]>;
|
|
9
|
+
/**
|
|
10
|
+
* The timestamp of the log entry.
|
|
11
|
+
*/
|
|
12
|
+
timestamp?: Date | string | number;
|
|
13
|
+
/**
|
|
14
|
+
* The message content of the log entry.
|
|
15
|
+
*/
|
|
16
|
+
children: Snippet<[]>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Line/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Line/index.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Line } from "./common/index.js";
|
|
2
|
+
import { default as LogRoot } from "./Log.svelte";
|
|
3
|
+
declare const Log: typeof LogRoot & {
|
|
4
|
+
/**
|
|
5
|
+
* The Log Line component for individual log entries.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```svelte
|
|
9
|
+
* <Log>
|
|
10
|
+
* <Log.Line
|
|
11
|
+
* line={1}
|
|
12
|
+
* timestamp={new Date()}
|
|
13
|
+
* >
|
|
14
|
+
* Application started successfully.
|
|
15
|
+
* </Log.Line>
|
|
16
|
+
* </Log>
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
Line: typeof Line;
|
|
20
|
+
};
|
|
21
|
+
export type { LineProps as LogLineProps } from "./common/index.js";
|
|
22
|
+
export type { LogProps, TimeZone as LogTimeZone } from "./types.js";
|
|
23
|
+
export { Log };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.ds.log {
|
|
2
|
+
display: block;
|
|
3
|
+
contain: inline-size layout paint;
|
|
4
|
+
overflow: auto;
|
|
5
|
+
|
|
6
|
+
--log-padding-inline: var(--lp-dimension-spacing-inline-m);
|
|
7
|
+
|
|
8
|
+
background-color: var(--lp-color-background-alt);
|
|
9
|
+
padding-inline-end: var(--log-padding-inline);
|
|
10
|
+
padding-block-end: var(--lp-dimension-spacing-block-xxxl);
|
|
11
|
+
|
|
12
|
+
tbody {
|
|
13
|
+
display: grid;
|
|
14
|
+
min-width: fit-content;
|
|
15
|
+
grid-template-columns: [line-number-start] auto [line-number-end
|
|
16
|
+
timestamp-start] max-content [timestamp-end content-start] 1fr [content-end];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { SvelteHTMLElements } from "svelte/elements";
|
|
2
|
+
type CommonLogProps = SvelteHTMLElements["table"] & {
|
|
3
|
+
/**
|
|
4
|
+
* If true, timestamps won't be shown in log lines.
|
|
5
|
+
*
|
|
6
|
+
* @default false
|
|
7
|
+
*/
|
|
8
|
+
hideTimestamps?: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* If true, long lines will wrap onto multiple lines.
|
|
11
|
+
*
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
wrapLines?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* An optional caption for the log table to provide additional context for assistive technologies. Not visually displayed.
|
|
17
|
+
*/
|
|
18
|
+
caption?: string;
|
|
19
|
+
};
|
|
20
|
+
interface DefaultFormatterLogProps extends CommonLogProps {
|
|
21
|
+
/**
|
|
22
|
+
* Allows displaying timestamps in UTC, runtime local time, or an explicit timezone.
|
|
23
|
+
*
|
|
24
|
+
* Uses `YYYY-MM-DD HH:mm:ss.SSS` format for all timezones.
|
|
25
|
+
*
|
|
26
|
+
* In SSR, `local` resolves to the server runtime timezone and may differ from the browser timezone during hydration.
|
|
27
|
+
* For deterministic SSR output in a user timezone, pass an explicit timezone (for example `Europe/Warsaw`).
|
|
28
|
+
* Invalid timezones will fall back to UTC.
|
|
29
|
+
*
|
|
30
|
+
* @default "UTC"
|
|
31
|
+
*
|
|
32
|
+
* Has no effect if `timestampFormatter` is provided.
|
|
33
|
+
*/
|
|
34
|
+
timeZone?: TimeZone;
|
|
35
|
+
timestampFormatter?: never;
|
|
36
|
+
}
|
|
37
|
+
interface CustomFormatterLogProps extends CommonLogProps {
|
|
38
|
+
/**
|
|
39
|
+
* A custom timestamp formatter. If provided, this will be used instead of the default timestamp formatting.
|
|
40
|
+
*
|
|
41
|
+
* `timeZone` prop is ignored when using a custom formatter, as it's assumed that the custom formatter will handle timezones internally if needed.
|
|
42
|
+
*/
|
|
43
|
+
timestampFormatter: Formatter;
|
|
44
|
+
timeZone?: never;
|
|
45
|
+
}
|
|
46
|
+
export type LogProps = DefaultFormatterLogProps | CustomFormatterLogProps;
|
|
47
|
+
export type LogContext = {
|
|
48
|
+
hideTimestamps: boolean;
|
|
49
|
+
wrapLines: boolean;
|
|
50
|
+
timestampFormatter: Formatter;
|
|
51
|
+
};
|
|
52
|
+
type ExplicitTimeZone = Exclude<Intl.DateTimeFormatOptions["timeZone"], undefined>;
|
|
53
|
+
export type TimeZone = "UTC" | "local" | ({} & ExplicitTimeZone);
|
|
54
|
+
type Formatter = {
|
|
55
|
+
format: (date: Date) => string;
|
|
56
|
+
};
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { TimeZone } from "../types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a default timestamp formatter that updates when the timezone changes. The formatter formats dates as `YYYY-MM-DD HH:mm:ss.SSS` in UTC, runtime local time, or an explicit timezone.
|
|
4
|
+
*
|
|
5
|
+
* @param getTimeZone A function that returns the current timezone.
|
|
6
|
+
* @returns An object with a reactive `format` function that formats dates according to the current timezone.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useDefaultTimestampFormatter(getTimeZone: () => TimeZone): {
|
|
9
|
+
format: (date: Date) => string;
|
|
10
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
const dateTimeFormatOptions = {
|
|
2
|
+
year: "numeric",
|
|
3
|
+
month: "2-digit",
|
|
4
|
+
day: "2-digit",
|
|
5
|
+
hour: "2-digit",
|
|
6
|
+
minute: "2-digit",
|
|
7
|
+
second: "2-digit",
|
|
8
|
+
fractionalSecondDigits: 3,
|
|
9
|
+
hour12: false,
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Creates a default timestamp formatter that updates when the timezone changes. The formatter formats dates as `YYYY-MM-DD HH:mm:ss.SSS` in UTC, runtime local time, or an explicit timezone.
|
|
13
|
+
*
|
|
14
|
+
* @param getTimeZone A function that returns the current timezone.
|
|
15
|
+
* @returns An object with a reactive `format` function that formats dates according to the current timezone.
|
|
16
|
+
*/
|
|
17
|
+
export function useDefaultTimestampFormatter(getTimeZone) {
|
|
18
|
+
const dateTimeFormat = $derived.by(() => {
|
|
19
|
+
const timeZone = getTimeZone();
|
|
20
|
+
try {
|
|
21
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
22
|
+
...dateTimeFormatOptions,
|
|
23
|
+
timeZone: timeZone === "local" ? undefined : timeZone,
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
if (error instanceof RangeError) {
|
|
28
|
+
console.warn(`Invalid timezone "${timeZone}" provided to Log component. Falling back to UTC.`);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return new Intl.DateTimeFormat("en-US", {
|
|
35
|
+
...dateTimeFormatOptions,
|
|
36
|
+
timeZone: "UTC",
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
const format = (date) => {
|
|
40
|
+
const parts = dateTimeFormat.formatToParts(date);
|
|
41
|
+
const partsObject = Object.fromEntries(parts.map((part) => [part.type, part.value]));
|
|
42
|
+
return `${partsObject.year}-${partsObject.month}-${partsObject.day} ${partsObject.hour}:${partsObject.minute}:${partsObject.second}.${partsObject.fractionalSecond}`;
|
|
43
|
+
};
|
|
44
|
+
return { format };
|
|
45
|
+
}
|
|
@@ -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;
|