Skip to content

feat(documentation): investigate and document cross component dom referencing #5524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
381 changes: 381 additions & 0 deletions packages/components/src/components.d.ts

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions packages/components/src/components/post-icon/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ some content
- [post-mainnavigation](../post-mainnavigation)
- [post-rating](../post-rating)
- [post-tag](../post-tag)
- [post-test-button](../post-test-button)
- [post-test-button2](../post-test-button2)
- [post-test-button3](../post-test-button3)

### Graph
```mermaid
Expand All @@ -48,6 +51,9 @@ graph TD;
post-mainnavigation --> post-icon
post-rating --> post-icon
post-tag --> post-icon
post-test-button --> post-icon
post-test-button2 --> post-icon
post-test-button3 --> post-icon
style post-icon fill:#f9f,stroke:#333,stroke-width:4px
```

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { Component, h, Host, Element } from '@stencil/core';

@Component({
tag: 'post-test-button-control',
styleUrl: 'post-test-button-control.scss',
shadow: true,
})
export class PostTestButtonControl {
@Element() hostEl: HTMLPostTestButtonControlElement;
private internalEl: HTMLElement;

private readonly handleToggleClick = () => {
if (this.hostEl && this.internalEl) {
const timestamp = Date.now();
this.internalEl.innerHTML = `<p>Controlled Text shown at ${timestamp}.</p>`;
}
};

render() {
return (
<Host
role="button"
tabindex="0"
aria-expanded="false"
aria-controls="text2"
onClick={this.handleToggleClick}
>
Toggle Text
<div
class="btn btn-primary"
aria-live="assertive"
id="text2"
ref={el => {
if (el) this.internalEl = el as HTMLElement;
}}
>
<p>Controlled Text shown at xxxxxxxxxxx.</p>
</div>
</Host>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# post-test-form



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { Component, h, Host, Prop } from '@stencil/core';
import { version } from '@root/package.json';

@Component({
tag: 'post-test-button',
styleUrl: 'post-test-button.scss',
shadow: true,
})
export class PostTestButton {
/**
* Defines the ariaLabelledbyId
*/
@Prop() ariaLabelledbyId?: string;

/**
* Defines the ariaDescribedbyId
*/
@Prop() ariaDescribedbyId?: string;

render() {
return (
// Shadow DOM - Same Shadow DOM
<Host
data-version={version}
class="btn btn-primary"
role="button"
tabindex="0"
aria-labelledby={this.ariaLabelledbyId}
aria-describedby={this.ariaDescribedbyId}
>
<slot name="label-slot"></slot>
<div>
<post-icon name="1022"></post-icon>
</div>
</Host>
);
}
}
31 changes: 31 additions & 0 deletions packages/components/src/components/post-test-button/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# post-test-form



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------------- | --------------------- | ----------------------------- | -------- | ----------- |
| `ariaDescribedbyId` | `aria-describedby-id` | Defines the ariaDescribedbyId | `string` | `undefined` |
| `ariaLabelledbyId` | `aria-labelledby-id` | Defines the ariaLabelledbyId | `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/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { Component, h, Host, Prop } from '@stencil/core';
import { version } from '@root/package.json';

@Component({
tag: 'post-test-button2',
styleUrl: 'post-test-button2.scss',
shadow: { delegatesFocus: true },
})
export class PostTestButton2 {
private internalEl: HTMLElement;
/**
* Defines the selected workaround
*/
@Prop() workaround?: string;

/**
* Defines the selected ariaLabelledbyId
*/
@Prop() ariaLabelledbyId?: string;

/**
* Defines the selected ariaDescribedbyId
*/
@Prop() ariaDescribedbyId?: string;

private setProperties() {
if (this.internalEl) {
const arialabelEl = document.querySelector(`[id=${this.ariaLabelledbyId}]`);
const ariadescEl = document.querySelector(`[id=${this.ariaDescribedbyId}]`);

if (this.workaround == 'ariaLabelledByElements') {
this.internalEl.ariaLabelledByElements = [arialabelEl];
} else {
this.internalEl.ariaLabelledByElements = [];
}

if (this.workaround == 'ariaDescribedByElements') {
this.internalEl.ariaDescribedByElements = [ariadescEl];
} else {
this.internalEl.ariaDescribedByElements = [];
}
}
}

componentDidLoad() {
this.setProperties();
}

componentDidUpdate() {
this.setProperties();
}

render() {
return (
// Shadow DOM - Same Shadow DOM
<Host data-version={version} class="btn btn-primary">
<slot name="label-slot"></slot>
<div ref={el => (this.internalEl = el as HTMLElement)} role="button" tabindex="0">
<post-icon name="1022"></post-icon>
</div>
</Host>
);
}
}
32 changes: 32 additions & 0 deletions packages/components/src/components/post-test-button2/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# post-test-form



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------------- | --------------------- | -------------------------------------- | -------- | ----------- |
| `ariaDescribedbyId` | `aria-describedby-id` | Defines the selected ariaDescribedbyId | `string` | `undefined` |
| `ariaLabelledbyId` | `aria-labelledby-id` | Defines the selected ariaLabelledbyId | `string` | `undefined` |
| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` |


## Dependencies

### Depends on

- [post-icon](../post-icon)

### Graph
```mermaid
graph TD;
post-test-button2 --> post-icon
style post-test-button2 fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import { Component, h, Host, Prop } from '@stencil/core';
import { version } from '@root/package.json';

@Component({
tag: 'post-test-button3',
styleUrl: 'post-test-button3.scss',
shadow: true,
})
export class PostTestButton3 {
/**
* Defines the ariaLabelledbyId
*/
@Prop() ariaLabelledbyId?: string;

/**
* Defines the ariaDescribedbyId
*/
@Prop() ariaDescribedbyId?: string;

private slotEl: HTMLSlotElement | undefined;
private internalEl: HTMLElement | undefined;

/**
* Defines the selected workaround
*/
@Prop() workaround?: string;

private setProperties() {
if (this.slotEl && this.internalEl) {
if (this.workaround == 'ariaLabelledByElements') {
const assignedElements = this.slotEl.assignedElements({ flatten: true });
const labelElement = assignedElements[0];
console.log(labelElement);
if (labelElement) {
this.internalEl.ariaLabelledByElements = [labelElement];
} else {
this.internalEl.ariaLabelledByElements = [];
}
}

if (this.workaround == 'ariaDescribedByElements') {
const assignedElements = this.slotEl.assignedElements({ flatten: true });
const descElement = assignedElements[0];

if (descElement) {
this.internalEl.ariaDescribedByElements = [descElement];
} else {
this.internalEl.ariaDescribedByElements = [];
}
}
}
}

componentDidLoad() {
this.setProperties();
}

componentDidUpdate() {
this.setProperties();
}

render() {
return (
// Shadow DOM - Same Shadow DOM
<Host data-version={version} class="btn btn-primary">
<slot name="label-slot" ref={el => (this.slotEl = el as HTMLSlotElement)}></slot>
<div ref={el => (this.internalEl = el as HTMLElement)} role="button" tabindex="0">
<post-icon name="1022"></post-icon>
</div>
</Host>
);
}
}
32 changes: 32 additions & 0 deletions packages/components/src/components/post-test-button3/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# post-test-form



<!-- Auto Generated Below -->


## Properties

| Property | Attribute | Description | Type | Default |
| ------------------- | --------------------- | ------------------------------- | -------- | ----------- |
| `ariaDescribedbyId` | `aria-describedby-id` | Defines the ariaDescribedbyId | `string` | `undefined` |
| `ariaLabelledbyId` | `aria-labelledby-id` | Defines the ariaLabelledbyId | `string` | `undefined` |
| `workaround` | `workaround` | Defines the selected workaround | `string` | `undefined` |


## Dependencies

### Depends on

- [post-icon](../post-icon)

### Graph
```mermaid
graph TD;
post-test-button3 --> post-icon
style post-test-button3 fill:#f9f,stroke:#333,stroke-width:4px
```

----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Component, h, Host } from '@stencil/core';

@Component({
tag: 'post-test-div',
styleUrl: 'post-test-div.scss',
shadow: true,
})
export class PostTestDiv {
render() {
return (
<Host role="list" tabindex="0">
<slot name="list-items"></slot>
</Host>
);
}
}
10 changes: 10 additions & 0 deletions packages/components/src/components/post-test-div/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# post-test-form



<!-- Auto Generated Below -->


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@use '@swisspost/design-system-styles/post-default.scss';
Loading
Loading