Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(docs): add custom registration example #30

Merged
merged 1 commit into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apiExamples/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<custom-skeleton shape="circle" style="width: 40px; height: 40px"></custom-skeleton>
<custom-skeleton shape="oval" style="width: 200px; height: 100px;"></custom-skeleton>
<custom-skeleton shape="rectangle" style="width: 400px; height: 300px"></custom-skeleton>
5 changes: 5 additions & 0 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@
});
</script>
<script type="module" data-demo-script="true" src="../index.js"></script>
<script type="module">
import { registerComponent } from '../index.js';

registerComponent('custom-skeleton');
</script>

<!-- If additional elements are needed for the demo, add them here. -->
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
Expand Down
34 changes: 34 additions & 0 deletions demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,38 @@ Use your imagination. Wherever data can be placed, an `<auro-skelelton>` element
</table>
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

## Recommended Use and Version Control

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 clement. 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-skeleton` custom element is defined automatically.

To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `registerComponent(name)` method and pass in a unique name.

```js
import './node_modules/@aurodesignsystem/auro-skeleton';
registerComponent('custom-skeleton');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-skeleton>` element.

<div class="exampleWrapper exampleWrapper--flex">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../../apiExamples/custom.html) -->
<!-- The below content is automatically added from ./../../apiExamples/custom.html -->
<custom-skeleton shape="circle" style="width: 40px; height: 40px"></custom-skeleton>
<custom-skeleton shape="oval" style="width: 200px; height: 100px;"></custom-skeleton>
<custom-skeleton shape="rectangle" style="width: 400px; height: 300px"></custom-skeleton>
<!-- AURO-GENERATED-CONTENT:END -->
</div>
<auro-accordion alignRight>
<span slot="trigger">See code</span>
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../apiExamples/custom.html) -->
<!-- The below code snippet is automatically added from ./../../apiExamples/custom.html -->

```html
<custom-skeleton shape="circle" style="width: 40px; height: 40px"></custom-skeleton>
<custom-skeleton shape="oval" style="width: 200px; height: 100px;"></custom-skeleton>
<custom-skeleton shape="rectangle" style="width: 400px; height: 300px"></custom-skeleton>
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>
32 changes: 32 additions & 0 deletions docs/partials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,35 @@ Use your imagination. Wherever data can be placed, an `<auro-skelelton>` element
<!-- AURO-GENERATED-CONTENT:END -->

</auro-accordion>

## Recommended Use and Version Control

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 clement. 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-skeleton` custom element is defined automatically.

To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `registerComponent(name)` method and pass in a unique name.

```js
import './node_modules/@aurodesignsystem/auro-skeleton';
registerComponent('custom-skeleton');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-skeleton>` element.

<div class="exampleWrapper exampleWrapper--flex">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../../apiExamples/custom.html) -->
<!-- The below content is automatically added from ./../../apiExamples/custom.html -->
<custom-skeleton></custom-skeleton>
<custom-skeleton bordered></custom-skeleton>
<!-- AURO-GENERATED-CONTENT:END -->
</div>
<auro-accordion alignRight>
<span slot="trigger">See code</span>
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../apiExamples/custom.html) -->
<!-- The below code snippet is automatically added from ./../../apiExamples/custom.html -->

```html
<custom-skeleton></custom-skeleton>
<custom-skeleton bordered></custom-skeleton>
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.