Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Selector Alignment fix #3368 #3370

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Oqtane.Client/Themes/BlazorTheme/Themes/Default.razor
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<div class="main g-0">
<div class="top-row px-4">
<div class="ms-auto"><UserProfile /> <Login /> <ControlPanel /></div>
<div class="ms-auto"><UserProfile /> <Login /> <ControlPanel LanguageDropdownAlignment="right" /></div>
</div>
<div class="container">
<div class="row px-4">
Expand Down
35 changes: 19 additions & 16 deletions Oqtane.Client/Themes/Controls/Theme/ControlPanel.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

@if (ShowLanguageSwitcher)
{
<LanguageSwitcher />
<LanguageSwitcher DropdownAlignment="@LanguageDropdownAlignment" />
}

@if (_showEditMode || (PageState.Page.IsPersonalizable && PageState.User != null && UserSecurity.IsAuthorized(PageState.User, RoleNames.Registered)))
Expand Down Expand Up @@ -239,6 +239,24 @@
}

@code{
[Parameter]
public string ButtonClass { get; set; } = "btn-outline-secondary";

[Parameter]
public string ContainerClass { get; set; } = "offcanvas offcanvas-end";

[Parameter]
public string HeaderClass { get; set; } = "offcanvas-header";

[Parameter]
public string BodyClass { get; set; } = "offcanvas-body overflow-auto";

[Parameter]
public bool ShowLanguageSwitcher { get; set; } = true;

[Parameter]
public string LanguageDropdownAlignment { get; set; } // Empty or Left or Right

private bool _canViewAdminDashboard = false;
private bool _showEditMode = false;
private bool _deleteConfirmation = false;
Expand Down Expand Up @@ -295,21 +313,6 @@
}
}

[Parameter]
public string ButtonClass { get; set; } = "btn-outline-secondary";

[Parameter]
public string ContainerClass { get; set; } = "offcanvas offcanvas-end";

[Parameter]
public string HeaderClass { get; set; } = "offcanvas-header";

[Parameter]
public string BodyClass { get; set; } = "offcanvas-body overflow-auto";

[Parameter]
public bool ShowLanguageSwitcher { get; set; } = true;

protected override async Task OnParametersSetAsync()
{
_canViewAdminDashboard = CanViewAdminDashboard();
Expand Down
9 changes: 7 additions & 2 deletions Oqtane.Client/Themes/Controls/Theme/LanguageSwitcher.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<button id="btnCultures" type="button" class="btn btn-outline-secondary dropdown-toggle" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<span class="oi oi-globe"></span>
</button>
<div class="dropdown-menu" aria-labelledby="btnCultures">
<div class="dropdown-menu @MenuAlignment" aria-labelledby="btnCultures">
@foreach (var culture in _supportedCultures)
{
<a class="dropdown-item @(CultureInfo.CurrentUICulture.Name == culture.Name ? "active" : String.Empty)" href="#" @onclick="@(async e => await SetCultureAsync(culture.Name))">@culture.DisplayName</a>
Expand All @@ -23,10 +23,15 @@

@code{
private IEnumerable<Culture> _supportedCultures;
[Parameter]
public string DropdownAlignment { get; set; } // Empty or Left or Right
private string MenuAlignment = string.Empty;

protected override void OnParametersSet()
{
var languages = PageState.Languages;
MenuAlignment = DropdownAlignment.ToLower() == "right" ? "dropdown-menu-end" : string.Empty;

var languages = PageState.Languages;
_supportedCultures = languages.Select(l => new Culture { Name = l.Code, DisplayName = l.Name });
}

Expand Down
2 changes: 1 addition & 1 deletion Oqtane.Client/Themes/OqtaneTheme/Themes/Default.razor
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<nav class="navbar navbar-dark bg-primary fixed-top">
<Logo /><Menu Orientation="Horizontal" />
<div class="controls ms-auto">
<div class="controls-group"><UserProfile ShowRegister="@_register" /> <Login ShowLogin="@_login" /> <ControlPanel /></div>
<div class="controls-group"><UserProfile ShowRegister="@_register" /> <Login ShowLogin="@_login" /> <ControlPanel LanguageDropdownAlignment="right" /></div>
</div>
</nav>
<div class="content">
Expand Down