Skip to content

Commit

Permalink
Re-work padding/height for dialog variants (#786)
Browse files Browse the repository at this point in the history
* Re-work padding/heigt for dialog variants

* Resolve review comments
  • Loading branch information
vnbaaij authored Sep 25, 2023
1 parent 57b8b52 commit 78e4101
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 140 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@
</div>
<div>
<FluentDialog @ref="_myFluentDialog" @bind-Hidden="@Hidden" aria-label="Simple dialog" Modal=@_modal TrapFocus=@_trapFocus PreventScroll=@_preventScroll @ondialogdismiss=OnDismiss>
<FluentDialogHeader Visible="false" />
<h2>Just a simple dialog</h2>
<p>The 'Close dialog' button is automatically focused.</p>
<p>The 'Another button' doesn't do anything other than showing it can receive focus.</p>
<p>The width, height and padding of the dialog are customized in (isolated) CSS</p>
<FluentButton Appearance="Appearance.Accent" Autofocus="true" @onclick="OnClose">Close dialog</FluentButton>
<FluentButton>Another button</FluentButton>

</FluentDialog>
</div>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
::deep > fluent-dialog::part(control) {
--dialog-width: 300px;
--dialog-height: 350px;
padding: 2rem;
padding: 2rem!important;
}
Original file line number Diff line number Diff line change
@@ -1,25 +1,8 @@
@implements IDialogContentComponent<SimplePerson>

@* Header *@
<FluentDialogHeader ShowDismiss="true">
<FluentStack VerticalAlignment="VerticalAlignment.Center">
<FluentIcon Value="@(new Icons.Regular.Size24.WindowApps())" />
<FluentLabel Typo="Typography.PaneHeader">
@Dialog.Instance.Parameters.Title
</FluentLabel>
</FluentStack>
</FluentDialogHeader>

@* Footer *@
<FluentDialogFooter>
<FluentButton Appearance="Appearance.Accent" OnClick="@SaveAsync">Close</FluentButton>
</FluentDialogFooter>

@* Body *@
<FluentDialogBody>
<FluentTextField @bind-Value="@Content.Firstname">FirstName:</FluentTextField>
<FluentNumberField @bind-Value="@Content.Age">Age:</FluentNumberField>
</FluentDialogBody>
<FluentDialogHeader Visible="false" />
<FluentDialogFooter Visible="false" />
<FluentDialogBody>hello</FluentDialogBody>

@code {
[Parameter]
Expand Down
70 changes: 0 additions & 70 deletions examples/Demo/Shared/Pages/Lab/IssueTester.razor
Original file line number Diff line number Diff line change
@@ -1,71 +1 @@
@page "/IssueTester"
@using Microsoft.Fast.Components.FluentUI
@inject DataSource Data
@inject HttpClient Http
@inject NavigationManager NavManager

<label for="people-listbox">Select a person</label>
<FluentSelect TOption="Person"
Items="@Data.People.WithVeryLongName()"
Id="people-listbox"
Width="200px"
Height="250px"
OptionValue="@(p => p.PersonId.ToString())"
OptionText="@(p => p.LastName + ", " + p.FirstName)"
@bind-Value="@SelectedValue"
@bind-SelectedOption="@SelectedPerson" />


<div style="height: 434px; overflow:auto;" tabindex="-1">
<FluentDataGrid ItemsProvider="foodRecallProvider" Virtualize="true" ItemSize="46" GenerateHeader="GenerateHeaderOption.Sticky" TGridItem="FoodRecall">
<PropertyColumn Title="ID" Property="@(c => c!.Event_Id)" />
<PropertyColumn Property="@(c => c!.State)" />
<PropertyColumn Property="@(c => c!.City)" />
<PropertyColumn Title="Company" Property="@(c => c!.Recalling_Firm)" />
<PropertyColumn Property="@(c => c!.Status)" />
<TemplateColumn Title="Actions" Align="@Align.End">
<FluentButton IconEnd="@(new Icons.Regular.Size16.Edit())" OnClick="@(() => DemoLogger.WriteLine("Edit clicked"))" />
<FluentButton IconEnd="@(new Icons.Regular.Size16.Delete())" OnClick="@(() => DemoLogger.WriteLine("Delete clicked"))" />
</TemplateColumn>
</FluentDataGrid>
</div>

<p>Total: <strong>@numResults results found</strong></p>
<p>
Selected value: @SelectedValue <br />
Selected person (strongly typed): @SelectedPerson?.ToString()
</p>

@code {
GridItemsProvider<FoodRecall> foodRecallProvider = default!;
int numResults;
Person? SelectedPerson;
string? SelectedValue = "4";


protected override async Task OnInitializedAsync()
{
// Define the GridRowsDataProvider. Its job is to convert QuickGrid's GridRowsDataProviderRequest into a query against
// an arbitrary data soure. In this example, we need to translate query parameters into the particular URL format
// supported by the external JSON API. It's only possible to perform whatever sorting/filtering/etc is supported
// by the external API.
foodRecallProvider = async req =>
{
var url = NavManager.GetUriWithQueryParameters("https://api.fda.gov/food/enforcement.json", new Dictionary<string, object?>
{
{ "skip", req.StartIndex },
{ "limit", req.Count },
});

var response = await Http.GetFromJsonAsync<FoodRecallQueryResult>(url, req.CancellationToken);
return GridItemsProviderResult.From(
items: response!.Results,
totalItemCount: response!.Meta.Results.Total);
};

// Display the number of results just for information. This is completely separate from the grid.
numResults = (await Http.GetFromJsonAsync<FoodRecallQueryResult>("https://api.fda.gov/food/enforcement.json"))!.Meta.Results.Total;
}


}
12 changes: 7 additions & 5 deletions examples/Demo/Shared/Pages/Panel/Examples/SimplePanel.razor
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@implements IDialogContentComponent<SimplePerson>

<h3>Hello @Content.Firstname </h3>
<p>Your lastname is @Content.Lastname and you are @Content.Age years young </p>
<FluentDialogBody>
<h3>Hello @Content.Firstname </h3>
<p>Your lastname is @Content.Lastname and you are @Content.Age years young </p>

<FluentTextField @bind-Value="@Content.Firstname">Your firstname:</FluentTextField>
<FluentTextField @bind-Value="@Content.Lastname">Your lastname:</FluentTextField>
<FluentNumberField @bind-Value="@Content.Age">Your age:</FluentNumberField>
<FluentTextField @bind-Value="@Content.Firstname">Your firstname:</FluentTextField>
<FluentTextField @bind-Value="@Content.Lastname">Your lastname:</FluentTextField>
<FluentNumberField @bind-Value="@Content.Age">Your age:</FluentNumberField>
</FluentDialogBody>

@code {
[Parameter]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
@using Microsoft.Fast.Components.FluentUI
@implements IDialogContentComponent<SplashScreenContent>

<FluentStack Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Center" Class="my-splash">
<img class="icon" src="@Content.Logo" />
<p>@Content.Message</p>
<h3>
@Content.Title
</h3>
<h3>
@Content.SubTitle
</h3>
<div style="width: 340px;">
<FluentProgress/>
</div>

<h3>
@Content.LoadingText
</h3>
</FluentStack>

@code{

<FluentDialogHeader Visible="false" />
<FluentDialogBody>
<FluentStack Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Center" Class="my-splash">
<img class="icon" src="@Content.Logo" />
<p>@Content.Message</p>
<h3>
@Content.Title
</h3>
<h3>
@Content.SubTitle
</h3>
<div style="width: 340px;">
<FluentProgress />
</div>

<h3>
@Content.LoadingText
</h3>
</FluentStack>
</FluentDialogBody>
<FluentDialogFooter Visible="false" />

@code {


[Parameter]
public SplashScreenContent Content { get; set; } = default!;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
@namespace Microsoft.Fast.Components.FluentUI
@implements IDialogContentComponent<SplashScreenContent>

<FluentStack Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Center" Class="fluent-launch">
<h1>
@Content.Title
</h1>
<h2>
@Content.SubTitle
</h2>
<FluentProgressRing />
<h3>
@Content.LoadingText
</h3>
<p>@Content.Message</p>
<div class="icon">
@(new MarkupString(Content.Logo!))
</div>
</FluentStack>
<FluentDialogHeader Visible="false" />
<FluentDialogBody>
<FluentStack Orientation="Orientation.Vertical" HorizontalAlignment="HorizontalAlignment.Center" Class="fluent-launch">
<h1>
@Content.Title
</h1>
<h2>
@Content.SubTitle
</h2>
<FluentProgressRing />
<h3>
@Content.LoadingText
</h3>
<p>@Content.Message</p>
<div class="icon">
@(new MarkupString(Content.Logo!))
</div>
</FluentStack>
</FluentDialogBody>
<FluentDialogFooter Visible="false" />

Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
.fluent-messagebox {
font-family: var(--body-font);
-webkit-font-smoothing: antialiased;
background-color: var( --neutral-layer-floating);
color: var( --neutral-foreground-rest);
word-break: break-word;
min-height: 80px;
padding-bottom: calc(16px + (var(--base-height-multiplier) + var(--density)) * var(--design-unit) * 1px);
}

.fluent-messagebox ::deep .icon {
Expand Down
18 changes: 12 additions & 6 deletions src/Core/Components/Dialog/FluentDialog.razor.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
fluent-dialog::part(control) {
--dialog-padding: 8px;
--dialog-padding: calc(var(--design-unit) * 6 * 1px);
position: relative;
padding: 0px var(--dialog-padding);
width: calc(var(--dialog-width) - 2 * var(--dialog-padding));
height: calc(var(--dialog-height) - 2 * var(--dialog-padding));
max-width: 90%;
max-height: 90%;
max-width: 80%;
}

fluent-dialog:has(div[class~="fluent-dialog-body"])::part(control) {
height: auto;
display: grid;
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
Expand All @@ -25,6 +25,7 @@ fluent-dialog[class~="right"]::part(control) {
border-width: 0;
max-height: 100%;
--dialog-height: 100%;
height: 100% !important;
}

fluent-dialog[class~="left"]::part(control) {
Expand All @@ -34,6 +35,7 @@ fluent-dialog[class~="left"]::part(control) {
border-width: 0;
max-height: 100%;
--dialog-height: 100%;
height: 100% !important;
}

fluent-dialog ::deep .fluent-dialog-header {
Expand All @@ -47,8 +49,7 @@ fluent-dialog ::deep .fluent-dialog-footer {
margin-top: auto;
padding: var(--dialog-padding) 0px;
bottom: 0px;
right: var(--dialog-padding);
position: absolute;
width: calc(100% - var(--dialog-padding) * 1px);
}

fluent-dialog:has(div[class~="fluent-dialog-body"]) ::deep .fluent-dialog-footer {
Expand All @@ -61,6 +62,11 @@ fluent-dialog:has(div[class~="fluent-dialog-body"]) ::deep .fluent-dialog-footer
fluent-dialog ::deep .fluent-dialog-body {
grid-area: dialog-body;
width: 100%;
height: auto;
min-height: 80px;
}

fluent-dialog:has(:not(div[class~="fluent-dialog-header"]))
{
padding: var(--dialog-padding) 0px 0px 0px;
height: calc(100% - var(--dialog-padding) - ((var(--base-height-multiplier) + var(--density)) * var(--design-unit) * 1px));
}

0 comments on commit 78e4101

Please sign in to comment.