|
| 1 | +<!-- |
| 2 | +The index.md file is a compiled document. No edits should be made directly to this file. |
| 3 | +README.md is created by running `npm run build:docs`. |
| 4 | +This file is generated based on a template fetched from `../docs/partials/index.md` |
| 5 | +--> |
| 6 | + |
| 7 | +# Table |
| 8 | + |
| 9 | +<!-- AURO-GENERATED-CONTENT:START (FILE:src=../docs/partials/description.md) --> |
| 10 | +<!-- The below content is automatically added from ../docs/partials/description.md --> |
| 11 | +Use the `auro-table` custom element to illustrate non-dynamic tabular data. The auro-table element is responsive, with a flexible layout and an easy-to-use JSON API. |
| 12 | +<!-- AURO-GENERATED-CONTENT:END --> |
| 13 | + |
| 14 | +## Use Cases |
| 15 | + |
| 16 | +<!-- AURO-GENERATED-CONTENT:START (FILE:src=../docs/partials/useCases.md) --> |
| 17 | +<!-- The below content is automatically added from ../docs/partials/useCases.md --> |
| 18 | +The `<auro-table>` element should be used in situations where users may: |
| 19 | + |
| 20 | +* Show static tabular data |
| 21 | +<!-- AURO-GENERATED-CONTENT:END --> |
| 22 | + |
| 23 | +## Example(s) |
| 24 | + |
| 25 | +<div class="exampleWrapper"> |
| 26 | + <!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/basic.html) --> |
| 27 | + <!-- The below content is automatically added from ../apiExamples/basic.html --> |
| 28 | + <auro-table |
| 29 | + columnHeaders='["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]' |
| 30 | + componentData='[ |
| 31 | + {"": "Dance class", "Monday": "5:00pm","Wednesday": "5:00pm" }, |
| 32 | + {"": "Night classes", "Thursday": "7:00pm","Friday": "7:00pm" }, |
| 33 | + {"": "Team meeting", "Wednesday": "10:00am" }, |
| 34 | + {"": "Morning workout", "Monday": "8:00am", "Tuesday": "8:00am", "Wednesday": "8:00am", "Thursday": "8:00am", "Friday": "8:00am" } |
| 35 | + ]'>My morning schedule |
| 36 | + </auro-table> |
| 37 | + <!-- AURO-GENERATED-CONTENT:END --> |
| 38 | +</div> |
| 39 | +<auro-accordion alignRight> |
| 40 | + <span slot="trigger">See code</span> |
| 41 | +<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/basic.html) --> |
| 42 | +<!-- The below code snippet is automatically added from ../apiExamples/basic.html --> |
| 43 | + |
| 44 | +```html |
| 45 | +<auro-table |
| 46 | + columnHeaders='["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]' |
| 47 | + componentData='[ |
| 48 | + {"": "Dance class", "Monday": "5:00pm","Wednesday": "5:00pm" }, |
| 49 | + {"": "Night classes", "Thursday": "7:00pm","Friday": "7:00pm" }, |
| 50 | + {"": "Team meeting", "Wednesday": "10:00am" }, |
| 51 | + {"": "Morning workout", "Monday": "8:00am", "Tuesday": "8:00am", "Wednesday": "8:00am", "Thursday": "8:00am", "Friday": "8:00am" } |
| 52 | + ]'>My morning schedule |
| 53 | +</auro-table> |
| 54 | +``` |
| 55 | +<!-- AURO-GENERATED-CONTENT:END --> |
| 56 | +</auro-accordion> |
| 57 | + |
| 58 | +## React and Svelte support |
| 59 | + |
| 60 | +```js |
| 61 | +const headers=JSON.stringify(["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]); |
| 62 | +const data=JSON.stringify([ |
| 63 | + {"": "Dance class", "Monday": "5:00pm","Wednesday": "5:00pm" }, |
| 64 | + {"": "Night classes", "Thursday": "7:00pm","Friday": "7:00pm" }, |
| 65 | + {"": "Team meeting", "Wednesday": "10:00am" }, |
| 66 | + {"": "Morning workout", "Monday": "8:00am", "Tuesday": "8:00am", "Wednesday": "8:00am", "Thursday": "8:00am", "Friday": "8:00am" } |
| 67 | +]) |
| 68 | + |
| 69 | +<auro-table nowrap columnHeaders={headers} componentData={data}>Default text</auro-table> |
| 70 | +``` |
| 71 | + |
| 72 | +Having a closing statement about your example helps to really complete the thought with your reader. |
| 73 | + |
| 74 | +## WC Style Sheets support |
| 75 | + |
| 76 | +For use cases where the general design of the Auro Table is needed, but the component is unseable, please use the [.auro_table](https://alaskaairlines.github.io/WebCoreStyleSheets/#utility-auro-css-#{$scope}.auro_table) styles from the Web Core Style Sheets library. |
| 77 | + |
| 78 | +```html |
| 79 | +<table class="auro_table"> |
| 80 | + <thead> |
| 81 | + <tr> |
| 82 | + <th>The table header</th> |
| 83 | + <th>The table header</th> |
| 84 | + </tr> |
| 85 | + </thead> |
| 86 | + <tbody> |
| 87 | + <tr> |
| 88 | + <td>The table body</td> |
| 89 | + <td>with two columns</td> |
| 90 | + </tr> |
| 91 | + <tr> |
| 92 | + <td>The table body</td> |
| 93 | + <td>with two columns</td> |
| 94 | + </tr> |
| 95 | + <tr> |
| 96 | + <td>The table body</td> |
| 97 | + <td>with two columns</td> |
| 98 | + </tr> |
| 99 | + </tbody> |
| 100 | +</table> |
| 101 | +``` |
| 102 | + |
| 103 | +## Recommended Use and Version Control |
| 104 | + |
| 105 | +There are two important parts of every Auro component. The <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom element. The class is exported and then used as part of defining the Web Component. When importing this component as described in the <a href="#install">install</a> section, the class is imported and the `auro-table` custom element is defined automatically. |
| 106 | + |
| 107 | +To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `AuroTable.register(name)` method and pass in a unique name. |
| 108 | + |
| 109 | +```js |
| 110 | +import { AuroTable } from './src/auro-table.js'; |
| 111 | + |
| 112 | +AuroTable.register('custom-table'); |
| 113 | +``` |
| 114 | + |
| 115 | +This will create a new custom element that you can use in your HTML that will function identically to the `auro-table` element. |
| 116 | + |
| 117 | +<div class="exampleWrapper"> |
| 118 | + <!-- AURO-GENERATED-CONTENT:START (FILE:src=../apiExamples/customTable.html) --> |
| 119 | + <!-- The below content is automatically added from ../apiExamples/customTable.html --> |
| 120 | + <custom-table |
| 121 | + columnHeaders='["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]' |
| 122 | + componentData='[ |
| 123 | + {"": "Dance class", "Monday": "5:00pm","Wednesday": "5:00pm" }, |
| 124 | + {"": "Night classes", "Thursday": "7:00pm","Friday": "7:00pm" }, |
| 125 | + {"": "Team meeting", "Wednesday": "10:00am" }, |
| 126 | + {"": "Morning workout", "Monday": "8:00am", "Tuesday": "8:00am", "Wednesday": "8:00am", "Thursday": "8:00am", "Friday": "8:00am" } |
| 127 | + ]'>My morning schedule |
| 128 | + </custom-table> |
| 129 | + <!-- AURO-GENERATED-CONTENT:END --> |
| 130 | +</div> |
| 131 | +<auro-accordion alignRight> |
| 132 | + <span slot="trigger">See code</span> |
| 133 | +<!-- AURO-GENERATED-CONTENT:START (CODE:src=../apiExamples/customTable.html) --> |
| 134 | +<!-- The below code snippet is automatically added from ../apiExamples/customTable.html --> |
| 135 | + |
| 136 | +```html |
| 137 | +<custom-table |
| 138 | + columnHeaders='["","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"]' |
| 139 | + componentData='[ |
| 140 | + {"": "Dance class", "Monday": "5:00pm","Wednesday": "5:00pm" }, |
| 141 | + {"": "Night classes", "Thursday": "7:00pm","Friday": "7:00pm" }, |
| 142 | + {"": "Team meeting", "Wednesday": "10:00am" }, |
| 143 | + {"": "Morning workout", "Monday": "8:00am", "Tuesday": "8:00am", "Wednesday": "8:00am", "Thursday": "8:00am", "Friday": "8:00am" } |
| 144 | + ]'>My morning schedule |
| 145 | +</custom-table> |
| 146 | +``` |
| 147 | +<!-- AURO-GENERATED-CONTENT:END --> |
| 148 | +</auro-accordion> |
0 commit comments