Skip to content

Commit f939d71

Browse files
committed
custom js card display based on card type
1 parent 37891d0 commit f939d71

3 files changed

Lines changed: 46 additions & 13 deletions

File tree

ims-docs.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@
101101
src="web-components/hero-section/hero-section.js"
102102
type="module"></script>
103103
<script src="web-components/footer/footer.js" type="module"></script>
104-
<script
105-
src="web-components/card-tile/card-tile.js"
106-
type="module"></script>
104+
<script src="web-components/card-tile/card-tile.js" type="module"></script>
107105
</head>
108106

109107
<!-- MASTHEAD_SITENAV_BEGIN -->
@@ -122,27 +120,31 @@
122120
<section class="white-bg pure-g card-section">
123121
<!-- IMS docs -->
124122
<card-tile
123+
cardtype="support"
125124
name="IMS Docs home"
126125
desc="Start here to search across IMS or IBM product information."
127-
link="https://www.ibm.com/docs/en/ims/latest"
126+
link="https://www.ibm.com/docs/en/ims/latest"
128127
class="pure-u-1 pure-u-lg-1-2">
129128
</card-tile>
130129
<!-- PDF docs -->
131130
<card-tile
131+
cardtype="support"
132132
name="PDF documentation"
133133
desc="Download PDF files of IMS documentation."
134134
link="https://www.ibm.com/docs/en/ims/latest?topic=documentation-pdf-files-ims"
135135
class="pure-u-1 pure-u-lg-1-2">
136136
</card-tile>
137137
<!-- Release planning -->
138138
<card-tile
139+
cardtype="support"
139140
name="Release planning"
140141
desc="See the latest continuous delivery product updates for IMS 15 and later."
141142
link="https://www.ibm.com/docs/en/ims/latest?topic=release-planning-ims"
142143
class="pure-u-1 pure-u-lg-1-2">
143144
</card-tile>
144145
<!-- IMS tools -->
145146
<card-tile
147+
cardtype="support"
146148
name="IMS tools"
147149
desc="Start here to get information on all IMS tools."
148150
link="https://www.ibm.com/docs/en/ims-tools"

ims-videos.html

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@
113113
<card-tile
114114
name="IMS Community Calls"
115115
desc="These calls cover the latest in what's going on in the world of IMS."
116+
level="Varies"
117+
time="Varies"
116118
link="https://mediacenter.ibm.com/playlist/dedicated/122579632/1_lgy10u5e/"
117119
id="ims-comm"
118120
class="pure-u-1 pure-u-lg-1-2 pure-u-xl-1-3"
@@ -149,6 +151,8 @@
149151
<card-tile
150152
name="IMS Insights Series"
151153
desc="These webinars cover timely topics such as new customer perspectives on IMS and managed ACBs."
154+
level="Varies"
155+
time="Varies"
152156
link="https://mediacenter.ibm.com/playlist/dedicated/122579632/1_05jsq9yl/1_ci4q5j5d"
153157
id="ims-insights"
154158
class="pure-u-1 pure-u-lg-1-2 pure-u-xl-1-3"
@@ -159,6 +163,8 @@
159163
<card-tile
160164
name="IMS Tools"
161165
desc="Review the various videos on IMS Tools."
166+
level="Varies"
167+
time="Varies"
162168
link="https://mediacenter.ibm.com/playlist/dedicated/189147413/1_cvhwa8r2/1_5xtr9qnf"
163169
id="ims-tools"
164170
class="pure-u-1 pure-u-lg-1-2 pure-u-xl-1-3"
@@ -225,6 +231,7 @@
225231
name="Managing IMS Buffers"
226232
desc="Check out these three playlists on VSAM, OSAM, and dynamic full-function databases buffers."
227233
level="Intermediate"
234+
time="Varies"
228235
link="https://mediacenter.ibm.com/playlist/details/1_ap436b3k/categoryId/122579632"
229236
linktext="VSAM"
230237
link2="https://mediacenter.ibm.com/playlist/details/1_ywfjxcwn/categoryId/122579632"

