Merge branch 'deep-ketch' into development
CI/CD Pipeline / i18n Catalog Check (push) Successful in 38s
CI/CD Pipeline / Build and Push App Docker Image (push) Successful in 3m11s
CI/CD Pipeline / Build and Push PocketBase Docker Image (push) Successful in 14s
CI/CD Pipeline / Deploy to Kubernetes (push) Successful in 8m31s

This commit is contained in:
2026-08-23 20:31:49 -07:00
29 changed files with 871 additions and 125 deletions
+56 -2
View File
@@ -1,15 +1,57 @@
import { useLayoutEffect, useRef } from "react";
import { Title, AppShell, Flex } from "@mantine/core";
import { useLingui } from "@lingui/react";
import { HeaderConfig } from "../types/header-config";
import BackButton from "./back-button";
const MIN_TITLE_SCALE = 0.55;
const Header = ({ collapsed, title, titleValues, withBackButton }: HeaderConfig) => {
const { i18n } = useLingui();
const titleRef = useRef<HTMLHeadingElement>(null);
const resolvedTitle =
typeof title === "string" || title === undefined
? title
: i18n._({ ...title, values: titleValues });
useLayoutEffect(() => {
const el = titleRef.current;
if (!el) return;
let cancelled = false;
const textWidth = () => {
const range = document.createRange();
range.selectNodeContents(el);
return range.getBoundingClientRect().width;
};
const fit = () => {
el.style.fontSize = "";
const available = el.clientWidth - 1;
if (available <= 0) return;
let needed = textWidth();
if (needed <= available) return;
const natural = parseFloat(getComputedStyle(el).fontSize);
let scale = Math.max(available / needed, MIN_TITLE_SCALE);
el.style.fontSize = `${natural * scale}px`;
for (let i = 0; i < 3 && scale > MIN_TITLE_SCALE && textWidth() > available; i++) {
scale = Math.max(scale * 0.98, MIN_TITLE_SCALE);
el.style.fontSize = `${natural * scale}px`;
}
};
fit();
document.fonts?.ready.then(() => {
if (!cancelled) fit();
});
const observer = new ResizeObserver(fit);
observer.observe(el);
return () => {
cancelled = true;
observer.disconnect();
};
}, [resolvedTitle]);
return (
<AppShell.Header
id='app-header'
@@ -20,8 +62,20 @@ const Header = ({ collapsed, title, titleValues, withBackButton }: HeaderConfig)
}}
>
{ withBackButton && <BackButton /> }
<Flex justify='center' px='md' mt={8}>
<Title order={1} lts='0.08em' style={{ userSelect: 'none' }}>
<Flex justify='center' px={48} mt={8} w='100%'>
<Title
ref={titleRef}
order={1}
lts='0.08em'
style={{
userSelect: 'none',
width: '100%',
textAlign: 'center',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis',
}}
>
{resolvedTitle?.toLocaleUpperCase()}
</Title>
</Flex>
@@ -5,11 +5,10 @@ const eventListerOptions = {
};
const useVisualViewportSize = () => {
const windowExists = typeof window !== 'undefined';
const [windowSize, setWindowSize] = useState({
width: windowExists ? window.visualViewport?.width || 0 : 0,
height: windowExists ? window.visualViewport?.height || 0 : 0,
top: windowExists ? window.visualViewport?.offsetTop || 0 : 0,
width: 0,
height: 0,
top: 0,
});
const rafRef = useRef<number | null>(null);