Skip to content

Commit

Permalink
[FluentGrid] Fix the Grid "external margins" (#1646)
Browse files Browse the repository at this point in the history
* Fix the Grid margin

* Update Gap to Spacing
  • Loading branch information
dvoituron authored Mar 6, 2024
1 parent b17ae90 commit a99bd38
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 28 deletions.
23 changes: 14 additions & 9 deletions examples/Demo/Shared/Pages/Grid/Examples/GridDefault.razor
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
<FluentSelect Items=@(Enum.GetValues<JustifyContent>())
OptionValue="@(c => c.ToAttributeValue())"
TOption="JustifyContent"
Position="SelectPosition.Below"
@bind-SelectedOption="@Justification" />
<br />
<br />
<FluentStack Style="margin-bottom: 24px;" VerticalAlignment="VerticalAlignment.Center">
<FluentLabel>Justify</FluentLabel>
<FluentSelect Items=@(Enum.GetValues<JustifyContent>())
OptionValue="@(c => c.ToAttributeValue())"
TOption="JustifyContent"
Position="SelectPosition.Below"
@bind-SelectedOption="@Justification" />

<FluentGrid Spacing="3" OnBreakpointEnter="@OnBreakpointEnterHandler" Justify="@Justification" Style="background-color: var(--neutral-layer-3);">
<FluentLabel>Spacing</FluentLabel>
<FluentSlider @bind-Value="@Spacing" Min="0" Max="10" Step="1" Style="max-width: 300px; margin-top: 18px;" />
</FluentStack>

<FluentGrid Spacing="@Spacing" OnBreakpointEnter="@OnBreakpointEnterHandler" Justify="@Justification" Style="background-color: var(--neutral-layer-3); padding: 4px; ">
<FluentGridItem xs="12">
<div class="card">
xs="12"
Expand Down Expand Up @@ -52,10 +56,11 @@
@code
{
JustifyContent Justification = JustifyContent.FlexStart;
int Spacing = 3;

void OnBreakpointEnterHandler(GridItemSize size)
{
Console.WriteLine($"Page Size: {size}");
DemoLogger.WriteLine($"Page Size: {size}");
}
}
}
6 changes: 3 additions & 3 deletions examples/Demo/Shared/Pages/Grid/Examples/GridMessage.razor
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<FluentGrid Justify="JustifyContent.FlexEnd"
Style="background-color: var(--neutral-layer-3); overflow: auto; resize: horizontal;">
<FluentGrid Justify="JustifyContent.FlexEnd"
Style="background-color: var(--neutral-layer-3); overflow: hidden; resize: horizontal; padding: 4px;">
<FluentGridItem Style="min-width: 200px;">
<FluentLabel>
Views must be setup in the Admin Portal to use this client application hosted by my company.
Expand All @@ -9,4 +9,4 @@
<FluentButton Appearance="Appearance.Neutral">Setup</FluentButton>
<FluentButton Appearance="Appearance.Neutral">Documentation</FluentButton>
</FluentGridItem>
</FluentGrid>
</FluentGrid>
8 changes: 5 additions & 3 deletions src/Core/Components/Grid/FluentGrid.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
@namespace Microsoft.FluentUI.AspNetCore.Components
@inherits FluentComponentBase

<div id="@GetId()" class="@ClassValue" style="@StyleValue" spacing="@Spacing" @attributes="AdditionalAttributes">
@ChildContent
</div>
<div class="@ClassValue" style="@StyleValue" @attributes="AdditionalAttributes">
<div id="@GetId()" class="fluent-grid" style="@($"justify-content: {Justify.ToAttributeValue()};")" spacing="@Spacing">
@ChildContent
</div>
</div>
2 changes: 0 additions & 2 deletions src/Core/Components/Grid/FluentGrid.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,10 @@ public FluentGrid()

/// <summary />
protected string? ClassValue => new CssBuilder(Class)
.AddClass($"fluent-grid")
.Build();

/// <summary />
protected string? StyleValue => new StyleBuilder(Style)
.AddStyle("justify-content", Justify.ToAttributeValue())
.Build();

protected async override Task OnAfterRenderAsync(bool firstRender)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

<div class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-ljlkesaj3r="">My content</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-9fxwfzgab8="">My content</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

<div class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-ljlkesaj3r="">
<div xs="1" sm="2" md="3" lg="4" xl="5" xxl="6">My cell</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-9fxwfzgab8="">
<div xs="1" sm="2" md="3" lg="4" xl="5" xxl="6">My cell</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

<div class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-ljlkesaj3r="">
<div xs="6" md="6">Cell 1</div>
<div xs="6" md="6">Cell 2</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-9fxwfzgab8="">
<div xs="6" md="6">Cell 1</div>
<div xs="6" md="6">Cell 2</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

<div class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-ljlkesaj3r="">
<div style="justify-content: center; display: flex; gap: 10px;" xs="1">My cell</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-9fxwfzgab8="">
<div style="justify-content: center; display: flex; gap: 10px;" xs="1">My cell</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

<div class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-ljlkesaj3r="">
<div style="min-width: 200px;" xs="0">My cell</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: flex-start;" spacing="3" b-9fxwfzgab8="">
<div style="min-width: 200px;" xs="0">My cell</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@

<div class="fluent-grid" style="justify-content: center;" spacing="5" b-ljlkesaj3r="">My content</div>
<div b-9fxwfzgab8="">
<div id="xxx" class="fluent-grid" style="justify-content: center;" spacing="5" b-9fxwfzgab8="">My content</div>
</div>

0 comments on commit a99bd38

Please sign in to comment.