web-components/card-tile/card-tile.js

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,23 @@ function createComponent(html) {
3131
* @param {boolean} shadow - A boolean indicating whether to use the shadow DOM for the element.
3232
* @returns {void}
3333
*/
34-
function setLink(url, linkText, cssSelector, name, shadow) {
34+
function setLink(url, linkText, cssSelector, name, cardType, shadow) {
3535
if (url != undefined) {
3636
const linkObj = shadow.querySelector(cssSelector);
3737
linkObj.href = url;
38-
const ariaText = (linkText != 'now') ? `Watch ${name}, ${linkText}` : `Watch ${name}`; // Change link text if defined
38+
39+
// Set link text and aria-label for link based on card type
40+
let ariaText;
41+
let newLinkText;
42+
if (cardType == 'video') {
43+
ariaText = (linkText != 'now') ? `Watch ${name}, ${linkText}` : `Watch ${name}`; // Change link text if defined
44+
newLinkText = `Watch ${linkText} →`;
45+
} else {
46+
ariaText = `Explore ${name}`;
47+
newLinkText = 'Explore →';
48+
}
3949
linkObj.setAttribute('aria-label', ariaText);
40-
linkObj.textContent = `Watch ${linkText} →`;
50+
linkObj.textContent = newLinkText;
4151
}
4252
}
4353

@@ -47,8 +57,7 @@ function createComponent(html) {
4757
// Creates an instance of cardCard
4858
constructor() {
4959
super();
50-
this.level = 'Varies';
51-
this.time = 'Varies';
60+
this.cardtype= 'video';
5261
this.linktext = 'now';
5362
}
5463

@@ -57,7 +66,7 @@ function createComponent(html) {
5766
* @returns {Array} An array of property names.
5867
*/
5968
static get observedAttributes() {
60-
return ['name', 'desc', 'level', 'time', 'link', 'linktext', 'link2', 'linktext2', 'link3', 'linktext3'];
69+
return ['cardtype', 'name', 'desc', 'level', 'time', 'link', 'linktext', 'link2', 'linktext2', 'link3', 'linktext3'];
6170
}
6271

6372
/**
@@ -79,6 +88,20 @@ function createComponent(html) {
7988
const shadow = this.attachShadow({mode: 'closed'});
8089
shadow.innerHTML = html;
8190

91+
// Set card type
92+
const cardSelector = shadow.querySelector('.card');
93+
switch (this.cardtype) {
94+
case 'video':
95+
cardSelector.classList.add('video-card');
96+
break;
97+
case 'support':
98+
cardSelector.classList.add('support-card');
99+
// Hide level and time
100+
const hideSelector = shadow.querySelector('.inline-g');
101+
hideSelector.style.display = 'none';
102+
break;
103+
}
104+
82105
// Set card name
83106
setContent('.card-name', this.name, shadow);
84107
// Set card desc
@@ -87,10 +110,11 @@ function createComponent(html) {
87110
setContent('.card-level', this.level, shadow);
88111
// Set card time
89112
setContent('.card-time', this.time, shadow);
113+
90114
// Set card links
91-
setLink(this.link, this.linktext, '.card-link', this.name, shadow);
92-
setLink(this.link2, this.linktext2, '.card-link-2', this.name, shadow);
93-
setLink(this.link3, this.linktext3, '.card-link-3', this.name, shadow);
115+
setLink(this.link, this.linktext, '.card-link', this.name, this.cardtype, shadow);
116+
setLink(this.link2, this.linktext2, '.card-link-2', this.name, this.cardtype, shadow);
117+
setLink(this.link3, this.linktext3, '.card-link-3', this.name, this.cardtype, shadow);
94118
}
95119
}
96120

0 commit comments

Comments
 (0)