Newer
Older
import {Component, Element, Host, h, Prop} from '@stencil/core';
import {IntroductionBgColors, HeadingVarians, HeadingSectionVariants} from '../../utils/utils';
@Component({
tag: 'hy-introduction',
styleUrl: 'hy-introduction.scss',
shadow: false,
})
export class HyIntroduction {
@Prop() variant: IntroductionBgColors = null;
@Prop() reversed: boolean = false;
@Prop() textTitle?: string;
@Prop() textDescription: string = null;
@Prop() url?: string;
@Prop() scLabel?: string;
@Prop() urlTitle?: string;
@Prop() imageUrl?: string;
@Prop() headerstyle: string = 'common';
@Element() el: HTMLElement;
componentDidLoad() {
let hyMainDiv = this.el.closest('.hy-main');
if (hyMainDiv) {
if (!hyMainDiv.classList.contains('with-sidebar')) {
this.headerstyle = 'large';
}
}
}
render() {
const classAttributes = [
'hy-introduction',
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
this.reversed && this.variant == null ? 'hy-introduction--reversed' : '',
this.variant
? `hy-introduction--with-bg hy-introduction--with-bg__${this.variant}`
: 'hy-introduction--without-bg',
].join(' ');
const contentWrapperClasses = [
'hy-introduction__content',
this.reversed && this.variant == null ? 'hy-introduction__content--reversed' : '',
this.imageUrl ? 'hy-introduction__content--with-image' : 'hy-introduction__content--without-image',
].join(' ');
return (
<Host>
<div class={classAttributes}>
<hy-main-content-wrapper>
<div class="hy-introduction__outer-content">
<div class={contentWrapperClasses}>
<hy-heading
class="hy-introduction__title"
heading={HeadingVarians.h2}
section={HeadingSectionVariants.introduction}
>
{this.textTitle}
</hy-heading>
<div class="hy-introduction__description">{this.textDescription}</div>
{this.url && (
<div class="hy-introduction__link__container">
<a class="hy-introduction__link" href={this.url} aria-label={this.scLabel}>
{this.urlTitle}
<span class="hy-introduction__link__icon">
<hy-icon icon={'hy-icon-arrow-right'} size={24} />
</span>
</a>
</div>
)}
</div>
{this.imageUrl && (
<div class="hy-introduction__image">
<hy-image image-url={this.imageUrl} aspectRatioWidth={7} aspectRatioHeight={5} />