-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Initial badge entry * Manage badge exit with icon button toggle's ShouldRender() => false; * Update Badge website page and docs * Release Notes update
- Loading branch information
1 parent
6e4436c
commit 0c2c055
Showing
22 changed files
with
409 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
@page "/badge" | ||
|
||
@inject IMBToastService ToastService | ||
|
||
|
||
|
||
<DemonstrationPage ComponentName="Badge" | ||
DemoComponent="@this" | ||
Title="Badge Demonstration"> | ||
<Description> | ||
<p> | ||
Shows badges set in html elements and embedded in buttons, icon buttons and icon toggle buttons. | ||
</p> | ||
</Description> | ||
|
||
<Controls> | ||
<p><MBSwitch @bind-Value="@Exited" Label="Applies the 'mb-badge--exited' class" /></p> | ||
</Controls> | ||
|
||
<PageContent> | ||
<div class="mdc-layout-grid__cell--span-4"> | ||
<MBCard AutoStyled="true"> | ||
<Primary> | ||
<h2 class="mb-card__title mdc-typography mdc-typography--headline6"> | ||
Badges in HTML elements | ||
</h2> | ||
|
||
<p class="mdc-typography--body1"> | ||
A badge must be the first element inside its parent div. The parent div must have both border and padding set to zero width. | ||
</p> | ||
|
||
<div style="height: 60px; width: 200px; background: var(--mb-color-blue-200); margin-top: 12px;"> | ||
<MBBadge BadgeStyle="MBBadgeStyle.ValueBearing" Value="99+" Exited="@Exited" /> | ||
<p class="mdc-typography--body1" style="margin-left: 12px; line-height: 60px;">Value Bearing badge</p> | ||
</div> | ||
|
||
<div style="height: 60px; width: 200px; background: var(--mb-color-blue-200); margin-top: 12px;"> | ||
<MBBadge BadgeStyle="MBBadgeStyle.BlankFullSized" Exited="@Exited" /> | ||
<p class="mdc-typography--body1" style="margin-left: 12px; line-height: 60px;">Blank Full Size badge</p> | ||
</div> | ||
|
||
<div style="height: 60px; width: 200px; background: var(--mb-color-blue-200); margin-top: 12px;"> | ||
<MBBadge BadgeStyle="MBBadgeStyle.Dot" Exited="@Exited" /> | ||
<p class="mdc-typography--body1" style="margin-left: 12px; line-height: 60px;">Dot badge</p> | ||
</div> | ||
</Primary> | ||
</MBCard> | ||
</div> | ||
|
||
|
||
<div class="mdc-layout-grid__cell--span-4"> | ||
<MBCard AutoStyled="true"> | ||
<Primary> | ||
<h2 class="mb-card__title mdc-typography mdc-typography--headline6"> | ||
Button badges | ||
</h2> | ||
|
||
<p> | ||
<MBButton ButtonStyle="@MBButtonStyle.Outlined" | ||
Label="Outlined Button" | ||
HasBadge="true" | ||
BadgeValue="!" | ||
BadgeExited="@Exited" /> | ||
</p> | ||
|
||
<p> | ||
<MBIconButton Icon="fa-dog" | ||
IconFoundry="@MBIconHelper.FAFoundry()" | ||
HasBadge="true" | ||
BadgeValue="!" | ||
BadgeExited="@Exited" /> | ||
</p> | ||
|
||
<p> | ||
<MBIconButtonToggle IconOff="mood" | ||
IconOn="sentiment_dissatisfied" | ||
HasBadge="true" | ||
BadgeValue="!" | ||
BadgeExited="@Exited" /> | ||
</p> | ||
</Primary> | ||
</MBCard> | ||
</div> | ||
</PageContent> | ||
</DemonstrationPage> | ||
|
||
|
||
|
||
@code { | ||
private bool Exited { get; set; } = false; | ||
} |
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
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,22 @@ | ||
--- | ||
uid: C.MBBadge | ||
title: MBBadge | ||
--- | ||
# MBBadge | ||
|
||
## Summary | ||
|
||
A badge that can either be places manually within a `<div>` or added via properties to an MBButton, MBIconButton or MBIconButtonToggle. Has the following properties: | ||
|
||
## Details | ||
|
||
- `ValueBearing`, `BlankFullSized` or `Dot` styles; | ||
- A string value to be displayed when the style is `ValueBearing`; and | ||
- An `Exited` property that closes the badge down with an animation (borrowed from FABs). | ||
|
||
| ||
|
||
| ||
|
||
[![Components](https://img.shields.io/static/v1?label=Components&message=Plus&color=red)](xref:A.PlusComponents) | ||
[![Docs](https://img.shields.io/static/v1?label=API%20Documentation&message=MBBadge&color=brightgreen)](xref:Material.Blazor.MBBadge) |
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,12 @@ | ||
@namespace Material.Blazor | ||
@inherits ComponentFoundation | ||
|
||
|
||
<span class="mb-badge @ActiveConditionalClasses @(@class)" | ||
style="@style"> | ||
|
||
@if (BadgeStyle == MBBadgeStyle.ValueBearing) | ||
{ | ||
<span class="mb-badge-value mdc-typography--caption">@Value</span> | ||
} | ||
</span> |
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,50 @@ | ||
using Material.Blazor.Internal; | ||
using Microsoft.AspNetCore.Components; | ||
using System.Threading.Tasks; | ||
|
||
namespace Material.Blazor | ||
{ | ||
/// <summary> | ||
/// A plus component badge placed at the top right of the containing div, overlapping the corner, but inside margin and padding.. | ||
/// </summary> | ||
public partial class MBBadge : ComponentFoundation | ||
{ | ||
/// <summary> | ||
/// The badge's style - see <see cref="MBBadgeStyle"/>, defaults to <see cref="MBBadgeStyle.ValueBearing"/>. | ||
/// </summary> | ||
[Parameter] public MBBadgeStyle BadgeStyle { get; set; } = MBBadgeStyle.ValueBearing; | ||
|
||
|
||
/// <summary> | ||
/// The button's density. | ||
/// </summary> | ||
[Parameter] public string Value { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// When true collapses the badge. | ||
/// </summary> | ||
[Parameter] public bool Exited { get; set; } | ||
|
||
|
||
// Would like to use <inheritdoc/> however DocFX cannot resolve to references outside Material.Blazor | ||
protected override async Task OnParametersSetAsync() | ||
{ | ||
await base.OnParametersSetAsync(); | ||
|
||
ConditionalCssClasses | ||
.AddIf("mb-badge--dot", () => BadgeStyle == MBBadgeStyle.Dot) | ||
.AddIf("mb-badge--exited", () => Exited); | ||
} | ||
|
||
|
||
/// <summary> | ||
/// Sets the exited value and calls SHC. | ||
/// </summary> | ||
internal void SetExited(bool exited) | ||
{ | ||
Exited = exited; | ||
_ = InvokeAsync(StateHasChanged); | ||
} | ||
} | ||
} |
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,71 @@ | ||
@use "sass:math"; | ||
@use '@material/theme/color-palette'; | ||
|
||
$background-color: color-palette.$red-500; | ||
$color: color-palette.$blue-grey-100; | ||
|
||
$regular-size: 20px; | ||
$regular-border-radius: math.div($regular-size, 2); | ||
$regular-offset: math.div($regular-size, 2); | ||
|
||
$dot-size: 10px; | ||
$dot-border-radius: math.div($dot-size, 2); | ||
$dot-offset: math.div($dot-size, 2); | ||
|
||
$icon-button-offset: 4px; | ||
|
||
:root { | ||
--mb-badge-background-color: var(--mb-color-red-700); | ||
--mb-badge-color: var(--mb-color-on-red-700); | ||
} | ||
|
||
.mb-badge-container { | ||
position: absolute; | ||
top: 0; | ||
left: 0; | ||
width: 100%; | ||
height: 100%; | ||
} | ||
|
||
.mdc-icon-button { | ||
.mb-badge-container { | ||
top: $icon-button-offset; | ||
left: -$icon-button-offset; | ||
} | ||
} | ||
|
||
.mb-badge { | ||
display: inline-flex; | ||
position: relative; | ||
float: right; | ||
align-items: center; | ||
justify-content: center; | ||
top: -$regular-offset; | ||
right: -$regular-offset; | ||
min-width: $regular-size; | ||
height: $regular-size; | ||
border-radius: $regular-border-radius; | ||
border: none; | ||
background-color: var(--mb-badge-background-color); | ||
color: var(--mb-badge-color); | ||
transition: 135ms 0ms cubic-bezier(0.4, 0, 1, 1); | ||
z-index: 2; | ||
|
||
&.mb-badge--dot { | ||
top: -$dot-offset; | ||
right: -$dot-offset; | ||
min-width: $dot-size; | ||
height: $dot-size; | ||
border-radius: $dot-border-radius; | ||
} | ||
|
||
&.mb-badge--exited { | ||
-webkit-transform: scale(0); | ||
transform: scale(0); | ||
opacity: 0; | ||
} | ||
} | ||
|
||
.mb-badge-value { | ||
padding: 0px 6px; | ||
} |
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
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
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
Oops, something went wrong.