PhoenixLiveCalendar.Utils.Sizing (PhoenixLiveCalendar v0.3.0)

Copy Markdown View Source

Server-side size estimation — the substitute for client measurement.

The views accept CSS dimension strings ("3rem", "48px"); layout decisions (how many text lines fit a block, whether a label fits a bar) need those as numbers. Everything here is an ESTIMATE in rem against the 16px root default — good enough to pick a content tier, never used for actual geometry (the browser still lays out from the real CSS values).

Summary

Functions

Estimated rendered width of a text label in rem at text-xs (~0.45rem per grapheme + padding).

Parses a CSS dimension string to rem. "3rem"3.0, "48px"3.0. Unparseable values (calc(...), percentages) fall back to default.

Functions

label_rem(text)

@spec label_rem(String.t() | nil) :: float()

Estimated rendered width of a text label in rem at text-xs (~0.45rem per grapheme + padding).

parse_rem(value, default \\ 3.0)

@spec parse_rem(String.t() | nil, number()) :: float()

Parses a CSS dimension string to rem. "3rem"3.0, "48px"3.0. Unparseable values (calc(...), percentages) fall back to default.