Skip to content

A Swiss Army knife for developers.

Improved layout management

Etienne Baudouxf0882dd5175d
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
index 77e4d185f..d4e9f3bba 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor
@@ -3,13 +3,19 @@
@inherits JSStyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <button id=@Id
- role="button"
- class="@(FinalCssClasses)"
- style="@(Style)"
- tabindex="0"
- @ref=Element
- @attributes="AdditionalAttributes">
- @ChildContent
- </button>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <button id=@Id
+ role="button"
+ class="@(FinalCssClasses)"
+ style="@(Style)"
+ tabindex="0"
+ @ref=Element
+ @attributes="AdditionalAttributes">
+ @ChildContent
+ </button>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.scss
index faed6ce39..a2c3a408b 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/Button/Button.razor.scss
@@ -15,7 +15,8 @@ button {
cursor: default;
border-radius: var(--control-corner-radius);
transition: 83ms ease background;
- width: fit-content;
+ width: inherit;
+ height: inherit;
&:focus-visible {
box-shadow: var(--focus-stroke);
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
index 80e87834e..9eeb2c19b 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor
@@ -3,32 +3,38 @@
@inherits JSStyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <label
- id=@Id
- role="button"
- class="checkbox-container @(IsEnabled ? string.Empty : "disabled")"
- style="@(Style)"
- @ref=Element>
- <span class="checkbox-inner">
- <input
- type="checkbox"
- tabindex="0"
- class="checkbox @(FinalCssClasses)"
- checked="@IsChecked"
- disabled="@(!IsEnabled)"
- @onclick:preventDefault="@(!IsEnabled)"
- @onchange="OnChange"
- @attributes="AdditionalAttributes" />
- <svg
- aria-hidden="true"
- class="checkbox-glyph"
- viewBox="0 0 24 24">
- <path
- class="path-checkmark"
- d="M 4.5303 12.9697 L 8.5 16.9393 L 18.9697 6.4697"
- fill="none" />
- </svg>
- </span>
- <TextBlock Text="@Text" />
- </label>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <label
+ id=@Id
+ role="button"
+ class="checkbox-container @(IsEnabled ? string.Empty : "disabled")"
+ style="@(Style)"
+ @ref=Element>
+ <span class="checkbox-inner">
+ <input
+ type="checkbox"
+ tabindex="0"
+ class="checkbox @(FinalCssClasses)"
+ checked="@IsChecked"
+ disabled="@(!IsEnabled)"
+ @onclick:preventDefault="@(!IsEnabled)"
+ @onchange="OnChange"
+ @attributes="AdditionalAttributes" />
+ <svg
+ aria-hidden="true"
+ class="checkbox-glyph"
+ viewBox="0 0 24 24">
+ <path
+ class="path-checkmark"
+ d="M 4.5303 12.9697 L 8.5 16.9393 L 18.9697 6.4697"
+ fill="none" />
+ </svg>
+ </span>
+ <TextBlock Text="@Text" />
+ </label>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor.scss
index 2e6e753cb..1ec7fddcc 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/CheckBox/CheckBox.razor.scss
@@ -75,7 +75,7 @@
}
&-container {
- @include flex($inline: true, $align: center);
+ @include flex($align: center);
@include typography-body;
color: var(--check-box-foreground) !important;
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
index 91e03a192..0130cb98e 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor
@@ -3,71 +3,79 @@
@inherits SelectBase<TElement>
<CascadingValue Value="this" IsFixed="false">
- <div id=@Id
- class="combo-box-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="combo-box-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="combo-box-header" Text="@Header" />
- }
-
- <Button @ref="_button"
- Class="@($"combo-box-button {FinalCssClasses}")"
- Appearance="ButtonAppearance.Neutral"
- IsEnabled="@IsEnabled"
- @onclick="@ToggleDropDown">
- @if (SelectedItem is not null)
+ @if (!string.IsNullOrWhiteSpace(Header))
{
- @ItemTemplate(SelectedItem)
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="combo-box-header" Text="@Header" />
}
- <div class="arrow-down-icon">
- <FontIcon Glyph="@('\uf2a6')" />
- </div>
- <Popover Open="_isOpen"
- AnchorOrigin="Origin.CenterCenter"
- TransformOrigin="Origin.CenterCenter"
- RelativeWidth="false"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <FocusTrapper Style="display: contents;"
- OnEscapeKeyPressed="OnEscapeKeyPressed"
- @onfocusout="OnEscapeKeyPressed">
- <ScrollViewer Orientation="Orientation.Vertical"
- IsEnabled="@IsEnabled"
- Class="@FinalCssClasses"
- Style="@Style"
- UseNativeScrollBar="true"
- AdditionalAttributes="@AdditionalAttributes">
- <ul @ref="_listBox"
- role="menu"
- class="combo-box-list-box"
- tabindex="0"
- @onkeydown="OnKeyDown">
+ <Button @ref="_button"
+ Class="@($"combo-box-button {FinalCssClasses}")"
+ HorizontalAlignment="@HorizontalAlignment"
+ Width="@Width"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsEnabled"
+ @onclick="@ToggleDropDown">
+ @if (SelectedItem is not null)
+ {
+ @ItemTemplate(SelectedItem)
+ }
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')" />
+ </div>
+
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.CenterCenter"
+ TransformOrigin="Origin.CenterCenter"
+ RelativeWidth="false"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ScrollViewer Orientation="Orientation.Vertical"
+ IsEnabled="@IsEnabled"
+ Class="@FinalCssClasses"
+ Style="@Style"
+ UseNativeScrollBar="true"
+ AdditionalAttributes="@AdditionalAttributes">
+ <ul @ref="_listBox"
+ role="menu"
+ class="combo-box-list-box"
+ tabindex="0"
+ @onkeydown="OnKeyDown">
- @if (Virtualize)
- {
- <Virtualize Items="@Items" Context="item">
- @RenderItem(item)
- </Virtualize>
- }
- else if (Items is not null)
- {
- foreach (var item in Items)
+ @if (Virtualize)
+ {
+ <Virtualize Items="@Items" Context="item">
+ @RenderItem(item)
+ </Virtualize>
+ }
+ else if (Items is not null)
{
- @RenderItem(item)
+ foreach (var item in Items)
+ {
+ @RenderItem(item)
+ }
}
- }
- </ul>
- </ScrollViewer>
- </FocusTrapper>
- </CascadingValue>
- </Popover>
- </Button>
- </div>
+ </ul>
+ </ScrollViewer>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
+ </div>
+ </Container>
</CascadingValue>
@code {
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.scss
index 42e1605e9..163c03db1 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ComboBox/ComboBox.razor.scss
@@ -4,7 +4,7 @@
@include typography-body;
&-with-header {
- display: inline-flex;
+ display: flex;
flex-direction: column;
position: relative;
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
index 37eafffaf..86583f4b7 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor
@@ -2,63 +2,71 @@
@inherits StyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <div id=@Id
- class="drop-down-list-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="drop-down-list-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="drop-down-list-header" Text="@Header" />
- }
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="drop-down-list-header" Text="@Header" />
+ }
- <Button Class="@($"drop-down-list-button {FinalCssClasses}")"
- Appearance="ButtonAppearance.Neutral"
- IsEnabled="@IsEnabled"
- @onclick="@ToggleDropDown">
- @ChildContent
- <div class="arrow-down-icon">
- <FontIcon Glyph="@('\uf2a6')"/>
- </div>
+ <Button Class="@($"drop-down-list-button {FinalCssClasses}")"
+ HorizontalAlignment="@HorizontalAlignment"
+ Width="@Width"
+ Appearance="ButtonAppearance.Neutral"
+ IsEnabled="@IsEnabled"
+ @onclick="@ToggleDropDown">
+ @ChildContent
+ <div class="arrow-down-icon">
+ <FontIcon Glyph="@('\uf2a6')"/>
+ </div>
- <Popover Open="_isOpen"
- AnchorOrigin="Origin.BottomCenter"
- TransformOrigin="Origin.TopCenter"
- RelativeWidth="false"
- Class="drop-down-list-drop-down"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <FocusTrapper Style="display: contents;"
- OnEscapeKeyPressed="OnEscapeKeyPressed"
- @onfocusout="OnEscapeKeyPressed">
- <ListBox @ref="_listBox"
- Items="Items"
- Context="item"
- Role="menu"
- OverrideDefaultItemTemplate="true"
- Virtualize="true"
- RaiseSelectionEventOnKeyboardNavigation="false"
- SelectedIndexChanged="OnDropDowlListItemSelected"
- UseNativeScrollBar="true"
- Class="context-menu-list-box"
- Style="max-height: 400px">
- <ItemTemplate>
- <li role="menuitem"
- class="@($"context-menu-item {(_listBox!.SelectedItem == item ? "selected" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}")"
- aria-disabled="@(item.IsEnabled ? string.Empty : "true")">
- <div class="icon-container">
- <FontIcon Glyph="@item.IconGlyph" FontFamily="@item.IconFontFamily" />
- </div>
- <TextBlock Class="text"
- NoWrap="true"
- Text="@item.Text" />
- </li>
- </ItemTemplate>
- </ListBox>
- </FocusTrapper>
- </CascadingValue>
- </Popover>
- </Button>
+ <Popover Open="_isOpen"
+ AnchorOrigin="Origin.BottomCenter"
+ TransformOrigin="Origin.TopCenter"
+ RelativeWidth="false"
+ Class="drop-down-list-drop-down"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <FocusTrapper Style="display: contents;"
+ OnEscapeKeyPressed="OnEscapeKeyPressed"
+ @onfocusout="OnEscapeKeyPressed">
+ <ListBox @ref="_listBox"
+ Items="Items"
+ Context="item"
+ Role="menu"
+ OverrideDefaultItemTemplate="true"
+ Virtualize="true"
+ RaiseSelectionEventOnKeyboardNavigation="false"
+ SelectedIndexChanged="OnDropDowlListItemSelected"
+ UseNativeScrollBar="true"
+ Class="context-menu-list-box"
+ Style="max-height: 400px">
+ <ItemTemplate>
+ <li role="menuitem"
+ class="@($"context-menu-item {(_listBox!.SelectedItem == item ? "selected" : string.Empty)} {(item.IsEnabled ? string.Empty : "disabled")}")"
+ aria-disabled="@(item.IsEnabled ? string.Empty : "true")">
+ <div class="icon-container">
+ <FontIcon Glyph="@item.IconGlyph" FontFamily="@item.IconFontFamily" />
+ </div>
+ <TextBlock Class="text"
+ NoWrap="true"
+ Text="@item.Text" />
+ </li>
+ </ItemTemplate>
+ </ListBox>
+ </FocusTrapper>
+ </CascadingValue>
+ </Popover>
+ </Button>
- </div>
+ </div>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.scss
index f314bcbcf..932f9e464 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/DropDownList/DropDownList.razor.scss
@@ -4,7 +4,7 @@
@include typography-body;
&-with-header {
- display: inline-flex;
+ display: flex;
flex-direction: column;
position: relative;
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
index 43920fa56..6c79009e2 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor
@@ -3,19 +3,25 @@
@inherits JSStyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <label id=@Id
- class="radio-button-container @(IsEnabled ? string.Empty : "disabled")"
- style="@(Style)"
- @ref=Element>
- <input type="radio"
- tabindex="0"
- class="radio-button @(FinalCssClasses)"
- checked="@IsChecked"
- disabled="@(!IsEnabled)"
- name="@Group"
- @onclick:preventDefault="@(!IsEnabled)"
- @onchange="OnChange"
- @attributes="AdditionalAttributes" />
- <TextBlock Text="@Text" />
- </label>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <label id=@Id
+ class="radio-button-container @(IsEnabled ? string.Empty : "disabled")"
+ style="@(Style)"
+ @ref=Element>
+ <input type="radio"
+ tabindex="0"
+ class="radio-button @(FinalCssClasses)"
+ checked="@IsChecked"
+ disabled="@(!IsEnabled)"
+ name="@Group"
+ @onclick:preventDefault="@(!IsEnabled)"
+ @onchange="OnChange"
+ @attributes="AdditionalAttributes" />
+ <TextBlock Text="@Text" />
+ </label>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor.scss
index 476dcc54d..00ee44083 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/RadioButton/RadioButton.razor.scss
@@ -108,7 +108,7 @@
}
&-container {
- @include flex($inline: true, $align: center);
+ @include flex($align: center);
@include typography-body;
color: var(--radio-button-foreground);
background-color: var(--radio-button-background);
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
index 41c5e7f2f..386ee3f3f 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor
@@ -3,21 +3,27 @@
@inherits JSStyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <label
- id=@Id
- role="button"
- class="toggle-switch-container @(IsEnabled ? string.Empty : "disabled")"
- style="@(Style)"
- @ref=Element>
- <input
- type="checkbox"
- tabindex="0"
- class="toggle-switch @(FinalCssClasses)"
- checked="@IsOn"
- disabled="@(!IsEnabled)"
- @onclick:preventDefault="@(!IsEnabled)"
- @onchange="OnChange"
- @attributes="AdditionalAttributes" />
- <TextBlock Text="@Text" />
- </label>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <label
+ id=@Id
+ role="button"
+ class="toggle-switch-container @(IsEnabled ? string.Empty : "disabled")"
+ style="@(Style)"
+ @ref=Element>
+ <input
+ type="checkbox"
+ tabindex="0"
+ class="toggle-switch @(FinalCssClasses)"
+ checked="@IsOn"
+ disabled="@(!IsEnabled)"
+ @onclick:preventDefault="@(!IsEnabled)"
+ @onchange="OnChange"
+ @attributes="AdditionalAttributes" />
+ <TextBlock Text="@Text" />
+ </label>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor.scss b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor.scss
index cc7a13319..a3f5d6589 100644
--- a/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/BasicInput/ToggleSwitch/ToggleSwitch.razor.scss
@@ -113,7 +113,7 @@ $control-fast-out-slow-in-easing: cubic-bezier(0, 0, 0, 1);
}
&-container {
- @include flex($inline: true, $align: center);
+ @include flex($align: center);
@include typography-body;
color: var(--toggle-switch-foreground) !important;
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor b/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
index 6d6e7ae36..4f4498f6f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/GridView/GridView.razor
@@ -4,49 +4,55 @@
@typeparam TElement
<CascadingValue Value="this" IsFixed="true">
- <ScrollViewer @ref=_scrollViewer
- Orientation="Orientation.Vertical"
- Class="@(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
- @if (Header is not null)
- {
- <div class="header">@Header</div>
- }
-
- @if (ItemsSource is not null)
- {
- Guard.IsNotNull(ItemTemplate);
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <ScrollViewer @ref=_scrollViewer
+ Orientation="Orientation.Vertical"
+ Class="@(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
+ @if (Header is not null)
+ {
+ <div class="header">@Header</div>
+ }
- foreach (IGrouping<TKey, TElement> group in ItemsSource)
+ @if (ItemsSource is not null)
{
- <section class="grid-view-group">
- <header class="grid-view-group-header">
- @if (GroupHeaderTemplate is null)
- {
- @group.Key?.ToString()
- }
- else
- {
- @GroupHeaderTemplate(group.Key)
- }
- </header>
+ Guard.IsNotNull(ItemTemplate);
+
+ foreach (IGrouping<TKey, TElement> group in ItemsSource)
+ {
+ <section class="grid-view-group">
+ <header class="grid-view-group-header">
+ @if (GroupHeaderTemplate is null)
+ {
+ @group.Key?.ToString()
+ }
+ else
+ {
+ @GroupHeaderTemplate(group.Key)
+ }
+ </header>
- <ul class="grid-view-items-container">
- @foreach (TElement item in group)
- {
- <li class="grid-view-item"
- style="min-width: @ItemMinWidth.ToPx()">
- <div class="grid-view-item-hover-filter" @onclick="() => OnItemClickAsync(item)">
- @ItemTemplate(item)
- </div>
- </li>
- }
- </ul>
- </section>
+ <ul class="grid-view-items-container">
+ @foreach (TElement item in group)
+ {
+ <li class="grid-view-item"
+ style="min-width: @ItemMinWidth.ToPx()">
+ <div class="grid-view-item-hover-filter" @onclick="() => OnItemClickAsync(item)">
+ @ItemTemplate(item)
+ </div>
+ </li>
+ }
+ </ul>
+ </section>
+ }
}
- }
- @Footer
- </ScrollViewer>
+ @Footer
+ </ScrollViewer>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
index 1ff703b19..b4369f415 100644
--- a/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Collections/ListBox/ListBox.razor
@@ -2,34 +2,42 @@
@typeparam TElement
@inherits SelectBase<TElement>
-<ScrollViewer Orientation="Orientation.Vertical"
- IsEnabled="@IsEnabled"
- Class="@FinalCssClasses"
- Style="@Style"
- UseNativeScrollBar="@UseNativeScrollBar"
- AdditionalAttributes="@AdditionalAttributes">
- <ul @ref="Element"
- role="@Role"
- class="list-box"
- tabindex="0"
- @onkeydown="OnKeyDown">
-
- @if (Virtualize)
- {
- <Virtualize Items="@Items" Context="item">
- @RenderItem(item)
- </Virtualize>
- }
- else if (Items is not null)
- {
- foreach (var item in Items)
- {
- @RenderItem(item)
- }
- }
-
- </ul>
-</ScrollViewer>
+<CascadingValue Value="this" IsFixed="true">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <ScrollViewer Orientation="Orientation.Vertical"
+ IsEnabled="@IsEnabled"
+ Class="@FinalCssClasses"
+ Style="@Style"
+ UseNativeScrollBar="@UseNativeScrollBar"
+ AdditionalAttributes="@AdditionalAttributes">
+ <ul @ref="Element"
+ role="@Role"
+ class="list-box"
+ tabindex="0"
+ @onkeydown="OnKeyDown">
+
+ @if (Virtualize)
+ {
+ <Virtualize Items="@Items" Context="item">
+ @RenderItem(item)
+ </Virtualize>
+ }
+ else if (Items is not null)
+ {
+ foreach (var item in Items)
+ {
+ @RenderItem(item)
+ }
+ }
+
+ </ul>
+ </ScrollViewer>
+ </Container>
+</CascadingValue>
@code {
private RenderFragment<TElement> RenderItem { get; set; } = default!;
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
index bdffc5b98..a3eb0e72e 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/FontIcon/FontIcon.razor.cs
@@ -2,6 +2,12 @@
public partial class FontIcon : StyledComponentBase
{
+ public FontIcon()
+ {
+ VerticalAlignment = VerticalAlignment.Center;
+ HorizontalAlignment = HorizontalAlignment.Center;
+ }
+
[Parameter]
public char Glyph { get; set; }
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
index 13d8f2fce..1b404d657 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor
@@ -2,35 +2,41 @@
@inherits StyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <svg @ref="Element"
- tabindex="-1"
- role="@((IsIndeterminate ? "status" : "progressbar"))"
- class="progress-bar @((IsIndeterminate ? "indeterminate" : string.Empty)) @FinalCssClasses"
- width="100%"
- height="3"
- style="@Style"
- @attributes="AdditionalAttributes">
- @if (IsIndeterminate)
- {
- <rect height="3"
- ry="3"
- class="progress-bar-track" />
- <rect height="3"
- ry="3"
- class="progress-bar-track" />
- }
- else
- {
- <rect width="100%"
- height="1"
- rx="0.5"
- y="1"
- class="progress-bar-rail" />
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <svg @ref="Element"
+ tabindex="-1"
+ role="@((IsIndeterminate ? "status" : "progressbar"))"
+ class="progress-bar @((IsIndeterminate ? "indeterminate" : string.Empty)) @FinalCssClasses"
+ width="100%"
+ height="3"
+ style="@Style"
+ @attributes="AdditionalAttributes">
+ @if (IsIndeterminate)
+ {
+ <rect height="3"
+ ry="3"
+ class="progress-bar-track" />
+ <rect height="3"
+ ry="3"
+ class="progress-bar-track" />
+ }
+ else
+ {
+ <rect width="100%"
+ height="1"
+ rx="0.5"
+ y="1"
+ class="progress-bar-rail" />
- <rect width="@(Value.ToPercentage())"
- height="3"
- rx="1.5"
- class="progress-bar-track" />
- }
- </svg>
+ <rect width="@(Value.ToPercentage())"
+ height="3"
+ rx="1.5"
+ class="progress-bar-track" />
+ }
+ </svg>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
index d6a27b400..3cbbcf508 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressBar/ProgressBar.razor.cs
@@ -4,6 +4,11 @@ namespace DevToys.Blazor.Components;
public partial class ProgressBar : StyledComponentBase
{
+ public ProgressBar()
+ {
+ VerticalAlignment = VerticalAlignment.Top;
+ }
+
[Parameter]
[Range(0.0, 100.0, ErrorMessage = $"{nameof(Value)} must be between 0 and 100.")]
public double Value { get; set; }
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
index 95331a3af..b45e18d4f 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor
@@ -2,19 +2,25 @@
@inherits StyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <svg @ref="Element"
- tabindex="-1"
- role="@((IsIndeterminate ? "status" : "progressbar"))"
- width="@(Size.ToPx())"
- height="@(Size.ToPx())"
- class="progress-ring @((IsIndeterminate ? "indeterminate" : string.Empty)) @FinalCssClasses"
- style="@Style"
- viewBox="0 0 16 16"
- @attributes="AdditionalAttributes">
- <circle cx="50%"
- cy="50%"
- r="@CircleElementR"
- stroke-dasharray="3"
- stroke-dashoffset="@(((100 - Value) / 100) * _circumference)" />
- </svg>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <svg @ref="Element"
+ tabindex="-1"
+ role="@((IsIndeterminate ? "status" : "progressbar"))"
+ width="@(Width.ToPx())"
+ height="@(Height.ToPx())"
+ class="progress-ring @((IsIndeterminate ? "indeterminate" : string.Empty)) @FinalCssClasses"
+ style="@Style"
+ viewBox="0 0 16 16"
+ @attributes="AdditionalAttributes">
+ <circle cx="50%"
+ cy="50%"
+ r="@CircleElementR"
+ stroke-dasharray="3"
+ stroke-dashoffset="@(((100 - Value) / 100) * _circumference)" />
+ </svg>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
index 455279781..23766159b 100644
--- a/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Feedback/ProgressRing/ProgressRing.razor.cs
@@ -7,13 +7,18 @@ public partial class ProgressRing : StyledComponentBase
private const int CircleElementR = 7;
private readonly double _circumference = Math.PI * (CircleElementR * 2);
+ public ProgressRing()
+ {
+ VerticalAlignment = VerticalAlignment.Center;
+ HorizontalAlignment = HorizontalAlignment.Center;
+ Height = 48;
+ Width = 48;
+ }
+
[Parameter]
[Range(0.0, 100.0, ErrorMessage = $"{nameof(Value)} must be between 0 and 100.")]
public double Value { get; set; }
- [Parameter]
- public int Size { get; set; } = 48;
-
[Parameter]
public bool IsIndeterminate { get; set; }
diff --git a/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs b/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs
new file mode 100644
index 000000000..db1a6e15e
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/HorizontalAlignment.cs
@@ -0,0 +1,9 @@
+namespace DevToys.Blazor.Components;
+
+public enum HorizontalAlignment
+{
+ Stretch,
+ Left,
+ Right,
+ Center
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor
new file mode 100644
index 000000000..b882b3d71
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor
@@ -0,0 +1,12 @@
+@namespace DevToys.Blazor.Components
+@inherits StyledComponentBase
+
+<CascadingValue Value="this" IsFixed="true">
+ <div class="@(FinalCssClasses)"
+ style="@(Style);@(FinalStyles)"
+ @attributes="AdditionalAttributes">
+ <div style="@(FinalInnerStyles)">
+ @ChildContent
+ </div>
+ </div>
+</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs
new file mode 100644
index 000000000..02fa5fae6
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/Container/Container.razor.cs
@@ -0,0 +1,87 @@
+namespace DevToys.Blazor.Components;
+
+public partial class Container : StyledComponentBase
+{
+ /// <summary>
+ /// Gets or sets the content to be rendered inside the component.
+ /// </summary>
+ [Parameter]
+ public RenderFragment? ChildContent { get; set; }
+
+ public string FinalStyles { get; private set; } = string.Empty;
+
+ public string FinalInnerStyles { get; private set; } = string.Empty;
+
+ protected override void OnParametersSet()
+ {
+ BuildStyleAttribute();
+ base.OnParametersSet();
+ }
+
+ private void BuildStyleAttribute()
+ {
+ var styleBuilder = new StyleBuilder();
+ var innerStyleBuilder = new StyleBuilder();
+ if (AdditionalAttributes is not null)
+ {
+ styleBuilder.AddStyleFromAttributes(AdditionalAttributes);
+ }
+
+ if (!string.IsNullOrWhiteSpace(Style))
+ {
+ styleBuilder.AddStyle(Style);
+ }
+
+ styleBuilder.AddImportantStyle("overflow", "hidden");
+ styleBuilder.AddImportantStyle("display", () => IsVisible ? "flex" : "none");
+ styleBuilder.AddImportantStyle("flex-direction", "row");
+ styleBuilder.AddImportantStyle("flex-wrap", "nowrap");
+
+ switch (HorizontalAlignment)
+ {
+ case HorizontalAlignment.Stretch:
+ innerStyleBuilder.AddImportantStyle("width", "100%", !Width.HasValue);
+ styleBuilder.AddImportantStyle("justify-content", "center", Width.HasValue);
+ break;
+
+ case HorizontalAlignment.Left:
+ styleBuilder.AddImportantStyle("justify-content", "flex-start");
+ break;
+
+ case HorizontalAlignment.Right:
+ styleBuilder.AddImportantStyle("justify-content", "flex-end");
+ break;
+
+ case HorizontalAlignment.Center:
+ styleBuilder.AddImportantStyle("justify-content", "center");
+ break;
+ }
+
+ switch (VerticalAlignment)
+ {
+ case VerticalAlignment.Stretch:
+ styleBuilder.AddImportantStyle("align-items", "stretch");
+ styleBuilder.AddImportantStyle("max-height", "100%", !Height.HasValue);
+ innerStyleBuilder.AddImportantStyle("max-height", "inherit", !Height.HasValue);
+ break;
+
+ case VerticalAlignment.Top:
+ styleBuilder.AddImportantStyle("align-items", "flex-start");
+ break;
+
+ case VerticalAlignment.Bottom:
+ styleBuilder.AddImportantStyle("align-items", "flex-end");
+ break;
+
+ case VerticalAlignment.Center:
+ styleBuilder.AddImportantStyle("align-items", "center");
+ break;
+ }
+
+ innerStyleBuilder.AddImportantStyle("width", Width.ToPx(), Width.HasValue);
+ innerStyleBuilder.AddImportantStyle("height", Height.ToPx(), Height.HasValue);
+
+ FinalStyles = styleBuilder.ToString();
+ FinalInnerStyles = innerStyleBuilder.ToString();
+ }
+}
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
index 7600d0f11..902027698 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/ScrollViewer/ScrollViewer.razor
@@ -2,11 +2,17 @@
@inherits StyledComponentBase
<CascadingValue Value="this" IsFixed="true">
- <div id=@Id
- class="scroll-viewer @(FinalCssClasses)"
- style="@(Style)"
- @ref=Element
- @attributes="AdditionalAttributes">
- @ChildContent
- </div>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="scroll-viewer @(FinalCssClasses)"
+ style="@(Style)"
+ @ref=Element
+ @attributes="AdditionalAttributes">
+ @ChildContent
+ </div>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
index c3b586f47..76546fbcb 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor
@@ -2,6 +2,12 @@
@inherits StyledComponentBase
-<div id="@Id" @ref="@Element" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
- @ChildContent
-</div>
\ No newline at end of file
+<Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id="@Id" @ref="@Element" class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
+ @ChildContent
+ </div>
+</Container>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
index fba694f0a..58ee8afeb 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.cs
@@ -54,7 +54,6 @@ public partial class StackPanel : StyledComponentBase
protected string? StyleValue => new StyleBuilder()
.AddStyle("column-gap", HorizontalGap.ToPx(), () => HorizontalGap.HasValue)
.AddStyle("row-gap", VerticalGap.ToPx(), () => VerticalGap.HasValue)
- .AddStyle("width", Width, () => !string.IsNullOrEmpty(Width))
.AddStyle("flex-wrap", "wrap", () => Wrap)
.AddStyle(Style)
.Build();
@@ -63,13 +62,13 @@ public partial class StackPanel : StyledComponentBase
/// The horizontal alignment of the components in the stack.
/// </summary>
[Parameter]
- public StackHorizontalAlignment HorizontalAlignment { get; set; } = StackHorizontalAlignment.Left;
+ public StackHorizontalAlignment ContentHorizontalAlignment { get; set; } = StackHorizontalAlignment.Left;
/// <summary>
/// The vertical alignment of the components in the stack.
/// </summary>
[Parameter]
- public StackVerticalAlignment VerticalAlignment { get; set; } = StackVerticalAlignment.Top;
+ public StackVerticalAlignment ContentVerticalAlignment { get; set; } = StackVerticalAlignment.Top;
/// <summary>
/// Gets or set the orientation of the stacked components.
@@ -77,12 +76,6 @@ public partial class StackPanel : StyledComponentBase
[Parameter]
public Orientation Orientation { get; set; } = Orientation.Horizontal;
- /// <summary>
- /// The width of the stack as a percentage string (default = 100%).
- /// </summary>
- [Parameter]
- public string Width { get; set; } = "100%";
-
/// <summary>
/// Gets or sets if the stack wraps.
/// </summary>
@@ -109,7 +102,7 @@ public partial class StackPanel : StyledComponentBase
private string GetHorizontalAlignment()
{
- return HorizontalAlignment switch
+ return ContentHorizontalAlignment switch
{
StackHorizontalAlignment.Left => "start",
StackHorizontalAlignment.Center => "center",
@@ -120,7 +113,7 @@ public partial class StackPanel : StyledComponentBase
private string GetVerticalAlignment()
{
- return VerticalAlignment switch
+ return ContentVerticalAlignment switch
{
StackVerticalAlignment.Top => "start",
StackVerticalAlignment.Center => "center",
diff --git a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.scss b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.scss
index 570413836..ff30fa933 100644
--- a/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.scss
+++ b/src/app/dev/DevToys.Blazor/Components/Layout/StackPanel/StackPanel.razor.scss
@@ -4,6 +4,7 @@
flex-wrap: nowrap;
align-items: stretch;
justify-content: stretch;
+ width: 100%;
}
.stack-horizontal {
@@ -12,4 +13,5 @@
flex-wrap: nowrap;
align-items: center;
justify-content: normal;
+ width: 100%;
}
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
index f144fc001..4e17f48ba 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBar.razor
@@ -15,31 +15,34 @@
<!-- Header -->
<div class="header">
- <Button Appearance="ButtonAppearance.Stealth"
- Class="button-icon"
- Style="margin: 5px 0px 0px 5px;"
- IsEnabled="@CanGoBack"
- title="Back"
- aria-label="Back"
- @onclick="OnBackButtonClicked">
- <FontIcon Glyph="@('\uF15B')" />
- </Button>
- @if (_sidebarState.IsHidden)
- {
+ <StackPanel Orientation="Orientation.Horizontal"
+ HorizontalAlignment="HorizontalAlignment.Left">
<Button Appearance="ButtonAppearance.Stealth"
Class="button-icon"
- title="Toggle Navigation"
- aria-label="Toggle Navigation"
- aria-controls="@NavId"
- aria-expanded="@_sidebarState.IsCollapsed"
- @onclick="OnToggleSidebarClick">
- <FontIcon Glyph="@('\uF560')" />
+ Style="margin: 5px 0px 0px 5px;"
+ IsEnabled="@CanGoBack"
+ title="Back"
+ aria-label="Back"
+ @onclick="OnBackButtonClicked">
+ <FontIcon Glyph="@('\uF15B')" />
</Button>
- }
+ @if (_sidebarState.IsHidden)
+ {
+ <Button Appearance="ButtonAppearance.Stealth"
+ Class="button-icon"
+ title="Toggle Navigation"
+ aria-label="Toggle Navigation"
+ aria-controls="@NavId"
+ aria-expanded="@_sidebarState.IsCollapsed"
+ @onclick="OnToggleSidebarClick">
+ <FontIcon Glyph="@('\uF560')" />
+ </Button>
+ }
- <div style="margin-left: 4px; display: inline;">
- @Header
- </div>
+ <div style="margin-left: 4px; display: inline;">
+ @Header
+ </div>
+ </StackPanel>
</div>
<!-- Sidebar -->
@@ -128,7 +131,9 @@
<!-- Content of the nav bar -->
<main>
- @Content
+ <Container>
+ @Content
+ </Container>
</main>
<!-- A transparent clickable area that appears when the sidebar is expanded overlay. Clicking on it will close the sidebar. -->
diff --git a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
index ab344be16..3cdd62913 100644
--- a/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Menu/NavBar/NavBarItem.razor
@@ -32,6 +32,7 @@
<div @onclick:stopPropagation="true">
<Button Appearance="ButtonAppearance.Stealth"
Class="sidebar-expand-group-button"
+ HorizontalAlignment="HorizontalAlignment.Right"
aria-expanded="true"
data-expanded="@(IsExpanded.ToString().ToLowerInvariant())"
@onclick="OnToggleExpandClick">
diff --git a/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs b/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
index 6f6021e51..67a9a7512 100644
--- a/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
+++ b/src/app/dev/DevToys.Blazor/Components/StyledComponentBase.cs
@@ -43,6 +43,38 @@ public abstract class StyledComponentBase : ComponentBase
[Parameter]
public bool IsEnabled { get; set; } = true;
+ /// <summary>
+ /// Gets or sets how the component should horizontally align.
+ /// </summary>
+ [Parameter]
+ public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Stretch;
+
+ /// <summary>
+ /// Gets or sets how the component should vertically align.
+ /// </summary>
+ [Parameter]
+ public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Stretch;
+
+ /// <summary>
+ /// Gets or sets the width the component should have.
+ /// If null, the component will take as much space as it can.
+ /// </summary>
+ [Parameter]
+ public int? Width { get; set; }
+
+ /// <summary>
+ /// Gets or sets the height the component should have.
+ /// If null, the component will take as much space as it can.
+ /// </summary>
+ [Parameter]
+ public int? Height { get; set; }
+
+ /// <summary>
+ /// Gets or sets whether the component should be visible. Default is true.
+ /// </summary>
+ [Parameter]
+ public bool IsVisible { get; set; } = true;
+
/// <summary>
/// Gets a list of CSS class to apply to the component.
/// </summary>
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
index 58713e068..9618a7af5 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/AutoSuggestBox/AutoSuggestBox.razor
@@ -3,41 +3,47 @@
@typeparam TElement
<CascadingValue Value="this" IsFixed="true">
- <div id="@Id" style="@Style">
- <TextBox @ref="_textBox"
- Class="@(FinalCssClasses)"
- @attributes="AdditionalAttributes"
- Type="TextBoxTypes.Search"
- Header="@Header"
- Placeholder="@Placeholder"
- IsEnabled="@IsEnabled"
- IsReadOnly="@IsReadOnly"
- TextChanged="@OnTextBoxTextChangedAsync"
- @onkeydown="@OnTextBoxKeyPress"
- @onfocusout="@OnTextBoxFocusLost">
- <Buttons>
- <FontIcon Glyph="@('\uF68F')" Style="transform: unset; left: 0; height: 16px; margin-left: 4px; margin-right: 4px;" />
- </Buttons>
- </TextBox>
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id="@Id" style="@Style">
+ <TextBox @ref="_textBox"
+ Class="@(FinalCssClasses)"
+ @attributes="AdditionalAttributes"
+ Type="TextBoxTypes.Search"
+ Header="@Header"
+ Placeholder="@Placeholder"
+ IsEnabled="@IsEnabled"
+ IsReadOnly="@IsReadOnly"
+ TextChanged="@OnTextBoxTextChangedAsync"
+ @onkeydown="@OnTextBoxKeyPress"
+ @onfocusout="@OnTextBoxFocusLost">
+ <Buttons>
+ <FontIcon Glyph="@('\uF68F')" Style="transform: unset; left: 0; height: 16px; margin-left: 4px; margin-right: 4px;" />
+ </Buttons>
+ </TextBox>
- <Popover Open="_showDropDown"
- AnchorOrigin="Origin.BottomLeft"
- TransformOrigin="Origin.TopLeft"
- RelativeWidth="true"
- Class="auto-suggest-box-drop-down"
- @ontouchend:stopPropagation>
- <CascadingValue Value="@this" IsFixed="true">
- <ListBox @ref="_resultListBox"
- Items="@Items"
- Context="item"
- RaiseSelectionEventOnKeyboardNavigation="false"
- UseNativeScrollBar="true"
- SelectedIndexChanged="OnSelectedIndexChanged">
- <ItemTemplate>
- @ItemTemplate(item)
- </ItemTemplate>
- </ListBox>
- </CascadingValue>
- </Popover>
- </div>
+ <Popover Open="_showDropDown"
+ AnchorOrigin="Origin.BottomLeft"
+ TransformOrigin="Origin.TopLeft"
+ RelativeWidth="true"
+ Class="auto-suggest-box-drop-down"
+ @ontouchend:stopPropagation>
+ <CascadingValue Value="@this" IsFixed="true">
+ <ListBox @ref="_resultListBox"
+ Items="@Items"
+ Context="item"
+ RaiseSelectionEventOnKeyboardNavigation="false"
+ UseNativeScrollBar="true"
+ SelectedIndexChanged="OnSelectedIndexChanged">
+ <ItemTemplate>
+ @ItemTemplate(item)
+ </ItemTemplate>
+ </ListBox>
+ </CascadingValue>
+ </Popover>
+ </div>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
index 93109c4e7..3ab723c7b 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/MonacoEditor/MonacoEditor.razor
@@ -2,26 +2,32 @@
@inherits RicherMonacoEditorBase
<CascadingValue Value="this" IsFixed="true">
- <div id="@(Id)-monaco-container"
- class="monaco-editor-standalone-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id="@(Id)-monaco-container"
+ class="monaco-editor-standalone-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="monaco-editor-standalone-header" Text="@Header" />
- }
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="monaco-editor-standalone-header" Text="@Header" />
+ }
- <div class="monaco-editor-standalone-container @(IsEnabled ? string.Empty : "disabled")"
- @ref=Element>
+ <div class="monaco-editor-standalone-container @(IsEnabled ? string.Empty : "disabled")"
+ @ref=Element>
- <ProgressRing id="@($"{Id}-loading")"
- IsIndeterminate="@ShowLoading"
- Style="@((ShowLoading ? string.Empty : "display: none;"))"/>
+ <ProgressRing id="@($"{Id}-loading")"
+ IsIndeterminate="@ShowLoading"
+ IsVisible="@ShowLoading" />
- <div id="@Id" class="monaco-editor-standalone-instance"></div>
+ <div id="@Id" class="monaco-editor-standalone-instance"></div>
- <div class="monaco-editor-standalone-underline" />
+ <div class="monaco-editor-standalone-underline" />
+ </div>
</div>
- </div>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
index d27d24148..d9f7f107a 100644
--- a/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
+++ b/src/app/dev/DevToys.Blazor/Components/Text/TextBox/TextBox.razor
@@ -2,49 +2,56 @@
@inherits MefComponentBase
<CascadingValue Value="this" IsFixed="true">
- <div id=@Id
- class="text-box-with-header @(FinalCssClasses)"
- style="@(Style)"
- @attributes="AdditionalAttributes">
+ <Container HorizontalAlignment="@HorizontalAlignment"
+ VerticalAlignment="@VerticalAlignment"
+ Width="@Width"
+ Height="@Height"
+ IsVisible="@IsVisible">
+ <div id=@Id
+ class="text-box-with-header @(FinalCssClasses)"
+ style="@(Style)"
+ @attributes="AdditionalAttributes">
- @if (!string.IsNullOrWhiteSpace(Header))
- {
- <TextBlock Appearance="TextBlockAppearance.Body" Class="text-box-header" Text="@Header" />
- }
+ @if (!string.IsNullOrWhiteSpace(Header))
+ {
+ <TextBlock Appearance="TextBlockAppearance.Body" Class="text-box-header" Text="@Header" />
+ }
- <div class="text-box-container @(IsEnabled ? string.Empty : "disabled") @(_isContextMenuOpened ? "is-context-menu-opened" : string.Empty)"
- @ref=Element>
+ <div class="text-box-container @(IsEnabled ? string.Empty : "disabled") @(_isContextMenuOpened ? "is-context-menu-opened" : string.Empty)"
+ @ref=Element>
- <ContextMenu IsEnabled="IsEnabled"
- OnContextMenuOpening="OnContextMenuOpening"
- OnContextMenuOpened="OnContextMenuOpened"
- OnContextMenuClosed="OnContextMenuClosedAsync"
- Items="_contextMenuItems">
- <InputText @ref="_input"
- class="@($"text-box {(IsEnabled ? string.Empty : "disabled")})")"
- placeholder="@Placeholder"
- disabled="@(!IsEnabled)"
- readonly="@(IsReadOnly)"
- type="@(Type.ToString().ToLowerInvariant())"
- @bind-Value="@Text"
- @oninput="@InputTextChangedAsync" />
- </ContextMenu>
+ <ContextMenu IsEnabled="IsEnabled"
+ OnContextMenuOpening="OnContextMenuOpening"
+ OnContextMenuOpened="OnContextMenuOpened"
+ OnContextMenuClosed="OnContextMenuClosedAsync"
+ Items="_contextMenuItems">
+ <InputText @ref="_input"
+ class="@($"text-box {(IsEnabled ? string.Empty : "disabled")})")"
+ placeholder="@Placeholder"
+ disabled="@(!IsEnabled)"
+ readonly="@(IsReadOnly)"
+ type="@(Type.ToString().ToLowerInvariant())"
+ @bind-Value="@Text"
+ @oninput="@InputTextChangedAsync" />
+ </ContextMenu>
- <div class="text-box-underline" />
- <div class="text-box-buttons">
- @if (IsEnabled && !IsReadOnly && !string.IsNullOrEmpty(Text))
- {
- <Button Appearance="ButtonAppearance.Stealth"
- Class="text-box-clear-button"
- title="Clear"
- aria-label="Clear"
- @onclick="OnClearClick">
- <FontIcon Glyph="@('\uF369')" />
- </Button>
- }
+ <div class="text-box-underline" />
+ <div class="text-box-buttons">
+ @if (IsEnabled && !IsReadOnly && !string.IsNullOrEmpty(Text))
+ {
+ <Button Appearance="ButtonAppearance.Stealth"
+ Class="text-box-clear-button"
+ HorizontalAlignment="HorizontalAlignment.Right"
+ title="Clear"
+ aria-label="Clear"
+ @onclick="OnClearClick">
+ <FontIcon Glyph="@('\uF369')" />
+ </Button>
+ }
- @Buttons
+ @Buttons
+ </div>
</div>
</div>
- </div>
+ </Container>
</CascadingValue>
\ No newline at end of file
diff --git a/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs b/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs
new file mode 100644
index 000000000..a279687f4
--- /dev/null
+++ b/src/app/dev/DevToys.Blazor/Components/VerticalAlignment.cs
@@ -0,0 +1,9 @@
+namespace DevToys.Blazor.Components;
+
+public enum VerticalAlignment
+{
+ Stretch,
+ Top,
+ Bottom,
+ Center
+}
diff --git a/src/app/dev/DevToys.Blazor/Core/Helpers/StyleBuilder.cs b/src/app/dev/DevToys.Blazor/Core/Helpers/StyleBuilder.cs
index 5eaf0dbda..b54bb042c 100644
--- a/src/app/dev/DevToys.Blazor/Core/Helpers/StyleBuilder.cs
+++ b/src/app/dev/DevToys.Blazor/Core/Helpers/StyleBuilder.cs
@@ -129,13 +129,63 @@ public struct StyleBuilder
return AddStyle(prop, values.ToString(), when && values.HasValue);
}
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon.
+ /// </summary>
+ /// <param name="style"></param>
+ public StyleBuilder AddImportantStyle(string style) => !string.IsNullOrWhiteSpace(style) ? AddRaw($"{style} !important;") : this;
+
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon..
+ /// </summary>
+ /// <param name="prop"></param>
+ /// <param name="value">Style to add</param>
+ /// <returns>StyleBuilder</returns>
+ public StyleBuilder AddImportantStyle(string prop, string value) => AddRaw($"{prop}:{value} !important;");
+
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon..
+ /// </summary>
+ /// <param name="prop"></param>
+ /// <param name="value">Style to conditionally add.</param>
+ /// <param name="when">Condition in which the style is added.</param>
+ /// <returns>StyleBuilder</returns>
+ public StyleBuilder AddImportantStyle(string prop, string value, bool when = true) => when ? this.AddImportantStyle(prop, value) : this;
+
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon..
+ /// </summary>
+ /// <param name="prop"></param>
+ /// <param name="value">Style to conditionally add.</param>
+ /// <param name="when">Condition in which the style is added.</param>
+ /// <returns></returns>
+ public StyleBuilder AddImportantStyle(string prop, Func<string> value, bool when = true) => when ? this.AddImportantStyle(prop, value()) : this;
+
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon..
+ /// </summary>
+ /// <param name="prop"></param>
+ /// <param name="value">Style to conditionally add.</param>
+ /// <param name="when">Condition in which the style is added.</param>
+ /// <returns>StyleBuilder</returns>
+ public StyleBuilder AddImportantStyle(string prop, string value, Func<bool> when) => this.AddImportantStyle(prop, value, when());
+
+ /// <summary>
+ /// Adds a conditional in-line style to the builder with space separator and closing semicolon..
+ /// </summary>
+ /// <param name="prop"></param>
+ /// <param name="value">Style to conditionally add.</param>
+ /// <param name="when">Condition in which the style is added.</param>
+ /// <returns>StyleBuilder</returns>
+ public StyleBuilder AddImportantStyle(string prop, Func<string> value, Func<bool> when) => this.AddImportantStyle(prop, value(), when());
+
/// <summary>
/// Adds a conditional in-line style when it exists in a dictionary to the builder with separator.
/// Null safe operation.
/// </summary>
/// <param name="additionalAttributes">Additional Attribute splat parameters</param>
/// <returns>StyleBuilder</returns>
- public StyleBuilder AddStyleFromAttributes(IReadOnlyDictionary<string, object> additionalAttributes) =>
+ public StyleBuilder AddStyleFromAttributes(IDictionary<string, object> additionalAttributes) =>
additionalAttributes == null ? this :
additionalAttributes.TryGetValue("style", out object? c) ? AddRaw(c.ToString() ?? string.Empty) : this;
diff --git a/src/app/dev/DevToys.Blazor/Pages/Index.razor b/src/app/dev/DevToys.Blazor/Pages/Index.razor
index 64346c834..61d3187ee 100644
--- a/src/app/dev/DevToys.Blazor/Pages/Index.razor
+++ b/src/app/dev/DevToys.Blazor/Pages/Index.razor
@@ -89,78 +89,79 @@
{
<div class="entranceThemeTransition" style="display: contents">
<ScrollViewer>
- <StackPanel Orientation="Orientation.Vertical">
- <TextBlock Appearance="TextBlockAppearance.TitleLarge" Text="@guiToolViewItem.ToolInstance.LongOrShortDisplayTitle" />
- <!-- TODO: Place here a component that takes in argument the guiToolViewItem -->
+ <StackPanel Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Stretch">
+ <TextBlock Appearance="TextBlockAppearance.TitleLarge" Text="@guiToolViewItem.ToolInstance.LongOrShortDisplayTitle" />
+ <!-- TODO: Place here a component that takes in argument the guiToolViewItem -->
- <MonacoEditor />
- <Button IsEnabled="true" @onclick="OnSetFavorite">Set favorite</Button>
- <Button IsEnabled="false">Set favorite</Button>
- <Button IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
- <Button IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
- <Button IsEnabled="true" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
- <Button IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
- <ProgressRing IsIndeterminate="true" />
- <ProgressRing Value="75" Size="32" />
- <TextBox Header="First name" Placeholder="Normal" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <TextBox Header="Middle name" Placeholder="Read only" IsReadOnly="true" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <TextBox Header="Last name" Placeholder="Disabled" IsEnabled="false" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
- <ProgressBar IsIndeterminate="true" Style="margin: 8px; max-width: 150px;" />
- <ProgressBar Value="75" Style="margin: 8px; max-width: 150px;" />
- <CheckBox IsChecked="true" Text="An option" />
- <CheckBox IsChecked="true" IsEnabled="false" Text="An option" />
- <CheckBox IsChecked="false" IsEnabled="false" Text="An option" />
- <DropDownList Header="Drop down list header"
- Items="@(new List<DropDownListItem>
+ <MonacoEditor />
+ <Button VerticalAlignment="VerticalAlignment.Center" IsEnabled="true" @onclick="OnSetFavorite">Set favorite</Button>
+ <Button HorizontalAlignment="HorizontalAlignment.Left" IsEnabled="false">Set favorite</Button>
+ <Button HorizontalAlignment="HorizontalAlignment.Center" IsEnabled="true" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button HorizontalAlignment="HorizontalAlignment.Right" Height="100" Width="200" IsEnabled="false" Appearance="ButtonAppearance.Accent">Set favorite</Button>
+ <Button IsEnabled="true" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
+ <Button VerticalAlignment="VerticalAlignment.Bottom" IsEnabled="false" Appearance="ButtonAppearance.Stealth">Set favorite</Button>
+ <ProgressRing IsIndeterminate="true" />
+ <ProgressRing Value="75" Size="32" />
+ <TextBox Header="First name" Placeholder="Normal" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <TextBox Header="Middle name" Placeholder="Read only" IsReadOnly="true" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <TextBox Header="Last name" Placeholder="Disabled" IsEnabled="false" Style="margin-top: 12px; margin-left: 8px; margin-right: 8px;" />
+ <ProgressBar IsIndeterminate="true" Width="150" HorizontalAlignment="HorizontalAlignment.Left" />
+ <ProgressBar Value="75" />
+ <CheckBox IsChecked="true" Text="An option" />
+ <CheckBox IsChecked="true" IsEnabled="false" Text="An option" />
+ <CheckBox IsChecked="false" IsEnabled="false" Text="An option" />
+ <DropDownList Header="Drop down list header"
+ Items="@(new List<DropDownListItem>
+ {
+ new DropDownListItem { Text = "Item 1", IconGlyph = '\uE670' },
+ new DropDownListItem { Text = "Item 2" },
+ new DropDownListItem { Text = "Item 3" },
+ new DropDownListItem { Text = "Item 4" },
+ new DropDownListItem { Text = "Item 5" },
+ new DropDownListItem { Text = "Item 6" },
+ new DropDownListItem { Text = "Item 7" },
+ new DropDownListItem { Text = "Item 8" },
+ new DropDownListItem { Text = "Item 9" },
+ new DropDownListItem { Text = "Item 10" },
+ new DropDownListItem { Text = "Item 11" },
+ new DropDownListItem { Text = "Item 12" },
+ new DropDownListItem { Text = "Item 13" },
+ new DropDownListItem { Text = "Item 14" },
+ new DropDownListItem { Text = "Item 15 - longer text" }
+ })">
+ <TextBlock Appearance="TextBlockAppearance.Body" Text="Click me!" />
+ </DropDownList>
+ <ToggleSwitch IsOn="true" Text="An option" />
+ <ToggleSwitch IsOn="true" IsEnabled="false" Text="An option" />
+ <ToggleSwitch IsOn="false" IsEnabled="false" Text="An option" />
+ <RadioButton Text="Option 1" Group="Group1"/>
+ <RadioButton Text="Option 2" Group="Group1"/>
+ <RadioButton Text="Option 3" Group="Group1"/>
+ <RadioButton Text="Option 4" Group="Group1" IsEnabled="false"/>
+ <ComboBox Items="@(new List<string>
{
- new DropDownListItem { Text = "Item 1", IconGlyph = '\uE670' },
- new DropDownListItem { Text = "Item 2" },
- new DropDownListItem { Text = "Item 3" },
- new DropDownListItem { Text = "Item 4" },
- new DropDownListItem { Text = "Item 5" },
- new DropDownListItem { Text = "Item 6" },
- new DropDownListItem { Text = "Item 7" },
- new DropDownListItem { Text = "Item 8" },
- new DropDownListItem { Text = "Item 9" },
- new DropDownListItem { Text = "Item 10" },
- new DropDownListItem { Text = "Item 11" },
- new DropDownListItem { Text = "Item 12" },
- new DropDownListItem { Text = "Item 13" },
- new DropDownListItem { Text = "Item 14" },
- new DropDownListItem { Text = "Item 15 - longer text" }
- })">
- <TextBlock Appearance="TextBlockAppearance.Body" Text="Click me!" />
- </DropDownList>
- <ToggleSwitch IsOn="true" Text="An option" />
- <ToggleSwitch IsOn="true" IsEnabled="false" Text="An option" />
- <ToggleSwitch IsOn="false" IsEnabled="false" Text="An option" />
- <RadioButton Text="Option 1" Group="Group1"/>
- <RadioButton Text="Option 2" Group="Group1"/>
- <RadioButton Text="Option 3" Group="Group1"/>
- <RadioButton Text="Option 4" Group="Group1" IsEnabled="false"/>
- <ComboBox Items="@(new List<string>
- {
- "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
- "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
- })"
- Context="item"
- @bind-SelectedIndex="@ComboBoxSelectedItem"
- Header="ComboBox header">
- <ItemTemplate>
- @item
- </ItemTemplate>
- </ComboBox>
- <ListBox Items="@(new List<string>
- {
- "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
- "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
- })"
- Context="item"
- SelectedIndex="1">
- <ItemTemplate>
- @item
- </ItemTemplate>
- </ListBox>
+ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
+ "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
+ })"
+ Context="item"
+ @bind-SelectedIndex="@ComboBoxSelectedItem"
+ Header="ComboBox header"
+ HorizontalAlignment="HorizontalAlignment.Left">
+ <ItemTemplate>
+ @item
+ </ItemTemplate>
+ </ComboBox>
+ <ListBox Items="@(new List<string>
+ {
+ "Item 1", "Item 2", "Item 3", "Item 4", "Item 5", "Item 6", "Item 7", "Item 8", "Item 9", "Item 10",
+ "Item 11", "Item 12", "Item 13", "Item 14", "Item 15", "Item 16 - longer text"
+ })"
+ Context="item"
+ SelectedIndex="1">
+ <ItemTemplate>
+ @item
+ </ItemTemplate>
+ </ListBox>
</StackPanel>
</ScrollViewer>
</div>
diff --git a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
index 3375d05db..ed224f688 100644
--- a/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
+++ b/src/app/dev/DevToys.Blazor/Pages/SubPages/ToolGroup.razor
@@ -25,7 +25,8 @@
<TextBlock Appearance="@TextBlockAppearance.Caption" Text="@item.Description" />
</div>
<div class="buttons" @onclick:stopPropagation="true">
- <Button Class="button"
+ <Button HorizontalAlignment="HorizontalAlignment.Right"
+ Class="button"
Appearance="@ButtonAppearance.Neutral"
@onclick="() => OnOpenInNewWindow(item)">
<FontIcon Class="fonticon" Glyph="@('\uEE7A')" />
diff --git a/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/StyleBuilderTests.cs b/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/StyleBuilderTests.cs
index 8e81cde45..d39292eba 100644
--- a/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/StyleBuilderTests.cs
+++ b/src/app/tests/DevToys.UnitTests/Blazor/Core/Helpers/StyleBuilderTests.cs
@@ -46,7 +46,7 @@ public class StyleBuilderTests
.AddStyle("padding", "35px")
.Build();
- IReadOnlyDictionary<string, object> attributes = new Dictionary<string, object> { { "style", StyleToRender } };
+ IDictionary<string, object> attributes = new Dictionary<string, object> { { "style", StyleToRender } };
string ClassToRender = new StyleBuilder().AddStyleFromAttributes(attributes).Build();
//assert