Skip to content

Commit 3b8f0dc

Browse files
committed
fix(floating): auto coerce to top when below threshold
1 parent ba185bc commit 3b8f0dc

File tree

5 files changed

+20
-19
lines changed

5 files changed

+20
-19
lines changed

src/components/AppComponent.vue

+2-4
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,6 @@ const onBack = () => {
155155
@include transition.scale;
156156
157157
.app-container {
158-
--max-header-width: 800px;
159-
160158
overflow: hidden;
161159
162160
header {
@@ -257,8 +255,8 @@ const onBack = () => {
257255
&.floating {
258256
header {
259257
top: layout.$floating-navbar-offset;
260-
left: calc(50% - var(--max-header-width) / 2);
261-
width: var(--max-header-width);
258+
left: calc(50% - #{layout.$floating-navbar-width} / 2);
259+
width: layout.$floating-navbar-width;
262260
}
263261
264262
main {

src/components/views/checkin/CheckinComponent.vue

+8-8
Original file line numberDiff line numberDiff line change
@@ -409,16 +409,16 @@ const onClick = () => {
409409
color: var(--white-80);
410410
}
411411
}
412-
}
413412
414-
&.reverse {
415-
height: layout.$top-safe-watching-height;
416-
padding-top: calc(#{layout.$safe-area-inset-top} / 1.5);
413+
&.reverse {
414+
height: layout.$top-safe-watching-height;
415+
padding-top: calc(#{layout.$safe-area-inset-top} / 1.5);
417416
418-
&:active,
419-
&:focus-within,
420-
&:hover {
421-
height: layout.$watching-open-height;
417+
&:active,
418+
&:focus-within,
419+
&:hover {
420+
height: layout.$watching-open-height;
421+
}
422422
}
423423
}
424424
}

src/stores/app-state.store.ts

+8-6
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ export const useAppStateStore = defineStore('app.state', () => {
3838

3939
const { navbarPosition } = useExtensionSettingsStoreRefs();
4040

41-
const { mobile, tablet } = watchBreakpoint(
41+
const { bottom, minimum, floating } = watchBreakpoint(
4242
appRef,
43-
{ mobile: 600, tablet: 1300 },
43+
{ bottom: 400, minimum: 800, floating: 1000 },
4444
{
45-
mobile: { width: window.innerWidth < 600 },
46-
tablet: { width: window.innerWidth < 1300 },
45+
bottom: { width: window.innerWidth < 400 },
46+
minimum: { width: window.innerWidth < 800 },
47+
floating: { width: window.innerWidth < 1000 },
4748
},
4849
);
4950

@@ -65,14 +66,15 @@ export const useAppStateStore = defineStore('app.state', () => {
6566
if (navbarPosition.value === NavbarPosition.Bottom) return true;
6667
if (!isWeb.value) return false;
6768
// web and small screen only
68-
return navbarPosition.value === NavbarPosition.Auto && mobile.width;
69+
return navbarPosition.value === NavbarPosition.Auto && bottom.width;
6970
}),
7071
floating: computed(() => {
72+
if (minimum.width) return false;
7173
// if (panelOpen.value) return false;
7274
if (navbarPosition.value === NavbarPosition.Floating) return true;
7375
if (!isWeb.value) return false;
7476
// web & big screen only
75-
return navbarPosition.value === NavbarPosition.Auto && tablet.width === false;
77+
return navbarPosition.value === NavbarPosition.Auto && floating.width === false;
7678
}),
7779
};
7880
});

src/styles/layout.scss

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $safe-content-height: calc(var(--full-height) - #{$safe-navbar-height});
1414
$safe-full-height: calc(var(--full-height) - #{$safe-area-inset-top});
1515

1616
// floating navbar
17+
$floating-navbar-width: 800px;
1718
$floating-navbar-offset: calc(1rem + #{$safe-area-inset-top / 3});
1819
$floating-navbar-height: calc(#{$floating-navbar-offset} + #{$header-navbar-height});
1920
$floating-open-drawer-height: calc(#{$floating-navbar-height} + #{$header-drawer-height});

src/utils/window.utils.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export const watchSize = (element: Ref<Element | undefined>, cb: ResizeObserverC
3636
export const watchBreakpoint = <Name extends string, Value extends number>(
3737
element: Ref<Element | undefined>,
3838
breakpoints: Record<Name, Value>,
39-
seed?: Record<Name, { height?: boolean; width?: boolean }>,
39+
seed?: Partial<Record<Name, { height?: boolean; width?: boolean }>>,
4040
): Record<Name, { height?: boolean; width?: boolean }> => {
4141
const result = reactive<Record<string, { height?: boolean; width?: boolean }>>(
4242
Object.fromEntries(Object.keys(breakpoints).map(key => [key, { height: undefined, width: undefined, ...seed?.[key as Name] }])),

0 commit comments

Comments
 (0)