All files / Rindu/components/DPIPLyrics DPIPLyrics.tsx

22.22% Statements 6/27
0% Branches 0/3
0% Functions 0/3
25% Lines 6/24

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 13719x   19x 19x 19x   19x                                                                                                                                                                                                                                                                 19x  
import { ReactElement, useEffect } from "react";
 
import { FullScreenLyrics, MiniPlayer, ResizablePanel } from "components";
import { ContextMenuContextProvider } from "context/ContextMenuContext";
import { useDisableGlobalContextMenu, useSpotify } from "hooks";
 
export const DPIPLyrics = (): ReactElement => {
  const { pipWindow } = useSpotify();
  useDisableGlobalContextMenu(pipWindow.current ?? undefined);
  useEffect(() => {
    Iif (!pipWindow.current) return;
    const { document: pipDoc } = pipWindow.current;
 
    pipDoc.documentElement.style.cssText = "";
    pipDoc.body.style.cssText = "";
 
    pipDoc.body.style.margin = "0";
    pipDoc.body.style.padding = "0";
    pipDoc.body.style.minHeight = "100svh";
    pipDoc.body.style.display = "contents";
 
    const style = document.createElement("style");
    style.textContent = `
      * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
      }
      html,body{
        height: 100svh;
        width: 100vw;
        max-height: 100svh;
        min-height: 100svh;
        overflow: hidden;
        background-color: black;
        display: contents;
        position: fixed;
      }
 
      .resize-handle {
        position: absolute;
        z-index: 1000;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: auto;
      }
 
      .resize-panel {
        position: relative;
      }
 
      .resize-handle.vertical {
        bottom: -6px;
        left: 0;
        right: 0;
        height: 24px;
        cursor: ns-resize;
      }
 
      .resize-grip {
        width: 36px;
        height: 4px;
        border-radius: 9999px;
        background: rgba(255, 255, 255, 0.2);
        opacity: 0;
        transform: scale(1);
        transition: opacity 0.2s ease, background 0.2s ease, transform 0.2s ease;
      }
 
      .resize-panel:hover .resize-grip,
      .resize-handle:hover .resize-grip {
        opacity: 1;
        background: rgba(255, 255, 255, 0.4);
        transform: scale(1.05);
      }
 
      .resize-grip.active {
        opacity: 1 !important;
        background: rgba(255, 255, 255, 0.7);
      }
 
      .lyrics-container-container {
        min-height: 0;
        margin-top: 0;
        margin-bottom: 0;
        display: flex;
        position: relative;
      }
    `;
    pipDoc.head.appendChild(style);
 
    return () => {
      pipDoc.documentElement.style.cssText = "";
      pipDoc.body.style.cssText = "";
      pipDoc.head.removeChild(style);
    };
  }, [pipWindow]);
 
  return (
    <ContextMenuContextProvider document={pipWindow.current?.document}>
      <div
        className="pipApp"
        style={{
          width: "100%",
          height: "100svh",
          flexDirection: "column",
          position: "relative",
          display: "flex",
        }}
      >
        <ResizablePanel.Group direction="column">
          <ResizablePanel.Panel
            direction="vertical"
            waitForImages={true}
            observeResize={true}
            maxSize="fit-content"
            minSize="125px"
            className="player-container"
            document={pipWindow.current?.document}
            defaultSize="450px"
            initialExpanded={true}
          >
            <MiniPlayer document={pipWindow.current?.document} />
          </ResizablePanel.Panel>
          <div style={{ flex: 1 }} className="lyrics-container-container">
            <FullScreenLyrics document={pipWindow.current?.document} />
          </div>
        </ResizablePanel.Group>
      </div>
      <div id="contextMenu"></div>
    </ContextMenuContextProvider>
  );
};
 
export default DPIPLyrics;