@@ -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