mirror of
https://github.com/status-im/consul.git
synced 2025-01-20 18:50:04 +00:00
25f3ebd66a
Builds on attach-shadow, adopt-styles and ShadowTemplate, this commit adds ShadowHost and finally CustomElement. CustomElement is a renderless component to help with the creation of native HTML Custom Elements along with runtime type checking and self-documentation for attributes, slots, cssprops and cssparts. As you will probably see there is a little more work to come here. But in the same breath, everything would be fine to go in as is.
19 lines
643 B
JavaScript
19 lines
643 B
JavaScript
import { helper } from '@ember/component/helper';
|
|
|
|
/**
|
|
* Conditionally maps classInfos (classes) to a string ready for typical DOM
|
|
* usage (i.e. space delimited)
|
|
*
|
|
* @typedef {([string, boolean] | [string])} classInfo
|
|
* @param {(classInfo | string)[]} entries - An array of 'entry-like' arrays of `classInfo`s to map
|
|
*/
|
|
const classMap = entries => {
|
|
const str = entries
|
|
.filter(Boolean)
|
|
.filter(entry => (typeof entry === 'string' ? true : entry[entry.length - 1]))
|
|
.map(entry => (typeof entry === 'string' ? entry : entry[0]))
|
|
.join(' ');
|
|
return str.length > 0 ? str : undefined;
|
|
};
|
|
export default helper(classMap);
|