feat: setting for disabling animations

This commit is contained in:
Filipe Medeiros 2021-10-12 10:42:32 +01:00
parent 31fde1f29c
commit 660788c78e
6 changed files with 133 additions and 64 deletions

View File

@ -1,10 +1,6 @@
<template> <template>
<div class="uk-flex"> <div class="uk-flex">
<Menu <Menu style="flexShrink: 0" />
style="flexShrink: 0"
:collapsed="menuCollapsed"
:toggleCollapsed="() => (menuCollapsed = !menuCollapsed)"
/>
<main <main
class="uk-container uk-container-expand" class="uk-container uk-container-expand"
style="height: 100vh; overflow: scroll; flex: 1;" style="height: 100vh; overflow: scroll; flex: 1;"
@ -13,7 +9,7 @@
> >
<router-view v-slot="{ Component }"> <router-view v-slot="{ Component }">
<keep-alive :max="5"> <keep-alive :max="5">
<component :is="Component" :key="$route.fullPath" :menuCollapsed="menuCollapsed" /> <component :is="Component" :key="$route.fullPath" />
</keep-alive> </keep-alive>
</router-view> </router-view>
@ -44,9 +40,6 @@ export default {
const isMobile = useIsMobile(); const isMobile = useIsMobile();
return { isMobile }; return { isMobile };
}, },
data() {
return { menuCollapsed: false };
},
mounted() { mounted() {
if (window.location.pathname === "/" || window.location.pathname.length == 0) if (window.location.pathname === "/" || window.location.pathname.length == 0)
switch (this.getPreferenceString("homepage", "trending")) { switch (this.getPreferenceString("homepage", "trending")) {

View File

@ -1,26 +1,41 @@
<template> <template>
<div <div
id="menu-desktop"
class="uk-height-viewport uk-flex uk-flex-column uk-flex-middle" class="uk-height-viewport uk-flex uk-flex-column uk-flex-middle"
:class="{ 'collapse-text': collapseText }" :class="{ 'collapse-text': collapseText }"
style="transition: width 400ms; padding: 32px 24px; height: 100vh;" style="padding: 32px 24px; height: 100vh;"
:style="{ width: collapsed ? '78px' : '291px', backgroundColor: secondaryBackgroundColor }" :style="{
width: collapsed ? '78px' : '291px',
backgroundColor: secondaryBackgroundColor,
transition: enableAnimations ? 'width 400ms' : 'none',
}"
> >
<div <div
class="uk-width-1-1 uk-flex uk-flex-middle uk-flex-between" class="uk-width-1-1 uk-flex uk-flex-middle uk-flex-between"
style="margin-bottom: 100px; height: 50px; transition: padding 400ms; padding: 0 14px;" style="margin-bottom: 100px; height: 50px;"
:style="collapseText ? 'padding: 0;' : {}" :style="{ padding: collapseText ? '0' : '0 14px', transition: enableAnimations ? 'padding 400ms;' : '' }"
:class="{ 'uk-flex uk-flex-center': collapsed }" :class="{ 'uk-flex uk-flex-center': collapsed }"
> >
<div style="transition: padding 400ms; flex: 1 0 30px;" :style="collapseText ? 'padding: 0 8px;' : {}"> <div
style="flex: 1 0 30px;"
:style="{ padding: collapseText ? '0 8px' : '', transition: enableAnimations ? 'padding 400ms;' : '' }"
>
<font-awesome-icon class="button highlight" @click="toggleCollapsed()" icon="bars" /> <font-awesome-icon class="button highlight" @click="toggleCollapsed()" icon="bars" />
</div> </div>
<div <div
class="uk-flex uk-flex-middle" class="uk-flex uk-flex-middle"
style="gap: 16px; transition: transform 300ms, gap 300ms;" :style="{
:style="collapseText ? 'transform: scale3d(0, 0, 0); gap: 0;' : 'transition-delay: 170ms'" transform: collapseText ? 'scale3d(0, 0, 0)' : 'none',
gap: collapseText ? '0' : '16px',
transitionDelay: !collapseText && enableAnimations ? '170ms' : 'none',
transition: enableAnimations ? 'transform 300ms, gap 300ms' : 'none',
}"
v-if="!hideText" v-if="!hideText"
> >
<img src="/img/pipedPlay.svg" :class="{ 'piped-play': !hideText }" /> <img
src="/img/pipedPlay.svg"
:class="{ 'piped-play': !hideText, 'enable-animations': enableAnimations }"
/>
<img src="/img/piped.svg" /> <img src="/img/piped.svg" />
</div> </div>
@ -32,6 +47,7 @@
<router-link <router-link
to="/" to="/"
class="highlight sidebar-link uk-flex" class="highlight sidebar-link uk-flex"
:class="{ 'enable-animations': enableAnimations }"
:style="collapseText ? 'padding: 6px 8px;' : {}" :style="collapseText ? 'padding: 6px 8px;' : {}"
> >
<font-awesome-icon icon="fire" /> <font-awesome-icon icon="fire" />
@ -39,13 +55,21 @@
</router-link> </router-link>
</li> </li>
<li> <li>
<router-link to="/feed" class="highlight sidebar-link uk-flex"> <router-link
to="/feed"
class="highlight sidebar-link uk-flex"
:class="{ 'enable-animations': enableAnimations }"
>
<font-awesome-icon icon="rss" /> <font-awesome-icon icon="rss" />
<span v-if="!hideText" v-t="'titles.feed'" /> <span v-if="!hideText" v-t="'titles.feed'" />
</router-link> </router-link>
</li> </li>
<li> <li>
<router-link to="/subscriptions" class="highlight sidebar-link uk-flex"> <router-link
to="/subscriptions"
class="highlight sidebar-link uk-flex"
:class="{ 'enable-animations': enableAnimations }"
>
<font-awesome-icon icon="heart" /> <font-awesome-icon icon="heart" />
<span v-if="!hideText" v-t="'titles.subscriptions'" /> <span v-if="!hideText" v-t="'titles.subscriptions'" />
</router-link> </router-link>
@ -56,6 +80,7 @@
<router-link <router-link
to="/preferences" to="/preferences"
class="highlight sidebar-link uk-width-1-1 uk-flex uk-flex-middle" class="highlight sidebar-link uk-width-1-1 uk-flex uk-flex-middle"
:class="{ 'enable-animations': enableAnimations }"
style="text-decoration: none;" style="text-decoration: none;"
> >
<font-awesome-icon icon="cog" /> <font-awesome-icon icon="cog" />
@ -64,17 +89,20 @@
<button <button
class="highlight logout-button button sidebar-link uk-width-1-1 uk-flex uk-flex-center uk-flex-middle" class="highlight logout-button button sidebar-link uk-width-1-1 uk-flex uk-flex-center uk-flex-middle"
:class="{ 'enable-animations': enableAnimations }"
:style="{ backgroundColor: backgroundColor }" :style="{ backgroundColor: backgroundColor }"
style="border-radius: 9999px; border: none; margin-top: 20px;" style="border-radius: 9999px; border: none; margin-top: 20px;"
@click="logout" @click="logout()"
> >
<span v-if="!hideText">Log out</span> <span v-if="!hideText" v-t="'actions.logout'" />
<font-awesome-icon icon="sign-out-alt" /> <font-awesome-icon icon="sign-out-alt" />
</button> </button>
</div> </div>
</template> </template>
<script> <script>
import { useMenuCollapsed } from "../store";
export default { export default {
data() { data() {
return { return {
@ -82,18 +110,14 @@ export default {
hideText: this.collapsed, hideText: this.collapsed,
}; };
}, },
props: { setup() {
collapsed: Boolean, const { menuCollapsed, toggleCollapsed } = useMenuCollapsed();
toggleCollapsed: Function, return { collapsed: menuCollapsed, toggleCollapsed };
},
methods: {
logout() {
alert("logging out");
},
}, },
watch: { watch: {
collapsed(collapsed) { collapsed(_collapsed) {
if (collapsed) { if (this.enableAnimations) {
if (_collapsed) {
this.collapseText = true; this.collapseText = true;
setTimeout(() => { setTimeout(() => {
this.hideText = true; this.hideText = true;
@ -104,6 +128,20 @@ export default {
this.collapseText = false; this.collapseText = false;
}, 0); }, 0);
} }
} else {
this.hideText = _collapsed;
this.collapseText = _collapsed;
}
},
},
methods: {
logout() {
alert("logging out");
},
},
computed: {
enableAnimations(_this) {
return !_this.getPreferenceBoolean("disableAnimations", true);
}, },
}, },
}; };
@ -146,52 +184,54 @@ export default {
} }
} }
.piped-play { #menu-desktop .piped-play.enable-animations {
animation: bump 300ms ease-in-out; animation: bump 300ms ease-in-out;
animation-delay: 700ms !important; animation-delay: 700ms !important;
} }
@media (prefers-reduced-motion) { @media (prefers-reduced-motion) {
.piped-play { #menu-desktop .piped-play {
animation: none; animation: none;
} }
} }
.logout-button { #menu-desktop .logout-button {
white-space: nowrap; white-space: nowrap;
} }
.button:hover { #menu-desktop .button:hover {
cursor: pointer; cursor: pointer;
} }
.highlight { #menu-desktop .highlight {
color: #abb2c6; color: #abb2c6;
} }
.sidebar-link { #menu-desktop .sidebar-link {
gap: 14px !important; gap: 14px !important;
padding: 10px 12px; padding: 10px 12px;
border-radius: 12px; border-radius: 12px;
}
#menu-desktop .sidebar-link.enable-animations {
transition: padding 400ms, gap 400ms; transition: padding 400ms, gap 400ms;
} }
.collapse-text .sidebar-link { #menu-desktop.collapse-text .sidebar-link {
padding: 6px; padding: 6px;
gap: 0px !important; gap: 0px !important;
} }
.sidebar-link span { #menu-desktop .sidebar-link.enable-animations span {
transition: font-size 400ms; transition: font-size 400ms;
} }
.collapse-text .sidebar-link span { .collapse-text .sidebar-link span {
font-size: 0; font-size: 0;
} }
.highlight:hover, #menu-desktop .highlight:hover,
.router-link-active { #menu-desktop .router-link-active {
color: #fff; color: #fff;
} }
.router-link-active { #menu-desktop .router-link-active {
background: linear-gradient(to right, #da22ff, #9733ee); background: linear-gradient(to right, #da22ff, #9733ee);
} }
</style> </style>

