From 990f372bf9bcfb0e096f3b044e3e4696b8677593 Mon Sep 17 00:00:00 2001 From: Myrta Sakellariou Date: Tue, 29 Apr 2025 19:32:07 +0200 Subject: [PATCH 01/26] chore(documentation): investigate cross-component referencing --- packages/components/src/components.d.ts | 71 +++++++++++++++++++ .../post-test-form/post-test-form.scss | 1 + .../post-test-form/post-test-form.tsx | 34 +++++++++ .../src/components/post-test-form/readme.md | 33 +++++++++ .../post-test-input/post-test-input.scss | 1 + .../post-test-input/post-test-input.tsx | 23 ++++++ .../src/components/post-test-input/readme.md | 30 ++++++++ .../post-test-label/post-test-label.scss | 1 + .../post-test-label/post-test-label.tsx | 23 ++++++ .../src/components/post-test-label/readme.md | 30 ++++++++ packages/components/src/index.html | 1 + .../src/stories/guidelines/ccr/ccr.docs.mdx | 8 +++ .../src/stories/guidelines/ccr/ccr.stories.ts | 16 +++++ 13 files changed, 272 insertions(+) create mode 100644 packages/components/src/components/post-test-form/post-test-form.scss create mode 100644 packages/components/src/components/post-test-form/post-test-form.tsx create mode 100644 packages/components/src/components/post-test-form/readme.md create mode 100644 packages/components/src/components/post-test-input/post-test-input.scss create mode 100644 packages/components/src/components/post-test-input/post-test-input.tsx create mode 100644 packages/components/src/components/post-test-input/readme.md create mode 100644 packages/components/src/components/post-test-label/post-test-label.scss create mode 100644 packages/components/src/components/post-test-label/post-test-label.tsx create mode 100644 packages/components/src/components/post-test-label/readme.md create mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx create mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts diff --git a/packages/components/src/components.d.ts b/packages/components/src/components.d.ts index 24d0efacf7..1f0604ccff 100644 --- a/packages/components/src/components.d.ts +++ b/packages/components/src/components.d.ts @@ -464,6 +464,28 @@ export namespace Components { */ "variant": 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } + interface PostTestForm { + /** + * Defines the id + */ + "theId"?: string; + /** + * Defines the id2 + */ + "theId2"?: string; + } + interface PostTestInput { + /** + * Defines the inputId + */ + "inputId"?: string; + } + interface PostTestLabel { + /** + * Defines the for + */ + "for"?: string; + } interface PostTogglebutton { /** * If `true`, the button is in the "on" state, otherwise it is in the "off" state. @@ -859,6 +881,24 @@ declare global { prototype: HTMLPostTagElement; new (): HTMLPostTagElement; }; + interface HTMLPostTestFormElement extends Components.PostTestForm, HTMLStencilElement { + } + var HTMLPostTestFormElement: { + prototype: HTMLPostTestFormElement; + new (): HTMLPostTestFormElement; + }; + interface HTMLPostTestInputElement extends Components.PostTestInput, HTMLStencilElement { + } + var HTMLPostTestInputElement: { + prototype: HTMLPostTestInputElement; + new (): HTMLPostTestInputElement; + }; + interface HTMLPostTestLabelElement extends Components.PostTestLabel, HTMLStencilElement { + } + var HTMLPostTestLabelElement: { + prototype: HTMLPostTestLabelElement; + new (): HTMLPostTestLabelElement; + }; interface HTMLPostTogglebuttonElement extends Components.PostTogglebutton, HTMLStencilElement { } var HTMLPostTogglebuttonElement: { @@ -905,6 +945,9 @@ declare global { "post-tab-panel": HTMLPostTabPanelElement; "post-tabs": HTMLPostTabsElement; "post-tag": HTMLPostTagElement; + "post-test-form": HTMLPostTestFormElement; + "post-test-input": HTMLPostTestInputElement; + "post-test-label": HTMLPostTestLabelElement; "post-togglebutton": HTMLPostTogglebuttonElement; "post-tooltip": HTMLPostTooltipElement; } @@ -1303,6 +1346,28 @@ declare namespace LocalJSX { */ "variant"?: 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } + interface PostTestForm { + /** + * Defines the id + */ + "theId"?: string; + /** + * Defines the id2 + */ + "theId2"?: string; + } + interface PostTestInput { + /** + * Defines the inputId + */ + "inputId"?: string; + } + interface PostTestLabel { + /** + * Defines the for + */ + "for"?: string; + } interface PostTogglebutton { /** * If `true`, the button is in the "on" state, otherwise it is in the "off" state. @@ -1357,6 +1422,9 @@ declare namespace LocalJSX { "post-tab-panel": PostTabPanel; "post-tabs": PostTabs; "post-tag": PostTag; + "post-test-form": PostTestForm; + "post-test-input": PostTestInput; + "post-test-label": PostTestLabel; "post-togglebutton": PostTogglebutton; "post-tooltip": PostTooltip; } @@ -1404,6 +1472,9 @@ declare module "@stencil/core" { "post-tab-panel": LocalJSX.PostTabPanel & JSXBase.HTMLAttributes; "post-tabs": LocalJSX.PostTabs & JSXBase.HTMLAttributes; "post-tag": LocalJSX.PostTag & JSXBase.HTMLAttributes; + "post-test-form": LocalJSX.PostTestForm & JSXBase.HTMLAttributes; + "post-test-input": LocalJSX.PostTestInput & JSXBase.HTMLAttributes; + "post-test-label": LocalJSX.PostTestLabel & JSXBase.HTMLAttributes; "post-togglebutton": LocalJSX.PostTogglebutton & JSXBase.HTMLAttributes; "post-tooltip": LocalJSX.PostTooltip & JSXBase.HTMLAttributes; } diff --git a/packages/components/src/components/post-test-form/post-test-form.scss b/packages/components/src/components/post-test-form/post-test-form.scss new file mode 100644 index 0000000000..4cd9a272da --- /dev/null +++ b/packages/components/src/components/post-test-form/post-test-form.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/core' as post; diff --git a/packages/components/src/components/post-test-form/post-test-form.tsx b/packages/components/src/components/post-test-form/post-test-form.tsx new file mode 100644 index 0000000000..5be2601253 --- /dev/null +++ b/packages/components/src/components/post-test-form/post-test-form.tsx @@ -0,0 +1,34 @@ +import { Component, h, Host, Prop } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-form', + styleUrl: 'post-test-form.scss', + shadow: true, +}) +export class PostTestForm { + /** + * Defines the id + */ + @Prop() theId?: string; + + /** + * Defines the id2 + */ + @Prop() theId2?: string; + + render() { + return ( + + + +
+ + +
+
+ ); + } +} diff --git a/packages/components/src/components/post-test-form/readme.md b/packages/components/src/components/post-test-form/readme.md new file mode 100644 index 0000000000..9e0cc1031c --- /dev/null +++ b/packages/components/src/components/post-test-form/readme.md @@ -0,0 +1,33 @@ +# post-test-form + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| -------- | ---------- | --------------- | -------- | ----------- | +| `theId` | `the-id` | Defines the id | `string` | `undefined` | +| `theId2` | `the-id-2` | Defines the id2 | `string` | `undefined` | + + +## Dependencies + +### Depends on + +- [post-test-input](../post-test-input) +- [post-test-label](../post-test-label) + +### Graph +```mermaid +graph TD; + post-test-form --> post-test-input + post-test-form --> post-test-label + style post-test-form fill:#f9f,stroke:#333,stroke-width:4px +``` + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-input/post-test-input.scss b/packages/components/src/components/post-test-input/post-test-input.scss new file mode 100644 index 0000000000..4cd9a272da --- /dev/null +++ b/packages/components/src/components/post-test-input/post-test-input.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/core' as post; diff --git a/packages/components/src/components/post-test-input/post-test-input.tsx b/packages/components/src/components/post-test-input/post-test-input.tsx new file mode 100644 index 0000000000..aa49f88221 --- /dev/null +++ b/packages/components/src/components/post-test-input/post-test-input.tsx @@ -0,0 +1,23 @@ +import { Component, h, Host, Prop } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-input', + styleUrl: 'post-test-input.scss', + shadow: true, +}) +export class PostTestInput { + /** + * Defines the inputId + */ + @Prop() inputId?: string; + + render() { + return ( + + + + + ); + } +} diff --git a/packages/components/src/components/post-test-input/readme.md b/packages/components/src/components/post-test-input/readme.md new file mode 100644 index 0000000000..95c6d6d3d2 --- /dev/null +++ b/packages/components/src/components/post-test-input/readme.md @@ -0,0 +1,30 @@ +# post-test-input + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| --------- | ---------- | ------------------- | -------- | ----------- | +| `inputId` | `input-id` | Defines the inputId | `string` | `undefined` | + + +## Dependencies + +### Used by + + - [post-test-form](../post-test-form) + +### Graph +```mermaid +graph TD; + post-test-form --> post-test-input + style post-test-input fill:#f9f,stroke:#333,stroke-width:4px +``` + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-label/post-test-label.scss b/packages/components/src/components/post-test-label/post-test-label.scss new file mode 100644 index 0000000000..4cd9a272da --- /dev/null +++ b/packages/components/src/components/post-test-label/post-test-label.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/core' as post; diff --git a/packages/components/src/components/post-test-label/post-test-label.tsx b/packages/components/src/components/post-test-label/post-test-label.tsx new file mode 100644 index 0000000000..05a0d03041 --- /dev/null +++ b/packages/components/src/components/post-test-label/post-test-label.tsx @@ -0,0 +1,23 @@ +import { Component, h, Host, Prop } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-label', + styleUrl: 'post-test-label.scss', + shadow: true, +}) +export class PostTestLabel { + /** + * Defines the for + */ + @Prop() for?: string; + + render() { + return ( + + + + + ); + } +} diff --git a/packages/components/src/components/post-test-label/readme.md b/packages/components/src/components/post-test-label/readme.md new file mode 100644 index 0000000000..f083cd1caf --- /dev/null +++ b/packages/components/src/components/post-test-label/readme.md @@ -0,0 +1,30 @@ +# post-avatar + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| -------- | --------- | --------------- | -------- | ----------- | +| `for` | `for` | Defines the for | `string` | `undefined` | + + +## Dependencies + +### Used by + + - [post-test-form](../post-test-form) + +### Graph +```mermaid +graph TD; + post-test-form --> post-test-label + style post-test-label fill:#f9f,stroke:#333,stroke-width:4px +``` + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/index.html b/packages/components/src/index.html index f64c03976c..3358a60d0a 100644 --- a/packages/components/src/index.html +++ b/packages/components/src/index.html @@ -178,5 +178,6 @@

