fix(kitty): wrong height
This commit is contained in:
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user