Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add responsiveness to top and bottom bars #1159

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 39 additions & 5 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,14 @@

<div ref="routerSection" class="router-view">
<div class="main-view" :class="{ 'edit-mode': widgetStore.editingMode }">
<div id="mainTopBar" class="bar top-bar">
<div
id="mainTopBar"
class="bar top-bar"
:style="[
interfaceStore.globalGlassMenuStyles,
interfaceStore.isOnSmallScreen && interfaceStore.isOnSmallScreen ? topBarScaleStyle : undefined,
]"
>
<button
class="flex items-center justify-center h-full aspect-square top-bar-hamburger"
:class="widgetStore.editingMode ? 'pointer-events-none' : 'pointer-events-auto'"
Expand Down Expand Up @@ -257,7 +264,14 @@
</div>
<div v-for="view in widgetStore.viewsToShow" :key="view.name">
<Transition name="fade">
<div v-show="view.name === currentSelectedViewName" class="bar bottom-bar">
<div
v-show="view.name === currentSelectedViewName"
class="bar bottom-bar"
:style="[
interfaceStore.globalGlassMenuStyles,
interfaceStore.isOnSmallScreen ? bottomBarScaleStyle : undefined,
]"
>
<MiniWidgetContainer
:container="view.miniWidgetContainers[0]"
:allow-editing="widgetStore.editingMode"
Expand Down Expand Up @@ -287,7 +301,7 @@
</template>

<script setup lang="ts">
import { onClickOutside, useDebounceFn, useFullscreen, useTimestamp } from '@vueuse/core'
import { onClickOutside, useDebounceFn, useFullscreen, useTimestamp, useWindowSize } from '@vueuse/core'
import { format } from 'date-fns'
import Swal from 'sweetalert2'
import { computed, DefineComponent, markRaw, onBeforeUnmount, onMounted, ref, watch } from 'vue'
Expand Down Expand Up @@ -588,6 +602,28 @@ const currentSelectedViewName = computed(() => widgetStore.currentView.name)
// Clock
const timeNow = useTimestamp({ interval: 1000 })

const { width: windowWidth } = useWindowSize()

const originalBarWidth = 1800

const topBarScaleStyle = computed(() => {
const scale = windowWidth.value / originalBarWidth
return {
transform: `scale(${scale})`,
transformOrigin: 'top left',
width: `${originalBarWidth}px`,
}
})

const bottomBarScaleStyle = computed(() => {
const scale = windowWidth.value / originalBarWidth
return {
transform: `scale(${scale})`,
transformOrigin: 'bottom left',
width: `${originalBarWidth}px`,
}
})

// Control showing mouse
let hideMouseTimeoutId: ReturnType<typeof setInterval>

Expand Down Expand Up @@ -723,12 +759,10 @@ body.hide-cursor {

.bar {
width: 100%;
background: rgba(108, 117, 125, 0.5);
display: flex;
justify-content: space-between;
z-index: 60;
position: absolute;
@apply backdrop-blur-[2px];
}

.bottom-bar {
Expand Down
Loading