lurq 0.65.1

A Rust UI toolkit with typed components, retained state, reactive signals, GPU rendering, and DevTools.
Documentation
use crate::app::theme::{BorderSize, ThemeBorderSizes};

#[derive(Clone, Copy, Debug, PartialEq)]
pub enum BorderSizeValue {
  Px(f32),
  Theme(BorderSize),
}

impl BorderSizeValue {
  /// A [`BorderSize::Extra`] missing from the theme resolves to `0.0` (no
  /// border), as an unresolved palette color paints nothing.
  pub fn resolve(&self, border_sizes: &ThemeBorderSizes) -> f32 {
    match self {
      Self::Px(value) => *value,
      Self::Theme(size) => border_sizes.try_get(*size).unwrap_or(0.0),
    }
  }

  pub fn as_px(&self) -> Option<f32> {
    match self {
      Self::Px(value) => Some(*value),
      Self::Theme(_) => None,
    }
  }
}

impl From<f32> for BorderSizeValue {
  fn from(value: f32) -> Self {
    Self::Px(value)
  }
}

impl From<BorderSize> for BorderSizeValue {
  fn from(value: BorderSize) -> Self {
    Self::Theme(value)
  }
}