Newer
Older
@Component({
tag: 'hy-general-list',
styleUrl: 'hy-general-list.scss',
shadow: true,
})
export class HyGeneralList {
@Prop() dataItems: ListItemValue[] | string;
private _dataItems: ListItemValue[];
@Watch('dataItems')
arrayDataWatcher(newValue: ListItemValue[] | string) {
if (typeof newValue === 'string') {
this._dataItems = JSON.parse(newValue);
} else {
this._dataItems = newValue;
}
}
componentWillLoad() {
this.arrayDataWatcher(this.dataItems);
}
render() {
const classAttributes = ['hy-general-list'].join(' ');
return (
<ul class={classAttributes}>
{this._dataItems.map((item) => (
<li>
data-location={item.url}
description={item.description}
id={item.id}
imageAlt={item.imageAlt}
imageUrl={item.imageUrl}
item-title={item.title}
label={item.label}
type={item.type}
url={item.url}
></hy-general-list-item>
</li>
))}
</ul>
);