11use dioxus:: prelude:: * ;
22
33use crate :: step:: Step ;
4+ use crate :: ui:: step_colors:: STEP_COLORS ;
45
56#[ component]
67pub fn StepArrows ( steps : Vec < Step > ) -> Element {
@@ -10,18 +11,20 @@ pub fn StepArrows(steps: Vec<Step>) -> Element {
1011 view_box: "0 0 8 8" ,
1112 preserve_aspect_ratio: "none" ,
1213 defs {
13- marker {
14- id: "arrowhead" ,
15- marker_units: "strokeWidth" ,
16- marker_width: "4" ,
17- marker_height: "4" ,
18- ref_x: "9" ,
19- ref_y: "5" ,
20- orient: "auto" ,
21- view_box: "0 0 10 10" ,
22- path {
23- d: "M 0 0 L 10 5 L 0 10 z" ,
24- style: "fill: var(--step-arrow); fill-opacity: var(--step-arrow-opacity);" ,
14+ for ( idx, color) in STEP_COLORS . iter( ) . enumerate( ) {
15+ marker {
16+ id: "arrowhead-{idx}" ,
17+ marker_units: "strokeWidth" ,
18+ marker_width: "4" ,
19+ marker_height: "4" ,
20+ ref_x: "9" ,
21+ ref_y: "5" ,
22+ orient: "auto" ,
23+ view_box: "0 0 10 10" ,
24+ path {
25+ d: "M 0 0 L 10 5 L 0 10 z" ,
26+ style: "fill: {color}; fill-opacity: var(--step-arrow-opacity);" ,
27+ }
2528 }
2629 }
2730 }
@@ -32,14 +35,23 @@ pub fn StepArrows(steps: Vec<Step>) -> Element {
3235 line {
3336 key: "{idx}" ,
3437 class: "step-arrow" ,
38+ style: "stroke: {step_color(idx)};" ,
3539 x1: "{(fc as f32) + 0.5}" ,
3640 y1: "{(fr as f32) + 0.5}" ,
3741 x2: "{(tc as f32) + 0.5}" ,
3842 y2: "{(tr as f32) + 0.5}" ,
39- marker_end: "url(#arrowhead)" ,
43+ marker_end: "url(#arrowhead-{color_index(idx)} )" ,
4044 }
4145 }
4246 }
4347 }
4448 }
4549}
50+
51+ fn color_index ( idx : usize ) -> usize {
52+ idx % STEP_COLORS . len ( )
53+ }
54+
55+ fn step_color ( idx : usize ) -> & ' static str {
56+ STEP_COLORS [ color_index ( idx) ]
57+ }
0 commit comments