Components package playground


+ diff --git a/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx b/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx new file mode 100644 index 0000000000..975f56bd1c --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx @@ -0,0 +1,8 @@ +import { Meta, Canvas } from '@storybook/blocks'; +import * as CCR from './ccr.stories'; + + + +# Cross Component Referencing + +## for/id ``, `` diff --git a/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts b/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts new file mode 100644 index 0000000000..03cbba90e8 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts @@ -0,0 +1,16 @@ +import { StoryObj } from '@storybook/web-components'; +import { MetaExtended } from '@root/types'; + +const meta: MetaExtended = { + id: '76ade552-2c03-4d6d-9dce-28daa340f7d3', + title: 'Guidelines/Cross Component Referencing', + parameters: { + badges: [], + }, +}; + +export default meta; + +type Story = StoryObj; + +export const Default: Story = {}; From 3f6d8327ebd8d9170fd723edc9baec204edc9b93 Mon Sep 17 00:00:00 2001 From: Myrta Sakellariou Date: Mon, 5 May 2025 14:14:38 +0200 Subject: [PATCH 02/26] documenting examples --- packages/components/src/components.d.ts | 124 ++++++++++++-- .../post-test-example/post-test-example.scss | 1 + .../post-test-example/post-test-example.tsx | 24 +++ .../components/post-test-example/readme.md | 17 ++ .../post-test-example2.scss | 1 + .../post-test-example2/post-test-example2.tsx | 66 ++++++++ .../components/post-test-example2/readme.md | 19 +++ .../post-test-example3.scss | 1 + .../post-test-example3/post-test-example3.tsx | 60 +++++++ .../components/post-test-example3/readme.md | 19 +++ .../post-test-form/post-test-form.scss | 1 - .../post-test-form/post-test-form.tsx | 34 ---- .../src/components/post-test-form/readme.md | 33 ---- .../post-test-input/post-test-input.scss | 2 +- .../post-test-input/post-test-input.tsx | 51 +++++- .../src/components/post-test-input/readme.md | 21 +-- .../post-test-label/post-test-label.scss | 2 +- .../post-test-label/post-test-label.tsx | 30 +++- .../src/components/post-test-label/readme.md | 21 +-- .../src/stories/guidelines/ccr/ccr.docs.mdx | 106 +++++++++++- .../src/stories/guidelines/ccr/ccr.stories.ts | 160 +++++++++++++++++- .../stories/guidelines/ccr/ccr.styles.scss | 0 .../guidelines/ccr/example0.sample.html | 5 + .../guidelines/ccr/example1.sample.html | 5 + .../guidelines/ccr/example2.sample.html | 7 + .../guidelines/ccr/example3.sample.html | 7 + .../guidelines/ccr/example4.sample.html | 6 + .../guidelines/ccr/example5.sample.html | 7 + .../guidelines/ccr/example6.sample.html | 8 + 29 files changed, 715 insertions(+), 123 deletions(-) create mode 100644 packages/components/src/components/post-test-example/post-test-example.scss create mode 100644 packages/components/src/components/post-test-example/post-test-example.tsx create mode 100644 packages/components/src/components/post-test-example/readme.md create mode 100644 packages/components/src/components/post-test-example2/post-test-example2.scss create mode 100644 packages/components/src/components/post-test-example2/post-test-example2.tsx create mode 100644 packages/components/src/components/post-test-example2/readme.md create mode 100644 packages/components/src/components/post-test-example3/post-test-example3.scss create mode 100644 packages/components/src/components/post-test-example3/post-test-example3.tsx create mode 100644 packages/components/src/components/post-test-example3/readme.md delete mode 100644 packages/components/src/components/post-test-form/post-test-form.scss delete mode 100644 packages/components/src/components/post-test-form/post-test-form.tsx delete mode 100644 packages/components/src/components/post-test-form/readme.md create mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.styles.scss create mode 100644 packages/documentation/src/stories/guidelines/ccr/example0.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example1.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example2.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example3.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example4.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example5.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/example6.sample.html diff --git a/packages/components/src/components.d.ts b/packages/components/src/components.d.ts index 1f0604ccff..3a329be517 100644 --- a/packages/components/src/components.d.ts +++ b/packages/components/src/components.d.ts @@ -464,27 +464,67 @@ export namespace Components { */ "variant": 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } - interface PostTestForm { + interface PostTestExample { + /** + * Defines the id + */ + "theId"?: string; + } + interface PostTestExample2 { + /** + * Defines the text of the retrieved label + */ + "foundLabelText"?: string; + /** + * Defines the id + */ + "theId"?: string; + /** + * Defines the selected workaround + */ + "workaround"?: string; + } + interface PostTestExample3 { + /** + * Defines the text of the retrieved label + */ + "foundLabelText"?: string; /** * Defines the id */ "theId"?: string; /** - * Defines the id2 + * Defines the selected workaround */ - "theId2"?: string; + "workaround"?: string; } interface PostTestInput { + /** + * Defines the selected workaround + */ + "foundLabelText"?: string; /** * Defines the inputId */ "inputId"?: string; + /** + * Defines the selected workaround + */ + "workaround"?: string; } interface PostTestLabel { /** * Defines the for */ "for"?: string; + /** + * Defines the label text + */ + "labelText": string; + /** + * Defines the selected workaround + */ + "workaround"?: string; } interface PostTogglebutton { /** @@ -881,11 +921,23 @@ declare global { prototype: HTMLPostTagElement; new (): HTMLPostTagElement; }; - interface HTMLPostTestFormElement extends Components.PostTestForm, HTMLStencilElement { + interface HTMLPostTestExampleElement extends Components.PostTestExample, HTMLStencilElement { + } + var HTMLPostTestExampleElement: { + prototype: HTMLPostTestExampleElement; + new (): HTMLPostTestExampleElement; + }; + interface HTMLPostTestExample2Element extends Components.PostTestExample2, HTMLStencilElement { } - var HTMLPostTestFormElement: { - prototype: HTMLPostTestFormElement; - new (): HTMLPostTestFormElement; + var HTMLPostTestExample2Element: { + prototype: HTMLPostTestExample2Element; + new (): HTMLPostTestExample2Element; + }; + interface HTMLPostTestExample3Element extends Components.PostTestExample3, HTMLStencilElement { + } + var HTMLPostTestExample3Element: { + prototype: HTMLPostTestExample3Element; + new (): HTMLPostTestExample3Element; }; interface HTMLPostTestInputElement extends Components.PostTestInput, HTMLStencilElement { } @@ -945,7 +997,9 @@ declare global { "post-tab-panel": HTMLPostTabPanelElement; "post-tabs": HTMLPostTabsElement; "post-tag": HTMLPostTagElement; - "post-test-form": HTMLPostTestFormElement; + "post-test-example": HTMLPostTestExampleElement; + "post-test-example2": HTMLPostTestExample2Element; + "post-test-example3": HTMLPostTestExample3Element; "post-test-input": HTMLPostTestInputElement; "post-test-label": HTMLPostTestLabelElement; "post-togglebutton": HTMLPostTogglebuttonElement; @@ -1346,27 +1400,67 @@ declare namespace LocalJSX { */ "variant"?: 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } - interface PostTestForm { + interface PostTestExample { + /** + * Defines the id + */ + "theId"?: string; + } + interface PostTestExample2 { + /** + * Defines the text of the retrieved label + */ + "foundLabelText"?: string; + /** + * Defines the id + */ + "theId"?: string; + /** + * Defines the selected workaround + */ + "workaround"?: string; + } + interface PostTestExample3 { + /** + * Defines the text of the retrieved label + */ + "foundLabelText"?: string; /** * Defines the id */ "theId"?: string; /** - * Defines the id2 + * Defines the selected workaround */ - "theId2"?: string; + "workaround"?: string; } interface PostTestInput { + /** + * Defines the selected workaround + */ + "foundLabelText"?: string; /** * Defines the inputId */ "inputId"?: string; + /** + * Defines the selected workaround + */ + "workaround"?: string; } interface PostTestLabel { /** * Defines the for */ "for"?: string; + /** + * Defines the label text + */ + "labelText"?: string; + /** + * Defines the selected workaround + */ + "workaround"?: string; } interface PostTogglebutton { /** @@ -1422,7 +1516,9 @@ declare namespace LocalJSX { "post-tab-panel": PostTabPanel; "post-tabs": PostTabs; "post-tag": PostTag; - "post-test-form": PostTestForm; + "post-test-example": PostTestExample; + "post-test-example2": PostTestExample2; + "post-test-example3": PostTestExample3; "post-test-input": PostTestInput; "post-test-label": PostTestLabel; "post-togglebutton": PostTogglebutton; @@ -1472,7 +1568,9 @@ declare module "@stencil/core" { "post-tab-panel": LocalJSX.PostTabPanel & JSXBase.HTMLAttributes; "post-tabs": LocalJSX.PostTabs & JSXBase.HTMLAttributes; "post-tag": LocalJSX.PostTag & JSXBase.HTMLAttributes; - "post-test-form": LocalJSX.PostTestForm & JSXBase.HTMLAttributes; + "post-test-example": LocalJSX.PostTestExample & JSXBase.HTMLAttributes; + "post-test-example2": LocalJSX.PostTestExample2 & JSXBase.HTMLAttributes; + "post-test-example3": LocalJSX.PostTestExample3 & JSXBase.HTMLAttributes; "post-test-input": LocalJSX.PostTestInput & JSXBase.HTMLAttributes; "post-test-label": LocalJSX.PostTestLabel & JSXBase.HTMLAttributes; "post-togglebutton": LocalJSX.PostTogglebutton & JSXBase.HTMLAttributes; diff --git a/packages/components/src/components/post-test-example/post-test-example.scss b/packages/components/src/components/post-test-example/post-test-example.scss new file mode 100644 index 0000000000..28612a51ef --- /dev/null +++ b/packages/components/src/components/post-test-example/post-test-example.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/post-default.scss'; diff --git a/packages/components/src/components/post-test-example/post-test-example.tsx b/packages/components/src/components/post-test-example/post-test-example.tsx new file mode 100644 index 0000000000..093f159b3f --- /dev/null +++ b/packages/components/src/components/post-test-example/post-test-example.tsx @@ -0,0 +1,24 @@ +import { Component, h, Host, Prop } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-example', + styleUrl: 'post-test-example.scss', + shadow: true, +}) +export class PostTestExample { + /** + * Defines the id + */ + @Prop() theId?: string; + + render() { + return ( + // Shadow DOM - Same Shadow DOM + + + + + ); + } +} diff --git a/packages/components/src/components/post-test-example/readme.md b/packages/components/src/components/post-test-example/readme.md new file mode 100644 index 0000000000..4126c2f6b3 --- /dev/null +++ b/packages/components/src/components/post-test-example/readme.md @@ -0,0 +1,17 @@ +# post-test-form + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| -------- | --------- | -------------- | -------- | ----------- | +| `theId` | `the-id` | Defines the id | `string` | `undefined` | + + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-example2/post-test-example2.scss b/packages/components/src/components/post-test-example2/post-test-example2.scss new file mode 100644 index 0000000000..28612a51ef --- /dev/null +++ b/packages/components/src/components/post-test-example2/post-test-example2.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/post-default.scss'; diff --git a/packages/components/src/components/post-test-example2/post-test-example2.tsx b/packages/components/src/components/post-test-example2/post-test-example2.tsx new file mode 100644 index 0000000000..2d7dbfc01c --- /dev/null +++ b/packages/components/src/components/post-test-example2/post-test-example2.tsx @@ -0,0 +1,66 @@ +import { Component, h, Host, Prop } from '@stencil/core'; +import { version } from '@root/package.json'; + +declare interface HTMLInputElementPlus extends HTMLInputElement { + ariaLabelledByElements: Element | Element[] | null; +} + +@Component({ + tag: 'post-test-example2', + styleUrl: 'post-test-example2.scss', + shadow: true, +}) +export class PostTestExample2 { + /** + * Defines the id + */ + @Prop() theId?: string; + + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + /** + * Defines the text of the retrieved label + */ + @Prop() foundLabelText?: string; + + private updateWorkaround() { + const lightDOMLabel = document.querySelector(`label[for="${this.theId}"]`); + + if (this.workaround == 'ariamixin') { + const customElement = document.querySelector(`post-test-example2[the-id="${this.theId}"]`); + const internalInput = customElement.shadowRoot.querySelector('input') as HTMLInputElementPlus; + internalInput.ariaLabelledByElements = [lightDOMLabel]; + } + if (this.workaround == 'arialabel') { + const lightDOMLabel = document.querySelector(`label[for="${this.theId}"]`); + if (lightDOMLabel) { + this.foundLabelText = lightDOMLabel.textContent; + } + } + } + componentDidLoad() { + this.updateWorkaround(); + } + + componentDidUpdate() { + this.updateWorkaround(); + } + + render() { + return ( + //Slotted Content - Shadow DOM (since slotted content is in the Light DOM) + + + + + ); + } +} diff --git a/packages/components/src/components/post-test-example2/readme.md b/packages/components/src/components/post-test-example2/readme.md new file mode 100644 index 0000000000..40a871a653 --- /dev/null +++ b/packages/components/src/components/post-test-example2/readme.md @@ -0,0 +1,19 @@ +# post-test-form + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| ---------------- | ------------------ | --------------------------------------- | -------- | ----------- | +| `foundLabelText` | `found-label-text` | Defines the text of the retrieved label | `string` | `undefined` | +| `theId` | `the-id` | Defines the id | `string` | `undefined` | +| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | + + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-example3/post-test-example3.scss b/packages/components/src/components/post-test-example3/post-test-example3.scss new file mode 100644 index 0000000000..28612a51ef --- /dev/null +++ b/packages/components/src/components/post-test-example3/post-test-example3.scss @@ -0,0 +1 @@ +@use '@swisspost/design-system-styles/post-default.scss'; diff --git a/packages/components/src/components/post-test-example3/post-test-example3.tsx b/packages/components/src/components/post-test-example3/post-test-example3.tsx new file mode 100644 index 0000000000..372e29d998 --- /dev/null +++ b/packages/components/src/components/post-test-example3/post-test-example3.tsx @@ -0,0 +1,60 @@ +import { Component, h, Host, Prop, Element } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-example3', + styleUrl: 'post-test-example3.scss', + shadow: true, +}) +export class PostTestExample3 { + @Element() host: HTMLPostTestExample3Element; + + /** + * Defines the id + */ + @Prop() theId?: string; + + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + /** + * Defines the text of the retrieved label + */ + @Prop() foundLabelText?: string; + + private setAriaLabel() { + const selector = `#${this.theId}`; + const targetInput = document.querySelector(selector); + + const lightDOMLabel = this.host.shadowRoot.querySelector(`label[for="${this.theId}"]`); + + if (lightDOMLabel) { + this.foundLabelText = lightDOMLabel.textContent; + } + if (this.workaround == 'arialabel') { + targetInput.setAttribute('aria-label', this.foundLabelText); + } else { + targetInput.removeAttribute('aria-label'); + } + } + + componentDidLoad() { + this.setAriaLabel(); + } + + componentDidUpdate() { + this.setAriaLabel(); + } + + render() { + return ( + // Shadow DOM - Light DOM + + + + + ); + } +} diff --git a/packages/components/src/components/post-test-example3/readme.md b/packages/components/src/components/post-test-example3/readme.md new file mode 100644 index 0000000000..40a871a653 --- /dev/null +++ b/packages/components/src/components/post-test-example3/readme.md @@ -0,0 +1,19 @@ +# post-test-form + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| ---------------- | ------------------ | --------------------------------------- | -------- | ----------- | +| `foundLabelText` | `found-label-text` | Defines the text of the retrieved label | `string` | `undefined` | +| `theId` | `the-id` | Defines the id | `string` | `undefined` | +| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | + + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-form/post-test-form.scss b/packages/components/src/components/post-test-form/post-test-form.scss deleted file mode 100644 index 4cd9a272da..0000000000 --- a/packages/components/src/components/post-test-form/post-test-form.scss +++ /dev/null @@ -1 +0,0 @@ -@use '@swisspost/design-system-styles/core' as post; diff --git a/packages/components/src/components/post-test-form/post-test-form.tsx b/packages/components/src/components/post-test-form/post-test-form.tsx deleted file mode 100644 index 5be2601253..0000000000 --- a/packages/components/src/components/post-test-form/post-test-form.tsx +++ /dev/null @@ -1,34 +0,0 @@ -import { Component, h, Host, Prop } from '@stencil/core'; -import { version } from '@root/package.json'; - -@Component({ - tag: 'post-test-form', - styleUrl: 'post-test-form.scss', - shadow: true, -}) -export class PostTestForm { - /** - * Defines the id - */ - @Prop() theId?: string; - - /** - * Defines the id2 - */ - @Prop() theId2?: string; - - render() { - return ( - - - -
- - -
-
- ); - } -} diff --git a/packages/components/src/components/post-test-form/readme.md b/packages/components/src/components/post-test-form/readme.md deleted file mode 100644 index 9e0cc1031c..0000000000 --- a/packages/components/src/components/post-test-form/readme.md +++ /dev/null @@ -1,33 +0,0 @@ -# post-test-form - - - - - - -## Properties - -| Property | Attribute | Description | Type | Default | -| -------- | ---------- | --------------- | -------- | ----------- | -| `theId` | `the-id` | Defines the id | `string` | `undefined` | -| `theId2` | `the-id-2` | Defines the id2 | `string` | `undefined` | - - -## Dependencies - -### Depends on - -- [post-test-input](../post-test-input) -- [post-test-label](../post-test-label) - -### Graph -```mermaid -graph TD; - post-test-form --> post-test-input - post-test-form --> post-test-label - style post-test-form fill:#f9f,stroke:#333,stroke-width:4px -``` - ----------------------------------------------- - -*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-input/post-test-input.scss b/packages/components/src/components/post-test-input/post-test-input.scss index 4cd9a272da..28612a51ef 100644 --- a/packages/components/src/components/post-test-input/post-test-input.scss +++ b/packages/components/src/components/post-test-input/post-test-input.scss @@ -1 +1 @@ -@use '@swisspost/design-system-styles/core' as post; +@use '@swisspost/design-system-styles/post-default.scss'; diff --git a/packages/components/src/components/post-test-input/post-test-input.tsx b/packages/components/src/components/post-test-input/post-test-input.tsx index aa49f88221..76f3d4fe88 100644 --- a/packages/components/src/components/post-test-input/post-test-input.tsx +++ b/packages/components/src/components/post-test-input/post-test-input.tsx @@ -1,21 +1,68 @@ -import { Component, h, Host, Prop } from '@stencil/core'; +import { Component, h, Host, Prop, Element } from '@stencil/core'; import { version } from '@root/package.json'; +declare interface HTMLInputElementPlus extends HTMLInputElement { + ariaLabelledByElements: Element | Element[] | null; +} + @Component({ tag: 'post-test-input', styleUrl: 'post-test-input.scss', shadow: true, }) export class PostTestInput { + @Element() host: HTMLPostTestInputElement; /** * Defines the inputId */ @Prop() inputId?: string; + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + /** + * Defines the selected workaround + */ + @Prop() foundLabelText?: string; + + private updateWorkaround() { + const lightDOMLabel = document.querySelector(`label[for="${this.inputId}"]`); + const customElement = document.querySelector(`post-test-input[input-id="${this.inputId}"]`); + const internalInput = customElement.shadowRoot.querySelector('input') as HTMLInputElementPlus; + if (this.workaround == 'ariamixin') { + internalInput.ariaLabelledByElements = [lightDOMLabel]; + } else { + internalInput.ariaLabelledByElements = null; + } + if (this.workaround == 'arialabel') { + const lightDOMLabel = document.querySelector(`label[for="${this.inputId}"]`); + console.log(lightDOMLabel); + if (lightDOMLabel) { + this.foundLabelText = lightDOMLabel.textContent; + } + } + } + + componentDidLoad() { + this.updateWorkaround(); + } + + componentDidUpdate() { + this.updateWorkaround(); + } + render() { return ( - + ); diff --git a/packages/components/src/components/post-test-input/readme.md b/packages/components/src/components/post-test-input/readme.md index 95c6d6d3d2..563058ba43 100644 --- a/packages/components/src/components/post-test-input/readme.md +++ b/packages/components/src/components/post-test-input/readme.md @@ -7,24 +7,13 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| --------- | ---------- | ------------------- | -------- | ----------- | -| `inputId` | `input-id` | Defines the inputId | `string` | `undefined` | +| Property | Attribute | Description | Type | Default | +| ---------------- | ------------------ | ------------------------------- | -------- | ----------- | +| `foundLabelText` | `found-label-text` | Defines the selected workaround | `string` | `undefined` | +| `inputId` | `input-id` | Defines the inputId | `string` | `undefined` | +| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | -## Dependencies - -### Used by - - - [post-test-form](../post-test-form) - -### Graph -```mermaid -graph TD; - post-test-form --> post-test-input - style post-test-input fill:#f9f,stroke:#333,stroke-width:4px -``` - ---------------------------------------------- *Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-label/post-test-label.scss b/packages/components/src/components/post-test-label/post-test-label.scss index 4cd9a272da..28612a51ef 100644 --- a/packages/components/src/components/post-test-label/post-test-label.scss +++ b/packages/components/src/components/post-test-label/post-test-label.scss @@ -1 +1 @@ -@use '@swisspost/design-system-styles/core' as post; +@use '@swisspost/design-system-styles/post-default.scss'; diff --git a/packages/components/src/components/post-test-label/post-test-label.tsx b/packages/components/src/components/post-test-label/post-test-label.tsx index 05a0d03041..e1685988ee 100644 --- a/packages/components/src/components/post-test-label/post-test-label.tsx +++ b/packages/components/src/components/post-test-label/post-test-label.tsx @@ -12,10 +12,38 @@ export class PostTestLabel { */ @Prop() for?: string; + /** + * Defines the label text + */ + @Prop() labelText: string; + + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + private setAriaLabel() { + const selector = `#${this.for}`; + const targetInput = document.querySelector(selector); + if (this.workaround == 'arialabel') { + targetInput.setAttribute('aria-label', this.labelText); + } else { + targetInput.removeAttribute('aria-label'); + } + } + + componentDidLoad() { + this.setAriaLabel(); + } + + componentDidUpdate() { + this.setAriaLabel(); + } + render() { return ( - + ); diff --git a/packages/components/src/components/post-test-label/readme.md b/packages/components/src/components/post-test-label/readme.md index f083cd1caf..b0336611a0 100644 --- a/packages/components/src/components/post-test-label/readme.md +++ b/packages/components/src/components/post-test-label/readme.md @@ -7,24 +7,13 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| -------- | --------- | --------------- | -------- | ----------- | -| `for` | `for` | Defines the for | `string` | `undefined` | +| Property | Attribute | Description | Type | Default | +| ------------ | ------------ | ------------------------------- | -------- | ----------- | +| `for` | `for` | Defines the for | `string` | `undefined` | +| `labelText` | `label-text` | Defines the label text | `string` | `undefined` | +| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | -## Dependencies - -### Used by - - - [post-test-form](../post-test-form) - -### Graph -```mermaid -graph TD; - post-test-form --> post-test-label - style post-test-label fill:#f9f,stroke:#333,stroke-width:4px -``` - ---------------------------------------------- *Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx b/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx index 975f56bd1c..cfcd3db631 100644 --- a/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx +++ b/packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx @@ -1,8 +1,108 @@ -import { Meta, Canvas } from '@storybook/blocks'; +import { Meta, Canvas, Source, Controls } from '@storybook/blocks'; import * as CCR from './ccr.stories'; +import example0 from './example0.sample.html?raw'; +import example1 from './example1.sample.html?raw'; +import example2 from './example2.sample.html?raw'; +import example3 from './example3.sample.html?raw'; +import example4 from './example4.sample.html?raw'; +import example5 from './example5.sample.html?raw'; +import example6 from './example6.sample.html?raw'; +import './ccr.styles.scss'; -# Cross Component Referencing +# Cross Component Referencing Cases -## for/id ``, `` +## 1. `for`/ `id` + +#### I. Referencing Within the Same DOM Tree + +
    +
  • Light DOM → Light DOM
  • + +Rendered Code Example + + +
  • Shadow DOM → Same Shadow DOM
  • + +Rendered Code Example + +
