-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added MdIcon demo page and added utility MdIconInline (not published …
…yet).
- Loading branch information
Showing
6 changed files
with
109 additions
and
0 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,77 @@ | ||
@page "/icon" | ||
|
||
<ComponentDemoPage Name="Icon" | ||
DesignUrl="https://m3.material.io/styles/icons/overview" | ||
ComponentUrl="https://github.com/material-components/material-web/blob/main/docs/components/icon.md" | ||
ComponentSourcePath="icon" | ||
BlazorComponentSourcePath="MdIcon.razor" | ||
BlazorDemoSourceName="Icon"> | ||
<Description> | ||
Icons are small symbols for actions or other items | ||
</Description> | ||
<ComponentDemo> | ||
<MarkdownBlock> | ||
`MdIcon` (which renders `<md-icon`) has a fixed size determined | ||
by `.material-symbols-outlined` (or other classes) CSS (24px) | ||
and right now there is no easy way to change it (see [this issue](https://github.com/material-components/material-web/issues/5055)). | ||
|
||
Blazor Material Web provides a utility component `MdIconInline` | ||
which set `font-size`, `font-weight`, `font-style` and `line-height` | ||
to `inherit` as well `vertical-align` to `middle`. | ||
Note that `MdIconInline` does not render `<md-icon>` element but a | ||
`span` with `material-symbols-outlined` class. You can customize it | ||
with `IconClass`. If you need to add additional CSS classes, use | ||
`Class` (uppercase) Blazor parameter. | ||
</MarkdownBlock> | ||
|
||
<div style=" | ||
font-size: @(fontSize)px; | ||
font-weight: @(fontWeight); | ||
font-style: @(fontStyleItalic ? "italic" : "normal")"> | ||
<p> | ||
<span>MdIcon:</span> | ||
<MdIcon>@(icon)</MdIcon> | ||
</p> | ||
|
||
<p> | ||
<span>MdIconInline:</span> | ||
<MdIconInline IconClass="@(MdIconInline.IconOutlined)" | ||
Class="extra-class"> | ||
@(icon) | ||
</MdIconInline> | ||
</p> | ||
</div> | ||
</ComponentDemo> | ||
<Tweaks> | ||
<MdTextField @bind-Value="icon" Label="Icon content" /> | ||
|
||
<div> | ||
<label> | ||
Font size: | ||
<MdSlider @bind-Value="fontSize" | ||
Min="1" Max="100" Labeled="true" /> | ||
</label> | ||
<span>@(fontSize)</span> | ||
</div> | ||
|
||
<div> | ||
<label> | ||
Font weight: | ||
<MdSlider @bind-Value="fontWeight" | ||
Min="100" Max="800" Step="100" Labeled="true" /> | ||
</label> | ||
<span>@(fontWeight)</span> | ||
</div> | ||
|
||
<LabeledSwitch @bind-Selected="fontStyleItalic" Label="Italic" /> | ||
</Tweaks> | ||
</ComponentDemoPage> | ||
|
||
@code { | ||
|
||
string icon = "send"; | ||
int fontSize = 30; | ||
int fontWeight = 400; | ||
bool fontStyleItalic; | ||
|
||
} |
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,5 @@ | ||
@inherits DefaultMdComponent | ||
|
||
<span class="@(IconClass) @(Class)" @ref="el" @attributes="AdditionalAttributes"> | ||
@(ChildContent) | ||
</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,16 @@ | ||
namespace BlazorMaterialWeb; | ||
|
||
partial class MdIconInline | ||
{ | ||
|
||
public const string IconSharp = "material-symbols-sharp"; | ||
public const string IconOutlined = "material-symbols-outlined"; | ||
public const string IconRound = "material-symbols-round"; | ||
|
||
[Parameter] | ||
public string IconClass { get; set; } = IconOutlined; | ||
|
||
[Parameter] | ||
public string Class { get; set; } = ""; | ||
|
||
} |
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,9 @@ | ||
.material-symbols-sharp, | ||
.material-symbols-rounded, | ||
.material-symbols-outlined { | ||
font-size: inherit; | ||
font-weight: inherit; | ||
font-style: inherit; | ||
line-height: inherit; | ||
vertical-align: middle; | ||
} |
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