module UI::DesignTokens::Device

Overview

Access point for the live device metrics provider.

UI::DesignTokens::Device.current returns the current DeviceMetrics snapshot by calling the renderer-installed provider; specs that want a deterministic value reset to the spec-time fallback via Device.reset_provider.

Extended Modules

Defined in:

ui/design_tokens.cr

Instance Method Summary

Instance Method Detail

def current : DeviceMetrics #

[View source]
def install_provider(&block : -> DeviceMetrics) : Nil #

Renderer-only entry point. UIKit / AppKit / Web renderers call this once on initialize to wire up a live OS-querying provider. The block returns the current metrics on every call (so consumers get fresh values on window resize / orientation change).


[View source]
def reset_provider : Nil #

Reset to the spec-time fallback. Used by specs that need to restore deterministic metrics after a renderer install.


[View source]