|
| 1 | +namespace BlazorExpress.Bulma.Demo.RCL; |
| 2 | + |
| 3 | +public partial class BlogMainLayout : MainLayoutBase |
| 4 | +{ |
| 5 | + #region Fields and Constants |
| 6 | + |
| 7 | + private bool isSidebarVisible = false; |
| 8 | + private HashSet<LinkGroup> linkGroups = new(); |
| 9 | + private Menu menuRef = default!; |
| 10 | + |
| 11 | + #endregion |
| 12 | + |
| 13 | + #region Methods |
| 14 | + |
| 15 | + protected override async Task OnAfterRenderAsync(bool firstRender) |
| 16 | + { |
| 17 | + if (firstRender) |
| 18 | + await JS.InvokeVoidAsync("initializeTheme"); |
| 19 | + |
| 20 | + await base.OnAfterRenderAsync(firstRender); |
| 21 | + } |
| 22 | + |
| 23 | + protected override void OnInitialized() |
| 24 | + { |
| 25 | + if (!linkGroups.Any()) |
| 26 | + linkGroups = GetLinkGroups(); |
| 27 | + |
| 28 | + base.OnInitialized(); |
| 29 | + } |
| 30 | + |
| 31 | + private HashSet<LinkGroup> GetLinkGroups() |
| 32 | + { |
| 33 | + var groups = new HashSet<LinkGroup>(); |
| 34 | + |
| 35 | + // GETTING STARTED |
| 36 | + groups.Add(new LinkGroup |
| 37 | + { |
| 38 | + Name = "GETTING STARTED", |
| 39 | + CssClass = "is-size-7 has-text-weight-bold has-text-danger", |
| 40 | + Links = [ |
| 41 | + new Link { Href = RouteConstants.Demos_Getting_Started_Introduction, Text = "Introduction" }, |
| 42 | + ] |
| 43 | + }); |
| 44 | + |
| 45 | + // FEATURES |
| 46 | + groups.Add(new LinkGroup |
| 47 | + { |
| 48 | + Name = "FEATURES", |
| 49 | + CssClass = "is-size-7 has-text-weight-bold has-text-warning", |
| 50 | + Links = [ |
| 51 | + new Link { Href = RouteConstants.Demos_Skeletons_Documentation, Text = "Skeletons" } |
| 52 | + ] |
| 53 | + }); |
| 54 | + |
| 55 | + // ICONS |
| 56 | + groups.Add(new LinkGroup |
| 57 | + { |
| 58 | + Name = "ICONS", |
| 59 | + CssClass = "is-size-7 has-text-weight-bold has-text-info", |
| 60 | + Links = [ |
| 61 | + new Link { Href = RouteConstants.Demos_BootstrapIcons_Documentation, Text = "Bootstrap Icons" }, |
| 62 | + new Link { Href = RouteConstants.Demos_GoogleFontIcons_Documentation, Text = "Google Font Icons" } |
| 63 | + ] |
| 64 | + }); |
| 65 | + |
| 66 | + // ELEMENTS |
| 67 | + groups.Add(new LinkGroup |
| 68 | + { |
| 69 | + Name = "ELEMENTS", |
| 70 | + CssClass = "is-size-7 has-text-weight-bold has-text-primary", |
| 71 | + Links = [ |
| 72 | + new Link { Href = RouteConstants.Demos_Block_Documentation, Text = "Block" }, |
| 73 | + new Link { Href = RouteConstants.Demos_Box_Documentation, Text = "Box" }, |
| 74 | + new Link { Href = RouteConstants.Demos_Button_Documentation, Text = "Button" }, |
| 75 | + new Link { Href = RouteConstants.Demos_DeleteButton_Documentation, Text = "Delete Button" }, |
| 76 | + new Link { Href = RouteConstants.Demos_Image_Documentation, Text = "Image" }, |
| 77 | + new Link { Href = RouteConstants.Demos_Notification_Documentation, Text = "Notification" }, |
| 78 | + new Link { Href = RouteConstants.Demos_ProgressBar_Documentation, Text = "Progress Bar" }, |
| 79 | + new Link { Href = RouteConstants.Demos_Tags_Documentation, Text = "Tags" }, |
| 80 | + ] |
| 81 | + }); |
| 82 | + |
| 83 | + // FORM |
| 84 | + groups.Add(new LinkGroup |
| 85 | + { |
| 86 | + Name = "FORM", |
| 87 | + CssClass = "is-size-7 has-text-weight-bold has-text-primary", |
| 88 | + Links = [ |
| 89 | + new Link { Href = RouteConstants.Demos_Form_DateInput_Documentation , Text = "Date Input" }, |
| 90 | + new Link { Href = RouteConstants.Demos_Form_EnumInput_Documentation , Text = "Enum Input" }, |
| 91 | + new Link { Href = RouteConstants.Demos_Form_OTPInput_Documentation , Text = "OTP Input" }, |
| 92 | + new Link { Href = RouteConstants.Demos_Form_TextInput_Documentation , Text = "Text Input" }, |
| 93 | + ] |
| 94 | + }); |
| 95 | + |
| 96 | + // COMPONENTS |
| 97 | + groups.Add(new LinkGroup |
| 98 | + { |
| 99 | + Name = "COMPONENTS", |
| 100 | + CssClass = "is-size-7 has-text-weight-bold has-text-dark", |
| 101 | + Links = [ |
| 102 | + new Link { Href = RouteConstants.Demos_Breadcrumb_Documentation, Text = "Breadcrumb" }, |
| 103 | + new Link { Href = RouteConstants.Demos_ConfirmDialog_Documentation, Text = "Confirm Dialog" }, |
| 104 | + new Link { Href = RouteConstants.Demos_GoogleMaps_Documentation, Text = "Google Maps" }, |
| 105 | + new Link { Href = RouteConstants.Demos_Grid_Documentation, Text = "Grid" }, |
| 106 | + new Link { Href = RouteConstants.Demos_Message_Documentation, Text = "Message" }, |
| 107 | + new Link { Href = RouteConstants.Demos_Modal_Documentation, Text = "Modal" }, |
| 108 | + new Link { Href = RouteConstants.Demos_Pagination_Documentation, Text = "Pagination" }, |
| 109 | + new Link { Href = RouteConstants.Demos_ScriptLoader_Documentation, Text = "Script Loader" }, |
| 110 | + new Link { Href = RouteConstants.Demos_Tabs_Documentation, Text = "Tabs" } |
| 111 | + ] |
| 112 | + }); |
| 113 | + |
| 114 | + // LAYOUT |
| 115 | + groups.Add(new LinkGroup |
| 116 | + { |
| 117 | + Name = "LAYOUT", |
| 118 | + CssClass = "is-size-7 has-text-weight-bold has-text-success", |
| 119 | + Links = [ |
| 120 | + new Link { Href = RouteConstants.Demos_Hero_Documentation, Text = "Hero" } |
| 121 | + ] |
| 122 | + }); |
| 123 | + |
| 124 | + return groups; |
| 125 | + } |
| 126 | + |
| 127 | + private Task SetAutoTheme() => SetTheme("system"); |
| 128 | + |
| 129 | + private Task SetDarkTheme() => SetTheme("dark"); |
| 130 | + |
| 131 | + private Task SetLightTheme() => SetTheme("light"); |
| 132 | + |
| 133 | + private async Task SetTheme(string themeName) => await JS.InvokeVoidAsync("setTheme", themeName); |
| 134 | + |
| 135 | + private void ToggleSidebarSection() |
| 136 | + { |
| 137 | + @menuRef.Toggle(); |
| 138 | + } |
| 139 | + |
| 140 | + #endregion |
| 141 | +} |
0 commit comments