wolf_graph_mermaid/
node_attributes.rs

1use crate::{details::format_custom_style, Color, NodeShape};
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct NodeAttributes {
5    pub label: Option<String>,
6    pub shape: Option<NodeShape>,
7    pub fill_color: Option<Color>,
8    pub stroke_color: Option<Color>,
9    pub stroke_width: Option<f64>,
10    pub dash_array: Option<Vec<f64>>,
11}
12
13impl NodeAttributes {
14    pub fn new(
15        label: Option<String>,
16        shape: Option<NodeShape>,
17        fill_color: Option<Color>,
18        stroke_color: Option<Color>,
19        stroke_width: Option<f64>,
20        dash_array: Option<Vec<f64>>,
21    ) -> Self {
22        Self {
23            label,
24            shape,
25            fill_color,
26            stroke_color,
27            stroke_width,
28            dash_array,
29        }
30    }
31
32    pub fn custom_style(&self) -> Option<String> {
33        format_custom_style(
34            self.fill_color.as_ref(),
35            self.stroke_color.as_ref(),
36            self.stroke_width,
37            self.dash_array.as_deref(),
38        )
39    }
40}