Skip to content

Commit bc8e212

Browse files
committed
learn hero section
1 parent 63d6f78 commit bc8e212

4 files changed

Lines changed: 52 additions & 16 deletions

File tree

ims-videos.html

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
<!-- Web components -->
8080
<script src="web-components/video-card/video-card.js" type="module"></script>
81+
<script src="web-components/hero-section/hero-section.js" type="module"></script>
8182
</head>
8283

8384
<!-- PAGE CONTENT -->
@@ -311,7 +312,7 @@ <h2 class="video-name"></h2>
311312
<div id="content" class="main-content">
312313
<main id="main">
313314
<!-- =========================== Hero =========================== -->
314-
<section class="learn-bg">
315+
<!-- <section class="learn-bg">
315316
<div id="intro-section" class="pure-g hero">
316317
<div class="pure-u-1 pure-u-md-1-24">
317318
<img src="wp-content/Icon_Managed ACBs_IMS DatabasePage.svg" alt="" class="icon icon-lg">
@@ -332,7 +333,15 @@ <h1>IMS videos</h1>
332333
</div>
333334
</div>
334335
</div>
335-
</section>
336+
</section> -->
337+
338+
<hero-section
339+
name="IMS videos"
340+
section="Learn"
341+
desc="<p>See the latest IMS educational videos here or click <b>Visit IBM MediaCenter</b> to search for more IMS video content.</p>"
342+
linktext="Visit IBM MediaCenter →"
343+
link="https://mediacenter.ibm.com/channel/IMS%2BEducational%2BVideos/122579632"
344+
></hero-section>
336345

337346
<!-- =========================== Filter =========================== -->
338347
<!-- remember, the behaviour is that clicking pulls you to the anchors -->

web-components/hero-section/hero-section.css

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@
55
color: white;
66
}
77

8+
.learn-bg {
9+
background-image: url(../../wp-content/backgrounds/Learn_HomepageBG.png);
10+
background-repeat: no-repeat;
11+
background-size: cover;
12+
background-position: right;
13+
color: black;
14+
}
15+
816
section {
917
display: grid;
1018
grid-template-columns: 4em 2fr;
@@ -23,6 +31,7 @@ section {
2331
img {
2432
grid-column: 1;
2533
grid-row: 2;
34+
width: 2em;
2635
}
2736

2837
.section {

web-components/hero-section/hero-section.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
<div class="links">
88
<a onfocus="closeNavMenu()"
99
rel="noopener noreferrer"
10-
class="link-primary button button-primary"
10+
class="button button-primary"
1111
>
12-
<span class="link-primary-text"></span>
12+
<span class="button-primary-text"></span>
1313
</a>
1414
<a rel="noopener noreferrer"
15-
class="link-secondary button button-secondary"
15+
class="button button-secondary"
1616
>
17-
<span class="link-secondary-text"></span>
17+
<span class="button-secondary-text"></span>
1818
</a>
1919
</div>
2020
</section>

web-components/hero-section/hero-section.js

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@ function createComponent(html) {
88

99
function setContent(cssSelector, content, shadow) {
1010
const selector = shadow.querySelector(cssSelector);
11-
selector.textContent = content;
11+
if (content.includes('<p>')) {
12+
let paragraph = document.createElement('p');
13+
paragraph.innerHTML = content;
14+
selector.appendChild(paragraph);
15+
} else {
16+
selector.textContent = content;
17+
}
1218
}
1319

14-
function setLink(cssSelector, url, name, shadow) {
20+
function setLink(cssSelector, url, shadow) {
1521
const link = shadow.querySelector(cssSelector);
1622
link.href = url;
17-
link.setAttribute('aria-label', `Learn more about ${name}`);
23+
if (url.includes('https://')) {
24+
link.setAttribute('target', '_blank');
25+
}
1826
}
1927

2028
function setImage(cssSelector, src, shadow) {
@@ -29,6 +37,7 @@ function createComponent(html) {
2937
// Creates element with default values
3038
constructor() {
3139
super();
40+
this.link2 = "";
3241
}
3342

3443
// Return array of properties to observe
@@ -51,19 +60,28 @@ function createComponent(html) {
5160
setContent('.section', this.section, shadow);
5261
setContent('.name', this.name, shadow);
5362
setContent('.desc', this.desc, shadow);
54-
setLink('.link-primary', this.link, this.name, shadow);
55-
setContent('.link-primary-text', this.linktext, shadow);
56-
setLink('.link-secondary', this.link2, this.name, shadow);
57-
setContent('.link-secondary-text', this.linktext2, shadow);
63+
setLink('.button-primary', this.link, shadow);
64+
setContent('.button-primary-text', this.linktext, shadow);
5865

59-
// Check if links are external
66+
if (this.link2 != "") {
67+
setLink('.button-secondary', this.link2, shadow);
68+
setContent('.button-secondary-text', this.linktext2, shadow);
69+
} else {
70+
const buttonSecondary = shadow.querySelector('.button-secondary');
71+
buttonSecondary.style.display = 'none';
72+
}
6073

74+
// Check if links are external
75+
const heroSection = shadow.querySelector('.hero');
6176
switch(this.section) {
6277
case 'Engage':
63-
const selector = shadow.querySelector('.hero');
64-
selector.classList.add('engage-bg');
78+
heroSection.classList.add('engage-bg');
6579
setImage('.image', 'wp-content/icons/icon_engage.svg', shadow);
6680
break;
81+
case 'Learn':
82+
heroSection.classList.add('learn-bg');
83+
setImage('.image', 'wp-content/Icon_Managed ACBs_IMS DatabasePage.svg', shadow);
84+
break;
6785
}
6886
}
6987
}

0 commit comments

Comments
 (0)