zu/circular_progress/
size.rs

1// Copyright (c) 2024 Xu Shaohua <shaohua@biofan.org>. All rights reserved.
2// Use of this source is governed by Lesser General Public License
3// that can be found in the LICENSE file.
4
5/// The size of the component.
6///
7/// If using a number, the pixel unit is assumed.
8/// If using a string, you need to provide the CSS unit
9#[derive(Debug, Clone, PartialEq, Eq)]
10pub enum Size {
11    Num(i32),
12    Str(String),
13}
14
15impl Size {
16    #[must_use]
17    pub fn css_value(&self) -> String {
18        match self {
19            Self::Num(num) => format!("width: {num}px; height: {num}px"),
20            Self::Str(s) => format!("width: {s}; height: {s};"),
21        }
22    }
23}