Skip to content

Commit 66a3907

Browse files
perf: modernize component example documentation #78
example code updated to reflect latest Auro element APIs example documentation layout improved custom registration updated and moved to install page core element descriptions updated doc build system now uses the latest version of auro-cli package json configuration updated to support latest auro-cli
1 parent 7025840 commit 66a3907

17 files changed

+1188
-306
lines changed

README.md

Lines changed: 37 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -15,128 +15,68 @@ The following sections are editable by making changes to the following files:
1515
| Use Cases | Examples for when to use this component | `./docs/partials/useCases.md` |
1616
| Additional Information | For use to add any component specific information | `./docs/partials/readmeAddlInfo.md` |
1717
| Component Example Code | HTML sample code of the components use | `./apiExamples/basic.html` |
18-
-->
19-
20-
# Backtotop
18+
-->
19+
20+
# {{ capitalize name }}
2121

2222
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/description.md) -->
23-
<!-- The below content is automatically added from ./docs/partials/description.md -->
24-
`<auro-backtotop>` is a [HTML custom element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) for the purpose of providing a quick and accessible means to jump back to the top of a long content page.
23+
<!-- AURO-GENERATED-CONTENT:END -->
2524

26-
The component will be hidden while the page Y scroll position is at the top. When scroll down begins the button will display in the bottom right corner of the page. While scrolling down the button will display only an arrow up icon. When scroll up occurs, the button will additionally display any slotted text content.
27-
<!-- AURO-GENERATED-CONTENT:END -->
2825
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/readmeAddlInfo.md) -->
29-
<!-- The below content is automatically added from ./docs/partials/readmeAddlInfo.md -->
30-
<!-- AURO-GENERATED-CONTENT This file is to be used for any additional content that should be included in the README.md which is specific to this component. -->
31-
<!-- AURO-GENERATED-CONTENT:END -->
32-
33-
## UI development browser support
26+
<!-- AURO-GENERATED-CONTENT:END -->
3427