View File

@ -1,5 +1,6 @@
<template> <template>
<div <div
id="menu-mobile"
class="uk-flex uk-flex-column uk-flex-middle uk-position-fixed uk-position-top" class="uk-flex uk-flex-column uk-flex-middle uk-position-fixed uk-position-top"
:class="{ 'uk-height-viewport': !collapsed }" :class="{ 'uk-height-viewport': !collapsed }"
style="padding: 24px 12px; width: 100vw; box-sizing: border-box; z-index: 9999; transition: min-height 40ms, height 400ms; overflow: hidden;" style="padding: 24px 12px; width: 100vw; box-sizing: border-box; z-index: 9999; transition: min-height 40ms, height 400ms; overflow: hidden;"
@ -58,13 +59,15 @@
style="border-radius: 9999px; border: none; margin-top: 20px;" style="border-radius: 9999px; border: none; margin-top: 20px;"
@click="logout" @click="logout"
> >
<span v-t="'actions.logout'">Log out</span> <span v-t="'actions.logout'" />
<font-awesome-icon icon="sign-out-alt" /> <font-awesome-icon icon="sign-out-alt" />
</button> </button>
</div> </div>
</template> </template>
<script> <script>
import { useMenuCollapsed } from "../store";
export default { export default {
data() { data() {
return { return {
@ -72,10 +75,12 @@ export default {
hideText: false, hideText: false,
}; };
}, },
props: {
collapsed: Boolean,
toggleCollapsed: Function,
setup() {
const { menuCollapsed, toggleCollapsed } = useMenuCollapsed();
return { collapsed: menuCollapsed, toggleCollapsed };
},
props: {
searchText: String, searchText: String,
onKeyUp: Function, onKeyUp: Function,
onInputFocus: Function, onInputFocus: Function,
@ -87,6 +92,11 @@ export default {
alert("logging out"); alert("logging out");
}, },
}, },
computed: {
disableAnimations(_this) {
return _this.getPreferenceBoolean("disableAnimations", false);
},
},
}; };
</script> </script>
@ -127,7 +137,7 @@ export default {
} }
} }
.piped-play { #menu-mobile .piped-play {
animation: bump 300ms ease-in-out 500ms; animation: bump 300ms ease-in-out 500ms;
} }
@media (prefers-reduced-motion) { @media (prefers-reduced-motion) {
@ -136,37 +146,39 @@ export default {
} }
} }
.logout-button { #menu-mobile .logout-button {
white-space: nowrap; white-space: nowrap;
} }
.button:hover { #menu-mobile .button:hover {
cursor: pointer; cursor: pointer;
} }
.highlight { #menu-mobile .highlight {
color: #abb2c6; color: #abb2c6;
} }
.sidebar-link { #menu-mobile .sidebar-link {
gap: 14px !important; gap: 14px !important;
padding: 10px 12px; padding: 10px 12px;
border-radius: 12px; border-radius: 12px;
transition: padding 500ms, gap 500ms; }
#menu-mobile .sidebar-link.enable-animations {
transition: padding 400ms, gap 400ms;
} }
.sidebar-link span { #menu-mobile .sidebar-link span {
transition: font-size 500ms, padding 500ms; transition: font-size 500ms, padding 500ms;
} }
.collapse-text .sidebar-link span { #menu-mobile.collapse-text .sidebar-link span {
font-size: 0; font-size: 0;
} }
.highlight:hover, #menu-mobile .highlight:hover,
.router-link-active { #menu-mobile .router-link-active {
color: #fff; color: #fff;
} }
.router-link-active { #menu-mobile .router-link-active {
background: linear-gradient(to right, #da22ff, #9733ee); background: linear-gradient(to right, #da22ff, #9733ee);
} }
</style> </style>

