Files
streamyfin/constants/TVTypography.ts
Lance Chant bab11addee Attempt 2 at scaling
Added some more logic for scaling to hopefully have a uniform state

Signed-off-by: Lance Chant <13349722+lancechant@users.noreply.github.com>
2026-04-10 15:59:50 +02:00

57 lines
1.6 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { TVTypographyScale, useSettings } from "@/utils/atoms/settings";
/**
* TV Typography Scale
*
* Consistent text sizes for TV interface components.
* Design values are for 1920×1080 and scaled proportionally
* to the actual viewport via scaleSize().
*/
import { scaleSize } from "@/utils/scaleSize";
export const TVTypography = {
/** Hero titles, movie/show names */
display: scaleSize(70),
/** Episode series name, major headings */
title: scaleSize(42),
/** Section headers (Cast, Technical Details, From this Series) */
heading: scaleSize(32),
/** Overview, actor names, card titles, metadata */
body: scaleSize(40),
/** Secondary text, labels, subtitles */
callout: scaleSize(26),
};
export type TVTypographyKey = keyof typeof TVTypography;
const scaleMultipliers: Record<TVTypographyScale, number> = {
[TVTypographyScale.Small]: 0.85,
[TVTypographyScale.Default]: 1.0,
[TVTypographyScale.Large]: 1.2,
[TVTypographyScale.ExtraLarge]: 1.4,
};
/**
* Hook that returns scaled TV typography values based on user settings.
* Use this instead of the static TVTypography constant for dynamic scaling.
*/
export const useScaledTVTypography = () => {
const { settings } = useSettings();
const scale =
scaleMultipliers[settings.tvTypographyScale] ??
scaleMultipliers[TVTypographyScale.Default];
return {
display: Math.round(TVTypography.display * scale),
title: Math.round(TVTypography.title * scale),
heading: Math.round(TVTypography.heading * scale),
body: Math.round(TVTypography.body * scale),
callout: Math.round(TVTypography.callout * scale),
};
};