@canonical/svelte-ds-app-launchpad 0.11.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/README.md +44 -0
- package/dist/components/Example/Example.ssr.test.d.ts +1 -0
- package/dist/components/Example/Example.ssr.test.js +48 -0
- package/dist/components/Example/Example.svelte +53 -0
- package/dist/components/Example/Example.svelte.d.ts +12 -0
- package/dist/components/Example/Example.svelte.test.d.ts +1 -0
- package/dist/components/Example/Example.svelte.test.js +42 -0
- package/dist/components/Example/__screenshots__/Example.svelte.test.ts/Example-component-attributes-applies-aria-label-1.png +0 -0
- package/dist/components/Example/__screenshots__/Example.svelte.test.ts/Example-component-attributes-applies-classes-1.png +0 -0
- package/dist/components/Example/__screenshots__/Example.svelte.test.ts/Example-component-attributes-applies-id-1.png +0 -0
- package/dist/components/Example/__screenshots__/Example.svelte.test.ts/Example-component-attributes-applies-style-1.png +0 -0
- package/dist/components/Example/__screenshots__/Example.svelte.test.ts/Example-component-renders-1.png +0 -0
- package/dist/components/Example/index.d.ts +2 -0
- package/dist/components/Example/index.js +3 -0
- package/dist/components/Example/types.d.ts +5 -0
- package/dist/components/Example/types.js +2 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +7 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!-- Generated by package v0.1.0 -->
|
|
2
|
+
# @canonical/svelte-ds-app-launchpad
|
|
3
|
+
|
|
4
|
+
Launchpad-specific components for the Pragma design system. This package provides Svelte UI components for the Launchpad application.
|
|
5
|
+
|
|
6
|
+
## Installation
|
|
7
|
+
|
|
8
|
+
```bash
|
|
9
|
+
bun add @canonical/svelte-ds-app-launchpad
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Usage
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
<script lang="ts">
|
|
16
|
+
import { Example } from "@canonical/svelte-ds-app-launchpad";
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<Example />
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Development
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Run checks
|
|
26
|
+
bun run check
|
|
27
|
+
|
|
28
|
+
# Run tests
|
|
29
|
+
bun run test
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Testing
|
|
33
|
+
|
|
34
|
+
Tests use **Vitest browser mode**, which requires **Playwright**. This setup is currently **experimental in Pragma**.
|
|
35
|
+
|
|
36
|
+
One-time setup (install Playwright browsers):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
bunx playwright install
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## License
|
|
43
|
+
|
|
44
|
+
LGPL-3.0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/* @canonical/generator-ds 0.11.0 */
|
|
2
|
+
import { render } from "@canonical/svelte-ssr-test";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
import Component from "./Example.svelte";
|
|
5
|
+
describe("Example SSR", () => {
|
|
6
|
+
const baseProps = {
|
|
7
|
+
"data-testid": "example",
|
|
8
|
+
};
|
|
9
|
+
describe("basics", () => {
|
|
10
|
+
it("doesn't throw", () => {
|
|
11
|
+
expect(() => {
|
|
12
|
+
render(Component, { props: { ...baseProps } });
|
|
13
|
+
}).not.toThrow();
|
|
14
|
+
});
|
|
15
|
+
it("renders", () => {
|
|
16
|
+
const page = render(Component, { props: { ...baseProps } });
|
|
17
|
+
expect(componentLocator(page)).toBeInstanceOf(page.window.HTMLDivElement);
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
describe("attributes", () => {
|
|
21
|
+
it.each([
|
|
22
|
+
["id", "test-id"],
|
|
23
|
+
["aria-label", "test-aria-label"],
|
|
24
|
+
])("applies %s", (attribute, expected) => {
|
|
25
|
+
const page = render(Component, {
|
|
26
|
+
props: { ...baseProps, [attribute]: expected },
|
|
27
|
+
});
|
|
28
|
+
expect(componentLocator(page).getAttribute(attribute)).toBe(expected);
|
|
29
|
+
});
|
|
30
|
+
it("applies classes", () => {
|
|
31
|
+
const page = render(Component, {
|
|
32
|
+
props: { class: "test-class", ...baseProps },
|
|
33
|
+
});
|
|
34
|
+
expect(componentLocator(page).classList).toContain("test-class");
|
|
35
|
+
expect(componentLocator(page).classList).toContain("ds");
|
|
36
|
+
expect(componentLocator(page).classList).toContain("example");
|
|
37
|
+
});
|
|
38
|
+
it("applies style", () => {
|
|
39
|
+
const page = render(Component, {
|
|
40
|
+
props: { style: "color: orange;", ...baseProps },
|
|
41
|
+
});
|
|
42
|
+
expect(componentLocator(page).style.color).toBe("orange");
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
function componentLocator(page) {
|
|
47
|
+
return page.getByTestId("example");
|
|
48
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
<!-- @canonical/generator-ds 0.11.0 -->
|
|
2
|
+
|
|
3
|
+
<script lang="ts">
|
|
4
|
+
import type { ExampleProps } from "./types.js";
|
|
5
|
+
|
|
6
|
+
const componentCssClassName = "ds example";
|
|
7
|
+
|
|
8
|
+
const { class: className, ...rest }: ExampleProps = $props();
|
|
9
|
+
let count = $state(0);
|
|
10
|
+
|
|
11
|
+
function handleClick() {
|
|
12
|
+
count++;
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div class={[componentCssClassName, className]} {...rest}>
|
|
17
|
+
<button onclick={handleClick}>Click me</button>
|
|
18
|
+
<p>Count: {count}</p>
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
<!-- @component
|
|
22
|
+
`Example` A reusable UI component that displays a button and a count.
|
|
23
|
+
|
|
24
|
+
## Example Usage
|
|
25
|
+
```svelte
|
|
26
|
+
<Example class="custom-class" id="unique-id" />
|
|
27
|
+
```
|
|
28
|
+
-->
|
|
29
|
+
|
|
30
|
+
<style>
|
|
31
|
+
.ds.example {
|
|
32
|
+
display: flex;
|
|
33
|
+
flex-direction: column;
|
|
34
|
+
gap: 1rem;
|
|
35
|
+
> button {
|
|
36
|
+
border-radius: 8px;
|
|
37
|
+
border: 1px solid transparent;
|
|
38
|
+
padding: 0.6em 1.2em;
|
|
39
|
+
font-size: 1em;
|
|
40
|
+
font-weight: 500;
|
|
41
|
+
background-color: #1a1a1a;
|
|
42
|
+
color: #fff;
|
|
43
|
+
transition: border-color 0.25s;
|
|
44
|
+
&:hover {
|
|
45
|
+
border-color: #646cff;
|
|
46
|
+
}
|
|
47
|
+
&:focus,
|
|
48
|
+
&:focus-visible {
|
|
49
|
+
outline: 4px auto -webkit-focus-ring-color;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
</style>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ExampleProps } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* `Example` A reusable UI component that displays a button and a count.
|
|
4
|
+
*
|
|
5
|
+
* ## Example Usage
|
|
6
|
+
* ```svelte
|
|
7
|
+
* <Example class="custom-class" id="unique-id" />
|
|
8
|
+
* ```
|
|
9
|
+
*/
|
|
10
|
+
declare const Example: import("svelte").Component<ExampleProps, {}, "">;
|
|
11
|
+
type Example = ReturnType<typeof Example>;
|
|
12
|
+
export default Example;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { render } from "vitest-browser-svelte";
|
|
3
|
+
import Component from "./Example.svelte";
|
|
4
|
+
describe("Example component", () => {
|
|
5
|
+
const baseProps = {
|
|
6
|
+
"data-testid": "example",
|
|
7
|
+
};
|
|
8
|
+
it("renders", async () => {
|
|
9
|
+
const page = render(Component, { ...baseProps });
|
|
10
|
+
await expect.element(componentLocator(page)).toBeInTheDocument();
|
|
11
|
+
await expect.element(page.getByText("Click me")).toBeVisible();
|
|
12
|
+
});
|
|
13
|
+
describe("attributes", () => {
|
|
14
|
+
it.each([
|
|
15
|
+
["id", "test-id"],
|
|
16
|
+
["aria-label", "test-aria-label"],
|
|
17
|
+
])("applies %s", async (attribute, expected) => {
|
|
18
|
+
const page = render(Component, { ...baseProps, [attribute]: expected });
|
|
19
|
+
await expect
|
|
20
|
+
.element(componentLocator(page))
|
|
21
|
+
.toHaveAttribute(attribute, expected);
|
|
22
|
+
});
|
|
23
|
+
it("applies classes", async () => {
|
|
24
|
+
const page = render(Component, { ...baseProps, class: "test-class" });
|
|
25
|
+
await expect.element(componentLocator(page)).toHaveClass("test-class");
|
|
26
|
+
await expect.element(componentLocator(page)).toHaveClass("ds");
|
|
27
|
+
await expect.element(componentLocator(page)).toHaveClass("example");
|
|
28
|
+
});
|
|
29
|
+
it("applies style", async () => {
|
|
30
|
+
const page = render(Component, {
|
|
31
|
+
...baseProps,
|
|
32
|
+
style: "color: orange;",
|
|
33
|
+
});
|
|
34
|
+
await expect
|
|
35
|
+
.element(componentLocator(page))
|
|
36
|
+
.toHaveStyle({ color: "orange" });
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
function componentLocator(page) {
|
|
41
|
+
return page.getByTestId("example");
|
|
42
|
+
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Example/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./Example/index.js";
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@canonical/svelte-ds-app-launchpad",
|
|
3
|
+
"description": "Launchpad-specific components for the Pragma design system.",
|
|
4
|
+
"version": "0.11.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"module": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.js",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"svelte": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"author": {
|
|
19
|
+
"email": "webteam@canonical.com",
|
|
20
|
+
"name": "Canonical Webteam"
|
|
21
|
+
},
|
|
22
|
+
"repository": {
|
|
23
|
+
"type": "git",
|
|
24
|
+
"url": "https://github.com/canonical/pragma"
|
|
25
|
+
},
|
|
26
|
+
"license": "LGPL-3.0",
|
|
27
|
+
"bugs": {
|
|
28
|
+
"url": "https://github.com/canonical/pragma/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/canonical/pragma/tree/main/packages/svelte/ds-app-launchpad#readme",
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "svelte-package -o dist -i src/lib --tsconfig ./tsconfig.json",
|
|
33
|
+
"build:all": "bun run build",
|
|
34
|
+
"check": "bun run check:biome && bun run check:ts && bun run check:webarchitect",
|
|
35
|
+
"check:fix": "bun run check:biome:fix && bun run check:ts",
|
|
36
|
+
"check:biome": "biome check",
|
|
37
|
+
"check:biome:fix": "biome check --write",
|
|
38
|
+
"check:ts": "svelte-check --tsconfig ./tsconfig.json",
|
|
39
|
+
"check:webarchitect": "webarchitect package-svelte -v",
|
|
40
|
+
"test": "vitest --run --project=ssr",
|
|
41
|
+
"test:watch": "vitest",
|
|
42
|
+
"test:server": "vitest --run --project=server",
|
|
43
|
+
"test:client": "vitest --run --project=client",
|
|
44
|
+
"test:ssr": "vitest --run --project=ssr",
|
|
45
|
+
"test:client:chromium": "vitest --run --project=client --browser=chromium",
|
|
46
|
+
"test:client:firefox": "vitest --run --project=client --browser=firefox",
|
|
47
|
+
"test:client:webkit": "vitest --run --project=client --browser=webkit",
|
|
48
|
+
"test:watch:client": "bun run test:watch --project=client --browser.headless=false"
|
|
49
|
+
},
|
|
50
|
+
"devDependencies": {
|
|
51
|
+
"@biomejs/biome": "2.3.11",
|
|
52
|
+
"@canonical/biome-config-svelte": "^0.11.0",
|
|
53
|
+
"@canonical/svelte-ssr-test": "^0.11.0",
|
|
54
|
+
"@canonical/typescript-config-svelte": "^0.12.0-experimental.0",
|
|
55
|
+
"@sveltejs/package": "^2.5.7",
|
|
56
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.4",
|
|
57
|
+
"@vitest/browser": "^4.0.18",
|
|
58
|
+
"@vitest/browser-playwright": "^4.0.18",
|
|
59
|
+
"bun-types": "^1.0.0",
|
|
60
|
+
"playwright": "^1.58.0",
|
|
61
|
+
"svelte-check": "^4.3.5",
|
|
62
|
+
"typescript": "^5.9.3",
|
|
63
|
+
"vite": "^7.3.1",
|
|
64
|
+
"vitest": "^4.0.18",
|
|
65
|
+
"vitest-browser-svelte": "^2.0.2"
|
|
66
|
+
},
|
|
67
|
+
"dependencies": {},
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"svelte": "^5.47.1"
|
|
70
|
+
}
|
|
71
|
+
}
|