+ +#### II. Referencing From Outside a Shadow DOM Into That Shadow DOM + +
    +
  • Light DOM → Shadow DOM
  • + +
    + +
    + Rendered Code Example + +
  • Slotted Content → Shadow DOM
  • + +
    + +
    + +
+ +
→ Workarounds
+ +
    +
  • Stick to the light and set the `shadow:false`.
  • +
  • + Use the `ariaLabelledByElements`: This has limited coverage ( ariaLabelledByElements Usage) and works only if the referencing element is in the light DOM and the referenced element in the shadowDom. +
  • +
  • Use `aria-label` with the label text directly on the `` element.
  • +
+ +### III. Referencing From Inside a Shadow DOM Out to the Light DOM + +
    +
  • Shadow DOM → Light DOM
  • + +
    + +
    + +
  • Shadow DOM → Slotted Content
  • + +
    + +
    + +
+ +
→ Workarounds
+ +
    +
  • Stick to the light and set the `shadow:false`.
  • +
  • Use `aria-label` with the label text directly on the `` element.
  • +
+ +### IV. Referencing From One Shadow DOM To Another Shadow DOM + +
    +
  • Shadow DOM → Other Shadow DOM
  • + +
    + +
    + +
+ +
→ Workarounds
+ +
    +
  • Set both components to `shadow:false`.
  • +
  • Use `aria-label` with the label text directly on the `` element.
  • +
