-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[dev-v5] Add FluentTextInput (#2930)
* Add FluentInputBase and FluentInputImmediateBase * Add FluentTextInput * Refactoring FluentInputBase (removing CurrentValue) * Add Base Unit Tests * Add Label * Add Appearance and sample * Add Immediate examples * Add missing properties * Add ObserveAttributeChanges to detect and apply the Value attribute * Fix the API comments * Fix Global Unit Tests * Add new tests * Fix Unit Tests * Add Unit Tests for Extension methods * [dev-v5] Use standard `InputBase` class (#2933) * Add FluentJSModule * Update the doc * Replace FluentInputBase with inheritance * - Fix runtime error (caused by using only Value) - Add 'Lab' page to do quick experiments - Exlude YT video because of constant script error - Adapt CopySources to use net9.0 TFM --------- Co-authored-by: Denis Voituron <[email protected]> Co-authored-by: Vincent Baaij <[email protected]> * Refactoring * Add default ValueExpression --------- Co-authored-by: Denis Voituron (MSFT) <[email protected]> Co-authored-by: Vincent Baaij <[email protected]>
- Loading branch information
1 parent
1704a59
commit ff47fd8
Showing
41 changed files
with
1,311 additions
and
128 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
examples/Demo/FluentUI.Demo.Client/DebugPages/EditFormPage.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,12 @@ | ||
@page "/Debug/EditForm" | ||
|
||
<h1>Just a simple page to do some experimenting</h1> | ||
|
||
<InputText @bind-Value="@MyValue" /> | ||
<FluentTextInput Value="@MyValue" /> | ||
|
||
MyValue: @MyValue | ||
|
||
@code { | ||
public string MyValue { get; set; } = "Test"; | ||
} |
21 changes: 21 additions & 0 deletions
21
...uentUI.Demo.Client/Documentation/Components/TextInput/Examples/TextInputAppearances.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,21 @@ | ||
<div style="display: flex; gap: 12px; margin-bottom: 24px;"> | ||
<FluentTextInput Appearance="@TextInputAppearance.Outline" Label="Outline" Placeholder="Outline" @bind-Value="@Value" /> | ||
<FluentTextInput Appearance="@TextInputAppearance.Underline" Label="Underline" Placeholder="Underline" @bind-Value="@Value" /> | ||
<FluentTextInput Appearance="@TextInputAppearance.FilledLighter" Label="FilledLighter" Placeholder="FilledLighter" @bind-Value="@Value" /> | ||
<FluentTextInput Appearance="@TextInputAppearance.FilledDarker" Label="FilledDarker" Placeholder="FilledDarker" @bind-Value="@Value" /> | ||
</div> | ||
|
||
<div style="display: flex; gap: 12px; margin-bottom: 24px;"> | ||
<FluentTextInput Size="@TextInputSize.Small" Label="Small" Placeholder="Small" @bind-Value="@Value" /> | ||
<FluentTextInput Size="@TextInputSize.Medium" Label="Medium" Placeholder="Medium" @bind-Value="@Value" /> | ||
<FluentTextInput Size="@TextInputSize.Large" Label="Large" Placeholder="Large" @bind-Value="@Value" /> | ||
</div> | ||
|
||
<div> | ||
Value = @Value | ||
</div> | ||
|
||
@code | ||
{ | ||
string Value = ""; | ||
} |
17 changes: 17 additions & 0 deletions
17
...FluentUI.Demo.Client/Documentation/Components/TextInput/Examples/TextInputImmediate.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,17 @@ | ||
<div style="display: flex; gap: 12px; margin-bottom: 24px;"> | ||
<FluentTextInput Appearance="@TextInputAppearance.Outline" | ||
Placeholder="Updated after 400ms" | ||
@bind-Value="@Value" | ||
@bind-Value:after="@(() => Console.WriteLine($"TextInput updated to '{Value}'.") )" | ||
Immediate="true" | ||
ImmediateDelay="400" /> | ||
</div> | ||
|
||
<div> | ||
Value = @Value | ||
</div> | ||
|
||
@code | ||
{ | ||
string Value = ""; | ||
} |
21 changes: 21 additions & 0 deletions
21
...entUI.Demo.Client/Documentation/Components/TextInput/Examples/TextInputPrefixSuffix.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,21 @@ | ||
<div style="display: flex; gap: 12px; margin-bottom: 24px;"> | ||
<FluentTextInput Label="Company Url" @bind-Value="@_sometext1"> | ||
<StartTemplate> | ||
<fluent-label>https://</fluent-label> | ||
</StartTemplate> | ||
<EndTemplate> | ||
<fluent-label>.com</fluent-label> | ||
</EndTemplate> | ||
</FluentTextInput> | ||
|
||
<FluentTextInput Label="Email" TextFieldType="TextInputType.Email" @bind-Value="@_sometext2" Style="width: 300px;"> | ||
<StartTemplate> | ||
<FluentIcon Value="@(new Icons.Regular.Size20.Mail())" /> | ||
</StartTemplate> | ||
</FluentTextInput> | ||
</div> | ||
|
||
@code { | ||
private string _sometext1 = "microsoft"; | ||
private string _sometext2 = "[email protected]"; | ||
} |
14 changes: 14 additions & 0 deletions
14
...emo/FluentUI.Demo.Client/Documentation/Components/TextInput/Examples/TextInputState.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,14 @@ | ||
<div style="display: flex; gap: 12px; margin-bottom: 24px;"> | ||
<FluentTextInput Required="true" Label="Required" Placeholder="Required" @bind-Value="@Value" /> | ||
<FluentTextInput Disabled="true" Label="Disabled" Placeholder="Disabled" @bind-Value="@Value" /> | ||
<FluentTextInput ReadOnly="true" Label="ReadOnly" Placeholder="ReadOnly" @bind-Value="@Value" /> | ||
</div> | ||
|
||
<div> | ||
Value = @Value | ||
</div> | ||
|
||
@code | ||
{ | ||
string Value = ""; | ||
} |
58 changes: 58 additions & 0 deletions
58
...Demo/FluentUI.Demo.Client/Documentation/Components/TextInput/FluentTextInput.md
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,58 @@ | ||
--- | ||
title: TextInput | ||
route: /TextInput | ||
--- | ||
|
||
# TextInput | ||
|
||
A **FluentTextInput** component enables a user to enter text into an app. | ||
It's typically used to capture a single line of text. | ||
The text displays on the screen in a simple, uniform format. | ||
|
||
## Appearance | ||
|
||
The apparent style of a text input can be changed by setting the `Appearance` property, but also by setting the `Size` property. | ||
|
||
You can also add a label to the text input by setting the `Label` property and a placeholder by setting the `Placeholder` property. | ||
The label will be automatically positioned above the text input, and the placeholder will be displayed inside the text input. | ||
|
||
We recommand to use a spacing of 24px between text fields and other components. | ||
|
||
{{ TextInputAppearances }} | ||
|
||
Although not recommended by FluentUI, an input can be rendered inline with text using a style attribute. | ||
|
||
``` | ||
<div> | ||
Name: | ||
<FluentTextInput Style="display: inline-block;" /> | ||
</div> | ||
``` | ||
|
||
## Binding with ImmediateDelay | ||
|
||
In some cases, you may want to bind the value of the text input to a property of a model | ||
and update the model immediately after the user types a character. But you may also want to delay the update. | ||
This can be achieved by setting the `Immediate` and the optional `ImmediateDelay` properties. | ||
|
||
{{ TextInputImmediate }} | ||
|
||
## States | ||
|
||
A text input can be in different states, such as `Disabled`, `ReadOnly`, and `Required`. | ||
|
||
{{ TextInputState }} | ||
|
||
## Prefix and Suffix | ||
|
||
You can use the `StartTemplate` and `EndTemplate` properties to add a prefix or a suffix to the text input | ||
as `https://` and `.com` or an icon. | ||
|
||
These templates are automatically positioned with a small margin between the text entered and the prefix/suffix. | ||
You cannot therefore fill the entire background of these templates, with a colour for example. | ||
|
||
{{ TextInputPrefixSuffix }} | ||
|
||
## API FluentTextInput | ||
|
||
{{ API Type=FluentTextInput }} |
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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ appsettings | |
blazor | ||
cref | ||
csproj | ||
datalist | ||
elementreference | ||
evenodd | ||
microsoft | ||
|
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.