-
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
`AuroSkeleton.register` is to easily register the element without extra importing `import '@aurodesignsystem/auro-skeleton'` will still register this element to `<auro-skeleton>` `import { AuroSkeleton } from '../src/auro-skeleton.js'` wont register this element until `AuroSkeleton.register` gets called
- Loading branch information
Showing
11 changed files
with
111 additions
and
25 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 { AuroSkeleton } from '../src/auro-skeleton.js'; | ||
|
||
AuroSkeleton.register('custom-skeleton'); |
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,75 @@ | ||
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}.util_displayInline{display:inline}.util_displayInlineBlock{display:inline-block}.util_displayBlock{display:block}.util_displayFlex{display:flex}.util_displayHidden{display:none}.util_displayHiddenVisually{position:absolute;overflow:hidden;clip:rect(1px, 1px, 1px, 1px);width:1px;height:1px;padding:0;border:0}:host{display:block;animation-duration:2s;animation-fill-mode:backwards;animation-iteration-count:infinite;animation-name:place-holder-shimmer;animation-timing-function:linear;background-repeat:no-repeat;background-size:1000px 100%}:host([shape=circle]){width:auto;border-radius:50%}:host([shape=oval]){border-radius:9999px}:host([shape=rectangle]){border-radius:var(--ds-border-radius, 0.375rem)}@keyframes place-holder-shimmer{from{background-position:-1000px 0}to{background-position:1000px 0}}`; | ||
|
||
var colorCss = css`:host{background-color:var(--ds-auro-skeleton-container-color);background-image:linear-gradient(to right, var(--ds-auro-skeleton-container-gradient-color-one) 10%, var(--ds-auro-skeleton-container-gradient-color-two) 40%, var(--ds-auro-skeleton-container-gradient-color-one) 60%)}`; | ||
|
||
var tokensCss = css`:host{--ds-auro-skeleton-container-color: var(--ds-color-container-subtle-default, #f7f8fa);--ds-auro-skeleton-container-gradient-color-one: var(--ds-color-container-subtle-default, #f7f8fa);--ds-auro-skeleton-container-gradient-color-two: var(--ds-color-container-tertiary-default, rgba(0, 0, 0, 0.03))}`; | ||
|
||
// Copyright (c) 2021 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-skeleton element provides users a way to indicate the loading of asynchronous content on a page. | ||
* | ||
* @attr {String} shape - Renders a circle, oval, or rectangle loader. | ||
*/ | ||
|
||
// build the component class | ||
class AuroSkeleton extends LitElement { | ||
constructor() { | ||
super(); | ||
|
||
/** | ||
* @private | ||
*/ | ||
this.runtimeUtils = new AuroLibraryRuntimeUtils(); | ||
} | ||
|
||
// function to define props used within the scope of this component | ||
static get properties() { | ||
return { | ||
// ...super.properties, | ||
}; | ||
} | ||
|
||
static get styles() { | ||
return [ | ||
styleCss, | ||
colorCss, | ||
tokensCss | ||
]; | ||
} | ||
|
||
/** | ||
* This will register this element with the browser. | ||
* @param {string} [name="auro-skeleton"] - The name of element that you want to register to. | ||
* | ||
* @example | ||
* AuroSkeleton.register("custom-skeleton") // this will register this element to <custom-skeleton/> | ||
* | ||
*/ | ||
static register(name = "auro-skeleton") { | ||
AuroLibraryRuntimeUtils.prototype.registerComponent(name, AuroSkeleton); | ||
} | ||
|
||
firstUpdated() { | ||
// Add the tag name as an attribute if it is different than the component name | ||
this.runtimeUtils.handleComponentTagRename(this, 'auro-skeleton'); | ||
} | ||
|
||
// 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` | ||
<span class="util_displayHiddenVisually">Loading...</span> | ||
`; | ||
} | ||
} | ||
|
||
AuroSkeleton.register('custom-skeleton'); |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
import { AuroSkeleton } from './src/auro-skeleton.js'; | ||
import * as RuntimeUtils from '@aurodesignsystem/auro-library/scripts/utils/runtimeUtils.mjs'; | ||
|
||
RuntimeUtils.default.prototype.registerComponent('custom-skeleton', AuroSkeleton); | ||
AuroSkeleton.register(); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
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