35-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/browserSupport.md) -->
36-
For the most up to date information on [UI development browser support](https://auro.alaskaair.com/support/browsersSupport)
28+
## Use Cases
29+
30+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
31+
<!-- AURO-GENERATED-CONTENT:END -->
3732

38-
<!-- AURO-GENERATED-CONTENT:END -->
39-
4033
## Install
4134

4235
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentInstall.md) -->
43-
[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-backtotop/testPublish.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-backtotop/actions/workflows/testPublish.yml)
44-
[![See it on NPM!](https://img.shields.io/npm/v/@aurodesignsystem/auro-backtotop?style=for-the-badge&color=orange)](https://www.npmjs.com/package/@aurodesignsystem/auro-backtotop)
45-
[![License](https://img.shields.io/npm/l/@aurodesignsystem/auro-backtotop?color=blue&style=for-the-badge)](https://www.apache.org/licenses/LICENSE-2.0)
46-
![ESM supported](https://img.shields.io/badge/ESM-compatible-FFE900?style=for-the-badge)
47-
48-
```shell
49-
$ npm i @aurodesignsystem/auro-backtotop
50-
```
51-
52-
<!-- AURO-GENERATED-CONTENT:END -->
53-
54-
### Design Token CSS Custom Property dependency
55-
56-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/designTokens.md) -->
57-
The use of any Auro custom element has a dependency on the [Auro Design Tokens](https://auro.alaskaair.com/getting-started/developers/design-tokens).
58-
59-
<!-- AURO-GENERATED-CONTENT:END -->
60-
61-
### Define dependency in project component
36+
<!-- AURO-GENERATED-CONTENT:END -->
37+
38+
### Define Dependency in Project
6239

6340
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImportDescription.md) -->
64-
Defining the component dependency within each component that is using the `<auro-backtotop>` component.
41+
<!-- AURO-GENERATED-CONTENT:END -->
6542

66-
<!-- AURO-GENERATED-CONTENT:END -->
67-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImport.md) -->
68-
69-
```js
70-
import "@aurodesignsystem/auro-backtotop";
71-
```
43+
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImport.md) -->
44+
<!-- AURO-GENERATED-CONTENT:END -->
7245

73-
<!-- AURO-GENERATED-CONTENT:END -->
74-
**Reference component in HTML**
75-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
76-
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
77-
78-
```html
79-
<auro-backtotop>Back to top</auro-backtotop>
80-
```
81-
<!-- AURO-GENERATED-CONTENT:END -->
82-
83-
## Use CDN
46+
### Use CDN
8447

8548
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/bundleInstallDescription.md) -->
86-
In cases where the project is not able to process JS assets, there are pre-processed assets available for use. Legacy browsers such as IE11 are no longer supported.
49+
<!-- AURO-GENERATED-CONTENT:END -->
8750

88-
```html
89-
<script type="module" src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-backtotop@latest/+esm"></script>
90-
```
51+
## Basic Example
9152

92-
<!-- AURO-GENERATED-CONTENT:END -->
93-
94-
## auro-backtotop use cases
53+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
54+
<!-- AURO-GENERATED-CONTENT:END -->
9555

96-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
97-
<!-- The below content is automatically added from ./docs/partials/useCases.md -->
98-
The `<auro-backtotop>` element should be used in situations where users may:
56+
## Custom Component Registration for Version Management
9957

100-
* Pages with large amounts of content where a shortcut to jump to the top of the page is appropriate.
101-
<!-- AURO-GENERATED-CONTENT:END -->
102-
103-
## API Code Examples
104-
105-
### Default auro-backtotop
58+
There are two key parts to every Auro component: the <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Classes">class</a> and the custom element definition.
59+
The class defines the component’s behavior, while the custom element registers it under a specific name so it can be used in HTML.
10660

107-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
108-
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
109-
110-
```html
111-
<auro-backtotop>Back to top</auro-backtotop>
112-
```
113-
<!-- AURO-GENERATED-CONTENT:END -->
114-
115-
## Development
61+
When you install the component as described on the `Install` page, the class is imported automatically, and the component is registered globally for you.
11662

117-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/developmentDescription.md) -->
118-
In order to develop against this project, if you are not part of the core team, you will be required to fork the project prior to submitting a pull request.
63+
However, if you need to load multiple versions of the same component on a single page (for example, when two projects depend on different versions), you can manually register the class under a custom element name to avoid conflicts.
11964

120-
Please be sure to review the [contribution guidelines](https://auro.alaskaair.com/contributing) for this project. Please make sure to **pay special attention** to the **conventional commits** section of the document.
65+
You can do this by importing only the component class and using the `register(name)` method with a unique name:
12166

122-
<!-- AURO-GENERATED-CONTENT:END -->
123-
124-
### Start development environment
67+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/customRegistration.md) -->
68+
<!-- AURO-GENERATED-CONTENT:END -->
12569

126-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/localhost.md) -->
127-
Once the project has been cloned to your local resource and you have installed all the dependencies you will need to open a shell session to run the **dev server**.
70+
<div class="exampleWrapper exampleWrapper--flex">
71+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./apiExamples/custom.html) -->
72+
<!-- AURO-GENERATED-CONTENT:END -->
73+
</div>
12874

129-
```shell
130-
$ npm run dev
131-
```
75+
<auro-accordion alignRight>
76+
<span slot="trigger">See code</span>
13277

133-
Open [localhost:8000](http://localhost:8000/)
134-
135-
<!-- AURO-GENERATED-CONTENT:END -->
136-
137-
### Testing
78+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/custom.html) -->
79+
<!-- AURO-GENERATED-CONTENT:END -->
13880

