Skip to content

Commit c30d49a

Browse files
committed
feature #978 Updated the design of the language selector (javiereguiluz)
This PR was merged into the master branch. Discussion ---------- Updated the design of the language selector I don't like the current design of the language selector for two reasons: * Locales are not sorted in any way, so it looks chaotic. * Each locale is shown in its own locale, adding to that chaotic feeling. I took inspiration from a real website which uses a massive language selector (the European Union): ![image](https://user-images.githubusercontent.com/73419/58486446-2f328c80-8166-11e9-9d34-39327d38cc16.png) I liked the idea of showing the "locale codes" as a hint of each language. That's why I'm proposing this redesign. Before/After comparison: ![image](https://user-images.githubusercontent.com/73419/58486491-41acc600-8166-11e9-980a-2d45d7cc3069.png) Commits ------- 0a1b5e8 Updated the design of the language selector
2 parents 2467113 + 0a1b5e8 commit c30d49a

File tree

7 files changed

+33
-69
lines changed

7 files changed

+33
-69
lines changed

assets/scss/app.scss

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,29 @@ header ul.nav li {
7272
margin-bottom: 0
7373
}
7474

75+
header .locales {
76+
min-width: 190px;
77+
}
7578
header .locales a {
76-
padding-right: 10px
79+
color: #212529;
80+
padding: 3px 15px;
81+
}
82+
header .locales a small {
83+
border-radius: 4px;
84+
border: 2px solid #dee2e6;
85+
color: #7b8a8b;
86+
float: left;
87+
font-size: 12px;
88+
line-height: 1.1;
89+
margin: 2px 10px 0 0;
90+
min-width: 26px;
91+
padding: 0px 3px;
92+
text-align: center;
93+
text-transform: uppercase;
94+
}
95+
header .locales .active small,
96+
header .locales a:hover small {
97+
color: inherit;
7798
}
7899

79100
.body-container {

public/build/2.88407626.js

Lines changed: 0 additions & 42 deletions
This file was deleted.

public/build/app.956651a3.css

Lines changed: 0 additions & 18 deletions
This file was deleted.

public/build/entrypoints.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"/build/app.d968f7b4.js"
99
],
1010
"css": [
11-
"/build/app.956651a3.css"
11+
"/build/app.b82aa2d9.css"
1212
]
1313
},
1414
"login": {
@@ -22,7 +22,7 @@
2222
"js": [
2323
"/build/runtime.1ba6bf05.js",
2424
"/build/0.c90fd7d1.js",
25-
"/build/2.88407626.js",
25+
"/build/2.efa1b34f.js",
2626
"/build/admin.fcbdf98b.js"
2727
],
2828
"css": [
@@ -43,9 +43,9 @@
4343
"/build/0.c90fd7d1.js": "sha384-FA3+8ecenjmV1Y751s0fKxGBNtyLBA8hDY4sqFoqvsCPOamLlA5ckhRBttBg1esp",
4444
"/build/1.a7e6a099.js": "sha384-Hzl+LtW/AmgisLfOcC+iJavxliy1Jo+6ZHQx6tpI+a7rAiHmtpwQXjNJ3S++W8fD",
4545
"/build/app.d968f7b4.js": "sha384-aBTepzTnPbLJJHay7+GXJjWy44Rr8TP/pDNaHnK+iV8OO9eMPRlWl6Xozx3AoIAD",
46-
"/build/app.956651a3.css": "sha384-xl0uSYZbOM6LJel0KzxxR775djP/OfHetuMP3CQ4P2u9nR22DNTzQiZSn/KpBEVq",
46+
"/build/app.b82aa2d9.css": "sha384-g1ZExByIuyZaSMNREM2zEeUY8q4/WgPcnP08HQKc+NLfIZfKoxdgFGjENSS+J0po",
4747
"/build/login.accd2411.js": "sha384-AnahE1JksyOZbxe/Gdg1twmMPucW4F1llK9OftiRo/Ud2L1ShQPtBLuN4MoCLb0f",
48-
"/build/2.88407626.js": "sha384-9dl5Ww46LD3oNY6DRlrBC55BAIxek/WM9UtDZkHqYYhEArp2bhE92WX47hO8hKL1",
48+
"/build/2.efa1b34f.js": "sha384-9dl5Ww46LD3oNY6DRlrBC55BAIxek/WM9UtDZkHqYYhEArp2bhE92WX47hO8hKL1",
4949
"/build/admin.fcbdf98b.js": "sha384-WUjuA0eQneXh3lch2au/1PamF7QluJ058id0ulV18pPtYqth8m+Rj7wnnUi7e0Sm",
5050
"/build/admin.5cc2ebf1.css": "sha384-ilLLAgcQxfeIVl6jV3AsZ2jmrWwgECQptl9HYwqc2NpYuTl6FEW46DBpDk5Q76sp",
5151
"/build/search.9f97b142.js": "sha384-5s1TWKIOKURbmNDZ7T8WvjCndmbonvVe69HxL2fY+mfXu5bEEN829itXQLf5eiLO"

public/build/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"build/0.c90fd7d1.js": "/build/0.c90fd7d1.js",
33
"build/1.a7e6a099.js": "/build/1.a7e6a099.js",
4-
"build/2.88407626.js": "/build/2.88407626.js",
4+
"build/2.efa1b34f.js": "/build/2.efa1b34f.js",
55
"build/admin.css": "/build/admin.5cc2ebf1.css",
66
"build/admin.js": "/build/admin.fcbdf98b.js",
7-
"build/app.css": "/build/app.956651a3.css",
7+
"build/app.css": "/build/app.b82aa2d9.css",
88
"build/app.js": "/build/app.d968f7b4.js",
99
"build/login.js": "/build/login.accd2411.js",
1010
"build/runtime.js": "/build/runtime.1ba6bf05.js",

src/Twig/AppExtension.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class AppExtension extends AbstractExtension
3636
public function __construct(Markdown $parser, string $locales)
3737
{
3838
$this->parser = $parser;
39-
$this->localeCodes = explode('|', $locales);
39+
40+
$localeCodes = explode('|', $locales);
41+
sort($localeCodes);
42+
$this->localeCodes = $localeCodes;
4043
}
4144

4245
/**

templates/base.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@
9191
</a>
9292
<ul class="dropdown-menu locales" role="menu" aria-labelledby="locales">
9393
{% for locale in locales() %}
94-
<li {% if app.request.locale == locale.code %}aria-checked="true" class="active"{% else %}aria-checked="false"{% endif %} role="menuitem"><a href="{{ path(app.request.get('_route', 'blog_index'), app.request.get('_route_params', [])|merge({_locale: locale.code})) }}">{{ locale.name|capitalize }}</a></li>
94+
<li {% if app.request.locale == locale.code %}aria-checked="true" class="active"{% else %}aria-checked="false"{% endif %} role="menuitem"><a href="{{ path(app.request.get('_route', 'blog_index'), app.request.get('_route_params', [])|merge({_locale: locale.code})) }}">{{ locale.name|capitalize }} <small>{{ locale.code[0:2] }}</small></a></li>
9595
{% endfor %}
9696
</ul>
9797
</li>

0 commit comments

Comments
 (0)