sequoia_style/
sheet_style.rs1use sequoia_core::Color;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
4pub struct SheetStyle {
5 pub background: Option<Color>,
6 pub border: Option<Color>,
7 pub border_width: Option<f32>,
8 pub radius: Option<f32>,
9}
10
11impl SheetStyle {
12 pub const fn new() -> Self {
13 Self {
14 background: None,
15 border: None,
16 border_width: None,
17 radius: None,
18 }
19 }
20
21 pub const fn background(mut self, color: Color) -> Self {
22 self.background = Some(color);
23 self
24 }
25
26 pub const fn border(mut self, color: Color) -> Self {
27 self.border = Some(color);
28 self
29 }
30
31 pub const fn border_width(mut self, width: f32) -> Self {
32 self.border_width = Some(width);
33 self
34 }
35
36 pub const fn radius(mut self, radius: f32) -> Self {
37 self.radius = Some(radius);
38 self
39 }
40}
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45
46 #[test]
47 fn const_composition_keeps_base() {
48 const CUSTOM: SheetStyle = SheetStyle::new().radius(12.0);
49 assert_eq!(CUSTOM.radius, Some(12.0));
50 assert_eq!(CUSTOM.background, None);
51 }
52}