Improve settings page's UI/UX on mobile

This commit is contained in:
Louis Lam 2022-03-04 23:20:42 +08:00
parent e3a0eaf6af
commit 88c3d952d3
3 changed files with 37 additions and 14 deletions

View File

@ -157,7 +157,7 @@ export default {
overflow: hidden; overflow: hidden;
text-decoration: none; text-decoration: none;
&.router-link-exact-active { &.router-link-exact-active, &.active {
color: $primary; color: $primary;
font-weight: bold; font-weight: bold;
} }

View File

@ -6,7 +6,7 @@
<div class="shadow-box"> <div class="shadow-box">
<div class="row"> <div class="row">
<div class="settings-menu"> <div v-if="showSubMenu" class="settings-menu col-lg-3 col-md-5">
<router-link <router-link
v-for="(item, key) in subMenus" v-for="(item, key) in subMenus"
:key="key" :key="key"
@ -17,8 +17,8 @@
</div> </div>
</router-link> </router-link>
</div> </div>
<div class="settings-content"> <div class="settings-content col-lg-9 col-md-7">
<div class="settings-content-header"> <div v-if="currentPage" class="settings-content-header">
{{ subMenus[currentPage].title }} {{ subMenus[currentPage].title }}
</div> </div>
<div class="mx-3"> <div class="mx-3">
@ -41,7 +41,6 @@ export default {
data() { data() {
return { return {
show: true, show: true,
settings: {}, settings: {},
settingsLoaded: false, settingsLoaded: false,
}; };
@ -52,11 +51,19 @@ export default {
let pathSplit = useRoute().path.split("/"); let pathSplit = useRoute().path.split("/");
let pathEnd = pathSplit[pathSplit.length - 1]; let pathEnd = pathSplit[pathSplit.length - 1];
if (!pathEnd || pathEnd === "settings") { if (!pathEnd || pathEnd === "settings") {
return "general"; return null;
} }
return pathEnd; return pathEnd;
}, },
showSubMenu() {
if (this.$root.isMobile) {
return !this.currentPage;
} else {
return true;
}
},
subMenus() { subMenus() {
return { return {
general: { general: {
@ -84,11 +91,26 @@ export default {
}, },
}, },
watch: {
"$root.isMobile"() {
this.loadGeneralPage();
}
},
mounted() { mounted() {
this.loadSettings(); this.loadSettings();
this.loadGeneralPage();
}, },
methods: { methods: {
// For desktop only, mobile do nothing
loadGeneralPage() {
if (!this.currentPage && !this.$root.isMobile) {
this.$router.push("/settings/general");
}
},
loadSettings() { loadSettings() {
this.$root.getSocket().emit("getSettings", (res) => { this.$root.getSocket().emit("getSettings", (res) => {
this.settings = res.data; this.settings = res.data;
@ -115,7 +137,7 @@ export default {
this.loadSettings(); this.loadSettings();
}); });
}, },
}, }
}; };
</script> </script>
@ -136,9 +158,6 @@ footer {
} }
.settings-menu { .settings-menu {
flex: 0 0 auto;
width: 300px;
a { a {
text-decoration: none !important; text-decoration: none !important;
} }
@ -171,9 +190,6 @@ footer {
} }
.settings-content { .settings-content {
flex: 0 0 auto;
width: calc(100% - 300px);
.settings-content-header { .settings-content-header {
width: calc(100% + 20px); width: calc(100% + 20px);
border-bottom: 1px solid #dee2e6; border-bottom: 1px solid #dee2e6;
@ -187,6 +203,14 @@ footer {
background: $dark-header-bg; background: $dark-header-bg;
border-bottom: 0; border-bottom: 0;
} }
.mobile & {
padding: 15px 0 0 0;
.dark & {
background-color: transparent;
}
}
} }
} }
</style> </style>

View File

@ -70,7 +70,6 @@ const routes = [
children: [ children: [
{ {
path: "general", path: "general",
alias: "",
component: General, component: General,
}, },
{ {