|
4 | 4 | @using PrompterOne.Shared.Localization |
5 | 5 | @inject IStringLocalizer<SharedResource> Localizer |
6 | 6 |
|
7 | | -<div class="ed-sidebar"> |
8 | | - <div class="ed-structure"> |
9 | | - <div class="ed-section-label">@Text(UiTextKey.EditorStructureSection)</div> |
10 | | - <div class="ed-tree"> |
11 | | - @foreach (var segment in Segments) |
12 | | - { |
13 | | - var segmentIsActive = segment.Index == ActiveSegmentIndex; |
14 | | - <button class="@GetSegmentCss(segment, segmentIsActive)" |
15 | | - data-nav="seg-@segment.Index" |
16 | | - data-active="@(segmentIsActive ? ActiveStateValue : InactiveStateValue)" |
17 | | - data-test="@UiTestIds.Editor.SegmentNavigation(segment.Index)" |
18 | | - type="button" |
19 | | - @onclick="() => OnNavigate.InvokeAsync(new EditorNavigationTarget(segment.Index, null, segment.StartIndex, segment.EndIndex))"> |
20 | | - <div class="ed-tree-dot"></div> |
21 | | - <span class="ed-tree-seg__name" title="@segment.Name">@segment.Name</span> |
22 | | - <small title="@segment.EmotionLabel">@segment.EmotionLabel</small> |
23 | | - </button> |
24 | | - <div class="ed-tree-children"> |
25 | | - @foreach (var block in segment.Blocks) |
26 | | - { |
27 | | - var blockIsActive = segment.Index == ActiveSegmentIndex && block.Index == ActiveBlockIndex; |
28 | | - <button class="ed-tree-block @(blockIsActive ? "active" : null)" |
29 | | - data-nav="blk-@segment.Index-@block.Index" |
30 | | - data-active="@(blockIsActive ? ActiveStateValue : InactiveStateValue)" |
31 | | - data-test="@UiTestIds.Editor.BlockNavigation(segment.Index, block.Index)" |
32 | | - type="button" |
33 | | - @onclick="() => OnNavigate.InvokeAsync(new EditorNavigationTarget(segment.Index, block.Index, block.StartIndex, block.EndIndex))"> |
34 | | - <span class="ed-tree-block__name" title="@block.Name">@block.Name</span> |
35 | | - <code>@block.TargetWpmLabel</code> |
36 | | - </button> |
37 | | - } |
38 | | - </div> |
39 | | - } |
40 | | - </div> |
| 7 | +<div class="ed-sidebar" |
| 8 | + data-collapsed="@(IsCollapsed ? ActiveStateValue : InactiveStateValue)" |
| 9 | + data-test="@UiTestIds.Editor.StructureSidebar"> |
| 10 | + <div class="ed-sidebar-topbar"> |
| 11 | + <button type="button" |
| 12 | + class="ed-sidebar-toggle" |
| 13 | + aria-controls="editor-structure-sidebar-body" |
| 14 | + aria-expanded="@(!IsCollapsed ? "true" : "false")" |
| 15 | + aria-label="@ToggleLabel" |
| 16 | + title="@ToggleLabel" |
| 17 | + data-sidebar-icon="left" |
| 18 | + data-test="@UiTestIds.Editor.StructureSidebarToggle" |
| 19 | + @onclick="() => ToggleRequested.InvokeAsync()"> |
| 20 | + <UiIcon Kind="UiIconKind.PanelLeft" Size="16" StrokeWidth="2.1m" /> |
| 21 | + </button> |
41 | 22 | </div> |
42 | 23 |
|
| 24 | + @if (!IsCollapsed) |
| 25 | + { |
| 26 | + <div id="editor-structure-sidebar-body" class="ed-structure"> |
| 27 | + <div class="ed-section-label">@Text(UiTextKey.EditorStructureSection)</div> |
| 28 | + <div class="ed-tree"> |
| 29 | + @foreach (var segment in Segments) |
| 30 | + { |
| 31 | + var segmentIsActive = segment.Index == ActiveSegmentIndex; |
| 32 | + <button class="@GetSegmentCss(segment, segmentIsActive)" |
| 33 | + data-nav="seg-@segment.Index" |
| 34 | + data-active="@(segmentIsActive ? ActiveStateValue : InactiveStateValue)" |
| 35 | + data-test="@UiTestIds.Editor.SegmentNavigation(segment.Index)" |
| 36 | + type="button" |
| 37 | + @onclick="() => OnNavigate.InvokeAsync(new EditorNavigationTarget(segment.Index, null, segment.StartIndex, segment.EndIndex))"> |
| 38 | + <div class="ed-tree-dot"></div> |
| 39 | + <span class="ed-tree-seg__name" title="@segment.Name">@segment.Name</span> |
| 40 | + <small title="@segment.EmotionLabel">@segment.EmotionLabel</small> |
| 41 | + </button> |
| 42 | + <div class="ed-tree-children"> |
| 43 | + @foreach (var block in segment.Blocks) |
| 44 | + { |
| 45 | + var blockIsActive = segment.Index == ActiveSegmentIndex && block.Index == ActiveBlockIndex; |
| 46 | + <button class="ed-tree-block @(blockIsActive ? "active" : null)" |
| 47 | + data-nav="blk-@segment.Index-@block.Index" |
| 48 | + data-active="@(blockIsActive ? ActiveStateValue : InactiveStateValue)" |
| 49 | + data-test="@UiTestIds.Editor.BlockNavigation(segment.Index, block.Index)" |
| 50 | + type="button" |
| 51 | + @onclick="() => OnNavigate.InvokeAsync(new EditorNavigationTarget(segment.Index, block.Index, block.StartIndex, block.EndIndex))"> |
| 52 | + <span class="ed-tree-block__name" title="@block.Name">@block.Name</span> |
| 53 | + <code>@block.TargetWpmLabel</code> |
| 54 | + </button> |
| 55 | + } |
| 56 | + </div> |
| 57 | + } |
| 58 | + </div> |
| 59 | + </div> |
| 60 | + } |
43 | 61 | </div> |
44 | 62 |
|
45 | 63 | @code { |
|
50 | 68 |
|
51 | 69 | [Parameter] public int ActiveSegmentIndex { get; set; } |
52 | 70 |
|
| 71 | + [Parameter] public bool IsCollapsed { get; set; } |
| 72 | + |
53 | 73 | [Parameter] public EventCallback<EditorNavigationTarget> OnNavigate { get; set; } |
54 | 74 |
|
55 | 75 | [Parameter] public IReadOnlyList<EditorOutlineSegmentViewModel> Segments { get; set; } = []; |
56 | 76 |
|
| 77 | + [Parameter] public string ToggleLabel { get; set; } = string.Empty; |
| 78 | + |
| 79 | + [Parameter] public EventCallback ToggleRequested { get; set; } |
| 80 | + |
57 | 81 | private static string GetEmotionClass(EditorOutlineSegmentViewModel segment) => |
58 | 82 | segment.EmotionKey switch |
59 | 83 | { |
|
0 commit comments