Skip to content

Commit 1ad3af7

Browse files
authored
Add live examples (#3147)
* chore(Multiselect): add live example to overview page * chore(Button): add live examples to overview and events pages * chore(NumericTextBox): add live examples to overview page
1 parent d94b0d3 commit 1ad3af7

File tree

4 files changed

+14
-164
lines changed

4 files changed

+14
-164
lines changed

components/button/events.md

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,10 @@ It receives argument of type [MouseEventArgs](https://docs.microsoft.com/en-us/d
2222

2323
>caption Handle the button click
2424
25-
````RAZOR
26-
@result
27-
<br />
28-
@moreInfo
29-
30-
<br />
31-
<TelerikButton OnClick="@OnClickHandler">Click me!</TelerikButton>
32-
33-
@code {
34-
string result;
35-
string moreInfo;
36-
37-
async Task OnClickHandler(MouseEventArgs args)
38-
{
39-
result = "Button was clicked at: " + DateTime.Now.ToString();
40-
moreInfo = "Ctrl was pressed when clicked: " + args.CtrlKey;
41-
}
42-
}
43-
````
25+
<demo metaUrl="client/button/events/" height="200"></demo>
4426

4527
@[template](/_contentTemplates/common/general-info.md#event-callback-can-be-async)
4628

47-
4829
## See Also
4930

5031
* [Telerik UI for Blazor Button Overview](slug:components/button/overview)

components/button/overview.md

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,7 @@ The Blazor Button provides a variety of styling options through the [built-in th
2424

2525
>caption Basic Blazor Button with `OnClick` event handler
2626
27-
````RAZOR
28-
@result
29-
<br />
30-
<TelerikButton OnClick="@OnClickHandler">Hello!</TelerikButton>
31-
32-
@code {
33-
private string result;
34-
35-
private async Task OnClickHandler()
36-
{
37-
result = DateTime.Now.ToString();
38-
}
39-
}
40-
````
27+
<demo metaUrl="client/button/overview/" height="200"></demo>
4128

4229
## Icons
4330

@@ -86,12 +73,10 @@ Add a reference to the component instance to use the [Button methods](slug:Teler
8673
| --- | --- |
8774
| `FocusAsync` | Focuses the Blazor Button component. Always call with `await`. @[template](/_contentTemplates/common/inputs.md#focus-kb) |
8875

89-
````RAZOR
76+
````RAZOR.skip-repl
9077
<TelerikButton @ref="ButtonRef">Hello!</TelerikButton>
9178
9279
@code {
93-
private Telerik.Blazor.Components.TelerikButton ButtonRef { get; set; }
94-
9580
protected override async Task OnAfterRenderAsync(bool firstRender)
9681
{
9782
await ButtonRef.FocusAsync();
@@ -104,7 +89,6 @@ Add a reference to the component instance to use the [Button methods](slug:Teler
10489
## Next Steps
10590

10691
* [Styling the Blazor Button](slug:button-styling)
107-
10892
* [Using Button Icons](slug:button-icons)
10993

11094

components/multiselect/overview.md

Lines changed: 5 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -23,57 +23,7 @@ The <a href="https://www.telerik.com/blazor-ui/multiselect" target="_blank">Blaz
2323

2424
>caption Basic Blazor MultiSelect two-way value binding, main features, and simple [data binding](slug:multiselect-databind)
2525
26-
````RAZOR
27-
<TelerikMultiSelect Data="@Countries"
28-
@bind-Value="@MultiSelectValues"
29-
TextField="@nameof(Country.Name)"
30-
ValueField="@nameof(Country.Id)"
31-
AutoClose="false"
32-
Placeholder="Select Balkan Countries"
33-
ShowClearButton="true">
34-
</TelerikMultiSelect>
35-
36-
@if (MultiSelectValues.Count > 0)
37-
{
38-
<ul>
39-
@foreach (int countryId in MultiSelectValues)
40-
{
41-
<li><code>Id</code> @countryId, <code>Name</code> @Countries.First(x => x.Id == countryId).Name</li>
42-
}
43-
</ul>
44-
}
45-
@code {
46-
private List<Country> Countries { get; set; } = new();
47-
private List<int> MultiSelectValues { get; set; } = new();
48-
49-
protected override void OnInitialized()
50-
{
51-
Countries.Add(new(1, "Albania"));
52-
Countries.Add(new(2, "Bosnia and Herzegovina"));
53-
Countries.Add(new(3, "Bulgaria"));
54-
Countries.Add(new(4, "Croatia"));
55-
Countries.Add(new(5, "Greece"));
56-
Countries.Add(new(6, "Kosovo"));
57-
Countries.Add(new(7, "Montenegro"));
58-
Countries.Add(new(8, "Romania"));
59-
Countries.Add(new(9, "Serbia"));
60-
Countries.Add(new(10, "Slovenia"));
61-
Countries.Add(new(11, "Turkey"));
62-
}
63-
64-
public class Country
65-
{
66-
public int Id { get; set; }
67-
public string Name { get; set; } = string.Empty;
68-
69-
public Country(int id, string name)
70-
{
71-
Id = id;
72-
Name = name;
73-
}
74-
}
75-
}
76-
````
26+
<demo metaUrl="client/multiselect/overview/" height="300"></demo>
7727

7828
## Data Binding
7929

@@ -152,25 +102,13 @@ The following parameters enable you to customize the [appearance](slug:multisele
152102

153103
The MultiSelect exposes settings for its dropdown (popup). To configure the options, declare a `<MultiSelectPopupSettings>` tag inside a `<MultiSelectSettings>` tag:
154104

155-
````RAZOR
105+
````RAZOR.skip-repl
156106
<TelerikMultiSelect Data="@MultiSelectData"
157-
@bind-Value="@SelectedItems"
158-
Filterable="true"
159-
FilterOperator="@StringFilterOperator.Contains"
160-
Placeholder="Filter by digit or letter"
161-
AutoClose="false"
162-
Width="240px">
107+
@bind-Value="@SelectedItems">
163108
<MultiSelectSettings>
164109
<MultiSelectPopupSettings Height="auto" MaxHeight="200px" MinHeight="75px" />
165110
</MultiSelectSettings>
166111
</TelerikMultiSelect>
167-
@code {
168-
private List<string> MultiSelectData { get; set; } = Enumerable.Range(1, 50)
169-
.Select(x => { return $"Item {x} {(char)Random.Shared.Next(65, 91)}{(char)Random.Shared.Next(65, 91)}"; })
170-
.ToList();
171-
172-
private List<string> SelectedItems { get; set; } = new List<string>();
173-
}
174112
````
175113

176114
The MultiSelect provides the following popup settings:
@@ -186,26 +124,15 @@ Add a reference to the component instance to use the [MultiSelect's methods](slu
186124

187125
@[template](/_contentTemplates/dropdowns/methods.md#methods-list)
188126

189-
````RAZOR
190-
<TelerikMultiSelect @ref="@MultiSelectRef"
191-
Data="@MultiSelectData"
192-
@bind-Value="@MultiSelectValue"
193-
Width="300px" />
127+
````RAZOR.skip-repl
128+
<TelerikMultiSelect @ref="@MultiSelectRef" .../>
194129
195130
<TelerikButton OnClick="@OpenPopup">Open Popup</TelerikButton>
196131
197132
@code {
198-
private TelerikMultiSelect<string, string> MultiSelectRef { get; set; }
199-
200-
private List<string> MultiSelectValue { get; set; }
201-
202-
private List<string> MultiSelectData { get; set; } = new List<string> { "first", "second", "third" };
203-
204133
private void OpenPopup()
205134
{
206135
MultiSelectRef.Open();
207-
208-
MultiSelectValue = new List<string>() { MultiSelectData.First() };
209136
210137
MultiSelectRef.Refresh();
211138
}

components/numerictextbox/overview.md

Lines changed: 6 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,9 @@ The <a href="https://www.telerik.com/blazor-ui/numeric-textbox" target="_blank">
1818
1. Bind a numeric data type to the component
1919
1. Optionally, set custom `Format`, `Min`, `Max` and `Step` values
2020

21-
>caption Basic numeric text box with its key features
21+
>caption Basic NumericTextBox with its key features
2222
23-
````RAZOR
24-
The new value is: @theValue
25-
26-
<TelerikNumericTextBox Format="C" Max="5m" Min="-5m" Step="0.33m" @bind-Value="@theValue"></TelerikNumericTextBox>
27-
28-
@code {
29-
private decimal theValue { get; set; } = 1.234m;
30-
}
31-
````
23+
<demo metaUrl="client/numerictextbox/overview/" height="250"></demo>
3224

3325
The Numeric TextBox component is generic, meaning that it takes the type of its value parameter as an argument. It can take `int`, `long`, `float`, `double` and `decimal` values. Therefore, the values for the `Min`, `Max` and `Step` properties must be of the same type as the `Value`, and the `ValueChanged` handler must also accommodate the corresponding value type.
3426

@@ -48,33 +40,7 @@ The Blazor Numeric TextBox allows you to define your desired custom format throu
4840

4941
>caption Using custom format strings with the Blazor Numeric TextBox
5042
51-
````RAZOR
52-
@Weight
53-
<br />
54-
<TelerikNumericTextBox Format="#.00 kg" Max="5m" Min="-5m" Step="0.33m" @bind-Value="@Weight"></TelerikNumericTextBox>
55-
<br />
56-
@code{
57-
decimal Weight { get; set; } = 3.456789m;
58-
}
59-
60-
@Rent
61-
<br />
62-
<TelerikNumericTextBox Decimals="2" Format="@RentFormat" @bind-Value="@Rent"></TelerikNumericTextBox>
63-
<br />
64-
@code{
65-
decimal Rent { get; set; } = 4567.89m;
66-
string RentFormat { get; set; } = System.Globalization.NumberFormatInfo.CurrentInfo.CurrencySymbol + "#.00 a year";
67-
}
68-
69-
@Units
70-
<br />
71-
<TelerikNumericTextBox Decimals="0" Format="@UnitsFormat" @bind-Value="@Units"></TelerikNumericTextBox>
72-
73-
@code{
74-
int Units { get; set; } = 12;
75-
string UnitsFormat { get; set; } = "# unit(s)";
76-
}
77-
````
43+
<demo metaUrl="client/numerictextbox/format-string/" height="400"></demo>
7844

7945
## Numeric TextBox Parameters
8046

@@ -117,20 +83,12 @@ The following parameters enable you to customize the [appearance](slug:numericte
11783

11884
The Numeric TextBox has a `FocusAsync` method that enables programmatic focus. To use it, obtain a reference to the component instance through `@ref`. @[template](/_contentTemplates/common/inputs.md#focus-kb)
11985

120-
````RAZOR
121-
<TelerikButton OnClick="@FocusTextBox">Focus TextBox</TelerikButton>
86+
````RAZOR.skip-repl
87+
<TelerikNumericTextBox @ref="@NumericTextBoxRef" .../>
12288
123-
<TelerikNumericTextBox @ref="@NumericTextBoxRef"
124-
@bind-Value="DecimalValue"
125-
Width="200px" />
89+
<TelerikButton OnClick="@FocusTextBox">Focus TextBox</TelerikButton>
12690
12791
@code {
128-
//determines the type of the component
129-
private decimal DecimalValue { get; set; }
130-
131-
//the Value type determines the type of the reference
132-
private TelerikNumericTextBox<decimal> NumericTextBoxRef { get; set; }
133-
13492
async Task FocusTextBox()
13593
{
13694
await NumericTextBoxRef.FocusAsync();

0 commit comments

Comments
 (0)