generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: experimental table web components
- Loading branch information
Showing
20 changed files
with
300 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
components/table/web-component/stories/01-default.stories.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<!-- @license CC0-1.0 --> | ||
|
||
import { Canvas, Meta, Story } from "@storybook/addon-docs"; | ||
import { TableExample } from "../template"; | ||
|
||
<Meta | ||
id="web-component-table" | ||
title="Web Component/Table" | ||
argTypes={{}} | ||
parameters={{ | ||
status: { | ||
type: "WORK IN PROGRESS", | ||
}, | ||
}} | ||
/> | ||
|
||
# Table | ||
|
||
This Table web component is experimental, please share your experiences with our team. | ||
|
||
The web component version of the Table component has not yet been tested for accessibility with various assistive tools. Using the CSS component of Table is recommended for now. | ||
|
||
Accessibility has been tested in the following manner: | ||
|
||
- Accessibility panel in Chrome Developer tools shows the same role structure as the native HTML table equivalent. | ||
|
||
For accessibility of `<table-header-cell>` you MUST set the `scope="col"` or `scope="row"` attribute. | ||
|
||
<Canvas> | ||
<Story name="Default">{TableExample.bind({})}</Story> | ||
</Canvas> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__body; | ||
|
||
display: table-row-group; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-body', | ||
styleUrl: 'table-body.scss', | ||
shadow: true, | ||
}) | ||
export class TableBody { | ||
render() { | ||
return ( | ||
<Host role="rowgroup"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__caption; | ||
|
||
display: table-caption; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { Component, h } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-caption', | ||
styleUrl: 'table-caption.scss', | ||
shadow: true, | ||
}) | ||
export class TableCaption { | ||
render() { | ||
// TODO: Associate with parent <utrecht-table> aria-labelledby attribute | ||
return <slot></slot>; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__cell; | ||
|
||
display: table-cell; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-cell', | ||
styleUrl: 'table-cell.scss', | ||
shadow: true, | ||
}) | ||
export class TableCell { | ||
render() { | ||
return ( | ||
<Host role="cell"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__footer; | ||
|
||
display: table-footer-group; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-footer', | ||
styleUrl: 'table-footer.scss', | ||
shadow: true, | ||
}) | ||
export class TableFooter { | ||
render() { | ||
return ( | ||
<Host role="rowgroup"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__header-cell; | ||
|
||
display: table-cell; | ||
} |
17 changes: 17 additions & 0 deletions
17
components/table/web-component/table-header-cell.stencil.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Component, h, Host, Prop } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-header-cell', | ||
styleUrl: 'table-header-cell.scss', | ||
shadow: true, | ||
}) | ||
export class TableHeaderCell { | ||
@Prop() scope: 'col' | 'row'; | ||
render() { | ||
return ( | ||
<Host role={this.scope === 'col' ? 'columnheader' : this.scope === 'row' ? 'rowheader' : 'cell'}> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__header; | ||
|
||
display: table-header-group; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-header', | ||
styleUrl: 'table-header.scss', | ||
shadow: true, | ||
}) | ||
export class TableHeader { | ||
render() { | ||
return ( | ||
<Host role="rowgroup"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table__row; | ||
|
||
display: table-row; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table-row', | ||
styleUrl: 'table-row.scss', | ||
shadow: true, | ||
}) | ||
export class TableRow { | ||
render() { | ||
return ( | ||
<Host role="row"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "../css/mixin"; | ||
|
||
:host { | ||
@include utrecht-table; | ||
|
||
display: table; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Component, h, Host } from '@stencil/core'; | ||
|
||
@Component({ | ||
tag: 'utrecht-table', | ||
styleUrl: 'table.scss', | ||
shadow: true, | ||
}) | ||
export class Table { | ||
render() { | ||
return ( | ||
<Host role="table"> | ||
<slot></slot> | ||
</Host> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
export const TableExample = () => ` | ||
<utrecht-table aria-labelledby="53818ecc-f9a6-4a9d-9e63-12a5ebb89e31"> | ||
<utrecht-table-caption id="53818ecc-f9a6-4a9d-9e63-12a5ebb89e31">Table</utrecht-table-caption> | ||
<utrecht-table-header> | ||
<utrecht-table-row> | ||
<utrecht-table-header-cell scope="col">Column header cell 1</utrecht-table-header-cell> | ||
<utrecht-table-header-cell scope="col">Column header cell 2</utrecht-table-header-cell> | ||
</utrecht-table-row> | ||
</utrecht-table-header> | ||
<utrecht-table-footer> | ||
<utrecht-table-row> | ||
<utrecht-table-cell>Footer cell 1</utrecht-table-cell> | ||
<utrecht-table-cell>Footer cell 2</utrecht-table-cell> | ||
</utrecht-table-row> | ||
</utrecht-table-footer> | ||
<utrecht-table-body> | ||
<utrecht-table-row> | ||
<utrecht-table-header-cell scope="row">Row header cell</utrecht-table-header-cell> | ||
<utrecht-table-cell>Cell</utrecht-table-cell> | ||
</utrecht-table-row> | ||
</utrecht-table-body> | ||
</utrecht-table> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters