Newer
Older

Ekaterina Kondareva
committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
export interface KeyHighlightValue {
heading: string;
description: string;
}
import {Component, ComponentInterface, Watch, Prop, h} from '@stencil/core';
import {KeyHighlightVariants} from '../../utils/utils';
@Component({
tag: 'hy-key-highlight-group',
styleUrl: 'hy-key-highlight-group.scss',
shadow: true
})
export class HyKeyHighlightGroup implements ComponentInterface {
@Prop() variant: KeyHighlightVariants = KeyHighlightVariants.default;
private _dataItems: KeyHighlightValue[];
@Prop() dataItems: KeyHighlightValue[] | string;
@Watch('dataItems')
arrayDataWatcher(newValue: KeyHighlightValue[] | string) {
if (typeof newValue === 'string') {
this._dataItems = JSON.parse(newValue);
} else {
this._dataItems = newValue;
}
}
componentWillLoad() {
this.arrayDataWatcher(this.dataItems);
}
render() {
const classAttributes = [this.variant, 'hy-key-highlight-group'].join(' ');
return (
<div class={classAttributes}>
{this._dataItems.map((x) => {
return <hy-key-highlight variant={this.variant} heading={x.heading} description={x.description} />;
})}
</div>
);
}
}