Skip to content

Commit 4005171

Browse files
committed
Fixes styling and layout issues for language switcher.
Shows user drop down for all users.
1 parent b56ba92 commit 4005171

File tree

3 files changed

+34
-45
lines changed

3 files changed

+34
-45
lines changed

kolibri/core/assets/src/styles/main.styl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ html
2828
// https://davidwalsh.name/html5-boilerplate
2929
font-size: 100%
3030
text-size-adjust: 100%
31-
overflow: hidden
3231
box-sizing: border-box
33-
32+
overflow-y: scroll
3433
// from normalize v5
3534
line-height: 1.15
3635

kolibri/core/assets/src/views/app-bar/index.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
<div slot="actions">
1111
<slot name="app-bar-actions"/>
1212
<ui-button
13-
v-if="isUserLoggedIn"
1413
icon="person"
1514
type="primary"
1615
color="primary"

kolibri/core/assets/src/views/language-switcher/index.vue

Lines changed: 33 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,28 @@
22

33
<div>
44
<div v-if="footer" class="page-footer">
5-
<div class="lang-container" :style="isMobile ? { width: '40%' } : {}">
6-
<p class="prompt" v-if="!isMobile">{{ $tr('changeLanguagePrompt') }}</p>
7-
<p v-for="language in footerLanguageOptions" :class="selectedLanguage.code===language.code ? 'selected' : 'choice'" @click="setAndSwitchLanguage(language)">
8-
{{ language.name }}
9-
</p>
5+
<div>
6+
<ul class="language-list">
7+
<li v-for="language in languageOptions" :class="selectedLanguage===language.code ? 'selected item' : 'choice item'" @click="setAndSwitchLanguage(language.code)">
8+
{{ language.name }}
9+
</li>
10+
</ul>
1011
</div>
11-
<k-button style="margin-top: 0" :text="$tr('moreLanguageButtonText')" :raised="false" @click="setModalOpen"/>
1212
</div>
1313
<core-modal
1414
v-if="showModal"
1515
:title="$tr('changeLanguageModalHeader')"
1616
@cancel="closeModal">
1717
<p>{{ $tr('changeLanguageSubHeader') }}</p>
18-
<p v-for="language in languageOptions" :class="selectedLanguage.code===language.code ? 'selected' : 'choice'" @click="selectedLanguage=language">
19-
{{ language.name }}
20-
</p>
18+
<k-radio-button
19+
v-for="language in languageOptions"
20+
class="choice"
21+
:key="language.code"
22+
:radiovalue="language.code"
23+
:value="selectedLanguage"
24+
:label="language.name"
25+
v-model="selectedLanguage"
26+
/>
2127
<div class="footer">
2228
<k-button :text="$tr('cancelButtonText')" :raised="false" :disabled="disabled" @click="closeModal"/>
2329
<k-button :text="$tr('confirmButtonText')" :primary="true" :disabled="disabled" @click="switchLanguage"/>
@@ -32,18 +38,15 @@
3238
3339
import coreModal from 'kolibri.coreVue.components.coreModal';
3440
import kButton from 'kolibri.coreVue.components.kButton';
41+
import kRadioButton from 'kolibri.coreVue.components.kRadioButton';
3542
import { httpClient } from 'kolibri.client';
3643
import { availableLanguages, currentLanguage } from 'kolibri.utils.i18n';
37-
import responsiveWindow from 'kolibri.coreVue.mixins.responsiveWindow';
3844
export default {
3945
name: 'languageSwitcherModalDialog',
40-
mixins: [responsiveWindow],
41-
components: { coreModal, kButton },
46+
components: { coreModal, kButton, kRadioButton },
4247
$trs: {
4348
changeLanguageModalHeader: 'Change language',
4449
changeLanguageSubHeader: 'Select the language you want to view Kolibri in',
45-
changeLanguagePrompt: 'Select language:',
46-
moreLanguageButtonText: 'More languages',
4750
cancelButtonText: 'Cancel',
4851
confirmButtonText: 'Confirm',
4952
},
@@ -67,22 +70,12 @@
6770
})
6871
.map(key => availableLanguages[key]);
6972
},
70-
footerLanguageOptions() {
71-
if (this.isMobile) {
72-
return this.languageOptions.filter(lang => lang.code !== currentLanguage).slice(0, 3);
73-
}
74-
return this.languageOptions.slice(0, 6);
75-
},
7673
currentLanguageName() {
7774
return availableLanguages[currentLanguage].name;
7875
},
7976
showModal() {
80-
console.log(this.internalModalOpen);
8177
return this.modalOpen || this.internalModalOpen;
8278
},
83-
isMobile() {
84-
return this.windowSize.breakpoint <= 1;
85-
},
8679
},
8780
props: {
8881
footer: {
@@ -96,15 +89,15 @@
9689
},
9790
data: () => ({
9891
disabled: false,
99-
selectedLanguage: availableLanguages[currentLanguage],
92+
selectedLanguage: currentLanguage,
10093
internalModalOpen: false,
10194
}),
10295
methods: {
10396
switchLanguage() {
10497
this.disabled = true;
10598
const path = this.Kolibri.urls['kolibri:set_language']();
10699
const entity = {
107-
language: this.selectedLanguage.code,
100+
language: this.selectedLanguage,
108101
};
109102
httpClient({
110103
path,
@@ -113,8 +106,8 @@
113106
global.location.reload(true);
114107
});
115108
},
116-
setAndSwitchLanguage(language) {
117-
this.selectedLanguage = language;
109+
setAndSwitchLanguage(languageCode) {
110+
this.selectedLanguage = languageCode;
118111
this.switchLanguage();
119112
},
120113
closeModal() {
@@ -138,33 +131,31 @@
138131
h1, p
139132
color: black
140133
141-
.more-button
142-
float: left
143-
144-
.selected
145-
font-weight: bold
146-
147134
.choice
148135
color: $core-action-normal
149-
text-decoration: underline $core-action-normal
150-
cursor: pointer
151136
137+
.selected
138+
font-weight: bold
152139
153140
.page-footer
154141
padding-left: 32px
155142
padding-top: 16px
156143
padding-bottom: 16px
157-
.lang-container
158-
display: inline-block
159-
p
160-
float: left
161-
padding-left: 10px
162-
margin: 0
163144
button
164145
float: right
165146
position: absolute
166147
167148
.prompt
168149
padding-right: 16px
169150
151+
.language-list
152+
list-style: none
153+
margin: 0
154+
padding: 0
155+
156+
.item
157+
display: inline-block
158+
padding-top: 6px
159+
padding-right: 20px
160+
170161
</style>

0 commit comments

Comments
 (0)