-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FluentCard: Add AreaRestricted parameter (#830)
* FluentCard: Add AreaRestricted parameter, update docs, tests and examples
- Loading branch information
Showing
10 changed files
with
188 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
examples/Demo/Shared/Pages/Card/Examples/CardAreaRestricted.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
@inject DataSource Data | ||
|
||
<FluentStack> | ||
<FluentCard Style="width: 300px;"> | ||
<p>This card's content is restricted to it's area. Open the select list below to see the result</p> | ||
<label for="people-listbox">Select a person</label> | ||
<FluentSelect TOption="Person" | ||
Items="@Data.People.WithVeryLongName()" | ||
Id="people-listbox" | ||
Width="200px" | ||
OptionValue="@(p => p.PersonId.ToString())" | ||
OptionText="@(p => p.LastName + ", " + p.FirstName)" | ||
@bind-Value="@SelectedValueART" | ||
@bind-SelectedOption="@SelectedPersonART" /> | ||
|
||
</FluentCard> | ||
<FluentCard Style="width: 300px;" AreaRestricted="false"> | ||
<p>This card's content is not restricted to it's area. Open the select list below to see the result</p> | ||
<label for="people-listbox">Select a person</label> | ||
<FluentSelect TOption="Person" | ||
Items="@Data.People.WithVeryLongName()" | ||
Id="people-listbox" | ||
Width="200px" | ||
OptionValue="@(p => p.PersonId.ToString())" | ||
OptionText="@(p => p.LastName + ", " + p.FirstName)" | ||
@bind-Value="@SelectedValueARF" | ||
@bind-SelectedOption="@SelectedPersonARF" /> | ||
|
||
</FluentCard> | ||
</FluentStack> | ||
@code | ||
{ | ||
Person? SelectedPersonART, SelectedPersonARF; | ||
string? SelectedValueART, SelectedValueARF; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1 @@ | ||
<div> | ||
<FluentCard class="state-override">Custom size using CSS</FluentCard> | ||
|
||
<BaseLayerLuminance Value="(float?)0.15"> | ||
<FluentCard ParentReference="@context"> | ||
<div class="contents"> | ||
<p>Dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</BaseLayerLuminance> | ||
|
||
<FluentDesignSystemProvider FillColor="#D6D6D6"> | ||
<FluentCard neutral-palette-source="#CABA8C"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark container</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> | ||
|
||
<BaseLayerLuminance Value="(float?)0.15"> | ||
<FluentCard neutral-palette-source="#CABA8C" ParentReference="@context"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</BaseLayerLuminance> | ||
|
||
<FluentDesignSystemProvider BaseLayerLuminance="(float?)0.15"> | ||
<FluentCard neutral-palette-source="#CABA8C"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
<FluentCard neutral-palette-source="#718E71" style="margin: 0; --card-height: 200px; --card-width: 460px;" > | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, nested, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> | ||
|
||
<FluentCard card-fill-color="#449544"> | ||
<div class="contents"> | ||
<p>Custom card-fill-color</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
<p> | ||
Note the stealth buttons have a slight fill, which is because the card-fill-color is explicit, but the stealth | ||
recipe gets its value from the neutral palette which has been created based on the card-fill-color, but does not | ||
contain that exact color. | ||
</p> | ||
</div> | ||
</FluentCard> | ||
|
||
<FluentDesignSystemProvider FillColor="#D6D6D6" AccentBaseColor="#718E71" NeutralBaseColor="#A90000"> | ||
<FluentCard> | ||
<div class="contents"> | ||
<p>Accent and neutral color by DSP</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Neutral">Neutral</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> | ||
</div> | ||
<FluentCard Class="my-custom-styling">Custom size (400x400) using CSS</FluentCard> |
4 changes: 4 additions & 0 deletions
4
examples/Demo/Shared/Pages/Card/Examples/CardDefault.razor.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
my-custom-styling { | ||
width: 400px; | ||
height: 400px; | ||
} |
84 changes: 84 additions & 0 deletions
84
examples/Demo/Shared/Pages/Card/Examples/CardStyling.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<BaseLayerLuminance Value="(float?)0.15"> | ||
<FluentCard ParentReference="@context"> | ||
<div class="contents"> | ||
<p>Dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</BaseLayerLuminance> | ||
|
||
<FluentDesignSystemProvider FillColor="#D6D6D6"> | ||
<FluentCard neutral-palette-source="#CABA8C"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark container</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> | ||
|
||
<BaseLayerLuminance Value="(float?)0.15"> | ||
<FluentCard neutral-palette-source="#CABA8C" ParentReference="@context"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</BaseLayerLuminance> | ||
|
||
<FluentDesignSystemProvider BaseLayerLuminance="(float?)0.15"> | ||
<FluentCard neutral-palette-source="#CABA8C"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
<FluentCard neutral-palette-source="#718E71" style="margin: 0; --card-height: 200px; --card-width: 460px;"> | ||
<div class="contents"> | ||
<p>Tinted neutral-palette-source, nested, dark</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> | ||
|
||
<FluentCard card-fill-color="#449544"> | ||
<div class="contents"> | ||
<p>Custom card-fill-color</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
<p> | ||
Note the stealth buttons have a slight fill, which is because the card-fill-color is explicit, but the stealth | ||
recipe gets its value from the neutral palette which has been created based on the card-fill-color, but does not | ||
contain that exact color. | ||
</p> | ||
</div> | ||
</FluentCard> | ||
|
||
<FluentDesignSystemProvider FillColor="#D6D6D6" AccentBaseColor="#718E71" NeutralBaseColor="#A90000"> | ||
<FluentCard> | ||
<div class="contents"> | ||
<p>Accent and neutral color by FluentDesignSystemProvider</p> | ||
<FluentButton Appearance="Appearance.Accent">Accent</FluentButton> | ||
<FluentButton Appearance="Appearance.Neutral">Neutral</FluentButton> | ||
<FluentButton Appearance="Appearance.Stealth">Stealth</FluentButton> | ||
<FluentButton Appearance="Appearance.Outline">Outline</FluentButton> | ||
<FluentButton Appearance="Appearance.Lightweight">Lightweight</FluentButton> | ||
</div> | ||
</FluentCard> | ||
</FluentDesignSystemProvider> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,25 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.Fast.Components.FluentUI.Utilities; | ||
|
||
namespace Microsoft.Fast.Components.FluentUI; | ||
|
||
public partial class FluentCard | ||
{ | ||
protected string? StyleValue => new StyleBuilder(Style) | ||
.AddStyle("content-visibility", "visible", !AreaRestricted) | ||
.AddStyle("contain", "style", !AreaRestricted) | ||
.Build(); | ||
|
||
/// <summary> | ||
/// By default, content in the card is restricted to the area of the card itself. | ||
/// If you want content to be able to overflow the card, set this property to false. | ||
/// </summary> | ||
[Parameter] | ||
public bool AreaRestricted { get; set; } = true; | ||
|
||
/// <summary> | ||
/// Gets or sets the content to be rendered inside the component. | ||
/// </summary> | ||
[Parameter] | ||
public RenderFragment? ChildContent { get; set; } | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
tests/Core/Card/FluentCardTests.FluentCard_NotAreaRestricted.verified.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<fluent-card style="content-visibility: visible; contain: style;" blazor:elementreference="xxx">childcontent</fluent-card> |
2 changes: 2 additions & 0 deletions
2
tests/Core/Card/FluentCardTests.FluentCard_NotAreaRestricted_AdditionalStyle.verified.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
|
||
<fluent-card style="content-visibility: visible; contain: style; background-color: red;" blazor:elementreference="xxx">childcontent</fluent-card> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters