Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
import { Predicate } from "effect";
import { useCSSVariable } from "uniwind";
import { MOBILE_TYPOGRAPHY } from "../../../lib/typography";
const TEXT_ROLE_VARIABLES = {
micro: "--text-3xs",
caption: "--text-2xs",
label: "--text-xs",
footnote: "--text-sm",
body: "--text-base",
headline: "--text-lg",
title: "--text-xl",
largeTitle: "--text-2xl",
display: "--text-3xl",
} as const satisfies Record<keyof typeof MOBILE_TYPOGRAPHY, string>;
export interface ScaledTextRole {
readonly fontSize: number;
readonly lineHeight: number;
}
/**
* Reads a typography role's current size from the Uniwind `--text-*` CSS
* variables (scaled at runtime with the base font size). Use for style-prop
* consumers that can't express their size as a `text-*` className. Reactive:
* re-renders when the appearance provider re-injects the variables.
*/
export function useScaledTextRole(role: keyof typeof MOBILE_TYPOGRAPHY): ScaledTextRole {
const variable = TEXT_ROLE_VARIABLES[role];
const [fontSize, lineHeight] = useCSSVariable([variable, `${variable}--line-height`]);
return {
fontSize: Predicate.isNumber(fontSize) ? fontSize : MOBILE_TYPOGRAPHY[role].fontSize,
lineHeight: Predicate.isNumber(lineHeight) ? lineHeight : MOBILE_TYPOGRAPHY[role].lineHeight,
};
}