feat(nvim): implement basic layout

This commit is contained in:
Pihkaal
2024-05-30 15:44:49 +02:00
parent e21d337d53
commit 3832a7ca52
9 changed files with 66 additions and 13 deletions

View File

@@ -51,7 +51,7 @@ export const Kitty = (props: {
setWidth(`${width}px`);
setHeight(`${height}px`);
setContext((ctx) => ({ ...(ctx ?? { active: false }), rows, cols }));
setContext(ctx => ({ ...(ctx ?? { active: false }), rows, cols }));
}, []);
useEffect(() => {
@@ -76,9 +76,9 @@ export const Kitty = (props: {
lineHeight: `${CHAR_HEIGHT}px`,
...(activeKitty === id
? {
borderColor: "#cdd6f4",
animationDuration: "200ms",
}
borderColor: "#cdd6f4",
animationDuration: "200ms",
}
: {}),
}}
ref={container}

View File

@@ -18,8 +18,12 @@ export const SpotifyPlayer = (props: {
<div
className="grid select-none"
style={{
gridTemplateColumns: `${CHAR_WIDTH}px ${CHAR_WIDTH * 8}px 1fr ${CHAR_WIDTH}px`,
gridTemplateRows: `${CHAR_HEIGHT}px ${CHAR_HEIGHT * 3}px ${CHAR_HEIGHT}px`,
gridTemplateColumns: `${CHAR_WIDTH}px ${
CHAR_WIDTH * 8
}px 1fr ${CHAR_WIDTH}px`,
gridTemplateRows: `${CHAR_HEIGHT}px ${
CHAR_HEIGHT * 3
}px ${CHAR_HEIGHT}px`,
}}
>
{kitty && <InnerSpotifyPlayer {...props} {...kitty} />}
@@ -35,7 +39,9 @@ const InnerSpotifyPlayer = (props: InnerKittyProps<typeof SpotifyPlayer>) => {
);
const emptySize = props.cols - 2 - fillSize;
const timeString = `${formatMMSS(props.played)}/${formatMMSS(props.duration)}`;
const timeString = `${formatMMSS(props.played)}/${formatMMSS(
props.duration,
)}`;
const timeStringLeft = Math.round(
(props.cols - 2) / 2 - timeString.length / 2,
);

View File

@@ -30,9 +30,9 @@ export const Music = () => {
if (metadata) return;
void fetch(song)
.then((r) => r.blob())
.then((b) => parseBlob(b))
.then((m) => {
.then(r => r.blob())
.then(b => parseBlob(b))
.then(m => {
if (!audio.current) return;
setMetadata(m);

View File

@@ -0,0 +1 @@
export const NvimEditor = () => <div className="h-full">editor</div>;

View File

@@ -0,0 +1 @@
export const NvimInput = () => <div>input</div>;

View File

@@ -0,0 +1,17 @@
export const NvimStatusBar = (props: {
label: string;
labelColor: string;
fileName: string;
}) => (
<div className="bg-[#29293c]">
<span className="text-black" style={{ background: props.labelColor }}>
{` ${props.label} `}
</span>
<span className="text-[#474353]" style={{ background: props.labelColor }}>
{"\ue0ba"}
</span>
<span className="bg-[#474353] text-[#373040]">{"\ue0ba"}</span>
<span className="bg-[#373040] text-white">{` ${props.fileName} `}</span>
<span className="bg-[#373040] text-[#29293c]">{"\ue0ba"}</span>
</div>
);

View File

@@ -0,0 +1 @@
export const NvimTree = () => <div className="h-full bg-[#0000001a]">tree</div>;

View File

@@ -0,0 +1,28 @@
import { CHAR_HEIGHT } from "../Kitty";
import { NvimEditor } from "./NvimEditor";
import { NvimInput } from "./NvimInput";
import { NvimStatusBar } from "./NvimStatusBar";
import { NvimTree } from "./NvimTree";
export const Nvim = () => (
<div
className="grid h-full"
style={{
gridTemplateColumns: `0.4fr 2fr`,
gridTemplateRows: `1fr ${CHAR_HEIGHT}px ${CHAR_HEIGHT}px`,
}}
>
<div style={{ gridArea: "1 / 1 / 1 / 2" }}>
<NvimTree />
</div>
<div style={{ gridArea: "1 / 2 / 1 / 3" }}>
<NvimEditor />
</div>
<div style={{ gridArea: "2 / 1 / 2 / 3" }}>
<NvimStatusBar label="INSERT" labelColor="#7ea7ca" fileName="README.md" />
</div>
<div style={{ gridArea: "3 / 1 / 3 / 3" }}>
<NvimInput />
</div>
</div>
);