mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-04-28 19:36:29 +01:00
feat(tv): add scalable typography with user-configurable text size
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { TVTypographyScale, useSettings } from "@/utils/atoms/settings";
|
||||
|
||||
/**
|
||||
* TV Typography Scale
|
||||
*
|
||||
@@ -23,3 +25,29 @@ export const TVTypography = {
|
||||
} as const;
|
||||
|
||||
export type TVTypographyKey = keyof typeof TVTypography;
|
||||
|
||||
const scaleMultipliers: Record<TVTypographyScale, number> = {
|
||||
[TVTypographyScale.Small]: 0.85,
|
||||
[TVTypographyScale.Default]: 1.0,
|
||||
[TVTypographyScale.Large]: 1.15,
|
||||
[TVTypographyScale.ExtraLarge]: 1.3,
|
||||
};
|
||||
|
||||
/**
|
||||
* 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),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user