feat: check screen size to enable or disable settings

+ redesign (again!) the playlist cards
This commit is contained in:
geoffrey45
2022-09-17 14:24:05 +03:00
parent fca59751c4
commit 5130f85300
13 changed files with 50 additions and 36 deletions
+3 -2
View File
@@ -8,8 +8,9 @@
:class="{ :class="{
showAltNP: settings.use_sidebar && settings.use_alt_np, showAltNP: settings.use_sidebar && settings.use_alt_np,
disableSidebar: !settings.use_sidebar, disableSidebar: !settings.use_sidebar,
extendWidth: settings.extend_width, extendWidth: settings.extend_width && settings.extend_width_enabled,
isSmall: !xl, isSmall: !xl,
addBorderRight: xxl,
}" }"
> >
<LeftSidebar /> <LeftSidebar />
@@ -33,7 +34,7 @@ import useQStore from "@/stores/queue";
import useModalStore from "@/stores/modal"; import useModalStore from "@/stores/modal";
import useContextStore from "@/stores/context"; import useContextStore from "@/stores/context";
import useSettingsStore from "@/stores/settings"; import useSettingsStore from "@/stores/settings";
import { xl } from "./composables/useBreakpoints"; import { xl, xxl } from "./composables/useBreakpoints";
import handleShortcuts from "@/composables/useKeyboard"; import handleShortcuts from "@/composables/useKeyboard";
import { readLocalStorage, writeLocalStorage } from "@/utils"; import { readLocalStorage, writeLocalStorage } from "@/utils";
+7 -2
View File
@@ -13,8 +13,8 @@
margin: 0 auto; margin: 0 auto;
margin-top: -$small; margin-top: -$small;
max-width: 1720px; max-width: 1720px;
padding-right: $medium; // padding-right: $medium;
border-right: solid 1px $gray4; // border-right: solid 1px $gray4;
padding-top: $small; padding-top: $small;
} }
@@ -24,6 +24,11 @@
max-width: 100%; max-width: 100%;
} }
#app-grid.addBorderRight {
border-right: solid 1px $gray4;
padding-right: $medium;
}
#app-grid.isSmall { #app-grid.isSmall {
grid-template-columns: min-content 1fr; grid-template-columns: min-content 1fr;
grid-template-areas: grid-template-areas:
+1 -1
View File
@@ -45,7 +45,7 @@ $secondary: $gray5;
$danger: $red; $danger: $red;
$track-hover: $gray4; $track-hover: $gray4;
$context: black; $context: black;
$playlist-card-bg: #46474C; $playlist-card-bg: $gray4;
// SVG COLORS // SVG COLORS
$default: $accent; $default: $accent;
+17 -19
View File
@@ -1,21 +1,23 @@
<template> <template>
<router-link <router-link
:to="{ name: 'PlaylistView', params: { pid: props.playlist.playlistid } }" :to="{ name: 'PlaylistView', params: { pid: playlist.playlistid } }"
:playlist="props.playlist"
class="p-card rounded noscroll" class="p-card rounded noscroll"
> >
<img :src="imguri + props.playlist.thumb" /> <img
<div class="overlay rounded pad-lg"> :src="imguri + playlist.thumb"
class="rounded border"
:class="{ noimg: !playlist.thumb }"
/>
<div class="overlay rounded">
<div class="p-name ellip">{{ playlist.name }}</div> <div class="p-name ellip">{{ playlist.name }}</div>
<div class="p-count"> <div class="p-count">
{{ playlist.count + ` ${playlist.count == 1 ? "Track" : "Tracks"}` }} {{ playlist.count + ` ${playlist.count === 1 ? "Track" : "Tracks"}` }}
</div> </div>
</div> </div>
</router-link> </router-link>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import play from "@/composables/usePlayFrom";
import { paths } from "../../config"; import { paths } from "../../config";
import { Playlist } from "../../interfaces"; import { Playlist } from "../../interfaces";
@@ -28,28 +30,24 @@ const props = defineProps<{
<style lang="scss"> <style lang="scss">
.p-card { .p-card {
position: relative;
background-color: $playlist-card-bg; background-color: $playlist-card-bg;
height: 10rem; display: grid;
grid-template-rows: 1fr max-content;
padding: 1rem;
gap: $small;
img { img {
width: 100%; width: 100%;
height: 100%; aspect-ratio: 1;
aspect-ratio: 1/1.2;
object-fit: cover; object-fit: cover;
transition: all 0.5s ease; transition: all 0.5s ease;
} }
img.noimg {
outline: 1px solid $gray2;
}
.overlay { .overlay {
position: absolute;
top: 0;
background-image: linear-gradient(
to top,
rgba(0, 0, 0, 0.55),
transparent 60%
);
height: 100%;
width: 100%;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
justify-content: flex-end; justify-content: flex-end;
+1 -1
View File
@@ -15,7 +15,7 @@
</div> </div>
<div class="options"> <div class="options">
<Switch <Switch
v-if="setting.type == SettingType.switch" v-if="setting.type == SettingType.binary"
@click="setting.action()" @click="setting.action()"
:state="setting.source()" :state="setting.source()"
/> />
+7 -3
View File
@@ -1,7 +1,11 @@
import { useBreakpoints, breakpointsTailwind } from "@vueuse/core"; import { useBreakpoints } from "@vueuse/core";
const breakpoints = useBreakpoints(breakpointsTailwind); const breakpoints = useBreakpoints({
xl: 1536,
xxl: 1720,
});
const xl = breakpoints.greater("xl"); const xl = breakpoints.greater("xl");
const xxl = breakpoints.greater("xxl");
export { xl }; export { xl, xxl };
+1 -1
View File
@@ -2,7 +2,7 @@ export enum SettingType {
text, text,
select, select,
multiselect, multiselect,
switch, binary,
} }
export interface SettingOption { export interface SettingOption {
+2 -1
View File
@@ -5,9 +5,10 @@ const settings = useSettingsStore;
const extend_to_full_width: Setting = { const extend_to_full_width: Setting = {
title: "Extend app to full screen width", title: "Extend app to full screen width",
type: SettingType.switch, type: SettingType.binary,
source: () => settings().extend_width, source: () => settings().extend_width,
action: () => settings().toggleExtendWidth(), action: () => settings().toggleExtendWidth(),
inactive: () => !settings().extend_width_enabled,
}; };
export default [extend_to_full_width]; export default [extend_to_full_width];
+1 -1
View File
@@ -5,7 +5,7 @@ const settings = useSettingsStore;
const use_alt_np: Setting = { const use_alt_np: Setting = {
title: "Use alternate now playing card", title: "Use alternate now playing card",
type: SettingType.switch, type: SettingType.binary,
source: () => settings().use_alt_np, source: () => settings().use_alt_np,
inactive: () => settings().disable_show_alt_np, inactive: () => settings().disable_show_alt_np,
action: () => settings().toggleUseRightNP(), action: () => settings().toggleUseRightNP(),
+1 -1
View File
@@ -5,7 +5,7 @@ const settings = useSettingsStore;
const use_sidebar: Setting = { const use_sidebar: Setting = {
title: "Use right sidebar", title: "Use right sidebar",
type: SettingType.switch, type: SettingType.binary,
source: () => settings().use_sidebar, source: () => settings().use_sidebar,
action: () => settings().toggleDisableSidebar(), action: () => settings().toggleDisableSidebar(),
}; };
+2 -1
View File
@@ -2,9 +2,10 @@ import { computed } from "vue";
import { ref } from "@vue/reactivity"; import { ref } from "@vue/reactivity";
const content_width = ref(0); const content_width = ref(0);
const window_width = ref(0);
const isSmall = computed(() => { const isSmall = computed(() => {
return content_width.value < 700; return content_width.value < 700;
}); });
export { content_width, isSmall }; export { content_width, window_width, isSmall };
+6 -2
View File
@@ -1,3 +1,4 @@
import { xxl, xl } from "@/composables/useBreakpoints";
import { defineStore } from "pinia"; import { defineStore } from "pinia";
export default defineStore("settings", { export default defineStore("settings", {
@@ -20,17 +21,20 @@ export default defineStore("settings", {
}, },
getters: { getters: {
show_alt_np(): boolean { show_alt_np(): boolean {
return this.use_sidebar && this.use_alt_np; return xl.value && this.use_sidebar && this.use_alt_np;
}, },
show_default_np(): boolean { show_default_np(): boolean {
return !this.show_alt_np; return !this.show_alt_np;
}, },
disable_show_alt_np(): boolean { disable_show_alt_np(): boolean {
return !this.use_sidebar; return !xl.value || !this.use_sidebar;
}, },
hide_queue_page(): boolean { hide_queue_page(): boolean {
return this.use_sidebar; return this.use_sidebar;
}, },
extend_width_enabled(): boolean {
return xxl.value
},
}, },
persist: true, persist: true,
}); });
+1 -1
View File
@@ -24,7 +24,7 @@ const pStore = usePStore();
scrollbar-color: $gray2 transparent; scrollbar-color: $gray2 transparent;
.grid { .grid {
grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
gap: 1rem; gap: 1rem;
} }
} }