-
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.
- Loading branch information
1 parent
801b7ff
commit 2ea2847
Showing
6 changed files
with
68 additions
and
2 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
services/ucd-lib-client/client/public/elements/components/graphics/dams-hero.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { LitElement } from 'lit-element'; | ||
import render from "./dams-hero.tpl.js"; | ||
|
||
/** | ||
* @class DamsHero | ||
* @description UI component for displaying a hero image | ||
* @prop {Array} srcOptions - Set of images sources to randomly display | ||
* @prop {String} src - Background image source | ||
*/ | ||
export default class DamsHero extends LitElement { | ||
|
||
static get properties() { | ||
return { | ||
src: {type: String}, | ||
srcOptions: {type: Array, attribute: "src-options"}, | ||
_selectedSrc: {type: String} | ||
}; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.render = render.bind(this); | ||
this.src = ""; | ||
this.srcOptions = []; | ||
} | ||
|
||
/** | ||
* @method _setSrc | ||
* @description Sets the background image src property. | ||
*/ | ||
_setSrc(){ | ||
let src = ""; | ||
let setCt = this.srcOptions.length; | ||
if ( setCt === 0 && this.src ) src = this.src; | ||
if ( !src && setCt > 0 ) { | ||
src = Math.floor(Math.random() * setCt + 1); | ||
} | ||
this._selectedSrc = src; | ||
} | ||
|
||
} | ||
|
||
customElements.define('dams-hero', DamsHero); |
13 changes: 13 additions & 0 deletions
13
services/ucd-lib-client/client/public/elements/components/graphics/dams-hero.tpl.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { html } from 'lit-element'; | ||
|
||
export default function render() { | ||
return html` | ||
<style> | ||
:host { | ||
display: block; | ||
} | ||
</style> | ||
<p>Hello world!</p> | ||
`;} |
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