Skip to content

Commit 28560a5

Browse files
committed
video card component
1 parent 4aac061 commit 28560a5

3 files changed

Lines changed: 144 additions & 0 deletions

File tree

ims-videos.html

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
<link href="wp-includes/css/grid-fluid.css" rel="stylesheet">
5252
<link href="wp-includes/css/tables.css" rel="stylesheet">
5353
<link href="wp-includes/css/pages/videos.css" rel="stylesheet">
54+
<link href="wp-includes/css/page.css" rel="stylesheet">
5455

5556
<!-- Hotjar Tracking Code for ibm.com/demos & githhub -->
5657
<script>
@@ -81,6 +82,8 @@
8182

8283
<!-- Dropdown nav menu -->
8384
<script src="wp-includes/js/navbar.js"></script>
85+
86+
<script src="wp-includes/js/web-components.js"></script>
8487
</head>
8588

8689
<!-- PAGE CONTENT -->
@@ -291,6 +294,24 @@ <h5>IMS support</h5>
291294
</header>
292295
</div>
293296

297+
<template id="video-card">
298+
<link href="wp-includes/css/web-components/video-card.css" rel="stylesheet">
299+
<link href="wp-includes/css/page.css" rel="stylesheet">
300+
<div class="video-card">
301+
<div>
302+
<h2 class="video-name"></h2>
303+
<p class="video-desc"></p>
304+
<div class="inline-g">
305+
<p><b>Level: </b><span class="video-level"></span></p>
306+
<p><b>Time: </b><span class="video-time"></span></p>
307+
</div>
308+
</div>
309+
<div>
310+
<a class="video-link">Watch now →</a>
311+
</div>
312+
</div>
313+
</template>
314+
294315
<!-- MAIN CONTENT -->
295316
<div id="content" class="site-content">
296317
<div class="content-area" id="content-area">
@@ -339,6 +360,18 @@ <h1>IMS videos</h1>
339360
<div class="pure-g video-card-container">
340361

341362
<h3 id="all" class="video-section-header-first">All roles</h3>
363+
364+
<div class="pure-u-1 pure-u-lg-1-2 pure-u-xl-1-3">
365+
<video-card
366+
name="Introduction to IMS"
367+
desc="If you're new to IMS, watch these short, high-level videos on IMS,
368+
database, transaction management, and application development."
369+
level="Beginner"
370+
time="1 hour"
371+
link="https://mediacenter.ibm.com/channel/Intro+to+IMS+Series/139456202"
372+
>
373+
</video-card>
374+
</div>
342375

343376
<!-- IMS Community Calls -->
344377
<div class="pure-u-1 pure-u-lg-1-3">
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
:root {
2+
/* Color */
3+
--white: #fff;
4+
--black: #000;
5+
--blue: #0f62fe;
6+
/* Background Color */
7+
--bg-light-gray: #f4f4f4;
8+
--bg-dark-gray-01: #1c1c1c;
9+
--bg-dark-gray-02: #2c2c2c;
10+
--bg-dark-blue: #003A6D;
11+
/* Button Color */
12+
--btn-prim: #0f62fe;
13+
--btn-prim-hover: #0050e6;
14+
--btn-secnd: #6f6f6f;
15+
--btn-scnd-hover: #5e5e5e;
16+
/* Font Color */
17+
--font-light-blue: #78A9FF;
18+
19+
/* Sizing */
20+
--plex-14: 0.875em;
21+
--plex-16: 1em;
22+
--plex-18: 1.125em;
23+
--plex-20: 1.25em;
24+
--plex-24: 1.5em;
25+
--plex-28: 1.75em;
26+
--plex-36: 2.25em;
27+
--plex-72: 4.5em;
28+
--plex-180: 11.25em;
29+
}
30+
31+
h2 {
32+
font-weight: 400;
33+
font-size: var(--plex-24);
34+
padding: 0em;
35+
margin: 0em;
36+
}
37+
38+
p {
39+
font-size: var(--plex-18);
40+
}
41+
42+
a {
43+
text-decoration: none;
44+
color: var(--blue);
45+
}
46+
47+
.video-card {
48+
background-color: var(--bg-light-gray);
49+
margin: 1em;
50+
padding: 2em;
51+
display: flex;
52+
flex-flow: column nowrap;
53+
}
54+
55+
.video-card div:nth-child(0) {
56+
flex-grow: 1;
57+
}
58+
59+
.video-card div:nth-child(1) {
60+
flex-grow: 4;
61+
}
62+
63+
/* 1024px and above screen sizes */
64+
@media screen and (min-width: 64em) {
65+
.video-card {
66+
height: 18.75em;
67+
}
68+
}

wp-includes/js/web-components.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// Web component
2+
class VideoCard extends HTMLElement {
3+
4+
static get observedAttributes() {
5+
return ['name', 'desc', 'level', 'time', 'link'];
6+
}
7+
8+
attributeChangedCallback(property, oldValue, newValue) {
9+
if (oldValue === newValue) return;
10+
this[property] = newValue;
11+
}
12+
13+
connectedCallback() {
14+
const shadow = this.attachShadow({mode: 'closed'});
15+
shadow.append(
16+
document.getElementById('video-card').content.cloneNode(true)
17+
);
18+
19+
// Set video name
20+
const videoName = shadow.querySelector('.video-name');
21+
videoName.textContent = `${this.name}`;
22+
23+
// Set video desc
24+
const videoDesc = shadow.querySelector('.video-desc');
25+
videoDesc.textContent = `${this.desc}`;
26+
27+
// Set video level
28+
const videoLevel = shadow.querySelector('.video-level');
29+
videoLevel.textContent = `${this.level}`;
30+
31+
// Set video time
32+
const videoTime = shadow.querySelector('.video-time');
33+
videoTime.textContent = `${this.time}`;
34+
35+
// Set video link
36+
const videoLink = shadow.querySelector('.video-link');
37+
videoLink.href = this.link;
38+
videoLink.setAttribute('alt', `Watch ${this.name} now`);
39+
}
40+
}
41+
42+
// Register component
43+
customElements.define('video-card', VideoCard);

0 commit comments

Comments
 (0)