View File

@ -176,6 +176,16 @@
<option value="avc">AVC (h.264)</option> <option value="avc">AVC (h.264)</option>
</select> </select>
<br /> <br />
<label for="disableAnimations"><b v-t="'preferences.disable_animations'"/></label>
<br />
<input
id="disableAnimations"
v-model="disableAnimations"
class="uk-checkbox"
type="checkbox"
@change="onChange($event)"
/>
<br />
<label for="chkDisableLBRY"><b v-t="'actions.disable_lbry'"/></label> <label for="chkDisableLBRY"><b v-t="'actions.disable_lbry'"/></label>
<br /> <br />
<input id="chkDisableLBRY" v-model="disableLBRY" class="uk-checkbox" type="checkbox" @change="onChange($event)" /> <input id="chkDisableLBRY" v-model="disableLBRY" class="uk-checkbox" type="checkbox" @change="onChange($event)" />
@ -273,6 +283,7 @@ export default {
enabledCodecs: ["av1", "vp9", "avc"], enabledCodecs: ["av1", "vp9", "avc"],
disableLBRY: false, disableLBRY: false,
proxyLBRY: false, proxyLBRY: false,
disableAnimations: false,
}; };
}, },
activated() { activated() {
@ -361,6 +372,7 @@ export default {
this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(","); this.enabledCodecs = this.getPreferenceString("enabledCodecs", "av1,vp9,avc").split(",");
this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false); this.disableLBRY = this.getPreferenceBoolean("disableLBRY", false);
this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false); this.proxyLBRY = this.getPreferenceBoolean("proxyLBRY", false);
this.disableAnimations = this.getPreferenceBoolean("disableAnimations", false);
if (this.selectedLanguage != "en") { if (this.selectedLanguage != "en") {
try { try {
this.CountryMap = await import("@/utils/CountryMaps/" + this.selectedLanguage + ".json").then( this.CountryMap = await import("@/utils/CountryMaps/" + this.selectedLanguage + ".json").then(
@ -414,6 +426,7 @@ export default {
localStorage.setItem("enabledCodecs", this.enabledCodecs.join(",")); localStorage.setItem("enabledCodecs", this.enabledCodecs.join(","));
localStorage.setItem("disableLBRY", this.disableLBRY); localStorage.setItem("disableLBRY", this.disableLBRY);
localStorage.setItem("proxyLBRY", this.proxyLBRY); localStorage.setItem("proxyLBRY", this.proxyLBRY);
localStorage.setItem("disableAnimations", this.disableAnimations);
if (shouldReload) window.location.reload(); if (shouldReload) window.location.reload();
} }

View File

@ -74,7 +74,8 @@
"instance_name": "Instance Name", "instance_name": "Instance Name",
"instance_locations": "Instance Locations", "instance_locations": "Instance Locations",
"has_cdn": "Has CDN?", "has_cdn": "Has CDN?",
"ssl_score": "SSL Score" "ssl_score": "SSL Score",
"disable_animations": "Disable animations"
}, },
"login": { "login": {
"username": "Username", "username": "Username",

View File

@ -9,3 +9,13 @@ export function useIsMobile() {
return isMobile; return isMobile;
} }
const menuCollapsed = ref(false);
export function useMenuCollapsed() {
return {
menuCollapsed,
toggleCollapsed: () => {
menuCollapsed.value = !menuCollapsed.value;
},
};
}