Skip to content

Commit

Permalink
Generalize the CSS style of the locale selection
Browse files Browse the repository at this point in the history
Make it reusable and move the icon from the CSS to the HTML.

Use label to make the icon clickable.

Add a title to the icon for improved usability.
  • Loading branch information
elia committed Jun 1, 2023
1 parent aa44e71 commit 19873db
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ $padding-y-navbar-submenu: 9px;
display: block;
height: 39px;
z-index: 1;
margin-bottom: 1em;

span {
font-size: $font-size-sm;
Expand Down Expand Up @@ -288,22 +289,37 @@ nav.menu {
}
}

.admin-locale-selection {
margin: 1em;
.admin-navbar-selection {
margin: 0 1em;
position: relative;
overflow: hidden;

i {
cursor: pointer;
}

&::after {
content: "\f0ac";
font-family: "FontAwesome";
position: absolute;
top: 0;
left: 0;
padding: .5rem 0 .5rem .25rem;
z-index: -1;
}

select.custom-select.fullwidth {
width: calc(100% - 2.5em);
display: inline-block;
}

.admin-nav-hidden & {
.js-locale-selection.custom-select {
position: relative;

i {
position: absolute;
}

select {
background-image: none;
background-color: transparent;
background-position: 1.5rem center;
background-size: 8px 9px;
Expand All @@ -313,6 +329,7 @@ nav.menu {
overflow: hidden;
text-indent: 1rem;
z-index: 1;
cursor: pointer;

&:focus {
box-shadow: none;
Expand All @@ -326,6 +343,12 @@ nav.menu {
bottom: 0;
}

body.admin-nav-hidden .admin-nav:not(.fits) {
.admin-navbar-selection::after {
z-index: 0;
}
}

.admin-login-nav {
list-style: none;
padding: 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<% available_locales = Spree.i18n_available_locales %>
<% if available_locales.size > 1 %>
<div class="admin-locale-selection">
<label class="admin-navbar-selection">
<i class="fa fa-globe fa-fw" title="<%= I18n.t('spree.choose_dashboard_locale') %>"></i>
<select class="js-locale-selection custom-select fullwidth">
<%=
options_for_select(
Expand All @@ -11,5 +12,5 @@
)
%>
</select>
</div>
</label>
<% end %>

0 comments on commit 19873db

Please sign in to comment.