139-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/testing.md) -->
140-
Automated tests are required for every Auro component. See `.\test\auro-backtotop.test.js` for the tests for this component. Run `npm run test` to run the tests and check code coverage. Tests must pass and meet a certain coverage threshold to commit. See [the testing documentation](https://auro.alaskaair.com/support/tests) for more details.
81+
</auro-accordion>
14182

142-
<!-- AURO-GENERATED-CONTENT:END -->

docs/api.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# auro-backtotop
22

3-
The auro-backtotop element provides users a way to quickly return to page top.
3+
The `auro-backtotop` element provides users a way to quickly return to page top.
44

55
### Properties & Attributes
66

7-
| Properties | Attributes | Type | Default | Description |
8-
| ---------- | ---------- | ------- | --------- | ------------------------------------------------------------------------------------------------------ |
9-
| disabled | disabled | boolean | | Render the trigger inline, will always be visible. |
10-
| variant | variant | string | "primary" | The variant attribute allows for rendering the button using the primary (default) or secondary styles. |
7+
| Properties | Attributes | Modifiers | Type | Default | Description |
8+
| ---------- | ---------- | --------- | ------------------------ | --------- | ------------------------------------------------------------------------------------------------------ |
9+
| disabled | disabled | | boolean | `false` | Render the trigger inline, will always be visible. |
10+
| variant | variant | | `primary` \| `secondary` | `primary` | The variant attribute allows for rendering the button using the primary (default) or secondary styles. |
1111

1212
### Methods
1313

14-
| Name | Parameters | Return | Description |
15-
| -------- | ------------------------------------------------------------------- | ------ | ------------------------------------------------- |
16-
| register | `name` (string) - The name of element that you want to register to. | | This will register this element with the browser. |
14+
| Name | Parameters | Return | Description |
15+
| -------- | -------------------------------------------------------------------- | ------ | ------------------------------------------------- |
16+
| register | `name` (string) - The name of the element that you want to register. | | This will register this element with the browser. |
1717

1818
### Slots
1919

docs/partials/api.md

Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../docs/api.md) -->
22
<!-- AURO-GENERATED-CONTENT:END -->
33

4-
## API Examples
5-
6-
### Basic
4+
## Basic
75

86
<div class="exampleWrapper">
97
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic.html) -->
108
<!-- AURO-GENERATED-CONTENT:END -->
11-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basicButtonOnly.html) -->
9+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basic_button-only.html) -->
1210
<!-- AURO-GENERATED-CONTENT:END -->
1311
</div>
12+
1413
<auro-accordion alignRight>
1514
<span slot="trigger">See code</span>
1615

@@ -19,14 +18,14 @@
1918

2019
</auro-accordion>
2120

22-
### Attribute Examples
21+
## Property & Attribute Examples
2322

24-
#### disabled
23+
### Disabled
2524

2625
This example demonstrates auro-backtotop in its disabled state.
2726

2827
<div class="exampleWrapper">
29-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/disabledButtonOnly.html) -->
28+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/disabled_button-only.html) -->
3029
<!-- AURO-GENERATED-CONTENT:END -->
3130
</div>
3231
<auro-accordion alignRight>
@@ -37,7 +36,7 @@ This example demonstrates auro-backtotop in its disabled state.
3736

3837
</auro-accordion>
3938

40-
#### variant
39+
### Variant
4140

4241
The `variant` attribute allows for rendering the button using the `primary` (default) or `secondary` styles.
4342

@@ -54,25 +53,9 @@ The `variant` attribute allows for rendering the button using the `primary` (def
5453

5554
</auro-accordion>
5655

57-
### Slot Examples
58-
59-
#### default
60-
61-
The default slot defines the content of the button.
62-
63-
<div class="exampleWrapper">
64-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/basicButtonOnly.html) -->
65-
<!-- AURO-GENERATED-CONTENT:END -->
66-
</div>
67-
<auro-accordion alignRight>
68-
<span slot="trigger">See code</span>
69-
70-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../apiExamples/basic.html) -->
71-
<!-- AURO-GENERATED-CONTENT:END -->
56+
## Slot Examples
7257

73-
</auro-accordion>
74-
75-
#### ariaLabel
58+
### Aria Label
7659

7760
The `ariaLabel` slot allows you to pass an aria-label to the HTML5 button. The default value is `"arrow-up"`.
7861

@@ -87,8 +70,3 @@ The `ariaLabel` slot allows you to pass an aria-label to the HTML5 button. The d
8770
<!-- AURO-GENERATED-CONTENT:END -->
8871

8972
</auro-accordion>
90-
91-
## Page Content For Demo
92-
93-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../apiExamples/pageContent.html) -->
94-
<!-- AURO-GENERATED-CONTENT:END -->

0 commit comments

Comments
 (0)