-
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
4a35a5a
commit f74ade2
Showing
11 changed files
with
2,363 additions
and
13 deletions.
There are no files selected for viewing
64 changes: 64 additions & 0 deletions
64
elements/brand/ucd-theme-slim-select/ucd-theme-slim-select.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,64 @@ | ||
import { LitElement } from 'lit'; | ||
import {render, styles} from "./ucd-theme-slim-select.tpl.js"; | ||
|
||
import SlimSelect from 'slim-select'; | ||
|
||
import { Mixin, MutationObserverElement } from "../../utils/index.js"; | ||
|
||
/** | ||
* @class UcdThemeSlimSelect | ||
* @classdesc UI component class for displaying a fancy select. This is a wrapper element around the 'slim-select' package. | ||
* | ||
* Patternlab URL: | ||
* - http://dev.webstyleguide.ucdavis.edu/redesign/?p=atoms-select-menu | ||
*/ | ||
export default class UcdThemeSlimSelect extends Mixin(LitElement) | ||
.with(MutationObserverElement) { | ||
|
||
static get properties() { | ||
return { | ||
|
||
}; | ||
} | ||
|
||
static get styles() { | ||
return styles(); | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.render = render.bind(this); | ||
} | ||
/** | ||
* @method connectedCallback | ||
* @private | ||
* @description Native lifecycle method called when element is connected | ||
*/ | ||
connectedCallback(){ | ||
super.connectedCallback(); | ||
this._childListObserver.disconnect(); | ||
this._childListObserver.observe(this, {subtree: true, childList: true, attributes: true, characterData: true}); | ||
} | ||
|
||
/** | ||
* @method _onChildListMutation | ||
* @private | ||
* @description Fires when light dom child list changes. Injected by MutationObserverElement mixin. | ||
*/ | ||
_onChildListMutation(){ | ||
const children = Array.from(this.children); | ||
if (children.length == 0 || children[0].tagName != "SELECT") return; | ||
const select = children[0].cloneNode(true); | ||
this.renderRoot.innerHTML= ""; | ||
this.renderRoot.appendChild(select); | ||
|
||
this.slimSelect = new SlimSelect({ | ||
select: select, | ||
onChange: (info) => this.dispatchEvent(new CustomEvent("change", {detail: info})) | ||
}); | ||
|
||
} | ||
|
||
} | ||
|
||
customElements.define('ucd-theme-slim-select', UcdThemeSlimSelect); |
26 changes: 26 additions & 0 deletions
26
elements/brand/ucd-theme-slim-select/ucd-theme-slim-select.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,26 @@ | ||
import { html, css } from 'lit'; | ||
|
||
import formStyles from "@ucd-lib/theme-sass/2_base_class/_forms.css.js"; | ||
import slimSelectStyles from "@ucd-lib/theme-sass/slim-select.css.js" | ||
import selectStyles from "@ucd-lib/theme-sass/4_component/_slim-select.css.js"; | ||
|
||
|
||
|
||
export function styles() { | ||
const elementStyles = css` | ||
:host { | ||
display: block; | ||
} | ||
`; | ||
|
||
return [ | ||
formStyles, | ||
slimSelectStyles, | ||
selectStyles, | ||
elementStyles]; | ||
} | ||
|
||
export function render() { | ||
return html` | ||
`;} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"name": "@ucd-lib/theme-elements", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "Custom elements for the UCD brand theme", | ||
"main": "index.js", | ||
"scripts": { | ||
|
@@ -9,8 +9,9 @@ | |
"author": "[email protected]", | ||
"license": "MIT", | ||
"dependencies": { | ||
"@ucd-lib/theme-sass": "^5.0.10", | ||
"@ucd-lib/theme-sass": "^5.0.11", | ||
"lit": "^2.0.0-rc.4", | ||
"photoswipe": "^4.1.3" | ||
"photoswipe": "^4.1.3", | ||
"slim-select": "^1.26.2" | ||
} | ||
} |
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
Oops, something went wrong.