Skip to content

Commit 28c4f5f

Browse files
jordanjones243DukeFerdinand
authored andcommitted
perf: modernize component example documentation #67
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 additional packages dependencies updated to latest versions
1 parent f4987fe commit 28c4f5f

20 files changed

+1706
-533
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,5 @@ coverage/
2424
## Added by Auro CLI migration (github-config-and-gitignore-changes)
2525
demo/*.md
2626
demo/*.min.js
27+
28+
custom-elements.json

README.md

Lines changed: 66 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ 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-slideshow>` is an [HTML custom element](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements) for the purpose of displaying a sequence of slides, which can automatically advance through the content or be manually controlled by the user.
2525

26-
The `<auro-slideshow>` component is a wrapper element. All slides are slotted content and must be direct children of the component. Slides must have assigned `width` and `height` properties to display properly.
26+
The `<auro-slideshow>` element is a wrapper element. All slides are slotted content and must be direct children of the element. Slides must have assigned `width` and `height` properties to display properly.
2727

28-
`<auro-slideshow>` is a fully customizable component and does not come with any features turned on by default. The features of `<auro-slideshow>` are turned on by including the proper attributes on the element.
28+
`<auro-slideshow>` is a fully customizable element and does not come with any features turned on by default. The features of `<auro-slideshow>` are turned on by including the proper attributes on the element.
2929

30-
**Note:** If all the slides can fit on the page at once, the slideshow will not activate.
30+
**Note:** If all the slides can fit on the screen at once, the slideshow will not activate.
3131
<!-- AURO-GENERATED-CONTENT:END -->
3232
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/readmeAddlInfo.md) -->
3333
<!-- The below content is automatically added from ./docs/partials/readmeAddlInfo.md -->
@@ -43,17 +43,21 @@ Both `navigation` and `pagination` can be used together, but at least one must b
4343
On mobile devices, `autoScroll` and `navigation` controls are automatically disabled. Users can navigate the slideshow by swiping left or right.
4444
<!-- AURO-GENERATED-CONTENT:END -->
4545

46-
## UI development browser support
46+
## Use Cases
4747

48-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/browserSupport.md) -->
49-
For the most up to date information on [UI development browser support](https://auro.alaskaair.com/support/browsersSupport)
48+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
49+
<!-- The below content is automatically added from ./docs/partials/useCases.md -->
50+
The `<auro-slideshow>` element should be used in situations where:
5051

52+
* A series of images or content needs to be displayed in a space-saving way
53+
* Autoplaying or autoscrolling functionality is needed
54+
* A current slide indicator is required
5155
<!-- AURO-GENERATED-CONTENT:END -->
5256

5357
## Install
5458

5559
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentInstall.md) -->
56-
[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-slideshow/testPublish.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-slideshow/actions/workflows/testPublish.yml)
60+
[![Build Status](https://img.shields.io/github/actions/workflow/status/AlaskaAirlines/auro-slideshow/release.yml?style=for-the-badge)](https://github.com/AlaskaAirlines/auro-slideshow/actions/workflows/release.yml)
5761
[![See it on NPM!](https://img.shields.io/npm/v/@aurodesignsystem/auro-slideshow?style=for-the-badge&color=orange)](https://www.npmjs.com/package/@aurodesignsystem/auro-slideshow)
5862
[![License](https://img.shields.io/npm/l/@aurodesignsystem/auro-slideshow?color=blue&style=for-the-badge)](https://www.apache.org/licenses/LICENSE-2.0)
5963
![ESM supported](https://img.shields.io/badge/ESM-compatible-FFE900?style=for-the-badge)
@@ -64,17 +68,10 @@ $ npm i @aurodesignsystem/auro-slideshow
6468

6569
<!-- AURO-GENERATED-CONTENT:END -->
6670

67-
### Design Token CSS Custom Property dependency
68-
69-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/designTokens.md) -->
70-
The use of any Auro custom element has a dependency on the [Auro Design Tokens](https://auro.alaskaair.com/getting-started/developers/design-tokens).
71-
72-
<!-- AURO-GENERATED-CONTENT:END -->
73-
74-
### Define dependency in project component
71+
### Define Dependency in Project
7572

7673
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImportDescription.md) -->
77-
Defining the component dependency within each component that is using the `<auro-slideshow>` component.
74+
Defining the dependency within each project that is using the `<auro-slideshow>` component.
7875

7976
<!-- AURO-GENERATED-CONTENT:END -->
8077
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/usage/componentImport.md) -->
@@ -84,32 +81,8 @@ import "@aurodesignsystem/auro-slideshow";
8481
```
8582

8683
<!-- AURO-GENERATED-CONTENT:END -->
87-
**Reference component in HTML**
88-
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
89-
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
9084

91-
```html
92-
<auro-slideshow>
93-
<div style="height: 480px">
94-
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=1" alt="Random image 1">
95-
</div>
96-
<div style="height: 480px">
97-
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=2" alt="Random image 2">
98-
</div>
99-
<div style="height: 480px">
100-
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=3" alt="Random image 3">
101-
</div>
102-
<div style="height: 480px">
103-
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=4" alt="Random image 4">
104-
</div>
105-
<div style="height: 480px">
106-
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=5" alt="Random image 5">
107-
</div>
108-
</auro-slideshow>
109-
```
110-
<!-- AURO-GENERATED-CONTENT:END -->
111-
112-
## Use CDN
85+
### Use CDN
11386

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

12194
<!-- AURO-GENERATED-CONTENT:END -->
12295

123-
## auro-slideshow use cases
124-
125-
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/useCases.md) -->
126-
<!-- The below content is automatically added from ./docs/partials/useCases.md -->
127-
The `<auro-slideshow>` element should be used in situations where:
128-
129-
* A series of images or content needs to be displayed in a space-saving way
130-
* Autoplaying or autoscrolling functionality is needed
131-
* A current slide indicator is required
132-
<!-- AURO-GENERATED-CONTENT:END -->
133-
134-
## API Code Examples
135-
136-
### Default auro-slideshow
96+
## Basic Example
13797

13898
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/basic.html) -->
13999
<!-- The below code snippet is automatically added from ./apiExamples/basic.html -->
@@ -159,31 +119,63 @@ The `<auro-slideshow>` element should be used in situations where:
159119
```
160120
<!-- AURO-GENERATED-CONTENT:END -->
161121

162-
## Development
122+
## Custom Component Registration for Version Management
163123

164-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/developmentDescription.md) -->
165-
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.
124+
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.
125+
The class defines the component’s behavior, while the custom element registers it under a specific name so it can be used in HTML.
166126

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

169-
<!-- AURO-GENERATED-CONTENT:END -->
170-
171-
### Start development environment
129+
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.
172130

173-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/localhost.md) -->
174-
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**.
131+
You can do this by importing only the component class and using the `register(name)` method with a unique name:
175132

176-
```shell
177-
$ npm run dev
133+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./docs/partials/customRegistration.md) -->
134+
<!-- The below content is automatically added from ./docs/partials/customRegistration.md -->
135+
136+
```js
137+
// Import the class only
138+
import { AuroSlideshow } from '@aurodesignsystem/auro-slideshow/class';
139+
140+
// Register with a custom name if desired
141+
AuroSlideshow.register('custom-slideshow');
178142
```
179143

180-
Open [localhost:8000](http://localhost:8000/)
181-
144+
This will create a new custom element `<custom-slideshow>` that behaves exactly like `<auro-slideshow>`, allowing both to coexist on the same page without interfering with each other.
182145
<!-- AURO-GENERATED-CONTENT:END -->
146+
<div class="exampleWrapper exampleWrapper--flex">
147+
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./apiExamples/custom.html) -->
148+
<!-- The below content is automatically added from ./apiExamples/custom.html -->
149+
<custom-slideshow navigation>
150+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
151+
<p>Slide 1</p>
152+
</div>
153+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
154+
<p>Slide 2</p>
155+
</div>
156+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
157+
<p>Slide 3</p>
158+
</div>
159+
</custom-slideshow>
160+
<!-- AURO-GENERATED-CONTENT:END -->
161+
</div>
162+
<auro-accordion alignRight>
163+
<span slot="trigger">See code</span>
164+
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./apiExamples/custom.html) -->
165+
<!-- The below code snippet is automatically added from ./apiExamples/custom.html -->
183166

184-
### Testing
185-
186-
<!-- AURO-GENERATED-CONTENT:START (REMOTE:url=https://raw.githubusercontent.com/AlaskaAirlines/auro-templates/main/templates/default/partials/development/testing.md) -->
187-
Automated tests are required for every Auro component. See `.\test\auro-slideshow.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.
188-
189-
<!-- AURO-GENERATED-CONTENT:END -->
167+
```html
168+
<custom-slideshow navigation>
169+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
170+
<p>Slide 1</p>
171+
</div>
172+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
173+
<p>Slide 2</p>
174+
</div>
175+
<div style="width: 400px; border: 2px solid #000; display: flex; justify-content: center;">
176+
<p>Slide 3</p>
177+
</div>
178+
</custom-slideshow>
179+
```
180+
<!-- AURO-GENERATED-CONTENT:END -->
181+
</auro-accordion>

apiExamples/autoplay.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
<auro-slideshow pagination autoplay playOnInit loop>
2+
<auro-slideshow autoplay playOnInit loop>
33
<div style="height: 480px">
44
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=1" alt="Random image 1">
55
</div>

apiExamples/delay.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
<auro-slideshow pagination autoplay delay="2000">
2+
<auro-slideshow autoplay delay="2000">
33
<div style="height: 480px">
44
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=1" alt="Random image 1">
55
</div>
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
<auro-slideshow fullBleed autoplay pagination navigation loop>
2+
<auro-slideshow fullBleed autoplay navigation loop>
33
<div style="height: 480px">
44
<img style="object-fit: cover;" src="https://picsum.photos/1000/480?random=1" alt="Random image 1">
55
</div>
@@ -21,4 +21,4 @@
2121
body {
2222
overflow-x: hidden;
2323
}
24-
</style>
24+
</style>

demo/api.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@
5151
<script type="module" data-demo-script="true" src="./api.min.js"></script>
5252

5353
<!-- If additional elements are needed for the demo, add them here. -->
54-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
54+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
5555
</body>
5656
</html>

demo/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@
5252
});
5353
</script>
5454
<!-- If additional elements are needed for the demo, add them here. -->
55-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
56-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-header@latest/dist/auro-header__bundled.js" type="module"></script>
57-
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-hyperlink@latest/dist/auro-hyperlink__bundled.js" type="module"></script>
55+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/+esm" type="module"></script>
56+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-header@latest/+esm" type="module"></script>
57+
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-hyperlink@latest/+esm" type="module"></script>
5858
</body>
5959
</html>

0 commit comments

Comments
 (0)