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

feat(api): add register static method #268

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 1 addition & 3 deletions demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@
Prism.highlightAll();
});
</script>
<script type="module" data-demo-script="true" src="../index.js"></script>
<script type="module">
<script type="module" data-demo-script="true">
import { initExamples } from './api.min.js';
initExamples();
</script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/dist/auro-icon__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-alert@latest/dist/auro-alert__bundled.js" type="module"></script>

<script src="https://cdn.jsdelivr.net/npm/marked@latest/marked.min.js"></script>
Expand Down
2 changes: 2 additions & 0 deletions demo/api.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { toggledTextExample } from "../apiExamples/toggledText";
import { roundedRightAlignExample } from "../apiExamples/roundedRightAlign";

import '../index.js';

export function initExamples(initCount) {
initCount = initCount || 0;

Expand Down
251 changes: 251 additions & 0 deletions demo/api.min.js

Large diffs are not rendered by default.

10 changes: 1 addition & 9 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,10 @@
});
</script>
<script type="module" data-demo-script="true">
import { AuroButton } from '../src/auro-button.js';
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-button', AuroButton);

import { initExamples } from './index.min.js';

registerComponent('custom-button');
import { initExamples } from './index.min.js';
initExamples();
</script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-accordion@latest/dist/auro-accordion__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-icon@latest/dist/auro-icon__bundled.js" type="module"></script>
<script src="https://cdn.jsdelivr.net/npm/@aurodesignsystem/auro-alert@latest/dist/auro-alert__bundled.js" type="module"></script>

<script src="https://cdn.jsdelivr.net/npm/marked@latest/marked.min.js"></script>
Expand Down
3 changes: 3 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { AuroButton } from '../src/auro-button.js';

AuroButton.register('custom-button');

export function initExamples(initCount) {
initCount = initCount || 0;
Expand Down
7 changes: 3 additions & 4 deletions demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -223,15 +223,14 @@ Don't combine `disabled` and `loading` attributes on any single instance of `aur

## 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-button` custom element is defined automatically.
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-button` 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.
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `AuroButton.register(name)` method and pass in a unique name.

```js
import { AuroButton } from './src/auro-button.js';
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-button', AuroButton);
AuroButton.register('custom-button');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-button>` element.
Expand Down
251 changes: 251 additions & 0 deletions demo/index.min.js

Large diffs are not rendered by default.

7 changes: 3 additions & 4 deletions docs/partials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,15 +136,14 @@ Don't combine `disabled` and `loading` attributes on any single instance of `aur

## 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-button` custom element is defined automatically.
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-button` 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.
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `AuroButton.register(name)` method and pass in a unique name.

```js
import { AuroButton } from './src/auro-button.js';
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-button', AuroButton);
AuroButton.register('custom-button');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-button>` element.
Expand Down
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { AuroButton } from './src/auro-button.js';
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-button', AuroButton);
AuroButton.register();
Loading
Loading