+ +## 2. `aria-labelledby` + +## 3. `aria-describedby` + +## 4. `aria-controls` + +## 3. `role` diff --git a/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts b/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts index 03cbba90e8..db67b56250 100644 --- a/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts +++ b/packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts @@ -1,5 +1,6 @@ -import { StoryObj } from '@storybook/web-components'; +import { StoryObj, Args } from '@storybook/web-components'; import { MetaExtended } from '@root/types'; +import { html } from 'lit'; const meta: MetaExtended = { id: '76ade552-2c03-4d6d-9dce-28daa340f7d3', @@ -13,4 +14,159 @@ export default meta; type Story = StoryObj; -export const Default: Story = {}; +export const ExampleHTML: Story = { + render: () => html` +
+ + +
+ `, +}; + +export const Example1: Story = { + render: () => html` `, +}; + +export const Example2: Story = { + argTypes: { + label: { + name: 'Label Text', + control: { + type: 'text', + }, + }, + workaround: { + name: 'Workaround', + control: { + type: 'radio', + }, + options: ['none', 'ariamixin', 'arialabel'], + }, + }, + args: { + workaround: 'none', + label: 'Label Text', + }, + render: (args: Args) => html` + + + `, +}; + +export const Example3: Story = { + argTypes: { + label: { + name: 'Label Text', + control: { + type: 'text', + }, + }, + workaround: { + name: 'Workaround', + control: { + type: 'radio', + }, + options: ['none', 'ariamixin', 'arialabel'], + }, + }, + args: { + workaround: 'none', + label: 'Label Text', + }, + render: (args: Args) => html` + + + + `, +}; + +export const Example4: Story = { + argTypes: { + label: { + name: 'Label Text', + control: { + type: 'text', + }, + }, + workaround: { + name: 'Workaround', + control: { + type: 'radio', + }, + options: ['none', 'arialabel'], + }, + }, + args: { + workaround: 'none', + label: 'Label Text', + }, + render: (args: Args) => html` + + + `, +}; + +export const Example5: Story = { + argTypes: { + label: { + name: 'Label Text', + control: { + type: 'text', + }, + }, + workaround: { + name: 'Workaround', + control: { + type: 'radio', + }, + options: ['none', 'arialabel'], + }, + }, + args: { + workaround: 'none', + label: 'Label Text', + }, + render: (args: Args) => html` + + `, +}; + +export const Example6: Story = { + argTypes: { + label: { + name: 'Label Text', + control: { + type: 'text', + }, + }, + workaround: { + name: 'Workaround', + control: { + type: 'radio', + }, + options: ['none', 'arialabel'], + }, + }, + args: { + workaround: 'none', + label: 'Label Text', + }, + render: (args: Args) => html` + `, +}; diff --git a/packages/documentation/src/stories/guidelines/ccr/ccr.styles.scss b/packages/documentation/src/stories/guidelines/ccr/ccr.styles.scss new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/documentation/src/stories/guidelines/ccr/example0.sample.html b/packages/documentation/src/stories/guidelines/ccr/example0.sample.html new file mode 100644 index 0000000000..0dbf07a414 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example0.sample.html @@ -0,0 +1,5 @@ + +
+ + +
diff --git a/packages/documentation/src/stories/guidelines/ccr/example1.sample.html b/packages/documentation/src/stories/guidelines/ccr/example1.sample.html new file mode 100644 index 0000000000..2354f16ca1 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example1.sample.html @@ -0,0 +1,5 @@ + + + + + diff --git a/packages/documentation/src/stories/guidelines/ccr/example2.sample.html b/packages/documentation/src/stories/guidelines/ccr/example2.sample.html new file mode 100644 index 0000000000..628c4bd668 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example2.sample.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages/documentation/src/stories/guidelines/ccr/example3.sample.html b/packages/documentation/src/stories/guidelines/ccr/example3.sample.html new file mode 100644 index 0000000000..67b7655817 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example3.sample.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages/documentation/src/stories/guidelines/ccr/example4.sample.html b/packages/documentation/src/stories/guidelines/ccr/example4.sample.html new file mode 100644 index 0000000000..38201e361a --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example4.sample.html @@ -0,0 +1,6 @@ + + + + + + diff --git a/packages/documentation/src/stories/guidelines/ccr/example5.sample.html b/packages/documentation/src/stories/guidelines/ccr/example5.sample.html new file mode 100644 index 0000000000..ba20cb48f7 --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example5.sample.html @@ -0,0 +1,7 @@ + + + + + + + diff --git a/packages/documentation/src/stories/guidelines/ccr/example6.sample.html b/packages/documentation/src/stories/guidelines/ccr/example6.sample.html new file mode 100644 index 0000000000..729201d54c --- /dev/null +++ b/packages/documentation/src/stories/guidelines/ccr/example6.sample.html @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From 7e6e7d2f5c90aeaa2d8613add51a1afa86222525 Mon Sep 17 00:00:00 2001 From: Myrta Sakellariou Date: Thu, 8 May 2025 13:20:53 +0200 Subject: [PATCH 03/26] more investigation --- packages/components/src/components.d.ts | 182 +++++++++--------- .../src/components/post-icon/readme.md | 2 + .../post-test-button.scss} | 0 .../post-test-button.tsx} | 13 +- .../readme.md | 13 ++ .../post-test-example2/post-test-example2.tsx | 66 ------- .../components/post-test-example2/readme.md | 19 -- .../post-test-example3/post-test-example3.tsx | 60 ------ .../components/post-test-example3/readme.md | 19 -- .../post-test-input/post-test-input.tsx | 70 ------- .../src/components/post-test-input/readme.md | 19 -- .../post-test-label/post-test-label.tsx | 33 +--- .../src/components/post-test-label/readme.md | 8 +- .../post-test-span.scss} | 0 .../post-test-span/post-test-span.tsx | 60 ++++++ .../src/components/post-test-span/readme.md | 20 ++ .../post-test-target.scss} | 0 .../post-test-target/post-test-target.tsx | 58 ++++++ .../src/components/post-test-target/readme.md | 16 ++ .../post-test-target2.scss} | 0 .../post-test-target2/post-test-target2.tsx | 50 +++++ .../components/post-test-target2/readme.md | 15 ++ .../post-test-target3/post-test-target3.scss | 1 + .../post-test-target3/post-test-target3.tsx | 20 ++ .../components/post-test-target3/readme.md | 8 + .../post-test-target4/post-test-target4.scss | 1 + .../post-test-target4/post-test-target4.tsx | 52 +++++ .../components/post-test-target4/readme.md | 8 + packages/components/src/index.html | 3 +- .../ccr/arialabelled/arialabelled.docs.mdx | 54 ++++++ .../ccr/arialabelled/arialabelled.stories.ts | 47 +++++ .../src/stories/guidelines/ccr/ccr.docs.mdx | 108 ----------- .../src/stories/guidelines/ccr/ccr.stories.ts | 172 ----------------- .../stories/guidelines/ccr/ccr.styles.scss | 0 .../guidelines/ccr/example0.sample.html | 5 - .../guidelines/ccr/example1.sample.html | 5 - .../guidelines/ccr/example2.sample.html | 7 - .../guidelines/ccr/example3.sample.html | 7 - .../guidelines/ccr/example4.sample.html | 6 - .../guidelines/ccr/example5.sample.html | 7 - .../guidelines/ccr/example6.sample.html | 8 - .../guidelines/ccr/forid/forid.docs.mdx | 98 ++++++++++ .../guidelines/ccr/forid/forid.stories.ts | 109 +++++++++++ 43 files changed, 739 insertions(+), 710 deletions(-) rename packages/components/src/components/{post-test-example/post-test-example.scss => post-test-button/post-test-button.scss} (100%) rename packages/components/src/components/{post-test-example/post-test-example.tsx => post-test-button/post-test-button.tsx} (52%) rename packages/components/src/components/{post-test-example => post-test-button}/readme.md (65%) delete mode 100644 packages/components/src/components/post-test-example2/post-test-example2.tsx delete mode 100644 packages/components/src/components/post-test-example2/readme.md delete mode 100644 packages/components/src/components/post-test-example3/post-test-example3.tsx delete mode 100644 packages/components/src/components/post-test-example3/readme.md delete mode 100644 packages/components/src/components/post-test-input/post-test-input.tsx delete mode 100644 packages/components/src/components/post-test-input/readme.md rename packages/components/src/components/{post-test-example2/post-test-example2.scss => post-test-span/post-test-span.scss} (100%) create mode 100644 packages/components/src/components/post-test-span/post-test-span.tsx create mode 100644 packages/components/src/components/post-test-span/readme.md rename packages/components/src/components/{post-test-example3/post-test-example3.scss => post-test-target/post-test-target.scss} (100%) create mode 100644 packages/components/src/components/post-test-target/post-test-target.tsx create mode 100644 packages/components/src/components/post-test-target/readme.md rename packages/components/src/components/{post-test-input/post-test-input.scss => post-test-target2/post-test-target2.scss} (100%) create mode 100644 packages/components/src/components/post-test-target2/post-test-target2.tsx create mode 100644 packages/components/src/components/post-test-target2/readme.md create mode 100644 packages/components/src/components/post-test-target3/post-test-target3.scss create mode 100644 packages/components/src/components/post-test-target3/post-test-target3.tsx create mode 100644 packages/components/src/components/post-test-target3/readme.md create mode 100644 packages/components/src/components/post-test-target4/post-test-target4.scss create mode 100644 packages/components/src/components/post-test-target4/post-test-target4.tsx create mode 100644 packages/components/src/components/post-test-target4/readme.md create mode 100644 packages/documentation/src/stories/guidelines/ccr/arialabelled/arialabelled.docs.mdx create mode 100644 packages/documentation/src/stories/guidelines/ccr/arialabelled/arialabelled.stories.ts delete mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.docs.mdx delete mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.stories.ts delete mode 100644 packages/documentation/src/stories/guidelines/ccr/ccr.styles.scss delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example0.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example1.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example2.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example3.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example4.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example5.sample.html delete mode 100644 packages/documentation/src/stories/guidelines/ccr/example6.sample.html create mode 100644 packages/documentation/src/stories/guidelines/ccr/forid/forid.docs.mdx create mode 100644 packages/documentation/src/stories/guidelines/ccr/forid/forid.stories.ts diff --git a/packages/components/src/components.d.ts b/packages/components/src/components.d.ts index 3a329be517..e5e47cebc4 100644 --- a/packages/components/src/components.d.ts +++ b/packages/components/src/components.d.ts @@ -464,68 +464,56 @@ export namespace Components { */ "variant": 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } - interface PostTestExample { + interface PostTestButton { /** * Defines the id */ "theId"?: string; } - interface PostTestExample2 { + interface PostTestLabel { /** - * Defines the text of the retrieved label + * Defines the for */ - "foundLabelText"?: string; + "for"?: string; + } + interface PostTestSpan { /** - * Defines the id + * Defines the id of the button to reference */ - "theId"?: string; + "btnId": string; /** - * Defines the selected workaround - */ - "workaround"?: string; - } - interface PostTestExample3 { - /** - * Defines the text of the retrieved label + * Defines the label text */ - "foundLabelText"?: string; + "labelText": string; /** - * Defines the id + * Defines the spanId */ - "theId"?: string; + "spanId"?: string; /** * Defines the selected workaround */ "workaround"?: string; } - interface PostTestInput { + interface PostTestTarget { /** * Defines the selected workaround */ - "foundLabelText"?: string; - /** - * Defines the inputId - */ - "inputId"?: string; + "ariaLabelledbyId"?: string; /** * Defines the selected workaround */ "workaround"?: string; } - interface PostTestLabel { - /** - * Defines the for - */ - "for"?: string; - /** - * Defines the label text - */ - "labelText": string; + interface PostTestTarget2 { /** * Defines the selected workaround */ "workaround"?: string; } + interface PostTestTarget3 { + } + interface PostTestTarget4 { + } interface PostTogglebutton { /** * If `true`, the button is in the "on" state, otherwise it is in the "off" state. @@ -921,35 +909,47 @@ declare global { prototype: HTMLPostTagElement; new (): HTMLPostTagElement; }; - interface HTMLPostTestExampleElement extends Components.PostTestExample, HTMLStencilElement { + interface HTMLPostTestButtonElement extends Components.PostTestButton, HTMLStencilElement { } - var HTMLPostTestExampleElement: { - prototype: HTMLPostTestExampleElement; - new (): HTMLPostTestExampleElement; + var HTMLPostTestButtonElement: { + prototype: HTMLPostTestButtonElement; + new (): HTMLPostTestButtonElement; }; - interface HTMLPostTestExample2Element extends Components.PostTestExample2, HTMLStencilElement { + interface HTMLPostTestLabelElement extends Components.PostTestLabel, HTMLStencilElement { } - var HTMLPostTestExample2Element: { - prototype: HTMLPostTestExample2Element; - new (): HTMLPostTestExample2Element; + var HTMLPostTestLabelElement: { + prototype: HTMLPostTestLabelElement; + new (): HTMLPostTestLabelElement; }; - interface HTMLPostTestExample3Element extends Components.PostTestExample3, HTMLStencilElement { + interface HTMLPostTestSpanElement extends Components.PostTestSpan, HTMLStencilElement { } - var HTMLPostTestExample3Element: { - prototype: HTMLPostTestExample3Element; - new (): HTMLPostTestExample3Element; + var HTMLPostTestSpanElement: { + prototype: HTMLPostTestSpanElement; + new (): HTMLPostTestSpanElement; }; - interface HTMLPostTestInputElement extends Components.PostTestInput, HTMLStencilElement { + interface HTMLPostTestTargetElement extends Components.PostTestTarget, HTMLStencilElement { } - var HTMLPostTestInputElement: { - prototype: HTMLPostTestInputElement; - new (): HTMLPostTestInputElement; + var HTMLPostTestTargetElement: { + prototype: HTMLPostTestTargetElement; + new (): HTMLPostTestTargetElement; }; - interface HTMLPostTestLabelElement extends Components.PostTestLabel, HTMLStencilElement { + interface HTMLPostTestTarget2Element extends Components.PostTestTarget2, HTMLStencilElement { } - var HTMLPostTestLabelElement: { - prototype: HTMLPostTestLabelElement; - new (): HTMLPostTestLabelElement; + var HTMLPostTestTarget2Element: { + prototype: HTMLPostTestTarget2Element; + new (): HTMLPostTestTarget2Element; + }; + interface HTMLPostTestTarget3Element extends Components.PostTestTarget3, HTMLStencilElement { + } + var HTMLPostTestTarget3Element: { + prototype: HTMLPostTestTarget3Element; + new (): HTMLPostTestTarget3Element; + }; + interface HTMLPostTestTarget4Element extends Components.PostTestTarget4, HTMLStencilElement { + } + var HTMLPostTestTarget4Element: { + prototype: HTMLPostTestTarget4Element; + new (): HTMLPostTestTarget4Element; }; interface HTMLPostTogglebuttonElement extends Components.PostTogglebutton, HTMLStencilElement { } @@ -997,11 +997,13 @@ declare global { "post-tab-panel": HTMLPostTabPanelElement; "post-tabs": HTMLPostTabsElement; "post-tag": HTMLPostTagElement; - "post-test-example": HTMLPostTestExampleElement; - "post-test-example2": HTMLPostTestExample2Element; - "post-test-example3": HTMLPostTestExample3Element; - "post-test-input": HTMLPostTestInputElement; + "post-test-button": HTMLPostTestButtonElement; "post-test-label": HTMLPostTestLabelElement; + "post-test-span": HTMLPostTestSpanElement; + "post-test-target": HTMLPostTestTargetElement; + "post-test-target2": HTMLPostTestTarget2Element; + "post-test-target3": HTMLPostTestTarget3Element; + "post-test-target4": HTMLPostTestTarget4Element; "post-togglebutton": HTMLPostTogglebuttonElement; "post-tooltip": HTMLPostTooltipElement; } @@ -1400,68 +1402,56 @@ declare namespace LocalJSX { */ "variant"?: 'white' | 'info' | 'success' | 'error' | 'warning' | 'yellow'; } - interface PostTestExample { + interface PostTestButton { /** * Defines the id */ "theId"?: string; } - interface PostTestExample2 { - /** - * Defines the text of the retrieved label - */ - "foundLabelText"?: string; + interface PostTestLabel { /** - * Defines the id + * Defines the for */ - "theId"?: string; + "for"?: string; + } + interface PostTestSpan { /** - * Defines the selected workaround + * Defines the id of the button to reference */ - "workaround"?: string; - } - interface PostTestExample3 { + "btnId"?: string; /** - * Defines the text of the retrieved label + * Defines the label text */ - "foundLabelText"?: string; + "labelText"?: string; /** - * Defines the id + * Defines the spanId */ - "theId"?: string; + "spanId"?: string; /** * Defines the selected workaround */ "workaround"?: string; } - interface PostTestInput { + interface PostTestTarget { /** * Defines the selected workaround */ - "foundLabelText"?: string; - /** - * Defines the inputId - */ - "inputId"?: string; + "ariaLabelledbyId"?: string; /** * Defines the selected workaround */ "workaround"?: string; } - interface PostTestLabel { - /** - * Defines the for - */ - "for"?: string; - /** - * Defines the label text - */ - "labelText"?: string; + interface PostTestTarget2 { /** * Defines the selected workaround */ "workaround"?: string; } + interface PostTestTarget3 { + } + interface PostTestTarget4 { + } interface PostTogglebutton { /** * If `true`, the button is in the "on" state, otherwise it is in the "off" state. @@ -1516,11 +1506,13 @@ declare namespace LocalJSX { "post-tab-panel": PostTabPanel; "post-tabs": PostTabs; "post-tag": PostTag; - "post-test-example": PostTestExample; - "post-test-example2": PostTestExample2; - "post-test-example3": PostTestExample3; - "post-test-input": PostTestInput; + "post-test-button": PostTestButton; "post-test-label": PostTestLabel; + "post-test-span": PostTestSpan; + "post-test-target": PostTestTarget; + "post-test-target2": PostTestTarget2; + "post-test-target3": PostTestTarget3; + "post-test-target4": PostTestTarget4; "post-togglebutton": PostTogglebutton; "post-tooltip": PostTooltip; } @@ -1568,11 +1560,13 @@ declare module "@stencil/core" { "post-tab-panel": LocalJSX.PostTabPanel & JSXBase.HTMLAttributes; "post-tabs": LocalJSX.PostTabs & JSXBase.HTMLAttributes; "post-tag": LocalJSX.PostTag & JSXBase.HTMLAttributes; - "post-test-example": LocalJSX.PostTestExample & JSXBase.HTMLAttributes; - "post-test-example2": LocalJSX.PostTestExample2 & JSXBase.HTMLAttributes; - "post-test-example3": LocalJSX.PostTestExample3 & JSXBase.HTMLAttributes; - "post-test-input": LocalJSX.PostTestInput & JSXBase.HTMLAttributes; + "post-test-button": LocalJSX.PostTestButton & JSXBase.HTMLAttributes; "post-test-label": LocalJSX.PostTestLabel & JSXBase.HTMLAttributes; + "post-test-span": LocalJSX.PostTestSpan & JSXBase.HTMLAttributes; + "post-test-target": LocalJSX.PostTestTarget & JSXBase.HTMLAttributes; + "post-test-target2": LocalJSX.PostTestTarget2 & JSXBase.HTMLAttributes; + "post-test-target3": LocalJSX.PostTestTarget3 & JSXBase.HTMLAttributes; + "post-test-target4": LocalJSX.PostTestTarget4 & JSXBase.HTMLAttributes; "post-togglebutton": LocalJSX.PostTogglebutton & JSXBase.HTMLAttributes; "post-tooltip": LocalJSX.PostTooltip & JSXBase.HTMLAttributes; } diff --git a/packages/components/src/components/post-icon/readme.md b/packages/components/src/components/post-icon/readme.md index cef5d0a101..d637583c24 100644 --- a/packages/components/src/components/post-icon/readme.md +++ b/packages/components/src/components/post-icon/readme.md @@ -33,6 +33,7 @@ some content - [post-mainnavigation](../post-mainnavigation) - [post-rating](../post-rating) - [post-tag](../post-tag) + - [post-test-button](../post-test-button) ### Graph ```mermaid @@ -48,6 +49,7 @@ graph TD; post-mainnavigation --> post-icon post-rating --> post-icon post-tag --> post-icon + post-test-button --> post-icon style post-icon fill:#f9f,stroke:#333,stroke-width:4px ``` diff --git a/packages/components/src/components/post-test-example/post-test-example.scss b/packages/components/src/components/post-test-button/post-test-button.scss similarity index 100% rename from packages/components/src/components/post-test-example/post-test-example.scss rename to packages/components/src/components/post-test-button/post-test-button.scss diff --git a/packages/components/src/components/post-test-example/post-test-example.tsx b/packages/components/src/components/post-test-button/post-test-button.tsx similarity index 52% rename from packages/components/src/components/post-test-example/post-test-example.tsx rename to packages/components/src/components/post-test-button/post-test-button.tsx index 093f159b3f..c484d3cb02 100644 --- a/packages/components/src/components/post-test-example/post-test-example.tsx +++ b/packages/components/src/components/post-test-button/post-test-button.tsx @@ -2,11 +2,11 @@ import { Component, h, Host, Prop } from '@stencil/core'; import { version } from '@root/package.json'; @Component({ - tag: 'post-test-example', - styleUrl: 'post-test-example.scss', + tag: 'post-test-button', + styleUrl: 'post-test-button.scss', shadow: true, }) -export class PostTestExample { +export class PostTestButton { /** * Defines the id */ @@ -15,9 +15,10 @@ export class PostTestExample { render() { return ( // Shadow DOM - Same Shadow DOM - - - + +
+ +
); } diff --git a/packages/components/src/components/post-test-example/readme.md b/packages/components/src/components/post-test-button/readme.md similarity index 65% rename from packages/components/src/components/post-test-example/readme.md rename to packages/components/src/components/post-test-button/readme.md index 4126c2f6b3..40b31cca52 100644 --- a/packages/components/src/components/post-test-example/readme.md +++ b/packages/components/src/components/post-test-button/readme.md @@ -12,6 +12,19 @@ | `theId` | `the-id` | Defines the id | `string` | `undefined` | +## Dependencies + +### Depends on + +- [post-icon](../post-icon) + +### Graph +```mermaid +graph TD; + post-test-button --> post-icon + style post-test-button fill:#f9f,stroke:#333,stroke-width:4px +``` + ---------------------------------------------- *Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-example2/post-test-example2.tsx b/packages/components/src/components/post-test-example2/post-test-example2.tsx deleted file mode 100644 index 2d7dbfc01c..0000000000 --- a/packages/components/src/components/post-test-example2/post-test-example2.tsx +++ /dev/null @@ -1,66 +0,0 @@ -import { Component, h, Host, Prop } from '@stencil/core'; -import { version } from '@root/package.json'; - -declare interface HTMLInputElementPlus extends HTMLInputElement { - ariaLabelledByElements: Element | Element[] | null; -} - -@Component({ - tag: 'post-test-example2', - styleUrl: 'post-test-example2.scss', - shadow: true, -}) -export class PostTestExample2 { - /** - * Defines the id - */ - @Prop() theId?: string; - - /** - * Defines the selected workaround - */ - @Prop() workaround?: string; - - /** - * Defines the text of the retrieved label - */ - @Prop() foundLabelText?: string; - - private updateWorkaround() { - const lightDOMLabel = document.querySelector(`label[for="${this.theId}"]`); - - if (this.workaround == 'ariamixin') { - const customElement = document.querySelector(`post-test-example2[the-id="${this.theId}"]`); - const internalInput = customElement.shadowRoot.querySelector('input') as HTMLInputElementPlus; - internalInput.ariaLabelledByElements = [lightDOMLabel]; - } - if (this.workaround == 'arialabel') { - const lightDOMLabel = document.querySelector(`label[for="${this.theId}"]`); - if (lightDOMLabel) { - this.foundLabelText = lightDOMLabel.textContent; - } - } - } - componentDidLoad() { - this.updateWorkaround(); - } - - componentDidUpdate() { - this.updateWorkaround(); - } - - render() { - return ( - //Slotted Content - Shadow DOM (since slotted content is in the Light DOM) - - - - - ); - } -} diff --git a/packages/components/src/components/post-test-example2/readme.md b/packages/components/src/components/post-test-example2/readme.md deleted file mode 100644 index 40a871a653..0000000000 --- a/packages/components/src/components/post-test-example2/readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# post-test-form - - - - - - -## Properties - -| Property | Attribute | Description | Type | Default | -| ---------------- | ------------------ | --------------------------------------- | -------- | ----------- | -| `foundLabelText` | `found-label-text` | Defines the text of the retrieved label | `string` | `undefined` | -| `theId` | `the-id` | Defines the id | `string` | `undefined` | -| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | - - ----------------------------------------------- - -*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-example3/post-test-example3.tsx b/packages/components/src/components/post-test-example3/post-test-example3.tsx deleted file mode 100644 index 372e29d998..0000000000 --- a/packages/components/src/components/post-test-example3/post-test-example3.tsx +++ /dev/null @@ -1,60 +0,0 @@ -import { Component, h, Host, Prop, Element } from '@stencil/core'; -import { version } from '@root/package.json'; - -@Component({ - tag: 'post-test-example3', - styleUrl: 'post-test-example3.scss', - shadow: true, -}) -export class PostTestExample3 { - @Element() host: HTMLPostTestExample3Element; - - /** - * Defines the id - */ - @Prop() theId?: string; - - /** - * Defines the selected workaround - */ - @Prop() workaround?: string; - - /** - * Defines the text of the retrieved label - */ - @Prop() foundLabelText?: string; - - private setAriaLabel() { - const selector = `#${this.theId}`; - const targetInput = document.querySelector(selector); - - const lightDOMLabel = this.host.shadowRoot.querySelector(`label[for="${this.theId}"]`); - - if (lightDOMLabel) { - this.foundLabelText = lightDOMLabel.textContent; - } - if (this.workaround == 'arialabel') { - targetInput.setAttribute('aria-label', this.foundLabelText); - } else { - targetInput.removeAttribute('aria-label'); - } - } - - componentDidLoad() { - this.setAriaLabel(); - } - - componentDidUpdate() { - this.setAriaLabel(); - } - - render() { - return ( - // Shadow DOM - Light DOM - - - - - ); - } -} diff --git a/packages/components/src/components/post-test-example3/readme.md b/packages/components/src/components/post-test-example3/readme.md deleted file mode 100644 index 40a871a653..0000000000 --- a/packages/components/src/components/post-test-example3/readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# post-test-form - - - - - - -## Properties - -| Property | Attribute | Description | Type | Default | -| ---------------- | ------------------ | --------------------------------------- | -------- | ----------- | -| `foundLabelText` | `found-label-text` | Defines the text of the retrieved label | `string` | `undefined` | -| `theId` | `the-id` | Defines the id | `string` | `undefined` | -| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | - - ----------------------------------------------- - -*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-input/post-test-input.tsx b/packages/components/src/components/post-test-input/post-test-input.tsx deleted file mode 100644 index 76f3d4fe88..0000000000 --- a/packages/components/src/components/post-test-input/post-test-input.tsx +++ /dev/null @@ -1,70 +0,0 @@ -import { Component, h, Host, Prop, Element } from '@stencil/core'; -import { version } from '@root/package.json'; - -declare interface HTMLInputElementPlus extends HTMLInputElement { - ariaLabelledByElements: Element | Element[] | null; -} - -@Component({ - tag: 'post-test-input', - styleUrl: 'post-test-input.scss', - shadow: true, -}) -export class PostTestInput { - @Element() host: HTMLPostTestInputElement; - /** - * Defines the inputId - */ - @Prop() inputId?: string; - - /** - * Defines the selected workaround - */ - @Prop() workaround?: string; - - /** - * Defines the selected workaround - */ - @Prop() foundLabelText?: string; - - private updateWorkaround() { - const lightDOMLabel = document.querySelector(`label[for="${this.inputId}"]`); - const customElement = document.querySelector(`post-test-input[input-id="${this.inputId}"]`); - const internalInput = customElement.shadowRoot.querySelector('input') as HTMLInputElementPlus; - if (this.workaround == 'ariamixin') { - internalInput.ariaLabelledByElements = [lightDOMLabel]; - } else { - internalInput.ariaLabelledByElements = null; - } - if (this.workaround == 'arialabel') { - const lightDOMLabel = document.querySelector(`label[for="${this.inputId}"]`); - console.log(lightDOMLabel); - if (lightDOMLabel) { - this.foundLabelText = lightDOMLabel.textContent; - } - } - } - - componentDidLoad() { - this.updateWorkaround(); - } - - componentDidUpdate() { - this.updateWorkaround(); - } - - render() { - return ( - - - - - ); - } -} diff --git a/packages/components/src/components/post-test-input/readme.md b/packages/components/src/components/post-test-input/readme.md deleted file mode 100644 index 563058ba43..0000000000 --- a/packages/components/src/components/post-test-input/readme.md +++ /dev/null @@ -1,19 +0,0 @@ -# post-test-input - - - - - - -## Properties - -| Property | Attribute | Description | Type | Default | -| ---------------- | ------------------ | ------------------------------- | -------- | ----------- | -| `foundLabelText` | `found-label-text` | Defines the selected workaround | `string` | `undefined` | -| `inputId` | `input-id` | Defines the inputId | `string` | `undefined` | -| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | - - ----------------------------------------------- - -*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-label/post-test-label.tsx b/packages/components/src/components/post-test-label/post-test-label.tsx index e1685988ee..aced83c574 100644 --- a/packages/components/src/components/post-test-label/post-test-label.tsx +++ b/packages/components/src/components/post-test-label/post-test-label.tsx @@ -12,38 +12,19 @@ export class PostTestLabel { */ @Prop() for?: string; - /** - * Defines the label text - */ - @Prop() labelText: string; - - /** - * Defines the selected workaround - */ - @Prop() workaround?: string; - - private setAriaLabel() { - const selector = `#${this.for}`; - const targetInput = document.querySelector(selector); - if (this.workaround == 'arialabel') { - targetInput.setAttribute('aria-label', this.labelText); - } else { - targetInput.removeAttribute('aria-label'); - } - } + private internalEl: HTMLElement | undefined; componentDidLoad() { - this.setAriaLabel(); - } - - componentDidUpdate() { - this.setAriaLabel(); + const targetEl = document.querySelector('#' + this.for); + targetEl.ariaLabelledByElements = [this.internalEl]; } render() { return ( - - + + ); diff --git a/packages/components/src/components/post-test-label/readme.md b/packages/components/src/components/post-test-label/readme.md index b0336611a0..cd4d27a38b 100644 --- a/packages/components/src/components/post-test-label/readme.md +++ b/packages/components/src/components/post-test-label/readme.md @@ -7,11 +7,9 @@ ## Properties -| Property | Attribute | Description | Type | Default | -| ------------ | ------------ | ------------------------------- | -------- | ----------- | -| `for` | `for` | Defines the for | `string` | `undefined` | -| `labelText` | `label-text` | Defines the label text | `string` | `undefined` | -| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | +| Property | Attribute | Description | Type | Default | +| -------- | --------- | --------------- | -------- | ----------- | +| `for` | `for` | Defines the for | `string` | `undefined` | ---------------------------------------------- diff --git a/packages/components/src/components/post-test-example2/post-test-example2.scss b/packages/components/src/components/post-test-span/post-test-span.scss similarity index 100% rename from packages/components/src/components/post-test-example2/post-test-example2.scss rename to packages/components/src/components/post-test-span/post-test-span.scss diff --git a/packages/components/src/components/post-test-span/post-test-span.tsx b/packages/components/src/components/post-test-span/post-test-span.tsx new file mode 100644 index 0000000000..14c7e74450 --- /dev/null +++ b/packages/components/src/components/post-test-span/post-test-span.tsx @@ -0,0 +1,60 @@ +import { Component, h, Host, Prop, Element } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-span', + styleUrl: 'post-test-span.scss', + shadow: true, +}) +export class PostTestSpan { + @Element() host: HTMLPostTestSpanElement; + + /** + * Defines the spanId + */ + @Prop() spanId?: string; + + /** + * Defines the label text + */ + @Prop() labelText: string; + + /** + * Defines the id of the button to reference + */ + @Prop() btnId: string; + + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + private setAriaLabel() { + const selector = `#${this.btnId}`; + const targetInput = document.querySelector(selector); + if (targetInput) { + if (this.workaround == 'arialabel') { + targetInput.setAttribute('aria-label-text', this.labelText); + } else { + targetInput.removeAttribute('aria-label-text'); + } + } + } + + componentWillLoad() { + this.setAriaLabel(); + } + + componentDidUpdate() { + this.setAriaLabel(); + } + + render() { + return ( + + {this.labelText} + + + ); + } +} diff --git a/packages/components/src/components/post-test-span/readme.md b/packages/components/src/components/post-test-span/readme.md new file mode 100644 index 0000000000..0e09377b1e --- /dev/null +++ b/packages/components/src/components/post-test-span/readme.md @@ -0,0 +1,20 @@ +# post-avatar + + + + + + +## Properties + +| Property | Attribute | Description | Type | Default | +| ------------ | ------------ | ----------------------------------------- | -------- | ----------- | +| `btnId` | `btn-id` | Defines the id of the button to reference | `string` | `undefined` | +| `labelText` | `label-text` | Defines the label text | `string` | `undefined` | +| `spanId` | `span-id` | Defines the spanId | `string` | `undefined` | +| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` | + + +---------------------------------------------- + +*Built with [StencilJS](https://stenciljs.com/)* diff --git a/packages/components/src/components/post-test-example3/post-test-example3.scss b/packages/components/src/components/post-test-target/post-test-target.scss similarity index 100% rename from packages/components/src/components/post-test-example3/post-test-example3.scss rename to packages/components/src/components/post-test-target/post-test-target.scss diff --git a/packages/components/src/components/post-test-target/post-test-target.tsx b/packages/components/src/components/post-test-target/post-test-target.tsx new file mode 100644 index 0000000000..d5b395eaec --- /dev/null +++ b/packages/components/src/components/post-test-target/post-test-target.tsx @@ -0,0 +1,58 @@ +// This provides a type declaration merge to include the ariaLabelledByElements +// property on the Element interface + +declare global { + interface Element { + ariaLabelledByElements: Element[]; + } +} + +import { Component, h, Host, Prop, Element } from '@stencil/core'; +import { version } from '@root/package.json'; + +@Component({ + tag: 'post-test-target', + styleUrl: 'post-test-target.scss', + shadow: true, +}) +export class PostTestTarget { + @Element() host: HTMLPostTestTargetElement; + + private internalEl: HTMLElement | undefined; + /** + * Defines the selected workaround + */ + @Prop() workaround?: string; + + /** + * Defines the selected workaround + */ + @Prop() ariaLabelledbyId?: string; + + private setAriaLabelledByElements() { + const labelEl = document.querySelector(`[for=${this.ariaLabelledbyId}]`); + if (this.workaround == 'ariamixin') { + this.internalEl.ariaLabelledByElements = [labelEl]; + } else { + this.internalEl.ariaLabelledByElements = []; + } + } + + componentDidLoad() { + this.setAriaLabelledByElements(); + } + + componentDidUpdate() { + this.setAriaLabelledByElements(); + } + + render() { + return ( + + {/* This could be ,