fix(kitty): wrong height

This commit is contained in:
Pihkaal
2024-07-25 11:22:32 +02:00
parent f8e3e20d9d
commit 68444945ef

View File

@@ -5,6 +5,7 @@ import {
useState, useState,
useCallback, useCallback,
useId, useId,
type HTMLAttributes,
} from "react"; } from "react";
import { type KittyContextProps } from "~/context/KittyContext"; import { type KittyContextProps } from "~/context/KittyContext";
import { useApp } from "~/hooks/useApp"; import { useApp } from "~/hooks/useApp";
@@ -45,6 +46,7 @@ export const Kitty = (props: {
const cols = Math.round( const cols = Math.round(
(container.current.clientWidth - PADDING_RIGHT) / CHAR_WIDTH, (container.current.clientWidth - PADDING_RIGHT) / CHAR_WIDTH,
); );
const rows = Math.round(container.current.clientHeight / CHAR_HEIGHT); const rows = Math.round(container.current.clientHeight / CHAR_HEIGHT);
const width = cols * CHAR_WIDTH; const width = cols * CHAR_WIDTH;
@@ -67,6 +69,10 @@ export const Kitty = (props: {
}; };
}, [snapToCharacter]); }, [snapToCharacter]);
const style: HTMLAttributes<HTMLDivElement>["style"] = props.rows
? { height }
: { maxHeight: height, height: "100%" };
return ( return (
<div className={props.className} onMouseEnter={handleMouseEnter}> <div className={props.className} onMouseEnter={handleMouseEnter}>
<div <div
@@ -86,7 +92,7 @@ export const Kitty = (props: {
> >
<div <div
className="whitespace-pre-wrap" className="whitespace-pre-wrap"
style={{ backdropFilter: "blur(2.5px)", width, height }} style={{ backdropFilter: "blur(2.5px)", width, ...style }}
> >
<KittyProvider value={context}>{props.children}</KittyProvider> <KittyProvider value={context}>{props.children}</KittyProvider>
</div> </div>