@dsn-starter-kit/components-web 1.0.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/LICENSE +21 -0
- package/README.md +120 -0
- package/dist/button/Button.d.ts +50 -0
- package/dist/button/Button.d.ts.map +1 -0
- package/dist/button/Button.js +247 -0
- package/dist/button/Button.js.map +1 -0
- package/dist/button/Button.test.d.ts +2 -0
- package/dist/button/Button.test.d.ts.map +1 -0
- package/dist/button/Button.test.js +299 -0
- package/dist/button/Button.test.js.map +1 -0
- package/dist/button/button-styles.generated.d.ts +2 -0
- package/dist/button/button-styles.generated.d.ts.map +1 -0
- package/dist/button/button-styles.generated.js +4 -0
- package/dist/button/button-styles.generated.js.map +1 -0
- package/dist/button/index.d.ts +3 -0
- package/dist/button/index.d.ts.map +1 -0
- package/dist/button/index.js +2 -0
- package/dist/button/index.js.map +1 -0
- package/dist/heading/Heading.d.ts +30 -0
- package/dist/heading/Heading.d.ts.map +1 -0
- package/dist/heading/Heading.js +79 -0
- package/dist/heading/Heading.js.map +1 -0
- package/dist/heading/Heading.test.d.ts +2 -0
- package/dist/heading/Heading.test.d.ts.map +1 -0
- package/dist/heading/Heading.test.js +157 -0
- package/dist/heading/Heading.test.js.map +1 -0
- package/dist/heading/heading-styles.generated.d.ts +2 -0
- package/dist/heading/heading-styles.generated.d.ts.map +1 -0
- package/dist/heading/heading-styles.generated.js +4 -0
- package/dist/heading/heading-styles.generated.js.map +1 -0
- package/dist/heading/index.d.ts +3 -0
- package/dist/heading/index.d.ts.map +1 -0
- package/dist/heading/index.js +2 -0
- package/dist/heading/index.js.map +1 -0
- package/dist/icon/Icon.d.ts +31 -0
- package/dist/icon/Icon.d.ts.map +1 -0
- package/dist/icon/Icon.js +110 -0
- package/dist/icon/Icon.js.map +1 -0
- package/dist/icon/Icon.test.d.ts +2 -0
- package/dist/icon/Icon.test.d.ts.map +1 -0
- package/dist/icon/Icon.test.js +193 -0
- package/dist/icon/Icon.test.js.map +1 -0
- package/dist/icon/icon-paths.generated.d.ts +2 -0
- package/dist/icon/icon-paths.generated.d.ts.map +1 -0
- package/dist/icon/icon-paths.generated.js +56 -0
- package/dist/icon/icon-paths.generated.js.map +1 -0
- package/dist/icon/icon-styles.generated.d.ts +2 -0
- package/dist/icon/icon-styles.generated.d.ts.map +1 -0
- package/dist/icon/icon-styles.generated.js +4 -0
- package/dist/icon/icon-styles.generated.js.map +1 -0
- package/dist/icon/index.d.ts +3 -0
- package/dist/icon/index.d.ts.map +1 -0
- package/dist/icon/index.js +2 -0
- package/dist/icon/index.js.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +71 -0
- package/dist/index.js.map +1 -0
- package/dist/link/Link.d.ts +52 -0
- package/dist/link/Link.d.ts.map +1 -0
- package/dist/link/Link.js +260 -0
- package/dist/link/Link.js.map +1 -0
- package/dist/link/Link.test.d.ts +2 -0
- package/dist/link/Link.test.d.ts.map +1 -0
- package/dist/link/Link.test.js +256 -0
- package/dist/link/Link.test.js.map +1 -0
- package/dist/link/index.d.ts +3 -0
- package/dist/link/index.d.ts.map +1 -0
- package/dist/link/index.js +2 -0
- package/dist/link/index.js.map +1 -0
- package/dist/link/link-styles.generated.d.ts +2 -0
- package/dist/link/link-styles.generated.d.ts.map +1 -0
- package/dist/link/link-styles.generated.js +4 -0
- package/dist/link/link-styles.generated.js.map +1 -0
- package/dist/ordered-list/OrderedList.d.ts +32 -0
- package/dist/ordered-list/OrderedList.d.ts.map +1 -0
- package/dist/ordered-list/OrderedList.js +72 -0
- package/dist/ordered-list/OrderedList.js.map +1 -0
- package/dist/ordered-list/OrderedList.test.d.ts +2 -0
- package/dist/ordered-list/OrderedList.test.d.ts.map +1 -0
- package/dist/ordered-list/OrderedList.test.js +82 -0
- package/dist/ordered-list/OrderedList.test.js.map +1 -0
- package/dist/ordered-list/index.d.ts +2 -0
- package/dist/ordered-list/index.d.ts.map +1 -0
- package/dist/ordered-list/index.js +2 -0
- package/dist/ordered-list/index.js.map +1 -0
- package/dist/ordered-list/ordered-list-styles.generated.d.ts +2 -0
- package/dist/ordered-list/ordered-list-styles.generated.d.ts.map +1 -0
- package/dist/ordered-list/ordered-list-styles.generated.js +4 -0
- package/dist/ordered-list/ordered-list-styles.generated.js.map +1 -0
- package/dist/paragraph/Paragraph.d.ts +26 -0
- package/dist/paragraph/Paragraph.d.ts.map +1 -0
- package/dist/paragraph/Paragraph.js +60 -0
- package/dist/paragraph/Paragraph.js.map +1 -0
- package/dist/paragraph/Paragraph.test.d.ts +2 -0
- package/dist/paragraph/Paragraph.test.d.ts.map +1 -0
- package/dist/paragraph/Paragraph.test.js +121 -0
- package/dist/paragraph/Paragraph.test.js.map +1 -0
- package/dist/paragraph/index.d.ts +3 -0
- package/dist/paragraph/index.d.ts.map +1 -0
- package/dist/paragraph/index.js +2 -0
- package/dist/paragraph/index.js.map +1 -0
- package/dist/paragraph/paragraph-styles.generated.d.ts +2 -0
- package/dist/paragraph/paragraph-styles.generated.d.ts.map +1 -0
- package/dist/paragraph/paragraph-styles.generated.js +4 -0
- package/dist/paragraph/paragraph-styles.generated.js.map +1 -0
- package/dist/unordered-list/UnorderedList.d.ts +22 -0
- package/dist/unordered-list/UnorderedList.d.ts.map +1 -0
- package/dist/unordered-list/UnorderedList.js +42 -0
- package/dist/unordered-list/UnorderedList.js.map +1 -0
- package/dist/unordered-list/UnorderedList.test.d.ts +2 -0
- package/dist/unordered-list/UnorderedList.test.d.ts.map +1 -0
- package/dist/unordered-list/UnorderedList.test.js +56 -0
- package/dist/unordered-list/UnorderedList.test.js.map +1 -0
- package/dist/unordered-list/index.d.ts +2 -0
- package/dist/unordered-list/index.d.ts.map +1 -0
- package/dist/unordered-list/index.js +2 -0
- package/dist/unordered-list/index.js.map +1 -0
- package/dist/unordered-list/unordered-list-styles.generated.d.ts +2 -0
- package/dist/unordered-list/unordered-list-styles.generated.d.ts.map +1 -0
- package/dist/unordered-list/unordered-list-styles.generated.js +4 -0
- package/dist/unordered-list/unordered-list-styles.generated.js.map +1 -0
- package/package.json +42 -0
- package/src/button/Button.test.ts +360 -0
- package/src/button/Button.ts +299 -0
- package/src/button/button-demo.html +477 -0
- package/src/button/button-styles.generated.ts +3 -0
- package/src/button/button.shadow.css +20 -0
- package/src/button/index.ts +2 -0
- package/src/heading/Heading.test.ts +186 -0
- package/src/heading/Heading.ts +104 -0
- package/src/heading/heading-styles.generated.ts +3 -0
- package/src/heading/heading.shadow.css +11 -0
- package/src/heading/index.ts +2 -0
- package/src/icon/Icon.test.ts +228 -0
- package/src/icon/Icon.ts +136 -0
- package/src/icon/icon-paths.generated.ts +55 -0
- package/src/icon/icon-styles.generated.ts +3 -0
- package/src/icon/icon.shadow.css +13 -0
- package/src/icon/index.ts +2 -0
- package/src/index.ts +83 -0
- package/src/link/Link.test.ts +309 -0
- package/src/link/Link.ts +284 -0
- package/src/link/index.ts +2 -0
- package/src/link/link-styles.generated.ts +3 -0
- package/src/link/link.shadow.css +15 -0
- package/src/ordered-list/OrderedList.test.ts +97 -0
- package/src/ordered-list/OrderedList.ts +84 -0
- package/src/ordered-list/index.ts +1 -0
- package/src/ordered-list/ordered-list-styles.generated.ts +3 -0
- package/src/ordered-list/ordered-list.shadow.css +11 -0
- package/src/paragraph/Paragraph.test.ts +143 -0
- package/src/paragraph/Paragraph.ts +77 -0
- package/src/paragraph/index.ts +2 -0
- package/src/paragraph/paragraph-styles.generated.ts +3 -0
- package/src/paragraph/paragraph.shadow.css +11 -0
- package/src/unordered-list/UnorderedList.test.ts +66 -0
- package/src/unordered-list/UnorderedList.ts +50 -0
- package/src/unordered-list/index.ts +1 -0
- package/src/unordered-list/unordered-list-styles.generated.ts +3 -0
- package/src/unordered-list/unordered-list.shadow.css +11 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSN Paragraph Web Component
|
|
3
|
+
*
|
|
4
|
+
* A custom element that provides a styled paragraph with multiple variants.
|
|
5
|
+
* Uses the same CSS classes and design tokens as the HTML and React paragraph components.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```html
|
|
9
|
+
* <dsn-paragraph>Default body text</dsn-paragraph>
|
|
10
|
+
* <dsn-paragraph variant="lead">Introductory text</dsn-paragraph>
|
|
11
|
+
* <dsn-paragraph variant="small-print">Terms and conditions apply.</dsn-paragraph>
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export type ParagraphVariant = 'default' | 'lead' | 'small-print';
|
|
16
|
+
|
|
17
|
+
// Auto-generated CSS from shared source — run `node scripts/build-css.js` to regenerate
|
|
18
|
+
import { paragraphStyles } from './paragraph-styles.generated';
|
|
19
|
+
|
|
20
|
+
export class DsnParagraph extends HTMLElement {
|
|
21
|
+
static get observedAttributes(): string[] {
|
|
22
|
+
return ['variant'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
private _paragraph: HTMLParagraphElement;
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
this.attachShadow({ mode: 'open' });
|
|
30
|
+
|
|
31
|
+
// Create the internal paragraph element
|
|
32
|
+
this._paragraph = document.createElement('p');
|
|
33
|
+
this._paragraph.innerHTML = '<slot></slot>';
|
|
34
|
+
|
|
35
|
+
// Create style element with embedded CSS
|
|
36
|
+
const style = document.createElement('style');
|
|
37
|
+
style.textContent = paragraphStyles;
|
|
38
|
+
|
|
39
|
+
this.shadowRoot!.appendChild(style);
|
|
40
|
+
this.shadowRoot!.appendChild(this._paragraph);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
connectedCallback(): void {
|
|
44
|
+
this._updateClasses();
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
attributeChangedCallback(): void {
|
|
48
|
+
this._updateClasses();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
private _updateClasses(): void {
|
|
52
|
+
const variant = this.variant;
|
|
53
|
+
|
|
54
|
+
const classes = [
|
|
55
|
+
'dsn-paragraph',
|
|
56
|
+
variant !== 'default' && `dsn-paragraph--${variant}`,
|
|
57
|
+
].filter(Boolean) as string[];
|
|
58
|
+
|
|
59
|
+
this._paragraph.className = classes.join(' ');
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// Property: variant
|
|
63
|
+
get variant(): ParagraphVariant {
|
|
64
|
+
return (this.getAttribute('variant') as ParagraphVariant) || 'default';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
set variant(value: ParagraphVariant) {
|
|
68
|
+
this.setAttribute('variant', value);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Register the custom element
|
|
73
|
+
export function defineParagraph(tagName = 'dsn-paragraph'): void {
|
|
74
|
+
if (!customElements.get(tagName)) {
|
|
75
|
+
customElements.define(tagName, DsnParagraph);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Auto-generated — do not edit manually.
|
|
2
|
+
// Source: paragraph.shadow.css + components-html source
|
|
3
|
+
export const paragraphStyles = "/**\n * Shadow DOM wrapper styles for the Paragraph Web Component.\n * The core paragraph styles are imported from the shared HTML/CSS source.\n */\n\n:host {\n display: block;\n}\n\n/* Shared paragraph styles - single source of truth */\n/**\n * Paragraph Component\n * Uses component tokens for consistent styling\n *\n * Base class includes the default variant styles — class=\"dsn-paragraph\" is sufficient\n * for the most common case. Variant modifiers (lead, small-print) override what differs.\n */\n\n.dsn-paragraph {\n font-family: var(--dsn-paragraph-font-family);\n font-weight: var(--dsn-paragraph-font-weight);\n color: var(--dsn-paragraph-color);\n max-inline-size: var(--dsn-paragraph-max-inline-size);\n margin-block-start: 0;\n font-size: var(--dsn-paragraph-default-font-size);\n line-height: var(--dsn-paragraph-default-line-height);\n margin-block-end: var(--dsn-paragraph-default-margin-block-end);\n}\n\n/* Lead Variant */\n.dsn-paragraph--lead {\n font-size: var(--dsn-paragraph-lead-font-size);\n line-height: var(--dsn-paragraph-lead-line-height);\n margin-block-end: var(--dsn-paragraph-lead-margin-block-end);\n}\n\n/* Small Print Variant */\n.dsn-paragraph--small-print {\n font-size: var(--dsn-paragraph-small-print-font-size);\n line-height: var(--dsn-paragraph-small-print-line-height);\n margin-block-end: var(--dsn-paragraph-small-print-margin-block-end);\n}\n\n";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow DOM wrapper styles for the Paragraph Web Component.
|
|
3
|
+
* The core paragraph styles are imported from the shared HTML/CSS source.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Shared paragraph styles - single source of truth */
|
|
11
|
+
@import '../../../components-html/src/paragraph/paragraph.css';
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, beforeEach } from 'vitest';
|
|
2
|
+
import { DsnUnorderedList, defineUnorderedList } from './UnorderedList';
|
|
3
|
+
|
|
4
|
+
// Register the custom element once for all tests
|
|
5
|
+
beforeAll(() => {
|
|
6
|
+
defineUnorderedList();
|
|
7
|
+
});
|
|
8
|
+
|
|
9
|
+
function createElement(): DsnUnorderedList {
|
|
10
|
+
const el = document.createElement('dsn-unordered-list') as DsnUnorderedList;
|
|
11
|
+
document.body.appendChild(el);
|
|
12
|
+
return el;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getInternalList(el: DsnUnorderedList): HTMLUListElement {
|
|
16
|
+
return el.shadowRoot!.querySelector('ul')!;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('DsnUnorderedList', () => {
|
|
20
|
+
beforeEach(() => {
|
|
21
|
+
document.body.innerHTML = '';
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe('rendering', () => {
|
|
25
|
+
it('creates a shadow root', () => {
|
|
26
|
+
const el = createElement();
|
|
27
|
+
expect(el.shadowRoot).not.toBeNull();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it('renders an internal ul element', () => {
|
|
31
|
+
const el = createElement();
|
|
32
|
+
const list = getInternalList(el);
|
|
33
|
+
expect(list).toBeInstanceOf(HTMLUListElement);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('renders a style element in shadow DOM', () => {
|
|
37
|
+
const el = createElement();
|
|
38
|
+
const style = el.shadowRoot!.querySelector('style');
|
|
39
|
+
expect(style).not.toBeNull();
|
|
40
|
+
expect(style!.textContent).toContain('.dsn-unordered-list');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it('renders a default slot for content projection', () => {
|
|
44
|
+
const el = createElement();
|
|
45
|
+
const slot = el.shadowRoot!.querySelector('slot');
|
|
46
|
+
expect(slot).not.toBeNull();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('applies dsn-unordered-list class to internal list', () => {
|
|
50
|
+
const el = createElement();
|
|
51
|
+
const list = getInternalList(el);
|
|
52
|
+
expect(list.classList.contains('dsn-unordered-list')).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
describe('defineUnorderedList', () => {
|
|
58
|
+
it('does not throw when called with an already-registered tag', () => {
|
|
59
|
+
expect(() => defineUnorderedList('dsn-unordered-list')).not.toThrow();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('registers a custom element with the default tag name', () => {
|
|
63
|
+
const el = document.createElement('dsn-unordered-list');
|
|
64
|
+
expect(el).toBeInstanceOf(DsnUnorderedList);
|
|
65
|
+
});
|
|
66
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DSN Unordered List Web Component
|
|
3
|
+
*
|
|
4
|
+
* A custom element that provides a styled unordered list with accent-colored bullet markers.
|
|
5
|
+
* Uses the same CSS classes and design tokens as the HTML and React components.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```html
|
|
9
|
+
* <dsn-unordered-list>
|
|
10
|
+
* <li>First item</li>
|
|
11
|
+
* <li>Second item</li>
|
|
12
|
+
* <li>Third item</li>
|
|
13
|
+
* </dsn-unordered-list>
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
// Auto-generated CSS from shared source — run `node scripts/build-css.js` to regenerate
|
|
18
|
+
import { unorderedListStyles } from './unordered-list-styles.generated';
|
|
19
|
+
|
|
20
|
+
export class DsnUnorderedList extends HTMLElement {
|
|
21
|
+
private _list: HTMLUListElement;
|
|
22
|
+
|
|
23
|
+
constructor() {
|
|
24
|
+
super();
|
|
25
|
+
this.attachShadow({ mode: 'open' });
|
|
26
|
+
|
|
27
|
+
// Create the internal list element
|
|
28
|
+
this._list = document.createElement('ul');
|
|
29
|
+
this._list.classList.add('dsn-unordered-list');
|
|
30
|
+
this._list.innerHTML = '<slot></slot>';
|
|
31
|
+
|
|
32
|
+
// Create style element with embedded CSS
|
|
33
|
+
const style = document.createElement('style');
|
|
34
|
+
style.textContent = unorderedListStyles;
|
|
35
|
+
|
|
36
|
+
this.shadowRoot!.appendChild(style);
|
|
37
|
+
this.shadowRoot!.appendChild(this._list);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
connectedCallback(): void {
|
|
41
|
+
this._list.className = 'dsn-unordered-list';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Register the custom element
|
|
46
|
+
export function defineUnorderedList(tagName = 'dsn-unordered-list'): void {
|
|
47
|
+
if (!customElements.get(tagName)) {
|
|
48
|
+
customElements.define(tagName, DsnUnorderedList);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DsnUnorderedList, defineUnorderedList } from './UnorderedList';
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// Auto-generated — do not edit manually.
|
|
2
|
+
// Source: unordered-list.shadow.css + components-html source
|
|
3
|
+
export const unorderedListStyles = "/**\n * Shadow DOM wrapper styles for the UnorderedList Web Component.\n * The core styles are imported from the shared HTML/CSS source.\n */\n\n:host {\n display: block;\n}\n\n/* Shared unordered list styles - single source of truth */\n/**\n * Unordered List Component\n * Uses component tokens for consistent styling.\n * Bullet markers are colored via the marker-color token.\n */\n\n.dsn-unordered-list {\n font-family: var(--dsn-unordered-list-font-family);\n font-weight: var(--dsn-unordered-list-font-weight);\n color: var(--dsn-unordered-list-color);\n font-size: var(--dsn-unordered-list-font-size);\n line-height: var(--dsn-unordered-list-line-height);\n max-inline-size: var(--dsn-unordered-list-max-inline-size);\n padding-inline-start: var(--dsn-unordered-list-padding-inline-start);\n margin-block-start: 0;\n margin-block-end: var(--dsn-unordered-list-margin-block-end);\n list-style-type: disc;\n}\n\n/* Colored bullet markers */\n.dsn-unordered-list ::marker {\n color: var(--dsn-unordered-list-marker-color);\n}\n\n/* Spacing between list items */\n.dsn-unordered-list > li {\n margin-block-end: var(--dsn-unordered-list-gap);\n}\n\n.dsn-unordered-list > li:last-child {\n margin-block-end: 0;\n}\n\n";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shadow DOM wrapper styles for the UnorderedList Web Component.
|
|
3
|
+
* The core styles are imported from the shared HTML/CSS source.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
:host {
|
|
7
|
+
display: block;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/* Shared unordered list styles - single source of truth */
|
|
11
|
+
@import '../../../components-html/src/unordered-list/unordered-list.css';
|