(info)
| 109 | |
| 110 | class CardContainer extends HTMLElement { |
| 111 | constructor(info) { |
| 112 | super(); |
| 113 | const uri = URI.fromString(info.uri); |
| 114 | const isPlayable = |
| 115 | uri.type === URI.Type.TRACK || |
| 116 | uri.type === URI.Type.PLAYLIST_V2 || |
| 117 | uri.type === URI.Type.ALBUM || |
| 118 | uri.type === URI.Type.EPISODE || |
| 119 | uri.type === URI.Type.PLAYLIST; |
| 120 | |
| 121 | this.innerHTML = ` |
| 122 | <style> |
| 123 | .bookmark-card .ButtonInner-md-iconOnly:hover { |
| 124 | transform: scale(1.06); |
| 125 | } |
| 126 | </style> |
| 127 | <div class="bookmark-card"> |
| 128 | ${ |
| 129 | info.imageUrl |
| 130 | ? `<img aria-hidden="false" draggable="false" loading="eager" src="${info.imageUrl}" alt="${info.title}" class="bookmark-card-image">` |
| 131 | : "" |
| 132 | } |
| 133 | <div class="bookmark-card-info"> |
| 134 | <div class="main-type-balladBold"><span>${info.title}</span></div> |
| 135 | <div class="main-type-mesto"><span>${info.description}</span></div> |
| 136 | ${ |
| 137 | info.time |
| 138 | ? ` |
| 139 | <div class="bookmark-fixed-height"> |
| 140 | <div class="bookmark-progress"> |
| 141 | <div class="bookmark-progress__bar" style="--progress:${info.progress}"></div> |
| 142 | </div> |
| 143 | <span class="bookmark-progress__time main-type-mesto">${Player.formatTime(info.time)}</span> |
| 144 | </div> |
| 145 | ` |
| 146 | : "" |
| 147 | } |
| 148 | </div> |
| 149 | ${ |
| 150 | isPlayable |
| 151 | ? `<div class="ButtonInner-md-iconOnly"><button class="main-playButton-PlayButton main-playButton-primary" data-tippy-content="Play" style="--size:48px;"><svg role="img" height="24" width="24" viewBox="0 0 16 16" fill="currentColor"><path d="M4.018 14L14.41 8 4.018 2z"></path></svg></button></div>` |
| 152 | : "" |
| 153 | } |
| 154 | <button class="bookmark-controls" data-tippy-content="${REMOVE_TEXT}"><svg width="8" height="8" viewBox="0 0 16 16" fill="currentColor">${ |
| 155 | Spicetify.SVGIcons.x |
| 156 | }</svg></button> |
| 157 | </div> |
| 158 | `; |
| 159 | |
| 160 | Spicetify.Tippy(this.querySelectorAll("[data-tippy-content]"), Spicetify.TippyProps); |
| 161 | if (isPlayable) { |
| 162 | /** @type {HTMLButtonElement} */ |
| 163 | const playButton = this.querySelector("button.main-playButton-PlayButton"); |
| 164 | playButton.onclick = (event) => { |
| 165 | onPlayClick(info); |
| 166 | event.stopPropagation(); |
| 167 | }; |
| 168 | } |
nothing calls this directly
no test coverage detected