@rgrmdesign/rgrm-ds-elements 0.1.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 +58 -0
- package/dist/chunk-D4TJU75K.js +49 -0
- package/dist/chunk-D4TJU75K.js.map +1 -0
- package/dist/chunk-LPYKX4DJ.js +64 -0
- package/dist/chunk-LPYKX4DJ.js.map +1 -0
- package/dist/chunk-OB3YM7YY.js +87 -0
- package/dist/chunk-OB3YM7YY.js.map +1 -0
- package/dist/heading/index.d.ts +11 -0
- package/dist/heading/index.js +11 -0
- package/dist/heading/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/paragraph/index.d.ts +11 -0
- package/dist/paragraph/index.js +11 -0
- package/dist/paragraph/index.js.map +1 -0
- package/dist/section/index.d.ts +11 -0
- package/dist/section/index.js +13 -0
- package/dist/section/index.js.map +1 -0
- package/package.json +67 -0
package/README.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# @rgrmdesign/rgrm-ds-elements
|
|
2
|
+
|
|
3
|
+
Web Components for the RGRM design system. Styles come from
|
|
4
|
+
[`@rgrmdesign/rgrm-ds-css`](../css/) and are loaded automatically on import.
|
|
5
|
+
|
|
6
|
+
Components use **light DOM** (an inner element with BEM classes) so design tokens
|
|
7
|
+
from the document apply normally.
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
pnpm add @rgrmdesign/rgrm-ds-elements @rgrmdesign/rgrm-ds-tokens
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
Import everything (registers all elements):
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
import '@rgrmdesign/rgrm-ds-tokens';
|
|
21
|
+
import '@rgrmdesign/rgrm-ds-elements';
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Or register a single component via its sub-path export:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import '@rgrmdesign/rgrm-ds-tokens';
|
|
28
|
+
import '@rgrmdesign/rgrm-ds-elements/heading';
|
|
29
|
+
import '@rgrmdesign/rgrm-ds-elements/paragraph';
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```html
|
|
33
|
+
<rgrm-heading level="display">Hero title.</rgrm-heading>
|
|
34
|
+
<rgrm-heading level="1">Page title.</rgrm-heading>
|
|
35
|
+
<rgrm-heading level="2">Section title.</rgrm-heading>
|
|
36
|
+
|
|
37
|
+
<rgrm-paragraph size="large">Lead paragraph.</rgrm-paragraph>
|
|
38
|
+
<rgrm-paragraph>Default body copy.</rgrm-paragraph>
|
|
39
|
+
<rgrm-paragraph size="small">Caption or fine print.</rgrm-paragraph>
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Heading (`<rgrm-heading>`)
|
|
43
|
+
|
|
44
|
+
| Attribute | Values | Description |
|
|
45
|
+
| --------- | ---------------------- | ----------------------------------------------------- |
|
|
46
|
+
| `level` | `1` … `6` \| `display` | Sets the scale (def. 2). `display` renders an `<h1>`. |
|
|
47
|
+
|
|
48
|
+
Also exported: `RgrmHeadingElement` (class), `RGRM_HEADING_TAG`
|
|
49
|
+
(`'rgrm-heading'`), and `headingClassNames(level, className?)`.
|
|
50
|
+
|
|
51
|
+
## Paragraph (`<rgrm-paragraph>`)
|
|
52
|
+
|
|
53
|
+
| Attribute | Values | Description |
|
|
54
|
+
| --------- | ------------------ | ----------------------------- |
|
|
55
|
+
| `size` | `small` \| `large` | Size modifier; omit for main. |
|
|
56
|
+
|
|
57
|
+
Also exported: `RgrmParagraphElement` (class), `RGRM_PARAGRAPH_TAG`
|
|
58
|
+
(`'rgrm-paragraph'`), and `paragraphClassNames(size, className?)`.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/paragraph/index.ts
|
|
2
|
+
import "@rgrmdesign/rgrm-ds-css/paragraph";
|
|
3
|
+
import { paragraphClassNames as paragraphClassNames2 } from "@rgrmdesign/rgrm-ds-core/paragraph";
|
|
4
|
+
|
|
5
|
+
// src/paragraph/paragraph-element.ts
|
|
6
|
+
import { paragraphClassNames } from "@rgrmdesign/rgrm-ds-core/paragraph";
|
|
7
|
+
var RGRM_PARAGRAPH_TAG = "rgrm-paragraph";
|
|
8
|
+
function parseSizeAttribute(value) {
|
|
9
|
+
return value === "small" || value === "large" ? value : void 0;
|
|
10
|
+
}
|
|
11
|
+
var RgrmParagraphElement = class extends HTMLElement {
|
|
12
|
+
static observedAttributes = ["size"];
|
|
13
|
+
#inner = document.createElement("p");
|
|
14
|
+
connectedCallback() {
|
|
15
|
+
this.#mountInner();
|
|
16
|
+
this.#applyClasses();
|
|
17
|
+
}
|
|
18
|
+
attributeChangedCallback(name) {
|
|
19
|
+
if (name === "size") {
|
|
20
|
+
this.#applyClasses();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
#mountInner() {
|
|
24
|
+
if (this.#inner.parentNode === this) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
while (this.firstChild) {
|
|
28
|
+
this.#inner.appendChild(this.firstChild);
|
|
29
|
+
}
|
|
30
|
+
this.appendChild(this.#inner);
|
|
31
|
+
}
|
|
32
|
+
#applyClasses() {
|
|
33
|
+
this.#inner.className = paragraphClassNames(
|
|
34
|
+
parseSizeAttribute(this.getAttribute("size"))
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// src/paragraph/index.ts
|
|
40
|
+
if (!customElements.get(RGRM_PARAGRAPH_TAG)) {
|
|
41
|
+
customElements.define(RGRM_PARAGRAPH_TAG, RgrmParagraphElement);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
RGRM_PARAGRAPH_TAG,
|
|
46
|
+
RgrmParagraphElement,
|
|
47
|
+
paragraphClassNames2 as paragraphClassNames
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=chunk-D4TJU75K.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/paragraph/index.ts","../src/paragraph/paragraph-element.ts"],"sourcesContent":["import '@rgrmdesign/rgrm-ds-css/paragraph';\n\nexport { paragraphClassNames, type ParagraphSize } from '@rgrmdesign/rgrm-ds-core/paragraph';\nexport {\n RGRM_PARAGRAPH_TAG,\n RgrmParagraphElement,\n} from './paragraph-element.js';\n\nimport { RGRM_PARAGRAPH_TAG, RgrmParagraphElement } from './paragraph-element.js';\n\nif (!customElements.get(RGRM_PARAGRAPH_TAG)) {\n customElements.define(RGRM_PARAGRAPH_TAG, RgrmParagraphElement);\n}\n","import { paragraphClassNames, type ParagraphSize } from '@rgrmdesign/rgrm-ds-core/paragraph';\n\nexport const RGRM_PARAGRAPH_TAG = 'rgrm-paragraph';\n\nfunction parseSizeAttribute(value: string | null): ParagraphSize | undefined {\n return value === 'small' || value === 'large' ? value : undefined;\n}\n\nexport class RgrmParagraphElement extends HTMLElement {\n static readonly observedAttributes = ['size'];\n\n readonly #inner = document.createElement('p');\n\n connectedCallback(): void {\n this.#mountInner();\n this.#applyClasses();\n }\n\n attributeChangedCallback(name: string): void {\n if (name === 'size') {\n this.#applyClasses();\n }\n }\n\n #mountInner(): void {\n if (this.#inner.parentNode === this) {\n return;\n }\n\n while (this.firstChild) {\n this.#inner.appendChild(this.firstChild);\n }\n\n this.appendChild(this.#inner);\n }\n\n #applyClasses(): void {\n this.#inner.className = paragraphClassNames(\n parseSizeAttribute(this.getAttribute('size')),\n );\n }\n}\n"],"mappings":";AAAA,OAAO;AAEP,SAAS,uBAAAA,4BAA+C;;;ACFxD,SAAS,2BAA+C;AAEjD,IAAM,qBAAqB;AAElC,SAAS,mBAAmB,OAAiD;AAC3E,SAAO,UAAU,WAAW,UAAU,UAAU,QAAQ;AAC1D;AAEO,IAAM,uBAAN,cAAmC,YAAY;AAAA,EACpD,OAAgB,qBAAqB,CAAC,MAAM;AAAA,EAEnC,SAAS,SAAS,cAAc,GAAG;AAAA,EAE5C,oBAA0B;AACxB,SAAK,YAAY;AACjB,SAAK,cAAc;AAAA,EACrB;AAAA,EAEA,yBAAyB,MAAoB;AAC3C,QAAI,SAAS,QAAQ;AACnB,WAAK,cAAc;AAAA,IACrB;AAAA,EACF;AAAA,EAEA,cAAoB;AAClB,QAAI,KAAK,OAAO,eAAe,MAAM;AACnC;AAAA,IACF;AAEA,WAAO,KAAK,YAAY;AACtB,WAAK,OAAO,YAAY,KAAK,UAAU;AAAA,IACzC;AAEA,SAAK,YAAY,KAAK,MAAM;AAAA,EAC9B;AAAA,EAEA,gBAAsB;AACpB,SAAK,OAAO,YAAY;AAAA,MACtB,mBAAmB,KAAK,aAAa,MAAM,CAAC;AAAA,IAC9C;AAAA,EACF;AACF;;;AD/BA,IAAI,CAAC,eAAe,IAAI,kBAAkB,GAAG;AAC3C,iBAAe,OAAO,oBAAoB,oBAAoB;AAChE;","names":["paragraphClassNames"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// src/heading/index.ts
|
|
2
|
+
import "@rgrmdesign/rgrm-ds-css/heading";
|
|
3
|
+
import { headingClassNames as headingClassNames2 } from "@rgrmdesign/rgrm-ds-core/heading";
|
|
4
|
+
|
|
5
|
+
// src/heading/heading-element.ts
|
|
6
|
+
import { headingClassNames } from "@rgrmdesign/rgrm-ds-core/heading";
|
|
7
|
+
var RGRM_HEADING_TAG = "rgrm-heading";
|
|
8
|
+
var DEFAULT_LEVEL = 2;
|
|
9
|
+
function parseLevelAttribute(value) {
|
|
10
|
+
if (value === "display") {
|
|
11
|
+
return "display";
|
|
12
|
+
}
|
|
13
|
+
const level = Number(value);
|
|
14
|
+
return Number.isInteger(level) && level >= 1 && level <= 6 ? level : DEFAULT_LEVEL;
|
|
15
|
+
}
|
|
16
|
+
var RgrmHeadingElement = class extends HTMLElement {
|
|
17
|
+
static observedAttributes = ["level"];
|
|
18
|
+
#inner = document.createElement("h2");
|
|
19
|
+
connectedCallback() {
|
|
20
|
+
this.#render();
|
|
21
|
+
}
|
|
22
|
+
attributeChangedCallback(name) {
|
|
23
|
+
if (name === "level") {
|
|
24
|
+
this.#render();
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
#render() {
|
|
28
|
+
const level = parseLevelAttribute(this.getAttribute("level"));
|
|
29
|
+
const tagName = level === "display" ? "h1" : `h${level}`;
|
|
30
|
+
if (this.#inner.localName !== tagName) {
|
|
31
|
+
const next = document.createElement(tagName);
|
|
32
|
+
while (this.#inner.firstChild) {
|
|
33
|
+
next.appendChild(this.#inner.firstChild);
|
|
34
|
+
}
|
|
35
|
+
if (this.#inner.parentNode === this) {
|
|
36
|
+
this.replaceChild(next, this.#inner);
|
|
37
|
+
}
|
|
38
|
+
this.#inner = next;
|
|
39
|
+
}
|
|
40
|
+
this.#mountInner();
|
|
41
|
+
this.#inner.className = headingClassNames(level);
|
|
42
|
+
}
|
|
43
|
+
#mountInner() {
|
|
44
|
+
if (this.#inner.parentNode === this) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
while (this.firstChild) {
|
|
48
|
+
this.#inner.appendChild(this.firstChild);
|
|
49
|
+
}
|
|
50
|
+
this.appendChild(this.#inner);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
// src/heading/index.ts
|
|
55
|
+
if (!customElements.get(RGRM_HEADING_TAG)) {
|
|
56
|
+
customElements.define(RGRM_HEADING_TAG, RgrmHeadingElement);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export {
|
|
60
|
+
RGRM_HEADING_TAG,
|
|
61
|
+
RgrmHeadingElement,
|
|
62
|
+
headingClassNames2 as headingClassNames
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=chunk-LPYKX4DJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/heading/index.ts","../src/heading/heading-element.ts"],"sourcesContent":["import '@rgrmdesign/rgrm-ds-css/heading';\n\nexport { headingClassNames, type HeadingLevel } from '@rgrmdesign/rgrm-ds-core/heading';\nexport { RGRM_HEADING_TAG, RgrmHeadingElement } from './heading-element.js';\n\nimport { RGRM_HEADING_TAG, RgrmHeadingElement } from './heading-element.js';\n\nif (!customElements.get(RGRM_HEADING_TAG)) {\n customElements.define(RGRM_HEADING_TAG, RgrmHeadingElement);\n}\n","import { headingClassNames, type HeadingLevel } from '@rgrmdesign/rgrm-ds-core/heading';\n\nexport const RGRM_HEADING_TAG = 'rgrm-heading';\n\nconst DEFAULT_LEVEL: HeadingLevel = 2;\n\nfunction parseLevelAttribute(value: string | null): HeadingLevel {\n if (value === 'display') {\n return 'display';\n }\n const level = Number(value);\n return Number.isInteger(level) && level >= 1 && level <= 6\n ? (level as HeadingLevel)\n : DEFAULT_LEVEL;\n}\n\nexport class RgrmHeadingElement extends HTMLElement {\n static readonly observedAttributes = ['level'];\n\n #inner: HTMLHeadingElement = document.createElement('h2');\n\n connectedCallback(): void {\n this.#render();\n }\n\n attributeChangedCallback(name: string): void {\n if (name === 'level') {\n this.#render();\n }\n }\n\n #render(): void {\n const level = parseLevelAttribute(this.getAttribute('level'));\n const tagName = level === 'display' ? 'h1' : `h${level}`;\n\n if (this.#inner.localName !== tagName) {\n const next = document.createElement(tagName) as HTMLHeadingElement;\n while (this.#inner.firstChild) {\n next.appendChild(this.#inner.firstChild);\n }\n if (this.#inner.parentNode === this) {\n this.replaceChild(next, this.#inner);\n }\n this.#inner = next;\n }\n\n this.#mountInner();\n this.#inner.className = headingClassNames(level);\n }\n\n #mountInner(): void {\n if (this.#inner.parentNode === this) {\n return;\n }\n\n while (this.firstChild) {\n this.#inner.appendChild(this.firstChild);\n }\n\n this.appendChild(this.#inner);\n }\n}\n"],"mappings":";AAAA,OAAO;AAEP,SAAS,qBAAAA,0BAA4C;;;ACFrD,SAAS,yBAA4C;AAE9C,IAAM,mBAAmB;AAEhC,IAAM,gBAA8B;AAEpC,SAAS,oBAAo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"@rgrmdesign/rgrm-ds-css/section";
|
|
3
|
+
import {
|
|
4
|
+
sectionClassNames as sectionClassNames2,
|
|
5
|
+
sectionContainerClassNames as sectionContainerClassNames2
|
|
6
|
+
} from "@rgrmdesign/rgrm-ds-core/section";
|
|
7
|
+
|
|
8
|
+
// src/section/section-element.ts
|
|
9
|
+
import {
|
|
10
|
+
RGRM_SECTION_BACKGROUND_CLASS,
|
|
11
|
+
sectionClassNames,
|
|
12
|
+
sectionContainerClassNames
|
|
13
|
+
} from "@rgrmdesign/rgrm-ds-core/section";
|
|
14
|
+
var RGRM_SECTION_TAG = "rgrm-section";
|
|
15
|
+
var SPACINGS = ["none", "small", "main", "large", "page-top"];
|
|
16
|
+
var WIDTHS = ["small", "main", "full"];
|
|
17
|
+
var THEMES = ["root", "dark", "brand"];
|
|
18
|
+
function parseSpacing(value) {
|
|
19
|
+
return SPACINGS.includes(value ?? "") ? value : "main";
|
|
20
|
+
}
|
|
21
|
+
function parseWidth(value) {
|
|
22
|
+
return WIDTHS.includes(value ?? "") ? value : "main";
|
|
23
|
+
}
|
|
24
|
+
function parseTheme(value) {
|
|
25
|
+
return THEMES.includes(value ?? "") ? value : "root";
|
|
26
|
+
}
|
|
27
|
+
var RgrmSectionElement = class extends HTMLElement {
|
|
28
|
+
static observedAttributes = ["theme", "spacing-top", "spacing-bottom", "width"];
|
|
29
|
+
#background = document.createElement("div");
|
|
30
|
+
#container = document.createElement("div");
|
|
31
|
+
#mounted = false;
|
|
32
|
+
connectedCallback() {
|
|
33
|
+
this.#mountInner();
|
|
34
|
+
this.#applyClasses();
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback() {
|
|
37
|
+
if (this.#mounted) {
|
|
38
|
+
this.#applyClasses();
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
#mountInner() {
|
|
42
|
+
if (this.#mounted) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
this.#background.className = RGRM_SECTION_BACKGROUND_CLASS;
|
|
46
|
+
const nodes = Array.from(this.childNodes);
|
|
47
|
+
for (const node of nodes) {
|
|
48
|
+
if (node.nodeType === Node.ELEMENT_NODE && node.getAttribute("slot") === "background") {
|
|
49
|
+
node.removeAttribute("slot");
|
|
50
|
+
this.#background.appendChild(node);
|
|
51
|
+
} else {
|
|
52
|
+
this.#container.appendChild(node);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (this.#background.childNodes.length > 0) {
|
|
56
|
+
this.appendChild(this.#background);
|
|
57
|
+
}
|
|
58
|
+
this.appendChild(this.#container);
|
|
59
|
+
this.#mounted = true;
|
|
60
|
+
}
|
|
61
|
+
#applyClasses() {
|
|
62
|
+
this.className = sectionClassNames({
|
|
63
|
+
spacingTop: parseSpacing(this.getAttribute("spacing-top")),
|
|
64
|
+
spacingBottom: parseSpacing(this.getAttribute("spacing-bottom"))
|
|
65
|
+
});
|
|
66
|
+
this.#container.className = sectionContainerClassNames(parseWidth(this.getAttribute("width")));
|
|
67
|
+
const theme = parseTheme(this.getAttribute("theme"));
|
|
68
|
+
if (theme === "root") {
|
|
69
|
+
this.removeAttribute("data-theme");
|
|
70
|
+
} else {
|
|
71
|
+
this.setAttribute("data-theme", theme);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
// src/section/index.ts
|
|
77
|
+
if (!customElements.get(RGRM_SECTION_TAG)) {
|
|
78
|
+
customElements.define(RGRM_SECTION_TAG, RgrmSectionElement);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
RGRM_SECTION_TAG,
|
|
83
|
+
RgrmSectionElement,
|
|
84
|
+
sectionClassNames2 as sectionClassNames,
|
|
85
|
+
sectionContainerClassNames2 as sectionContainerClassNames
|
|
86
|
+
};
|
|
87
|
+
//# sourceMappingURL=chunk-OB3YM7YY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/section/index.ts","../src/section/section-element.ts"],"sourcesContent":["import '@rgrmdesign/rgrm-ds-css/section';\n\nexport {\n sectionClassNames,\n sectionContainerClassNames,\n type SectionTheme,\n type SectionSpacing,\n type SectionWidth,\n} from '@rgrmdesign/rgrm-ds-core/section';\nexport { RGRM_SECTION_TAG, RgrmSectionElement } from './section-element.js';\n\nimport { RGRM_SECTION_TAG, RgrmSectionElement } from './section-element.js';\n\nif (!customElements.get(RGRM_SECTION_TAG)) {\n customElements.define(RGRM_SECTION_TAG, RgrmSectionElement);\n}\n","import {\n RGRM_SECTION_BACKGROUND_CLASS,\n sectionClassNames,\n sectionContainerClassNames,\n type SectionSpacing,\n type SectionTheme,\n type SectionWidth,\n} from '@rgrmdesign/rgrm-ds-core/section';\n\nexport const RGRM_SECTION_TAG = 'rgrm-section';\n\nconst SPACINGS: readonly SectionSpacing[] = ['none', 'small', 'main', 'large', 'page-top'];\nconst WIDTHS: readonly SectionWidth[] = ['small', 'main', 'full'];\nconst THEMES: readonly SectionTheme[] = ['root', 'dark', 'brand'];\n\nfunction parseSpacing(value: string | null): SectionSpacing {\n return (SPACINGS as readonly string[]).includes(value ?? '') ? (value as SectionSpacing) : 'main';\n}\n\nfunction parseWidth(value: string | null): SectionWidth {\n return (WIDTHS as readonly string[]).includes(value ?? '') ? (value as SectionWidth) : 'main';\n}\n\nfunction parseTheme(value: string | null): SectionTheme {\n return (THEMES as readonly string[]).includes(value ?? '') ? (value as SectionTheme) : 'root';\n}\n\nexport class RgrmSectionElement extends HTMLElement {\n static readonly observedAttributes = ['theme', 'spacing-top', 'spacing-bottom', 'width'];\n\n readonly #background = document.createElement('div');\n readonly #container = document.createElement('div');\n #mounted = false;\n\n connectedCallback(): void {\n this.#mountInner();\n this.#applyClasses();\n }\n\n attributeChangedCallback(): void {\n if (this.#mounted) {\n this.#applyClasses();\n }\n }\n\n #mountInner(): void {\n if (this.#mounted) {\n return;\n }\n\n this.#background.className = RGRM_SECTION_BACKGROUND_CLASS;\n\n const nodes = Array.from(this.childNodes);\n for (const node of nodes) {\n if (\n node.nodeType === Node.ELEMENT_NODE &&\n (node as Element).getAttribute('slot') === 'background'\n ) {\n (node as Element).removeAttribute('slot');\n this.#background.appendChild(node);\n } else {\n this.#container.appendChild(node);\n }\n }\n\n if (this.#background.childNodes.length > 0) {\n this.appendChild(this.#background);\n }\n this.appendChild(this.#container);\n this.#mounted = true;\n }\n\n #applyClasses(): void {\n this.className = sectionClassNames({\n spacingTop: parseSpacing(this.getAttribute('spacing-top')),\n spacingBottom: parseSpacing(this.getAttribute('spacing-bottom')),\n });\n\n this.#container.className = sectionContainerClassNames(parseWidth(this.getAttribute('width')));\n\n const theme = parseTheme(this.getAttribute('theme'));\n if (theme === 'root') {\n this.removeAttribute('data-theme');\n } else {\n this.setAttribute('data-theme', theme);\n }\n }\n}\n"],"mappings":";AAAA,OAAO;AAEP;AAAA,EACE,qBAAAA;AAAA,EACA,8BAAAC;AAAA,OAIK;;;ACRP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAIK;AAEA,IAAM,mBAAmB;AAEhC,IAAM,WAAsC,CAAC,QAAQ,SAAS,QAAQ,SAAS,UAAU;AACzF,IAAM,SAAkC,CAAC,SAAS,QAAQ,MAAM;AAChE,IAAM,SAAkC,CAAC,QAAQ,QAAQ,OAAO;AAEhE,SAAS,aAAa,OAAsC;AAC1D,SAAQ,SAA+B,SAAS,SAAS,EAAE,IAAK,QAA2B;AAC7F;AAEA,SAAS,WAAW,OAAoC;AACtD,SAAQ,OAA6B,SAAS,SAAS,EAAE,IAAK,QAAyB;AACzF;AAEA,SAAS,WAAW,OAAoC;AACtD,SAAQ,OAA6B,SAAS,SAAS,EAAE,IAAK,QAAyB;AACzF;AAEO,IAAM,qBAAN,cAAiC,YAAY;AAAA,EAClD,OAAgB,qBAAqB,CAAC,SAAS,eAAe,kBAAkB,OAAO;AAAA,EAE9E,cAAc,SAAS,cAAc,KAAK;AAAA,EAC1C,aAAa,SAAS,cAAc,KAAK;AAAA,EAClD,WAAW;AAA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headingClassNames } from '@rgrmdesign/rgrm-ds-core/heading';
|
|
2
|
+
|
|
3
|
+
declare const RGRM_HEADING_TAG = "rgrm-heading";
|
|
4
|
+
declare class RgrmHeadingElement extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static readonly observedAttributes: string[];
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(name: string): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { RGRM_HEADING_TAG, RgrmHeadingElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { HeadingLevel, headingClassNames } from '@rgrmdesign/rgrm-ds-core/heading';
|
|
2
|
+
export { RGRM_HEADING_TAG, RgrmHeadingElement } from './heading/index.js';
|
|
3
|
+
export { ParagraphSize, paragraphClassNames } from '@rgrmdesign/rgrm-ds-core/paragraph';
|
|
4
|
+
export { RGRM_PARAGRAPH_TAG, RgrmParagraphElement } from './paragraph/index.js';
|
|
5
|
+
export { SectionSpacing, SectionTheme, SectionWidth, sectionClassNames, sectionContainerClassNames } from '@rgrmdesign/rgrm-ds-core/section';
|
|
6
|
+
export { RGRM_SECTION_TAG, RgrmSectionElement } from './section/index.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RGRM_HEADING_TAG,
|
|
3
|
+
RgrmHeadingElement,
|
|
4
|
+
headingClassNames
|
|
5
|
+
} from "./chunk-LPYKX4DJ.js";
|
|
6
|
+
import {
|
|
7
|
+
RGRM_PARAGRAPH_TAG,
|
|
8
|
+
RgrmParagraphElement,
|
|
9
|
+
paragraphClassNames
|
|
10
|
+
} from "./chunk-D4TJU75K.js";
|
|
11
|
+
import {
|
|
12
|
+
RGRM_SECTION_TAG,
|
|
13
|
+
RgrmSectionElement,
|
|
14
|
+
sectionClassNames,
|
|
15
|
+
sectionContainerClassNames
|
|
16
|
+
} from "./chunk-OB3YM7YY.js";
|
|
17
|
+
export {
|
|
18
|
+
RGRM_HEADING_TAG,
|
|
19
|
+
RGRM_PARAGRAPH_TAG,
|
|
20
|
+
RGRM_SECTION_TAG,
|
|
21
|
+
RgrmHeadingElement,
|
|
22
|
+
RgrmParagraphElement,
|
|
23
|
+
RgrmSectionElement,
|
|
24
|
+
headingClassNames,
|
|
25
|
+
paragraphClassNames,
|
|
26
|
+
sectionClassNames,
|
|
27
|
+
sectionContainerClassNames
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { ParagraphSize, paragraphClassNames } from '@rgrmdesign/rgrm-ds-core/paragraph';
|
|
2
|
+
|
|
3
|
+
declare const RGRM_PARAGRAPH_TAG = "rgrm-paragraph";
|
|
4
|
+
declare class RgrmParagraphElement extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static readonly observedAttributes: string[];
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(name: string): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { RGRM_PARAGRAPH_TAG, RgrmParagraphElement };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export { SectionSpacing, SectionTheme, SectionWidth, sectionClassNames, sectionContainerClassNames } from '@rgrmdesign/rgrm-ds-core/section';
|
|
2
|
+
|
|
3
|
+
declare const RGRM_SECTION_TAG = "rgrm-section";
|
|
4
|
+
declare class RgrmSectionElement extends HTMLElement {
|
|
5
|
+
#private;
|
|
6
|
+
static readonly observedAttributes: string[];
|
|
7
|
+
connectedCallback(): void;
|
|
8
|
+
attributeChangedCallback(): void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { RGRM_SECTION_TAG, RgrmSectionElement };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
RGRM_SECTION_TAG,
|
|
3
|
+
RgrmSectionElement,
|
|
4
|
+
sectionClassNames,
|
|
5
|
+
sectionContainerClassNames
|
|
6
|
+
} from "../chunk-OB3YM7YY.js";
|
|
7
|
+
export {
|
|
8
|
+
RGRM_SECTION_TAG,
|
|
9
|
+
RgrmSectionElement,
|
|
10
|
+
sectionClassNames,
|
|
11
|
+
sectionContainerClassNames
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@rgrmdesign/rgrm-ds-elements",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Web Components for the RGRM design system. Styles come from @rgrmdesign/rgrm-ds-css.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/RGRMdesign/rgrm-ds.git",
|
|
10
|
+
"directory": "packages/elements"
|
|
11
|
+
},
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
},
|
|
17
|
+
"./heading": {
|
|
18
|
+
"types": "./dist/heading/index.d.ts",
|
|
19
|
+
"import": "./dist/heading/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./paragraph": {
|
|
22
|
+
"types": "./dist/paragraph/index.d.ts",
|
|
23
|
+
"import": "./dist/paragraph/index.js"
|
|
24
|
+
},
|
|
25
|
+
"./section": {
|
|
26
|
+
"types": "./dist/section/index.d.ts",
|
|
27
|
+
"import": "./dist/section/index.js"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist"
|
|
32
|
+
],
|
|
33
|
+
"sideEffects": [
|
|
34
|
+
"@rgrmdesign/rgrm-ds-css",
|
|
35
|
+
"./dist/index.js",
|
|
36
|
+
"./dist/heading/index.js",
|
|
37
|
+
"./dist/paragraph/index.js",
|
|
38
|
+
"./dist/section/index.js"
|
|
39
|
+
],
|
|
40
|
+
"dependencies": {
|
|
41
|
+
"@rgrmdesign/rgrm-ds-core": "0.1.0",
|
|
42
|
+
"@rgrmdesign/rgrm-ds-css": "0.1.0"
|
|
43
|
+
},
|
|
44
|
+
"peerDependencies": {
|
|
45
|
+
"@rgrmdesign/rgrm-ds-tokens": ">=0.5.0"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"@rgrmdesign/rgrm-ds-tokens": "^0.5.0",
|
|
49
|
+
"rimraf": "^6.0.1",
|
|
50
|
+
"tsup": "^8.5.1",
|
|
51
|
+
"typescript": "^5.9.3"
|
|
52
|
+
},
|
|
53
|
+
"keywords": [
|
|
54
|
+
"custom-elements",
|
|
55
|
+
"design-system",
|
|
56
|
+
"typography",
|
|
57
|
+
"web-components"
|
|
58
|
+
],
|
|
59
|
+
"publishConfig": {
|
|
60
|
+
"access": "public"
|
|
61
|
+
},
|
|
62
|
+
"scripts": {
|
|
63
|
+
"build": "tsup",
|
|
64
|
+
"dev": "tsup --watch",
|
|
65
|
+
"clean": "rimraf dist"
|
|
66
|
+
}
|
|
67
|
+
}
|