11using MudExtensions . Utilities ;
22using Microsoft . AspNetCore . Components ;
33using MudBlazor ;
4- using MudBlazor . Extensions ;
54using MudBlazor . Utilities ;
65
76namespace MudExtensions
@@ -16,14 +15,27 @@ public partial class MudStepperExtended : MudComponentBase
1615 MudAnimate _animate = new ( ) ;
1716 Guid _animateGuid = Guid . NewGuid ( ) ;
1817
18+ /// <summary>
19+ /// Gets the CSS class string that represents the current visual state of the stepper component.
20+ /// </summary>
21+ /// <remarks>The returned class string includes base and orientation-specific classes, as well as
22+ /// any additional classes specified by the user. This property is typically used to apply styling to the
23+ /// stepper element based on its configuration.</remarks>
24+ protected string ? Classname => new CssBuilder ( "mud-stepper-extended" )
25+ . AddClass ( "mud-stepper-horizontal-extended" , ! Vertical )
26+ . AddClass ( "mud-stepper-vertical-extended" , Vertical )
27+ . AddClass ( Class )
28+ . Build ( ) ;
29+
1930 /// <summary>
2031 ///
2132 /// </summary>
22- protected string ? HeaderClassname => new CssBuilder ( "d-flex align-center mud-stepper-header gap-4 pa-3" )
33+ protected string ? HeaderClassname => new CssBuilder ( "d-flex align-center mud-stepper-header-extended gap-4 pa-3" )
2334 . AddClass ( "mud-ripple" , Ripple && ! Linear )
24- . AddClass ( "cursor-pointer mud-stepper-header-non-linear" , ! Linear )
35+ . AddClass ( "cursor-pointer mud-stepper-header-non-linear-extended " , ! Linear )
2536 . AddClass ( "flex-column" , ! Vertical )
2637 . AddClass ( "flex-row" , Vertical )
38+ . AddClass ( HeaderClass )
2739 . Build ( ) ;
2840
2941 /// <summary>
@@ -43,78 +55,31 @@ public partial class MudStepperExtended : MudComponentBase
4355 . Build ( ) ;
4456
4557 /// <summary>
46- ///
58+ /// Gets the CSS class string that represents the current progress state of the stepper component, including
59+ /// orientation, header size, mobile view, and step count.
4760 /// </summary>
48- protected string ? AvatarStylename => new StyleBuilder ( )
49- . AddStyle ( "z-index: 20" )
50- . AddStyle ( "background-color" , "var(--mud-palette-background)" , Variant == Variant . Outlined )
61+ /// <remarks>The returned class string reflects the visual configuration of the stepper and can be
62+ /// used to style the progress indicator appropriately. The value updates dynamically based on the component's
63+ /// properties such as orientation and step count.</remarks>
64+ protected string ProgressClassname => new CssBuilder ( "mud-stepper-progress-extended" )
65+ . AddClass ( "vertical" , Vertical )
66+ . AddClass ( "horizontal" , ! Vertical )
67+ . AddClass ( $ "header-size-{ HeaderSize . ToDescriptionString ( ) } ")
68+ . AddClass ( "mobile" , MobileView )
69+ . AddClass ( $ "steps-{ Steps . Count } ")
5170 . Build ( ) ;
5271
53- /// <summary>
54- ///
55- /// </summary>
56- /// <returns></returns>
57- protected string ? GetMobileStyle ( )
58- {
59- if ( Vertical )
60- {
61- return "grid-column:1;margin-inline-start:22px;" ;
62- }
63- else
64- {
65- return "grid-row:1;margin-top:22px;" ;
66- }
67- }
6872
6973 /// <summary>
70- ///
74+ /// Gets the CSS class string used to style the stepper avatar based on the current variant.
7175 /// </summary>
72- /// <returns></returns>
73- protected string ? GetStepperStyle ( )
74- {
75- var count = Steps . Count * 2 ;
76- if ( Vertical )
77- {
78- return $ "display:grid;grid-template-rows:repeat({ count } , 1fr);";
79- }
80- else
81- {
82- return $ "display:grid;grid-template-columns:repeat({ count } , 1fr);";
83- }
84- }
76+ /// <remarks>The returned class name reflects the visual style of the avatar, including background
77+ /// styling when the variant is set to outlined. This property is intended for use in rendering the component's
78+ /// HTML and may change if the variant changes.</remarks>
79+ protected string AvatarClassname => new CssBuilder ( "mud-stepper-avatar-extended" )
80+ . AddClass ( "mud-stepper-avatar-bg-extended" , Variant == Variant . Outlined )
81+ . Build ( ) ;
8582
86- /// <summary>
87- ///
88- /// </summary>
89- /// <returns></returns>
90- protected string ? GetStepperSubStyle ( )
91- {
92- if ( Vertical )
93- {
94- return "grid-row-start:1;grid-row-end:-1;flex-direction:column;grid-column:1;list-style:none;display:flex;" ;
95- }
96- else
97- {
98- return "grid-column-start:1;grid-column-end:-1;flex-direction:row;grid-row:1;list-style:none;display:flex;" ;
99- }
100- }
101-
102- /// <summary>
103- ///
104- /// </summary>
105- /// <returns></returns>
106- protected string ? GetStepPercent ( )
107- {
108- var dPercent = ( 100.0 / Steps . Count ) . ToInvariantString ( ) ;
109- if ( Vertical )
110- {
111- return $ "height:{ dPercent } %";
112- }
113- else
114- {
115- return $ "width:{ dPercent } %";
116- }
117- }
11883
11984 /// <summary>
12085 /// Returns a formatted string representing the current step position in the mobile step sequence.
@@ -140,40 +105,6 @@ protected internal string GetMobileStepPositionText()
140105 return string . Empty ;
141106 }
142107
143-
144- /// <summary>
145- ///
146- /// </summary>
147- /// <returns></returns>
148- protected string ? GetStepClass ( )
149- {
150- if ( Vertical )
151- {
152- return $ "d-flex";
153- }
154- else
155- {
156- return $ "" ;
157- }
158- }
159-
160- /// <summary>
161- ///
162- /// </summary>
163- /// <returns></returns>
164- protected string ? GetProgressLinearStyle ( )
165- {
166- var end = Steps . Count * 2 ;
167- if ( Vertical )
168- {
169- return $ "grid-row-start:2;grid-row-end:{ end } ;grid-column:1/-1;display:inline-grid;left:{ ( HeaderSize == Size . Medium ? 30 : HeaderSize == Size . Large ? 38 : 22 ) } px;z-index:10;transform:rotateX(180deg);";
170- }
171- else
172- {
173- return $ "grid-column-start:2;grid-column-end:{ end } ;grid-row:1/-1;display:inline-grid;top:{ ( HeaderSize == Size . Medium ? 30 : HeaderSize == Size . Large ? 38 : 22 ) } px;{ ( HeaderSize == Size . Small ? "height:2px;" : HeaderSize == Size . Medium ? "height:3px;" : null ) } { ( MobileView ? "margin-inline-start:40px;" : null ) } z-index:10";
174- }
175- }
176-
177108 private int _activeIndex ;
178109 internal int ActiveIndex
179110 {
@@ -206,9 +137,36 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
206137 /// </summary>
207138 protected void UpdateProgressValue ( )
208139 {
209- ProgressValue = _activeIndex * ( 100.0 / ( Steps . Count - 1 ) ) ;
140+ int total = Steps . Count ;
141+
142+ if ( ActiveIndex == - 1 )
143+ {
144+ ProgressValue = 0 ;
145+ return ;
146+ }
147+
148+ if ( ActiveIndex == total )
149+ {
150+ ProgressValue = 100 ;
151+ return ;
152+ }
153+
154+ if ( total <= 1 )
155+ {
156+ ProgressValue = 0 ;
157+ return ;
158+ }
159+
160+ ProgressValue = ( ActiveIndex / ( double ) ( total - 1 ) ) * 100.0 ;
210161 }
211162
163+
164+ /// <summary>
165+ /// Gets or sets the CSS class to apply to the header element.
166+ /// </summary>
167+ [ Parameter ]
168+ public string ? HeaderClass { get ; set ; }
169+
212170 /// <summary>
213171 /// Provides CSS classes for the step content.
214172 /// </summary>
0 commit comments