Skip to content

Commit f7a8005

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 f7a8005

18 files changed

+2484
-1840
lines changed

README.md

Lines changed: 42 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -23,24 +23,26 @@ The following sections are editable by making changes to the following files:
2323
<!-- The below content is automatically added from ./docs/partials/description.md -->
2424
`<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.
2525

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.
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.
2727
<!-- AURO-GENERATED-CONTENT:END -->
2828
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/readmeAddlInfo.md) -->
2929
<!-- The below content is automatically added from ./docs/partials/readmeAddlInfo.md -->
3030
<!-- 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. -->
3131
<!-- AURO-GENERATED-CONTENT:END -->
3232

33-
## UI development browser support
33+
## Use Cases
3434

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)
35+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
36+
<!-- The below content is automatically added from ./docs/partials/useCases.md -->
37+
The `<auro-backtotop>` element should be used in situations where users may:
3738

39+
* Pages with large amounts of content where a shortcut to jump to the top of the page is appropriate.
3840
<!-- AURO-GENERATED-CONTENT:END -->
3941

4042
## Install
4143

4244
<!-- 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)
45+
[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-backtotop/release.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-backtotop/actions/workflows/release.yml)
4446
[![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)
4547
[![License](https://img.shields.io/npm/l/@aurodesignsystem/auro-backtotop?color=blue&style=for-the-badge)](https://www.apache.org/licenses/LICENSE-2.0)
4648
![ESM supported](https://img.shields.io/badge/ESM-compatible-FFE900?style=for-the-badge)
@@ -51,17 +53,10 @@ $ npm i @aurodesignsystem/auro-backtotop
5153

5254
<!-- AURO-GENERATED-CONTENT:END -->
5355

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
56+
### Define Dependency in Project
6257

6358
<!-- 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.
59+
Defining the dependency within each project that is using the `<auro-backtotop>` component.
6560

6661
<!-- AURO-GENERATED-CONTENT:END -->
6762
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImport.md) -->
@@ -70,17 +65,9 @@ Defining the component dependency within each component that is using the `<auro
7065
import "@aurodesignsystem/auro-backtotop";
7166
```
7267

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-
```
8168
<!-- AURO-GENERATED-CONTENT:END -->
8269

83-
## Use CDN
70+
### Use CDN
8471

8572
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/bundleInstallDescription.md) -->
8673
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.
@@ -91,18 +78,7 @@ In cases where the project is not able to process JS assets, there are pre-proce
9178

9279
<!-- AURO-GENERATED-CONTENT:END -->
9380

94-
## auro-backtotop use cases
95-
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:
99-
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
81+
## Basic Example
10682

10783
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
10884
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
@@ -112,31 +88,43 @@ The `<auro-backtotop>` element should be used in situations where users may:
11288
```
11389
<!-- AURO-GENERATED-CONTENT:END -->
11490

115-
## Development
91+
## Custom Component Registration for Version Management
11692

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.
93+
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.
94+
The class defines the component’s behavior, while the custom element registers it under a specific name so it can be used in HTML.
11995

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.
96+
When you install the component as described on the `Install` page, the class is imported automatically, and the component is registered globally for you.
12197

122-
<!-- AURO-GENERATED-CONTENT:END -->
123-
124-
### Start development environment
98+
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.
12599

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**.
100+
You can do this by importing only the component class and using the `register(name)` method with a unique name:
128101

129-
```shell
130-
$ npm run dev
102+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/customRegistration.md) -->
103+
<!-- The below content is automatically added from ./docs/partials/customRegistration.md -->
104+
105+
```js
106+
// Import the class only
107+
import { AuroBackToTop } from '@aurodesignsystem/auro-backtotop/class';
108+
109+
// Register with a custom name if desired
110+
AuroBackToTop.register('custom-backtotop');
131111
```
132112

133-
Open [localhost:8000](http://localhost:8000/)
134-
113+
This will create a new custom element `<custom-backtotop>` that behaves exactly like `<auro-backtotop>`, allowing both to coexist on the same page without interfering with each other.
135114
<!-- AURO-GENERATED-CONTENT:END -->
115+
<div class="exampleWrapper exampleWrapper--flex">
116+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./apiExamples/custom.html) -->
117+
<!-- The below content is automatically added from ./apiExamples/custom.html -->
118+
<custom-backtotop>Custom back to top</custom-backtotop>
119+
<!-- AURO-GENERATED-CONTENT:END -->
120+
</div>
121+
<auro-accordion alignRight>
122+
<span slot="trigger">See code</span>
123+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/custom.html) -->
124+
<!-- The below code snippet is automatically added from ./apiExamples/custom.html -->
136125

137-
### Testing
138-
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.
141-
142-
<!-- AURO-GENERATED-CONTENT:END -->
126+
```html
127+
<custom-backtotop>Custom back to top</custom-backtotop>
128+
```
129+
<!-- AURO-GENERATED-CONTENT:END -->
130+
</auro-accordion>

apiExamples/custom.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<custom-backtotop>Custom back to top</custom-backtotop>

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

0 commit comments

Comments
 (0)