Browse Source

Add support for displaying a link to the song

Thomas Dy 4 năm trước cách đây
mục cha
commit
f229796f96
4 tập tin đã thay đổi với 18 bổ sung0 xóa
  1. 1 0
      dist/index.html
  2. 8 0
      dist/style.css
  3. 8 0
      src/game/select.ts
  4. 1 0
      src/level.ts

+ 1 - 0
dist/index.html

@@ -22,6 +22,7 @@
             <div class="genre"></div>
             <div class="creator"></div>
             <div class="title"></div>
+            <div class="link"></div>
           </div>
         </div>
         <div id="song-list"></div>

+ 8 - 0
dist/style.css

@@ -281,6 +281,14 @@
   font-size: 1.875em;
 }
 
+.song-info .link {
+  min-height: 1.5em;
+}
+
+.song-info .link a {
+  color: var(--base-color);
+}
+
 /* }}} */
 
 /* song-list {{{ */

+ 8 - 0
src/game/select.ts

@@ -73,6 +73,14 @@ namespace game {
       this.songInfo.querySelector('.genre')!.textContent = level.genre;
       this.songInfo.querySelector('.creator')!.textContent = level.creator;
       this.songInfo.querySelector('.title')!.textContent = level.name;
+      const linkContainer = this.songInfo.querySelector('.link')!;
+      linkContainer.innerHTML = '';
+      if (level.songLink) {
+        const link = document.createElement('a');
+        link.href = level.songLink;
+        link.textContent = "More info";
+        linkContainer.appendChild(link);
+      }
     }
 
     chooseSong(index: number): void {

+ 1 - 0
src/level.ts

@@ -18,6 +18,7 @@ namespace level {
     difficulty: string | null,
     audio: string | null,
     background?: string | null,
+    songLink?: string,
     lines: Line[]
   }