Newer
Older
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
44
45
46
47
48
49
50
export interface ProcessFlowValue {
phaseTitle: string;
boxes: string;
}
import {Component, ComponentInterface, h, Prop, Watch} from '@stencil/core';
import {HeadingVarians} from '../../utils/utils';
@Component({
tag: 'hy-large-process-flow',
styleUrl: 'hy-large-process-flow.scss',
shadow: true,
})
export class HyLargeProcessFlow implements ComponentInterface {
private _dataItems: ProcessFlowValue[];
@Prop() dataItems: ProcessFlowValue[] | string;
@Watch('dataItems')
arrayDataWatcher(newValue: ProcessFlowValue[] | string) {
if (typeof newValue === 'string') {
this._dataItems = JSON.parse(newValue);
} else {
this._dataItems = newValue;
}
}
componentWillLoad() {
this.arrayDataWatcher(this.dataItems);
}
render() {
const classAttributes = ['hy-large-process-flow'].join(' ');
return (
<div class={classAttributes}>
{this._dataItems.map((x, index) => {
let phases = JSON.stringify(x.boxes);
const headingClasses =
index !== 0 ? 'hy-large-process-flow__multi-phase-title' : 'hy-large-process-flow__first-phase';
return [
<hy-heading class={headingClasses} heading={HeadingVarians.h3}>
{x.phaseTitle}
</hy-heading>,
<hy-large-process-flow-phase data-items={phases} />,
];
})}
</div>
);
}
}