feat: use new way to work with group sizes

This commit is contained in:
Pihkaal
2024-02-10 02:04:28 +01:00
parent 1d314d6a3d
commit 286dfefe71
3 changed files with 53 additions and 53 deletions

View File

@@ -1,7 +1,5 @@
import { BrowserRouter } from "react-router-dom"; import { BrowserRouter } from "react-router-dom";
import { MusicPlayer } from "./components/MusicPlayer"; import { MusicPlayer } from "./components/MusicPlayer";
import { MusicVisualizer } from "./components/MusicVisualizer";
import { Nvim } from "./components/Nvim/Nvim";
import { Kitty } from "./components/Kitty"; import { Kitty } from "./components/Kitty";
import { AppContextProvider } from "./context/AppContext"; import { AppContextProvider } from "./context/AppContext";
import { Waybar } from "./components/Waybar/Waybar"; import { Waybar } from "./components/Waybar/Waybar";
@@ -19,7 +17,7 @@ function App() {
<Kitty className="flex-1"></Kitty> <Kitty className="flex-1"></Kitty>
<div className="flex gap-3 h-[142px]"> <div className="flex h-[142px] gap-3">
<Kitty className="flex-1 select-none"> <Kitty className="flex-1 select-none">
<MusicPlayer <MusicPlayer
title="Last Tango in Kyoto" title="Last Tango in Kyoto"

View File

@@ -10,6 +10,6 @@ export const Kitty = (props: { children?: ReactNode; className?: string }) => (
)} )}
style={{ backdropFilter: "blur(2px)" }} style={{ backdropFilter: "blur(2px)" }}
> >
<Terminal>{props.children}</Terminal> <Terminal font="20px JetbrainsMono">{props.children}</Terminal>
</div> </div>
); );

View File

@@ -1,5 +1,5 @@
import { useEffect, useState } from "react"; import { useEffect, useState } from "react";
import { Bar, Frame, Group, Terminal, Text, useTerminal } from "react-dom-curse"; import { Bar, Frame, Group, Text, useTerminal } from "react-dom-curse";
import { theme } from "~/utils/theme"; import { theme } from "~/utils/theme";
const formatDurationMSS = (duration: number) => { const formatDurationMSS = (duration: number) => {
@@ -15,7 +15,7 @@ export const MusicPlayer = (props: {
album: string; album: string;
duration: number; duration: number;
}) => { }) => {
const { terminal } = useTerminal(); const { width } = useTerminal();
const [played, setPlayed] = useState(0); const [played, setPlayed] = useState(0);
useEffect(() => { useEffect(() => {
@@ -34,49 +34,51 @@ export const MusicPlayer = (props: {
<Group <Group
x={0} x={0}
y={0} y={0}
width={terminal.width} width={width}
height={terminal.height} height={5}
style={{ foreground: theme.white }} style={{ foreground: theme.white }}
> >
<Frame <Frame x={0} y={0} width={width} height={5} border="single">
x={0} <Text x={0} y={0} style={{ foreground: theme.cyan, bold: true }}>
y={0}
width={terminal.width}
height={terminal.height}
border="single"
>
<Text x={0} y={0} style={{ foreground: theme.cyan }}>
{props.title} · {props.artist} {props.title} · {props.artist}
</Text> </Text>
<Text x={0} y={1} style={{ foreground: theme.yellow }}> <Text x={0} y={1} style={{ foreground: theme.yellow }}>
{props.album} {props.album}
</Text> </Text>
<Group x={0} y={2} width={terminal.width} height={1}> <Group x={0} y={2} width={width} height={1}>
<Bar <Bar
x={0} x={0}
y={0} y={0}
style={{ foreground: theme.green, background: "#55576d" }} style={{
foreground: theme.green,
background: "#55576d",
bold: true,
}}
char=" " char=" "
size={terminal.width} size={width}
direction="horizontal" direction="horizontal"
/> />
<Bar <Bar
x={0} x={0}
y={0} y={0}
style={{ foreground: "#55576d", background: theme.green }} style={{
foreground: "#55576d",
background: theme.green,
bold: true,
}}
char=" " char=" "
size={terminal.width * (played / props.duration)} size={width * (played / props.duration)}
direction="horizontal" direction="horizontal"
/> />
<Text x={Math.floor(terminal.width / 2 - time.length / 2)} y={0}> <Text x={Math.floor(width / 2 - time.length / 2 - 1)} y={0}>
{time} {time}
</Text> </Text>
</Group> </Group>
</Frame> </Frame>
<Text x={1} y={0} style={{ foreground: theme.magenta }}> <Text x={1} y={0} style={{ foreground: theme.magenta }}>
Playback {"Playback".substring(0, Math.min(8, width - 2))}
</Text> </Text>
</Group> </Group>
); );