-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.razor
More file actions
65 lines (56 loc) · 1.5 KB
/
Copy pathApp.razor
File metadata and controls
65 lines (56 loc) · 1.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<header>
<button @onclick="OnClickAddNew">Add New Block</button>
<button @onclick="OnClickAppendText">Append Text</button>
<button @onclick="OnClickToggleOutline">Toggle Outline</button>
</header>
<main class="@CssClass">
<div class="left">
<h3>Normal</h3>
<div class="blocks">
@foreach (var block in _blocks)
{
<NormalTextBox @key="block.Id" Text="@block.Text" />
}
</div>
</div>
<div class="right">
<h3>Sliding</h3>
<div class="blocks">
@foreach (var block in _blocks)
{
<SlidingTextBox @key="block.Id" Text="@block.Text" />
}
</div>
</div>
</main>
@code
{
public class Block
{
public int Id { get; set; }
public string Text { get; set; } = "";
}
private List<Block> _blocks = [];
private bool _showOutline = false;
private string CssClass => _showOutline ? "show-outline" : "";
private void OnClickAddNew()
{
_blocks.Insert(0, new Block
{
Id = _blocks.Count + 1,
Text = $"Block {_blocks.Count + 1}: {LoremGenerator.GetNext()}"
});
}
private void OnClickAppendText()
{
var lastBlock = _blocks.FirstOrDefault();
if (lastBlock != null)
{
lastBlock.Text += " " + LoremGenerator.GetNext();
}
}
private void OnClickToggleOutline()
{
_showOutline = !_showOutline;
}
}