Skip to content

Commit

Permalink
feat: add new setting to disable blur for low-performance device (#2561)
Browse files Browse the repository at this point in the history
  • Loading branch information
shuuji3 committed Jan 18, 2024
1 parent b0125eb commit f79d84a
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 4 deletions.
6 changes: 5 additions & 1 deletion components/main/MainContent.vue
Expand Up @@ -10,6 +10,7 @@ defineProps<{
const container = ref()
const route = useRoute()
const userSettings = useUserSettings()
const { height: windowHeight } = useWindowSize()
const { height: containerHeight } = useElementBounding(container)
const wideLayout = computed(() => route.meta.wideLayout ?? false)
Expand All @@ -26,10 +27,13 @@ const containerClass = computed(() => {
<template>
<div ref="container" :class="containerClass">
<div
sticky top-0 z10 backdrop-blur
sticky top-0 z10
pt="[env(safe-area-inset-top,0)]"
bg="[rgba(var(--rgb-bg-base),0.7)]"
class="native:lg:w-[calc(100vw-5rem)] native:xl:w-[calc(135%+(100vw-1200px)/2)]"
:class="{
'backdrop-blur': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
}"
>
<div flex justify-between px5 py2 :class="{ 'xl:hidden': $route.name !== 'tag' }" class="native:xl:flex" border="b base">
<div flex gap-3 items-center :overflow-hidden="!noOverflowHidden ? '' : false" py2 w-full>
Expand Down
9 changes: 8 additions & 1 deletion components/modal/ModalDialog.vue
Expand Up @@ -56,6 +56,7 @@ const visible = defineModel<boolean>({ required: true })
const deactivated = useDeactivated()
const route = useRoute()
const userSettings = useUserSettings()
/** scrollable HTML element */
const elDialogMain = ref<HTMLDivElement>()
Expand Down Expand Up @@ -156,7 +157,13 @@ useEventListener('keydown', (e: KeyboardEvent) => {
<!-- corresponding to issue: #106, so please don't remove it. -->

<!-- Mask layer: blur -->
<div class="dialog-mask" absolute inset-0 z-0 bg-transparent opacity-100 backdrop-filter backdrop-blur-sm touch-none />
<div
class="dialog-mask"
:class="{
'backdrop-blur-sm': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
}"
absolute inset-0 z-0 bg-transparent opacity-100 backdrop-filter touch-none
/>
<!-- Mask layer: dimming -->
<div class="dialog-mask" absolute inset-0 z-0 bg-black opacity-48 touch-none h="[calc(100%+0.5px)]" @click="clickMask" />
<!-- Dialog container -->
Expand Down
8 changes: 6 additions & 2 deletions components/nav/NavBottomMoreMenu.vue
Expand Up @@ -13,7 +13,10 @@ function toggleVisible() {
}
const buttonEl = ref<HTMLDivElement>()
/** Close the drop-down menu if the mouse click is not on the drop-down menu button when the drop-down menu is opened */
/**
* Close the drop-down menu if the mouse click is not on the drop-down menu button when the drop-down menu is opened
* @param mouse
*/
function clickEvent(mouse: MouseEvent) {
if (mouse.target && !buttonEl.value?.children[0].contains(mouse.target as any)) {
if (modelValue.value) {
Expand Down Expand Up @@ -141,11 +144,12 @@ const { dragging, dragDistance } = invoke(() => {
:class="{
'duration-0': dragging,
'duration-250': !dragging,
'backdrop-blur-md': !getPreferences(userSettings, 'optimizeForLowPerformanceDevice'),
}"
transition="transform ease-in"
flex-1 min-w-48 py-6 mb="-1px"
of-y-auto scrollbar-hide overscroll-none max-h="[calc(100vh-200px)]"
rounded-t-lg bg="white/85 dark:neutral-900/85" backdrop-filter backdrop-blur-md
rounded-t-lg bg="white/85 dark:neutral-900/85" backdrop-filter
border-t-1 border-base
>
<!-- Nav -->
Expand Down
2 changes: 2 additions & 0 deletions composables/settings/definition.ts
Expand Up @@ -19,6 +19,7 @@ export interface PreferencesSettings {
hideNews: boolean
grayscaleMode: boolean
enableAutoplay: boolean
optimizeForLowPerformanceDevice: boolean
enableDataSaving: boolean
enablePinchToZoom: boolean
useStarFavoriteIcon: boolean
Expand Down Expand Up @@ -72,6 +73,7 @@ export const DEFAULT__PREFERENCES_SETTINGS: PreferencesSettings = {
hideNews: false,
grayscaleMode: false,
enableAutoplay: true,
optimizeForLowPerformanceDevice: false,
enableDataSaving: false,
enablePinchToZoom: false,
useStarFavoriteIcon: false,
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Expand Up @@ -528,6 +528,7 @@
"hide_username_emojis": "Hide username emojis",
"hide_username_emojis_description": "Hides emojis from usernames in timelines. Emojis will still be visible in their profiles.",
"label": "Preferences",
"optimize_for_low_performance_device": "Optimize for low performance device",
"title": "Experimental Features",
"use_star_favorite_icon": "Use star favorite icon",
"user_picker": "User Picker",
Expand Down
6 changes: 6 additions & 0 deletions pages/settings/preferences/index.vue
Expand Up @@ -34,6 +34,12 @@ const userSettings = useUserSettings()
>
{{ $t('settings.preferences.enable_autoplay') }}
</SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'optimizeForLowPerformanceDevice')"
@click="togglePreferences('optimizeForLowPerformanceDevice')"
>
{{ $t('settings.preferences.optimize_for_low_performance_device') }}
</SettingsToggleItem>
<SettingsToggleItem
:checked="getPreferences(userSettings, 'enableDataSaving')"
@click="togglePreferences('enableDataSaving')"
Expand Down

0 comments on commit f79d84a

Please sign in to comment.