1use ravenrs_style::Semantic;
2
3use crate::context::{BuildCx, NodeId};
4use crate::{Fill, IconName, View, util};
5
6#[derive(Clone, Copy, Debug)]
9#[cfg_attr(feature = "live", ravenrs_live::expose(part = "fields"))]
10pub struct Icon {
11 name: IconName,
12 size: f32,
13 color: Fill,
14}
15
16#[cfg_attr(feature = "live", ravenrs_live::expose)]
17impl Icon {
18 pub fn new(name: IconName) -> Self {
20 Self { name, size: 16.0, color: Semantic::Ink.into() }
21 }
22
23 pub fn size(mut self, size: f32) -> Self {
25 self.size = size;
26 self
27 }
28
29 pub fn color(mut self, color: impl Into<Fill>) -> Self {
31 self.color = color.into();
32 self
33 }
34}
35
36impl View for Icon {
37 fn build(&self, cx: &mut BuildCx<'_>) -> NodeId {
38 let color = self.color.resolve(cx.theme());
39 util::icon(cx, self.name, self.size, color)
40 }
41}