@@ -8,7 +8,7 @@ namespace MudExtensions
88 public partial class MudSplitter : MudComponentBase
99 {
1010
11- Guid _styleGuid = Guid . NewGuid ( ) ;
11+ readonly Guid _styleGuid = Guid . NewGuid ( ) ;
1212 MudSlider < double > _slider ;
1313
1414 protected string Classname => new CssBuilder ( "mud-splitter" )
@@ -34,7 +34,7 @@ public partial class MudSplitter : MudComponentBase
3434
3535 //string _height;
3636 /// <summary>
37- /// The height of splitter.
37+ /// The height of splitter. For example: "400px"
3838 /// </summary>
3939 [ Parameter ]
4040 public string Height { get ; set ; }
@@ -54,50 +54,62 @@ public partial class MudSplitter : MudComponentBase
5454 /// <summary>
5555 /// The two contents' (sections) styles, seperated by space.
5656 /// </summary>
57+ [ Obsolete ( "StyleContent is deprecated, please use property ContentStyle, StartContentStyle or EndContentStyle to set the style." ) ]
5758 [ Parameter ]
5859 public string StyleContent { get ; set ; }
5960
6061 /// <summary>
61- /// The splitter bar's styles, seperated by space. All styles have to include !important and end with ';'
62+ /// The style to apply to both content sections, seperated by space.
63+ /// </summary>
64+ [ Parameter ]
65+ public string ContentStyle { get ; set ; }
66+
67+ /// <summary>
68+ /// The style of the <see cref="StartContent"/>, seperated by space. Overrules <see cref=" StyleContent"/>
6269 /// </summary>
6370 [ Parameter ]
71+ public string StartContentStyle { get ; set ; }
72+
73+ /// <summary>
74+ /// The style of the <see cref="EndContent"/>, seperated by space. Overrules <see cref=" StyleContent"/>
75+ /// </summary>
76+ [ Parameter ]
77+ public string EndContentStyle { get ; set ; }
78+
79+ /// <summary>
80+ /// The splitter bar's styles, seperated by space. The style string should end with: "!important;"
81+ /// </summary>
82+ [ Obsolete ( "StyleBar is deprecated, please use property BarStyle to set the bar's style." ) ]
83+ [ Parameter ]
6484 public string StyleBar { get ; set ; } = "width:2px !important;" ;
6585
86+ /// <summary>
87+ /// The splitter bar's styles, seperated by space. The style string should end with: "!important;"
88+ /// </summary>
89+ /// <remarks>The default is 2px</remarks>
90+ [ Parameter ]
91+ public string BarStyle { get ; set ; } = "width:2px !important;" ;
92+
6693 /// <summary>
6794 /// The slide sensitivity that should between 0.01 and 10. Smaller values increase the smooth but reduce performance. Default is 0.1
6895 /// </summary>
6996 [ Parameter ]
7097 public double Sensitivity { get ; set ; } = 0.1d ;
7198
72- [ Obsolete ( "DisableSlide is deprecated, please use property EnableSlide to set Slide." ) ]
73- [ Parameter ]
74- public bool DisableSlide
75- {
76- get { return ! EnableSlide ; }
77- set { EnableSlide = ! value ; }
78- }
7999 /// <summary>
80100 /// If true, user can interact with splitter bar.
81- /// Default is true.
82101 /// </summary>
102+ /// <remarks>The default is true</remarks>
83103 [ Parameter ]
84104 public bool EnableSlide { get ; set ; } = true ;
85105
86- [ Obsolete ( "DisableMargin is deprecated, please use property EnableMargin to set Margin." ) ]
87- [ Parameter ]
88- public bool DisableMargin
89- {
90- get { return ! EnableMargin ; }
91- set { EnableMargin = ! value ; }
92- }
93106 /// <summary>
94107 /// Enables the default margin.
95- /// Default is true.
96108 /// </summary>
109+ /// <remarks>The default is true, which adds class: "ma-2"</remarks>
97110 [ Parameter ]
98111 public bool EnableMargin { get ; set ; } = true ;
99112
100-
101113 ///// <summary>
102114 ///// If true, splitter bar goes vertical.
103115 ///// </summary>
@@ -110,11 +122,11 @@ public bool DisableMargin
110122 [ Parameter ]
111123 public RenderFragment EndContent { get ; set ; }
112124
113-
114125 /// <summary>
115126 /// The start content's percentage.
116127 /// Default is 50.
117128 /// </summary>
129+ /// <remarks>The default is 50</remarks>
118130 [ Parameter ]
119131 public double Dimension { get ; set ; } = 50 ;
120132
@@ -124,30 +136,35 @@ public bool DisableMargin
124136 [ Parameter ]
125137 public EventCallback OnDoubleClicked { get ; set ; }
126138
127- protected override async Task OnInitializedAsync ( )
128- {
129- await base . OnInitializedAsync ( ) ;
130- await UpdateDimension ( Dimension ) ;
131- }
132139
133- protected async Task UpdateDimension ( double percentage )
140+ string EffectiveStartStyle { get { return ! string . IsNullOrWhiteSpace ( StartContentStyle ) ? StartContentStyle : ! string . IsNullOrWhiteSpace ( ContentStyle ) ? ContentStyle : StyleContent ; } }
141+ string EffectiveEndStyle { get { return ! string . IsNullOrWhiteSpace ( EndContentStyle ) ? EndContentStyle : ! string . IsNullOrWhiteSpace ( ContentStyle ) ? ContentStyle : StyleContent ; } }
142+ string EffectiveHeight { get { return $ "height:{ ( ! string . IsNullOrWhiteSpace ( Height ) ? Height : "0px" ) } !important;"; } }
143+ string EffectiveBarStyle { get { return ! string . IsNullOrWhiteSpace ( BarStyle ) ? BarStyle : StyleBar ; } }
144+ string EffectiveColor { get { return $ "background-color:var(--mud-palette-{ ( Color == Color . Default ? "action-default" : Color . ToDescriptionString ( ) ) } ) !important;"; } }
145+
146+
147+ protected Task UpdateDimension ( double percentage )
134148 {
135149 Dimension = percentage ;
136- if ( DimensionChanged . HasDelegate )
137- await DimensionChanged . InvokeAsync ( percentage ) ;
138- }
139150
140- /// <summary>
141- /// Updates the dimension with given the start content's percentage
142- /// </summary>
143- /// <param name="percentage"></param>
144- [ Obsolete ( "SetDimensions is deprecated, please use property Dimension to set start content's percentage." ) ]
145- public Task SetDimensions ( double percentage ) => UpdateDimension ( percentage ) ;
151+ if ( Dimension < 0 )
152+ Dimension = 0 ;
153+ else if ( Dimension > 100 )
154+ Dimension = 100 ;
146155
147- async Task OnDoubleClick ( )
156+ if ( DimensionChanged . HasDelegate )
157+ _ = DimensionChanged . InvokeAsync ( percentage ) ;
158+
159+ return Task . CompletedTask ;
160+ }
161+
162+ Task OnDoubleClick ( )
148163 {
149164 if ( OnDoubleClicked . HasDelegate )
150- await OnDoubleClicked . InvokeAsync ( ) ;
165+ _ = OnDoubleClicked . InvokeAsync ( ) ;
166+
167+ return Task . CompletedTask ;
151168 }
152169 }
153170}
0 commit comments