Skip to main content

Module utils

Module utils 

Source
Expand description

UI-related utilities

Structs§

CornerSolver
Solver for arbitrarily deep nested corner radii.
FormatDistance
SearchInputWidth
WithRemSize
An element that sets a particular rem size for its children.

Enums§

DateTimeType

Constants§

TRAFFIC_LIGHT_PADDING

Functions§

apca_contrast
Calculates the perceptual lightness contrast using APCA. Returns a value between approximately -108 and 106. Negative values indicate light text on dark background. Positive values indicate dark text on light background.
calculate_contrast_ratio
Calculates the contrast ratio between two colors according to WCAG 2.0 standards.
capitalize
Capitalizes the first character of a string.
ensure_minimum_contrast
Adjusts the foreground color to meet the minimum APCA contrast against the background. The minimum_apca_contrast should be an absolute value (e.g., 75 for Lc 75).
format_distance
Get the time difference between two dates into a relative human readable string.
format_distance_from_now
Get the time difference between a date and now as relative human readable string.
fuzzy_matches
Returns true when every character of query appears in order within candidate (case-insensitive). An empty query matches everything.
fuzzy_subsequence_score
Scores a case-insensitive subsequence match. Higher is better. Returns None when query is non-empty and not a subsequence of candidate.
inner_corner_radius
Calculates the child’s content-corner radius for a single nested level.
is_light
Returns true if the current theme is light or vibrant light.
platform_title_bar_height
Returns the platform-appropriate title bar height.
reveal_in_file_manager_label
Returns the platform-appropriate label for the “reveal in file manager” action.