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 #82 #38

Merged
merged 2 commits into from
Oct 23, 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
2 changes: 1 addition & 1 deletion demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@
<!-- 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>

<script type="module" src="../index.js" data-demo-script="true"></script>
<script type="module" src="./api.min.js" data-demo-script="true"></script>
</body>
</html>
1 change: 1 addition & 0 deletions demo/api.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import '../index.js';
292 changes: 292 additions & 0 deletions demo/api.min.js

Large diffs are not rendered by default.

13 changes: 1 addition & 12 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,7 @@
<!-- 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>

<script type="module" src="../index.js" data-demo-script="true"></script>
<script type="module">
import { AuroSideNav } from '../src/auro-sidenav.js';
import { AuroSideNavItem } from '../src/auro-sidenavitem.js';
import { AuroSideNavSection } from '../src/auro-sidenavsection.js';

import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-sidenav', AuroSideNav);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavitem', AuroSideNavItem);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavsection', AuroSideNavSection);
</script>
<script type="module" src="./index.min.js" data-demo-script="true"></script>

<script>
// This design token variable can be whatever/from wherever you want
Expand Down
13 changes: 13 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/* eslint-disable jsdoc/require-jsdoc, no-magic-numbers, no-param-reassign */

import { AuroSideNav } from '../src/auro-sidenav.js';
import { AuroSideNavItem } from '../src/auro-sidenavitem.js';
import { AuroSideNavSection } from '../src/auro-sidenavsection.js';

AuroSideNav.register();
AuroSideNavItem.register();
AuroSideNavSection.register();

AuroSideNav.register('custom-sidenav');
AuroSideNavItem.register('custom-sidenavitem');
AuroSideNavSection.register('custom-sidenavsection');
12 changes: 5 additions & 7 deletions demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,20 +349,18 @@ The `<auro-sidenav>` element uses the attribute `static` to toggle on/off accord

## 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-sidenav>` 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-sidenav>` 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.
sun-mota marked this conversation as resolved.
Show resolved Hide resolved
To protect from versioning conflicts with other instances of the component being loaded, it is recommended to use our `register(name)` method in our `AuroSideNav` related components and pass in a unique name.

```js
import { AuroSideNav } from './src/auro-sidenav.js';
import { AuroSideNavItem } from './src/auro-sidenavitem.js';
import { AuroSideNavSection } from './src/auro-sidenavsection.js';

import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-sidenav', AuroSideNav);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavitem', AuroSideNavItem);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavsection', AuroSideNavSection);
AuroSideNav.register('custom-sidenav');
AuroSideNavItem.register('custom-sidenavitem');
AuroSideNavSection.register('custom-sidenavsection');
```

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

Large diffs are not rendered by default.

12 changes: 5 additions & 7 deletions docs/partials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,20 +131,18 @@ The `<auro-sidenav>` element uses the attribute `static` to toggle on/off accord

## 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-sidenav>` 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-sidenav>` 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 `register(name)` method in our `AuroSideNav` related components and pass in a unique name.

```js
import { AuroSideNav } from './src/auro-sidenav.js';
import { AuroSideNavItem } from './src/auro-sidenavitem.js';
import { AuroSideNavSection } from './src/auro-sidenavsection.js';

import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-sidenav', AuroSideNav);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavitem', AuroSideNavItem);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavsection', AuroSideNavSection);
AuroSideNav.register('custom-sidenav');
AuroSideNavItem.register('custom-sidenavitem');
AuroSideNavSection.register('custom-sidenavsection');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-sidenav>` element.
Expand Down
7 changes: 3 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import { AuroSideNav } from './src/auro-sidenav.js';
import { AuroSideNavItem } from './src/auro-sidenavitem.js';
import { AuroSideNavSection } from './src/auro-sidenavsection.js';

import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-sidenav', AuroSideNav);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavitem', AuroSideNavItem);
RuntimeUtils.default.prototype.registerComponent('custom-sidenavsection', AuroSideNavSection);
AuroSideNav.register();
AuroSideNavItem.register();
AuroSideNavSection.register();
Loading
Loading