-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): add register static method #21
- `AuroForm.register` is to easily register the element without extra importing - `import '@aurodesignsystem/auro-form'` will still register this element to `<auro-form>` - `import { AuroForm } from '../src/auro-form'` wont register this element until `AuroForm.register` gets called
- Loading branch information
Showing
14 changed files
with
187 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { AuroForm } from "../src/auro-form.js" | ||
|
||
AuroForm.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { css, LitElement, html } from 'lit'; | ||
import AuroLibraryRuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs'; | ||
|
||
var styleCss = css`*,*:before,*:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}*:focus-visible{outline:0}*:focus-visible{outline:0}:focus:not(:focus-visible){outline:3px solid transparent}.testClass{display:inline-block;padding:var(--auro-text-body-size-default);border:1px solid var(--auro-color-border-error-on-light);color:var(--auro-color-border-error-on-light)}:focus-visible{background-color:var(--auro-color-border-error-on-light);color:var(--auro-color-base-white)}`; | ||
|
||
// Copyright (c) 2024 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license | ||
// See LICENSE in the project root for license information. | ||
|
||
|
||
// See https://git.io/JJ6SJ for "How to document your components using JSDoc" | ||
/** | ||
* The auro-form element provides users a way to ... (it would be great if you fill this out). | ||
* | ||
* @attr {Boolean} fixed - Uses fixed pixel values for element shape | ||
* @attr {String} cssClass - Applies designated CSS class to demo element - you want to delete me! | ||
*/ | ||
|
||
// build the component class | ||
class AuroForm extends LitElement { | ||
// constructor() { | ||
// super(); | ||
// } | ||
|
||
// This function is to define props used within the scope of this component | ||
// Be sure to review https://lit.dev/docs/components/properties/ | ||
// to understand how to use reflected attributes with your property settings. | ||
static get properties() { | ||
return { | ||
// ...super.properties, | ||
|
||
// this property is DEMO ONLY! Please delete. | ||
cssClass: { type: String } | ||
}; | ||
} | ||
|
||
static get styles() { | ||
return [styleCss]; | ||
} | ||
|
||
/** | ||
* This will register this element with the browser. | ||
* @param {string} [name="auro-form"] - The name of element that you want to register to. | ||
* | ||
* @example | ||
* AuroForm.register("custom-form") // this will register this element to <custom-form/> | ||
* | ||
*/ | ||
static register(name = "auro-form") { | ||
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroForm); | ||
} | ||
|
||
// When using auroElement, use the following attribute and function when hiding content from screen readers. | ||
// aria-hidden="${this.hideAudible(this.hiddenAudible)}" | ||
|
||
// function that renders the HTML and CSS into the scope of the component | ||
render() { | ||
return html` | ||
<!-- this is demo code, DO NOT USE IN YOUR ELEMENT --> | ||
<div class=${this.cssClass} tabindex="0"> | ||
<slot></slot> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
AuroForm.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { AuroForm } from '../src/auro-form.js'; | ||
|
||
AuroForm.register(); | ||
AuroForm.register('custom-form'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { css, LitElement, html } from 'lit'; | ||
import AuroLibraryRuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs'; | ||
|
||
var styleCss = css`*,*:before,*:after{box-sizing:border-box}@media(prefers-reduced-motion: reduce){*,*:before,*:after{animation-duration:.01ms !important;animation-iteration-count:1 !important;transition-duration:.01ms !important}}*:focus-visible{outline:0}*:focus-visible{outline:0}:focus:not(:focus-visible){outline:3px solid transparent}.testClass{display:inline-block;padding:var(--auro-text-body-size-default);border:1px solid var(--auro-color-border-error-on-light);color:var(--auro-color-border-error-on-light)}:focus-visible{background-color:var(--auro-color-border-error-on-light);color:var(--auro-color-base-white)}`; | ||
|
||
// Copyright (c) 2024 Alaska Airlines. All right reserved. Licensed under the Apache-2.0 license | ||
// See LICENSE in the project root for license information. | ||
|
||
|
||
// See https://git.io/JJ6SJ for "How to document your components using JSDoc" | ||
/** | ||
* The auro-form element provides users a way to ... (it would be great if you fill this out). | ||
* | ||
* @attr {Boolean} fixed - Uses fixed pixel values for element shape | ||
* @attr {String} cssClass - Applies designated CSS class to demo element - you want to delete me! | ||
*/ | ||
|
||
// build the component class | ||
class AuroForm extends LitElement { | ||
// constructor() { | ||
// super(); | ||
// } | ||
|
||
// This function is to define props used within the scope of this component | ||
// Be sure to review https://lit.dev/docs/components/properties/ | ||
// to understand how to use reflected attributes with your property settings. | ||
static get properties() { | ||
return { | ||
// ...super.properties, | ||
|
||
// this property is DEMO ONLY! Please delete. | ||
cssClass: { type: String } | ||
}; | ||
} | ||
|
||
static get styles() { | ||
return [styleCss]; | ||
} | ||
|
||
/** | ||
* This will register this element with the browser. | ||
* @param {string} [name="auro-form"] - The name of element that you want to register to. | ||
* | ||
* @example | ||
* AuroForm.register("custom-form") // this will register this element to <custom-form/> | ||
* | ||
*/ | ||
static register(name = "auro-form") { | ||
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroForm); | ||
} | ||
|
||
// When using auroElement, use the following attribute and function when hiding content from screen readers. | ||
// aria-hidden="${this.hideAudible(this.hiddenAudible)}" | ||
|
||
// function that renders the HTML and CSS into the scope of the component | ||
render() { | ||
return html` | ||
<!-- this is demo code, DO NOT USE IN YOUR ELEMENT --> | ||
<div class=${this.cssClass} tabindex="0"> | ||
<slot></slot> | ||
</div> | ||
`; | ||
} | ||
} | ||
|
||
AuroForm.register(); | ||
AuroForm.register('custom-form'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { AuroForm } from './src/auro-form.js'; | ||
|
||
AuroForm.register(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { AuroInput } from './auro-input.js'; | ||
import { AuroInput } from './src/auro-input.js'; | ||
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs'; | ||
|
||
RuntimeUtils.default.prototype.registerComponent('custom-input', AuroInput); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
// @TODO: import all components | ||
// import { AuroDropdown } from './components/dropdown/src/'; | ||
// import { AuroForm } from './components/form/src/'; | ||
// import { AuroInput } from './components/input/src/'; | ||
|
||
import './components/input/index.js'; | ||
import './components/form/index.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters