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 #136 #132 #137

Merged
merged 16 commits into from
Nov 5, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
9 changes: 9 additions & 0 deletions apiExamples/custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<custom-flight
flights='["AS 1436"]'
duration="161"
departureTime="2022-07-13T12:15:00-07:00"
departureStation="SEA"
arrivalTime="2022-07-13T14:56:00-07:00"
arrivalStation="LAX">
<auro-flightline></auro-flightline>
</custom-flight>
1 change: 0 additions & 1 deletion demo/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
<script type="module" src="../index.js"></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>
sun-mota marked this conversation as resolved.
Show resolved Hide resolved
</body>
</html>
3 changes: 1 addition & 2 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,9 @@
Prism.highlightAll();
});
</script>
<script type="module" src="../index.js"></script>
<script type="module" src="./index.min.js"></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>
sun-mota marked this conversation as resolved.
Show resolved Hide resolved
</body>
</html>
4 changes: 4 additions & 0 deletions demo/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { AuroFlight } from '../src/auro-flight.js';

AuroFlight.register();
AuroFlight.register('custom-flight');
47 changes: 47 additions & 0 deletions demo/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,53 @@ The following example illustrates additional data regarding departure and arriva
</auro-accordion>
<hr/>

## 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 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-flight` custom element is defined automatically.

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

```js
import { AuroFlight } from '@aurodesignsystem/auro-flight/src/auro-flight.js';

AuroFlight.register('custom-flight');
```

This will create a new custom element that you can use in your HTML that will function identically to the `<auro-flight>` 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-flight
flights='["AS 1436"]'
duration="161"
departureTime="2022-07-13T12:15:00-07:00"
departureStation="SEA"
arrivalTime="2022-07-13T14:56:00-07:00"
arrivalStation="LAX">
<auro-flightline></auro-flightline>
</custom-flight>
<!-- 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-flight
flights='["AS 1436"]'
duration="161"
departureTime="2022-07-13T12:15:00-07:00"
departureStation="SEA"
arrivalTime="2022-07-13T14:56:00-07:00"
arrivalStation="LAX">
<auro-flightline></auro-flightline>
</custom-flight>
```
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>

## DoT regulations

Department of Transportation regulations mandate that the arrival and departure cities' font size and color be identical to the operational disclosures (for instance, AA 3210 is operated by Envoy Air on behalf of American Airlines).
Expand Down
479 changes: 479 additions & 0 deletions demo/index.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions docs/partials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,29 @@ The following example illustrates additional data regarding departure and arriva

<hr/>

## 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 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-flight` custom element is defined automatically.

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

```js
import { AuroFlight } from '@aurodesignsystem/auro-flight/src/auro-flight.js';

AuroFlight.register('custom-flight');
```

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

<div class="exampleWrapper exampleWrapper--flex">
<!-- AURO-GENERATED-CONTENT:START (FILE:src=./../../apiExamples/custom.html) -->
<!-- AURO-GENERATED-CONTENT:END -->
</div>
<auro-accordion alignRight>
<span slot="trigger">See code</span>
<!-- AURO-GENERATED-CONTENT:START (CODE:src=./../../apiExamples/custom.html) -->
<!-- AURO-GENERATED-CONTENT:END -->
</auro-accordion>


## DoT regulations
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 { AuroFlight } from './src/auro-flight.js';
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs';

RuntimeUtils.default.prototype.registerComponent('custom-flight', AuroFlight);
AuroFlight.register();
Loading