All files / Rindu/components/FullScreenLyrics FullScreenLyrics.tsx

40% Statements 4/10
0% Branches 0/14
0% Functions 0/2
40% Lines 4/10

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163    19x 19x 19x 19x                                                                                                                                                                                                                                                                                                                          
import { ReactElement } from "react";
 
import { LyricLine } from "./LyricLine";
import { LoadingSpinner, LyricsPIPButton } from "components";
import { useAuth, useHeader, useLyricsContext } from "hooks";
import { getLineType } from "utils";
 
export default function FullScreenLyrics(): ReactElement {
  const {
    lyricsProgressMs,
    lyricsBackgroundColor,
    lyrics,
    lyricsError,
    lyricsLoading,
  } = useLyricsContext();
 
  const { isPremium } = useAuth();
 
  useHeader({
    disableOpacityChange: true,
    alwaysDisplayColor: false,
    showOnFixed: false,
    disableBackground: true,
  });
 
  return (
    <div className="lyrics-container">
      {!lyrics ? (
        <div className="message-container">
          {lyricsLoading && <LoadingSpinner />}
          {lyricsError && !lyricsLoading && (
            <div className="lyrics-error">
              <p>{lyricsError}</p>
            </div>
          )}
        </div>
      ) : null}
      {lyrics && lyrics.lines.length > 0 && (
        <div className="lyrics">
          {lyrics.lines.map((line, i) => {
            const type = getLineType({
              currentLine: line,
              lyricsProgressMs,
              nextLine: lyrics.lines[i + 1],
              index: i,
            });
 
            return <LyricLine line={line} type={type} key={i} />;
          })}
        </div>
      )}
      {isPremium && !!document?.pictureInPictureEnabled && (
        <LyricsPIPButton background={lyricsBackgroundColor} />
      )}
      <style jsx>{`
        :global(.app) {
          background-color: ${lyricsBackgroundColor};
          position: relative;
        }
        .lyrics-container :global(.lyrics-pip-button) {
          position: fixed;
          top: calc(100% - 150px);
          transform: translateY(-50%);
          right: 30px;
          cursor: pointer;
        }
        .lyrics-container :global(.lyrics-pip-button:hover) {
          filter: brightness(1.2);
        }
        .lyrics-container :global(.lyrics-pip-button::after) {
          position: absolute;
          content: "";
          top: calc(-1 * var(--border-width));
          left: calc(-1 * var(--border-width));
          z-index: -1;
          width: calc(100% + var(--border-width) * 2);
          height: calc(100% + var(--border-width) * 2);
          background: linear-gradient(
            60deg,
            ${lyricsBackgroundColor ?? "transparent"} 0%,
            #ffffff80 50%,
            ${lyricsBackgroundColor ?? "transparent"} 100%
          );
          background-size: 300% 300%;
          background-position: 0 50%;
          border-radius: calc(2 * var(--border-width));
          animation: moveGradient 4s alternate infinite;
        }
        @keyframes moveGradient {
          50% {
            background-position: 100% 50%;
          }
        }
      `}</style>
      <style jsx>{`
        .lyrics-container {
          margin-top: 60px;
          width: 100%;
          display: flex;
          min-width: calc(100% - 128px);
          font-size: 24px;
          font-weight: 700;
          letter-spacing: -0.04em;
          line-height: 42px;
          max-width: max-content;
          position: sticky;
          top: 0;
        }
        @media (max-width: 768px) {
          .lyrics-container {
            margin: 30px 64px;
            font-size: 24px;
          }
          .line {
            padding-left: 0;
          }
        }
        @media (max-width: 658px) {
          .lyrics-container {
            margin: 30px 0px 0px 0px;
            font-size: 18px;
          }
          .line {
            padding-left: 0;
          }
        }
        .message-container {
          width: 100%;
          height: calc((var(--vh, 1vh) * 100) - 90px - 60px);
        }
        .line {
          font-size: 32px;
          font-weight: 700;
          letter-spacing: -0.04em;
          line-height: 54px;
          cursor: pointer;
          transition: all 0.1s ease-out 0s;
        }
        .lyrics {
          font-size: 2rem;
          color: #fff;
          padding: 1rem;
        }
        .lyrics-error {
          font-size: 2rem;
          color: #fff;
          text-align: center;
          padding: 1rem;
          display: flex;
          justify-content: center;
          align-items: center;
          height: 100%;
        }
        @media screen and (max-width: 1000px) {
          div.lyrics-container :global(.lyrics-pip-button) {
            top: calc(100% - 200px);
          }
        }
      `}</style>
    </div>
  );
}