@canonical/svelte-ds-app-launchpad 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/Welcome.mdx +3 -2
- package/dist/components/Breadcrumbs/Breadcrumbs.ssr.test.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.ssr.test.js +101 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.svelte +139 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.stories.svelte.d.ts +19 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.svelte +107 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.svelte.d.ts +27 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.svelte.test.d.ts +1 -0
- package/dist/components/Breadcrumbs/Breadcrumbs.svelte.test.js +298 -0
- package/dist/components/Breadcrumbs/__screenshots__/Breadcrumbs.svelte.test.ts/Breadcrumbs-component-accessibility-focus-management-allows-focusing-links-with-tab-key-1.png +0 -0
- package/dist/components/Breadcrumbs/__screenshots__/Breadcrumbs.svelte.test.ts/Breadcrumbs-component-accessibility-focus-management-allows-focusing-links-with-tab-key-when-segments-are-collapsed-1.png +0 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/CollapsedItems.svelte +43 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/CollapsedItems.svelte.d.ts +5 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/index.js +2 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/styles.css +70 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/types.d.ts +7 -0
- package/dist/components/Breadcrumbs/common/CollapsedItems/types.js +1 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/ExpandedItems.svelte +44 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/ExpandedItems.svelte.d.ts +5 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/index.js +2 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/styles.css +37 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/types.d.ts +14 -0
- package/dist/components/Breadcrumbs/common/ExpandedItems/types.js +1 -0
- package/dist/components/Breadcrumbs/common/common/Item/Item.svelte +26 -0
- package/dist/components/Breadcrumbs/common/common/Item/Item.svelte.d.ts +4 -0
- package/dist/components/Breadcrumbs/common/common/Item/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/common/common/Item/index.js +2 -0
- package/dist/components/Breadcrumbs/common/common/Item/types.d.ts +5 -0
- package/dist/components/Breadcrumbs/common/common/Item/types.js +1 -0
- package/dist/components/Breadcrumbs/common/common/index.d.ts +1 -0
- package/dist/components/Breadcrumbs/common/common/index.js +1 -0
- package/dist/components/Breadcrumbs/common/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/common/index.js +2 -0
- package/dist/components/Breadcrumbs/index.d.ts +2 -0
- package/dist/components/Breadcrumbs/index.js +2 -0
- package/dist/components/Breadcrumbs/styles.css +24 -0
- package/dist/components/Breadcrumbs/types.d.ts +28 -0
- package/dist/components/Breadcrumbs/types.js +2 -0
- package/dist/components/Button/Button.stories.svelte +3 -3
- package/dist/components/Button/Button.svelte +19 -19
- package/dist/components/Button/Button.svelte.test.js +7 -21
- package/dist/components/Button/common/Content/Content.svelte +10 -10
- package/dist/components/Button/common/Content/styles.css +53 -52
- package/dist/components/Button/types.d.ts +1 -1
- package/dist/components/Checkbox/Checkbox.svelte.test.js +0 -1
- package/dist/components/Checkbox/__screenshots__/Checkbox.svelte.test.ts/Checkbox-component-Checked-state-toggles-on-click-1.png +0 -0
- package/dist/components/Checkbox/__screenshots__/Checkbox.svelte.test.ts/Checkbox-component-Events-emits-change-event-on-click-1.png +0 -0
- package/dist/components/Checkbox/styles.css +2 -2
- package/dist/components/Chip/Chip.stories.svelte +3 -2
- package/dist/components/Chip/Chip.svelte.test.js +20 -4
- package/dist/components/Chip/__screenshots__/Chip.svelte.test.ts/Chip-component-Initial-Rendering-should-apply-custom-class-and-modifiers-1.png +0 -0
- package/dist/components/Chip/__screenshots__/Chip.svelte.test.ts/Chip-component-Initial-Rendering-should-not-render-a-button-when-dismiss-is-provided-1.png +0 -0
- package/dist/components/Chip/__screenshots__/Chip.svelte.test.ts/Chip-component-Initial-Rendering-should-not-render-a-button-when-readonly-is-provided-1.png +0 -0
- package/dist/components/DescriptionList/DescriptionList.ssr.test.d.ts +1 -0
- package/dist/components/DescriptionList/DescriptionList.ssr.test.js +50 -0
- package/dist/components/DescriptionList/DescriptionList.stories.svelte +39 -0
- package/dist/components/DescriptionList/DescriptionList.stories.svelte.d.ts +19 -0
- package/dist/components/DescriptionList/DescriptionList.svelte +43 -0
- package/dist/components/DescriptionList/DescriptionList.svelte.d.ts +18 -0
- package/dist/components/DescriptionList/DescriptionList.svelte.test.d.ts +1 -0
- package/dist/components/DescriptionList/DescriptionList.svelte.test.js +45 -0
- package/dist/components/DescriptionList/common/Item/Item.ssr.test.d.ts +1 -0
- package/dist/components/DescriptionList/common/Item/Item.ssr.test.js +66 -0
- package/dist/components/DescriptionList/common/Item/Item.stories.svelte +34 -0
- package/dist/components/DescriptionList/common/Item/Item.stories.svelte.d.ts +19 -0
- package/dist/components/DescriptionList/common/Item/Item.svelte +21 -0
- package/dist/components/DescriptionList/common/Item/Item.svelte.d.ts +5 -0
- package/dist/components/DescriptionList/common/Item/Item.svelte.test.d.ts +1 -0
- package/dist/components/DescriptionList/common/Item/Item.svelte.test.js +62 -0
- package/dist/components/DescriptionList/common/Item/index.d.ts +2 -0
- package/dist/components/DescriptionList/common/Item/index.js +3 -0
- package/dist/components/DescriptionList/common/Item/styles.css +64 -0
- package/dist/components/DescriptionList/common/Item/types.d.ts +14 -0
- package/dist/components/DescriptionList/common/Item/types.js +2 -0
- package/dist/components/DescriptionList/common/index.d.ts +1 -0
- package/dist/components/DescriptionList/common/index.js +1 -0
- package/dist/components/DescriptionList/context.d.ts +2 -0
- package/dist/components/DescriptionList/context.js +2 -0
- package/dist/components/DescriptionList/index.d.ts +17 -0
- package/dist/components/DescriptionList/index.js +6 -0
- package/dist/components/DescriptionList/styles.css +29 -0
- package/dist/components/DescriptionList/types.d.ts +14 -0
- package/dist/components/DescriptionList/types.js +2 -0
- package/dist/components/Link/Link.ssr.test.d.ts +1 -0
- package/dist/components/Link/Link.ssr.test.js +59 -0
- package/dist/components/Link/Link.stories.svelte +18 -0
- package/dist/components/Link/Link.stories.svelte.d.ts +19 -0
- package/dist/components/Link/Link.svelte +25 -0
- package/dist/components/Link/Link.svelte.d.ts +15 -0
- package/dist/components/Link/Link.svelte.test.d.ts +1 -0
- package/dist/components/Link/Link.svelte.test.js +56 -0
- package/dist/components/Link/index.d.ts +2 -0
- package/dist/components/Link/index.js +2 -0
- package/dist/components/Link/styles.css +19 -0
- package/dist/components/Link/types.d.ts +7 -0
- package/dist/components/Link/types.js +2 -0
- package/dist/components/NumberInput/NumberInput.svelte +11 -11
- package/dist/components/Popover/Popover.ssr.test.d.ts +1 -0
- package/dist/components/Popover/Popover.ssr.test.js +70 -0
- package/dist/components/Popover/Popover.stories.svelte +170 -0
- package/dist/components/Popover/Popover.stories.svelte.d.ts +4 -0
- package/dist/components/Popover/Popover.svelte +103 -0
- package/dist/components/Popover/Popover.svelte.d.ts +36 -0
- package/dist/components/Popover/Popover.svelte.test.d.ts +1 -0
- package/dist/components/Popover/Popover.svelte.test.js +137 -0
- package/dist/components/Popover/index.d.ts +2 -0
- package/dist/components/Popover/index.js +2 -0
- package/dist/components/Popover/styles.css +7 -0
- package/dist/components/Popover/test.fixtures.svelte +25 -0
- package/dist/components/Popover/test.fixtures.svelte.d.ts +26 -0
- package/dist/components/Popover/types.d.ts +58 -0
- package/dist/components/Popover/types.js +2 -0
- package/dist/components/Radio/Radio.svelte.test.js +0 -1
- package/dist/components/Radio/__screenshots__/Radio.svelte.test.ts/Radio-component-Checked-state-can-be-checked-by-on-click-1.png +0 -0
- package/dist/components/Radio/__screenshots__/Radio.svelte.test.ts/Radio-component-Events-emits-change-event-on-click-1.png +0 -0
- package/dist/components/Spinner/Spinner.stories.svelte +7 -7
- package/dist/components/Spinner/Spinner.svelte +5 -5
- package/dist/components/Spinner/Spinner.svelte.test.js +2 -6
- package/dist/components/Spinner/styles.css +9 -9
- package/dist/components/Switch/Switch.ssr.test.js +0 -1
- package/dist/components/Switch/Switch.svelte.test.js +0 -1
- package/dist/components/Switch/__screenshots__/Switch.svelte.test.ts/Switch-component-Accessibility-can-be-toggled-with-space-key-1.png +0 -0
- package/dist/components/Switch/__screenshots__/Switch.svelte.test.ts/Switch-component-Events-emits-change-event-on-click-1.png +0 -0
- package/dist/components/Switch/__screenshots__/Switch.svelte.test.ts/Switch-component-Switch-state-can-be-disabled-1.png +0 -0
- package/dist/components/Switch/__screenshots__/Switch.svelte.test.ts/Switch-component-Switch-state-toggles-checked-state-on-click-1.png +0 -0
- package/dist/components/TextInput/TextInput.ssr.test.js +6 -1
- package/dist/components/TextInput/TextInput.svelte +11 -11
- package/dist/components/TextInput/TextInput.svelte.test.js +7 -1
- package/dist/components/Textarea/Textarea.stories.svelte +26 -26
- package/dist/components/Textarea/Textarea.svelte +21 -21
- package/dist/components/Textarea/utils/__screenshots__/calculateDynamicRows.svelte.test.ts/Textarea---calculateDynamicRows-Swapped-min-max-swaps-min-and-max-when-max-is-smaller-than-min-1.png +0 -0
- package/dist/components/common/ButtonPrimitive/ButtonPrimitive.svelte.test.js +1 -3
- package/dist/components/common/InputPrimitive/InputPrimitive.ssr.test.js +6 -1
- package/dist/components/common/InputPrimitive/InputPrimitive.svelte.test.js +7 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +4 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/modifier-families/styles/density.css +6 -2
- package/dist/styles/index.css +1 -4
- package/dist/test-utils.d.ts +6 -0
- package/dist/test-utils.js +18 -0
- package/dist/usePositionArea.svelte.d.ts +57 -0
- package/dist/usePositionArea.svelte.js +145 -0
- package/package.json +18 -18
- package/LICENSE +0 -166
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* @canonical/generator-ds 0.17.1 */
|
|
2
|
+
import { render } from "@canonical/svelte-ssr-test";
|
|
3
|
+
import { createRawSnippet } from "svelte";
|
|
4
|
+
import { describe, expect, it, vi } from "vitest";
|
|
5
|
+
import Component from "./Item.svelte";
|
|
6
|
+
vi.mock("../../context.js", () => {
|
|
7
|
+
return {
|
|
8
|
+
getDescriptionListContext: () => ({
|
|
9
|
+
layout: "auto",
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
describe("Item SSR", () => {
|
|
14
|
+
const baseProps = {
|
|
15
|
+
children: createRawSnippet(() => ({
|
|
16
|
+
render: () => `<span>Description</span>`,
|
|
17
|
+
})),
|
|
18
|
+
name: "Term",
|
|
19
|
+
"data-testid": "description-list-item",
|
|
20
|
+
};
|
|
21
|
+
describe("basics", () => {
|
|
22
|
+
it("doesn't throw", () => {
|
|
23
|
+
expect(() => {
|
|
24
|
+
render(Component, { props: { ...baseProps } });
|
|
25
|
+
}).not.toThrow();
|
|
26
|
+
});
|
|
27
|
+
it("renders", () => {
|
|
28
|
+
const page = render(Component, { props: { ...baseProps } });
|
|
29
|
+
expect(componentLocator(page)).toBeInstanceOf(page.window.HTMLDivElement);
|
|
30
|
+
expect(termLocator(page).textContent).toBe("Term");
|
|
31
|
+
expect(descriptionLocator(page).textContent).toBe("Description");
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
describe("attributes", () => {
|
|
35
|
+
it.each([
|
|
36
|
+
["id", "test-id"],
|
|
37
|
+
["aria-label", "test-aria-label"],
|
|
38
|
+
])("applies %s", (attribute, expected) => {
|
|
39
|
+
const page = render(Component, {
|
|
40
|
+
props: { ...baseProps, [attribute]: expected },
|
|
41
|
+
});
|
|
42
|
+
expect(componentLocator(page).getAttribute(attribute)).toBe(expected);
|
|
43
|
+
});
|
|
44
|
+
it("applies classes", () => {
|
|
45
|
+
const page = render(Component, {
|
|
46
|
+
props: { class: "test-class", ...baseProps },
|
|
47
|
+
});
|
|
48
|
+
expect(componentLocator(page).classList).toContain("test-class");
|
|
49
|
+
});
|
|
50
|
+
it("applies style", () => {
|
|
51
|
+
const page = render(Component, {
|
|
52
|
+
props: { style: "color: orange;", ...baseProps },
|
|
53
|
+
});
|
|
54
|
+
expect(componentLocator(page).style.color).toBe("orange");
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
function componentLocator(page) {
|
|
59
|
+
return page.getByTestId("description-list-item");
|
|
60
|
+
}
|
|
61
|
+
function termLocator(page) {
|
|
62
|
+
return page.getByRole("term");
|
|
63
|
+
}
|
|
64
|
+
function descriptionLocator(page) {
|
|
65
|
+
return page.getByRole("definition");
|
|
66
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
3
|
+
import { setDescriptionListContext } from "../../context.js";
|
|
4
|
+
import { DescriptionList } from "../../index.js";
|
|
5
|
+
import Item from "./Item.svelte";
|
|
6
|
+
|
|
7
|
+
const { Story } = defineMeta({
|
|
8
|
+
title: "Components/DescriptionList/Item",
|
|
9
|
+
tags: ["autodocs"],
|
|
10
|
+
component: Item,
|
|
11
|
+
args: {
|
|
12
|
+
name: "Example term",
|
|
13
|
+
},
|
|
14
|
+
argTypes: {
|
|
15
|
+
children: {
|
|
16
|
+
control: { disable: true },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts">
|
|
23
|
+
setDescriptionListContext({
|
|
24
|
+
layout: "auto",
|
|
25
|
+
});
|
|
26
|
+
</script>
|
|
27
|
+
|
|
28
|
+
<Story name="Default">
|
|
29
|
+
{#snippet template({ children: _, ...args })}
|
|
30
|
+
<DescriptionList>
|
|
31
|
+
<DescriptionList.Item {...args}>Example description</DescriptionList.Item>
|
|
32
|
+
</DescriptionList>
|
|
33
|
+
{/snippet}
|
|
34
|
+
</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Item from "./Item.svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Item: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Item = InstanceType<typeof Item>;
|
|
19
|
+
export default Item;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.17.1 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import { getDescriptionListContext } from "../../context.js";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
import type { ItemProps } from "./types.js";
|
|
7
|
+
|
|
8
|
+
const componentCssClassName = "ds description-list-item";
|
|
9
|
+
|
|
10
|
+
let { class: className, name, children, ...rest }: ItemProps = $props();
|
|
11
|
+
|
|
12
|
+
const descriptionListContext = getDescriptionListContext();
|
|
13
|
+
</script>
|
|
14
|
+
|
|
15
|
+
<div
|
|
16
|
+
class={[componentCssClassName, className, descriptionListContext.layout]}
|
|
17
|
+
{...rest}
|
|
18
|
+
>
|
|
19
|
+
<dt>{name}</dt>
|
|
20
|
+
<dd>{@render children()}</dd>
|
|
21
|
+
</div>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/* @canonical/generator-ds 0.17.1 */
|
|
2
|
+
import { createRawSnippet } from "svelte";
|
|
3
|
+
import { describe, expect, it, vi } from "vitest";
|
|
4
|
+
import { render } from "vitest-browser-svelte";
|
|
5
|
+
import Component from "./Item.svelte";
|
|
6
|
+
vi.mock("../../context.js", () => {
|
|
7
|
+
return {
|
|
8
|
+
getDescriptionListContext: () => ({
|
|
9
|
+
layout: "auto",
|
|
10
|
+
}),
|
|
11
|
+
};
|
|
12
|
+
});
|
|
13
|
+
describe("Item component", () => {
|
|
14
|
+
const baseProps = {
|
|
15
|
+
children: createRawSnippet(() => ({
|
|
16
|
+
render: () => `<span>Description</span>`,
|
|
17
|
+
})),
|
|
18
|
+
name: "Term",
|
|
19
|
+
"data-testid": "description-list-item",
|
|
20
|
+
};
|
|
21
|
+
it("renders", async () => {
|
|
22
|
+
const page = render(Component, { ...baseProps });
|
|
23
|
+
await expect.element(componentLocator(page)).toBeInTheDocument();
|
|
24
|
+
await expect.element(termLocator(page)).toHaveTextContent("Term");
|
|
25
|
+
await expect
|
|
26
|
+
.element(descriptionLocator(page))
|
|
27
|
+
.toHaveTextContent("Description");
|
|
28
|
+
});
|
|
29
|
+
describe("attributes", () => {
|
|
30
|
+
it.each([
|
|
31
|
+
["id", "test-id"],
|
|
32
|
+
["aria-label", "test-aria-label"],
|
|
33
|
+
])("applies %s", async (attribute, expected) => {
|
|
34
|
+
const page = render(Component, { ...baseProps, [attribute]: expected });
|
|
35
|
+
await expect
|
|
36
|
+
.element(componentLocator(page))
|
|
37
|
+
.toHaveAttribute(attribute, expected);
|
|
38
|
+
});
|
|
39
|
+
it("applies classes", async () => {
|
|
40
|
+
const page = render(Component, { ...baseProps, class: "test-class" });
|
|
41
|
+
await expect.element(componentLocator(page)).toHaveClass("test-class");
|
|
42
|
+
});
|
|
43
|
+
it("applies style", async () => {
|
|
44
|
+
const page = render(Component, {
|
|
45
|
+
...baseProps,
|
|
46
|
+
style: "color: orange;",
|
|
47
|
+
});
|
|
48
|
+
await expect
|
|
49
|
+
.element(componentLocator(page))
|
|
50
|
+
.toHaveStyle({ color: "orange" });
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
function componentLocator(page) {
|
|
55
|
+
return page.getByTestId("description-list-item");
|
|
56
|
+
}
|
|
57
|
+
function termLocator(page) {
|
|
58
|
+
return page.getByRole("term");
|
|
59
|
+
}
|
|
60
|
+
function descriptionLocator(page) {
|
|
61
|
+
return page.getByRole("definition");
|
|
62
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
.ds.description-list-item {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--lp-dimension-spacing-block-xs);
|
|
5
|
+
|
|
6
|
+
dt {
|
|
7
|
+
order: 1;
|
|
8
|
+
font: var(--lp-typography-paragraph-s-strong);
|
|
9
|
+
color: var(--lp-color-text-muted);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
dd {
|
|
13
|
+
order: 3;
|
|
14
|
+
font: var(--lp-typography-paragraph-s);
|
|
15
|
+
color: var(--lp-color-text-default);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/* Horizontal line for list layout */
|
|
19
|
+
&::before {
|
|
20
|
+
content: "";
|
|
21
|
+
order: 2;
|
|
22
|
+
height: 1px;
|
|
23
|
+
flex-grow: 1;
|
|
24
|
+
background: repeating-linear-gradient(
|
|
25
|
+
to right,
|
|
26
|
+
var(--lp-color-border-low-contrast) 0px 2px,
|
|
27
|
+
transparent 2px 4px
|
|
28
|
+
);
|
|
29
|
+
flex-basis: 10%;
|
|
30
|
+
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
&.list {
|
|
35
|
+
flex-direction: row;
|
|
36
|
+
align-items: baseline;
|
|
37
|
+
gap: var(--lp-dimension-spacing-inline-xs);
|
|
38
|
+
|
|
39
|
+
&::before {
|
|
40
|
+
display: block;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dd {
|
|
44
|
+
text-align: end;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
&.auto {
|
|
49
|
+
/* Defined in DescriptionList.svelte */
|
|
50
|
+
@container description-list (width <= 573px) {
|
|
51
|
+
flex-direction: row;
|
|
52
|
+
align-items: baseline;
|
|
53
|
+
gap: var(--lp-dimension-spacing-inline-xs);
|
|
54
|
+
|
|
55
|
+
&::before {
|
|
56
|
+
display: block;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
dd {
|
|
60
|
+
text-align: end;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Snippet } from "svelte";
|
|
2
|
+
import type { SvelteHTMLElements } from "svelte/elements";
|
|
3
|
+
type BaseProps = SvelteHTMLElements["div"];
|
|
4
|
+
export interface ItemProps extends BaseProps {
|
|
5
|
+
/**
|
|
6
|
+
* Term/name of the item
|
|
7
|
+
*/
|
|
8
|
+
name: string;
|
|
9
|
+
/**
|
|
10
|
+
* Description/content of the item
|
|
11
|
+
*/
|
|
12
|
+
children: Snippet<[]>;
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Item/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Item/index.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Item } from "./common/index.js";
|
|
2
|
+
import { default as DescriptionListRoot } from "./DescriptionList.svelte";
|
|
3
|
+
declare const DescriptionList: typeof DescriptionListRoot & {
|
|
4
|
+
/**
|
|
5
|
+
* The `DescriptionList.Item` component represents an individual term and its corresponding description within a `DescriptionList`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```svelte
|
|
9
|
+
* <DescriptionList>
|
|
10
|
+
* <DescriptionList.Item term="ID">134</DescriptionList.Item>
|
|
11
|
+
* </DescriptionList>
|
|
12
|
+
*/
|
|
13
|
+
Item: typeof Item;
|
|
14
|
+
};
|
|
15
|
+
export type { ItemProps as DescriptionListItemProps } from "./common/index.js";
|
|
16
|
+
export type { DescriptionListProps } from "./types.js";
|
|
17
|
+
export { DescriptionList };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
.ds.description-list-container {
|
|
2
|
+
container: description-list / inline-size;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.ds.description-list {
|
|
6
|
+
display: grid;
|
|
7
|
+
row-gap: var(--lp-dimension-spacing-block-xs);
|
|
8
|
+
column-gap: var(--lp-dimension-spacing-inline-xs);
|
|
9
|
+
--min-width-description-list-item: 160px;
|
|
10
|
+
|
|
11
|
+
&.grid {
|
|
12
|
+
grid-template-columns: repeat(
|
|
13
|
+
auto-fit,
|
|
14
|
+
minmax(var(--min-width-description-list-item), 1fr)
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.auto {
|
|
19
|
+
/*
|
|
20
|
+
width > 621 - (2 * 24) = narrow breakpoint - (2 * padding) = 573px
|
|
21
|
+
*/
|
|
22
|
+
@container description-list (width > 573px) {
|
|
23
|
+
grid-template-columns: repeat(
|
|
24
|
+
auto-fit,
|
|
25
|
+
minmax(var(--min-width-description-list-item), 1fr)
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { SvelteHTMLElements } from "svelte/elements";
|
|
2
|
+
export type BaseProps = SvelteHTMLElements["dl"];
|
|
3
|
+
export interface DescriptionListProps extends BaseProps {
|
|
4
|
+
/**
|
|
5
|
+
* The layout of the list's items.
|
|
6
|
+
* @default "auto"
|
|
7
|
+
*/
|
|
8
|
+
layout?: Layout;
|
|
9
|
+
}
|
|
10
|
+
export interface DescriptionListContext {
|
|
11
|
+
layout: Layout;
|
|
12
|
+
}
|
|
13
|
+
type Layout = "list" | "grid" | "auto";
|
|
14
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Generated by @canonical/summon:component-svelte v0.1.0
|
|
2
|
+
import { render } from "@canonical/svelte-ssr-test";
|
|
3
|
+
import { createRawSnippet } from "svelte";
|
|
4
|
+
import { describe, expect, it } from "vitest";
|
|
5
|
+
import Component from "./Link.svelte";
|
|
6
|
+
describe("Link SSR", () => {
|
|
7
|
+
const baseProps = {
|
|
8
|
+
children: createRawSnippet(() => ({
|
|
9
|
+
render: () => `<span>Link</span>`,
|
|
10
|
+
})),
|
|
11
|
+
href: "https://ubuntu.com",
|
|
12
|
+
"data-testid": "link",
|
|
13
|
+
};
|
|
14
|
+
describe("basics", () => {
|
|
15
|
+
it("doesn't throw", () => {
|
|
16
|
+
expect(() => {
|
|
17
|
+
render(Component, { props: { ...baseProps } });
|
|
18
|
+
}).not.toThrow();
|
|
19
|
+
});
|
|
20
|
+
it("renders", () => {
|
|
21
|
+
const page = render(Component, { props: { ...baseProps } });
|
|
22
|
+
expect(componentLocator(page)).toBeInstanceOf(page.window.HTMLAnchorElement);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
describe("attributes", () => {
|
|
26
|
+
it.each([
|
|
27
|
+
["id", "test-id"],
|
|
28
|
+
["aria-label", "test-aria-label"],
|
|
29
|
+
])("applies %s", (attribute, expected) => {
|
|
30
|
+
const page = render(Component, {
|
|
31
|
+
props: { ...baseProps, [attribute]: expected },
|
|
32
|
+
});
|
|
33
|
+
expect(componentLocator(page).getAttribute(attribute)).toBe(expected);
|
|
34
|
+
});
|
|
35
|
+
it("applies classes", () => {
|
|
36
|
+
const page = render(Component, {
|
|
37
|
+
props: { ...baseProps, class: "test-class" },
|
|
38
|
+
});
|
|
39
|
+
expect(componentLocator(page).classList).toContain("test-class");
|
|
40
|
+
expect(componentLocator(page).classList).toContain("ds");
|
|
41
|
+
expect(componentLocator(page).classList).toContain("link");
|
|
42
|
+
});
|
|
43
|
+
it("applies soft class when soft is true", () => {
|
|
44
|
+
const page = render(Component, {
|
|
45
|
+
props: { ...baseProps, soft: true },
|
|
46
|
+
});
|
|
47
|
+
expect(componentLocator(page).classList).toContain("soft");
|
|
48
|
+
});
|
|
49
|
+
it("applies style", () => {
|
|
50
|
+
const page = render(Component, {
|
|
51
|
+
props: { ...baseProps, style: "color: orange;" },
|
|
52
|
+
});
|
|
53
|
+
expect(componentLocator(page).style.color).toBe("orange");
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
function componentLocator(page) {
|
|
58
|
+
return page.getByTestId("link");
|
|
59
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<script lang="ts" module>
|
|
2
|
+
// Generated by @canonical/summon:component-svelte v0.1.0
|
|
3
|
+
import { defineMeta } from "@storybook/addon-svelte-csf";
|
|
4
|
+
import Link from "./Link.svelte";
|
|
5
|
+
|
|
6
|
+
const { Story } = defineMeta({
|
|
7
|
+
title: "Components/Link",
|
|
8
|
+
tags: ["autodocs"],
|
|
9
|
+
component: Link,
|
|
10
|
+
args: {
|
|
11
|
+
href: "https://ubuntu.com",
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<Story name="Default">Link</Story>
|
|
17
|
+
|
|
18
|
+
<Story name="Soft" args={{ soft: true }}>Soft link</Story>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import Link from "./Link.svelte";
|
|
2
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
3
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
4
|
+
$$bindings?: Bindings;
|
|
5
|
+
} & Exports;
|
|
6
|
+
(internal: unknown, props: {
|
|
7
|
+
$$events?: Events;
|
|
8
|
+
$$slots?: Slots;
|
|
9
|
+
}): Exports & {
|
|
10
|
+
$set?: any;
|
|
11
|
+
$on?: any;
|
|
12
|
+
};
|
|
13
|
+
z_$$bindings?: Bindings;
|
|
14
|
+
}
|
|
15
|
+
declare const Link: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
16
|
+
[evt: string]: CustomEvent<any>;
|
|
17
|
+
}, {}, {}, string>;
|
|
18
|
+
type Link = InstanceType<typeof Link>;
|
|
19
|
+
export default Link;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<!-- Generated by @canonical/summon:component-svelte v0.1.0 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { LinkProps } from "./types";
|
|
5
|
+
import "./styles.css";
|
|
6
|
+
|
|
7
|
+
const componentCssClassName = "ds link";
|
|
8
|
+
|
|
9
|
+
let { class: className, children, soft, ...rest }: LinkProps = $props();
|
|
10
|
+
</script>
|
|
11
|
+
|
|
12
|
+
<a class={[componentCssClassName, className, { soft }]} {...rest}>
|
|
13
|
+
{@render children?.()}
|
|
14
|
+
</a>
|
|
15
|
+
|
|
16
|
+
<!-- @component
|
|
17
|
+
`Link` is a styled anchor element.
|
|
18
|
+
|
|
19
|
+
## Example Usage
|
|
20
|
+
```svelte
|
|
21
|
+
<Link href="https://ubuntu.com" target="_blank" rel="noopener">
|
|
22
|
+
Canonical
|
|
23
|
+
</Link>
|
|
24
|
+
```
|
|
25
|
+
-->
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LinkProps } from "./types";
|
|
2
|
+
import "./styles.css";
|
|
3
|
+
/**
|
|
4
|
+
* `Link` is a styled anchor element.
|
|
5
|
+
*
|
|
6
|
+
* ## Example Usage
|
|
7
|
+
* ```svelte
|
|
8
|
+
* <Link href="https://ubuntu.com" target="_blank" rel="noopener">
|
|
9
|
+
* Canonical
|
|
10
|
+
* </Link>
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
declare const Link: import("svelte").Component<LinkProps, {}, "">;
|
|
14
|
+
type Link = ReturnType<typeof Link>;
|
|
15
|
+
export default Link;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Generated by @canonical/summon:component-svelte v0.1.0
|
|
2
|
+
import { createRawSnippet } from "svelte";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import { render } from "vitest-browser-svelte";
|
|
5
|
+
import Component from "./Link.svelte";
|
|
6
|
+
describe("Link component", () => {
|
|
7
|
+
const baseProps = {
|
|
8
|
+
children: createRawSnippet(() => ({
|
|
9
|
+
render: () => `<span>Link</span>`,
|
|
10
|
+
})),
|
|
11
|
+
href: "https://ubuntu.com",
|
|
12
|
+
"data-testid": "link",
|
|
13
|
+
};
|
|
14
|
+
it("renders", async () => {
|
|
15
|
+
const page = render(Component, { ...baseProps });
|
|
16
|
+
await expect.element(componentLocator(page)).toBeInTheDocument();
|
|
17
|
+
await expect.element(page.getByText("Link")).toBeVisible();
|
|
18
|
+
});
|
|
19
|
+
describe("attributes", () => {
|
|
20
|
+
it.each([
|
|
21
|
+
["id", "test-id"],
|
|
22
|
+
["aria-label", "test-aria-label"],
|
|
23
|
+
])("applies %s", async (attribute, expected) => {
|
|
24
|
+
const page = render(Component, { ...baseProps, [attribute]: expected });
|
|
25
|
+
await expect
|
|
26
|
+
.element(componentLocator(page))
|
|
27
|
+
.toHaveAttribute(attribute, expected);
|
|
28
|
+
});
|
|
29
|
+
it("applies classes", async () => {
|
|
30
|
+
const page = render(Component, { ...baseProps, class: "test-class" });
|
|
31
|
+
await expect.element(componentLocator(page)).toHaveClass("test-class");
|
|
32
|
+
await expect.element(componentLocator(page)).toHaveClass("ds");
|
|
33
|
+
await expect.element(componentLocator(page)).toHaveClass("link");
|
|
34
|
+
});
|
|
35
|
+
it("inherits parent color when soft is true", async () => {
|
|
36
|
+
const parentColor = "rgb(255, 0, 0)";
|
|
37
|
+
document.body.style.color = parentColor;
|
|
38
|
+
const page = render(Component, { ...baseProps, soft: true });
|
|
39
|
+
await expect.element(componentLocator(page)).toHaveStyle({
|
|
40
|
+
color: parentColor,
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
it("applies style", async () => {
|
|
44
|
+
const page = render(Component, {
|
|
45
|
+
...baseProps,
|
|
46
|
+
style: "color: orange;",
|
|
47
|
+
});
|
|
48
|
+
await expect
|
|
49
|
+
.element(componentLocator(page))
|
|
50
|
+
.toHaveStyle({ color: "orange" });
|
|
51
|
+
});
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
function componentLocator(page) {
|
|
55
|
+
return page.getByTestId("link");
|
|
56
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/* Generated by @canonical/summon:component-svelte v0.1.0 */
|
|
2
|
+
|
|
3
|
+
.ds.link {
|
|
4
|
+
outline-offset: 0px;
|
|
5
|
+
text-decoration: none;
|
|
6
|
+
color: var(--lp-color-text-link-default);
|
|
7
|
+
|
|
8
|
+
&:not(.soft):visited {
|
|
9
|
+
color: var(--lp-color-text-link-visited);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
&:hover {
|
|
13
|
+
text-decoration: underline;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
&.soft {
|
|
17
|
+
color: inherit;
|
|
18
|
+
}
|
|
19
|
+
}
|