Skip to content

Commit 7573348

Browse files
feat(ui): add cross-platform content offset and macOS drag region (#693)
1 parent 800f746 commit 7573348

10 files changed

Lines changed: 24 additions & 11 deletions

File tree

src/renderer/App.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useApp, useTheme } from '@/composables'
44
import { i18n, ipc } from '@/electron'
55
import { RouterName } from '@/router'
66
import { isSpaceRouteName } from '@/spaceDefinitions'
7+
import { isMac } from '@/utils'
78
import { LoaderCircle } from 'lucide-vue-next'
89
import { loadWASM } from 'onigasm'
910
import onigasmFile from 'onigasm/lib/onigasm.wasm?url'
@@ -64,8 +65,9 @@ init()
6465
<template>
6566
<Tooltip.TooltipProvider>
6667
<div
68+
v-if="isMac"
6769
data-title-bar
68-
class="absolute top-0 z-50 h-[var(--title-bar-height)] w-full select-none"
70+
class="absolute top-0 z-50 h-3 w-full select-none"
6971
/>
7072
<RouterView v-slot="{ Component, route: currentRoute }">
7173
<AppSpaceShell v-if="isSpaceRouteName(currentRoute.name)">

src/renderer/components/app-space-shell/AppSpaceShell.vue

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
<script setup lang="ts">
2+
import { isMac } from '@/utils'
3+
</script>
4+
15
<template>
26
<div class="grid h-screen grid-cols-[72px_1fr] overflow-hidden">
3-
<div class="bg-background border-border/70 mt-2 border-r">
7+
<div
8+
class="bg-background border-border/70 border-r"
9+
:class="isMac && 'mt-2.5'"
10+
>
411
<SpaceRail />
512
</div>
613
<div class="min-h-0 min-w-0 overflow-hidden">

src/renderer/components/editor/Editor.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ onMounted(() => {
463463
<template>
464464
<div
465465
data-editor
466-
class="grid h-full grid-rows-[auto_1fr_auto] overflow-hidden pt-[var(--title-bar-height)]"
466+
class="grid h-full grid-rows-[auto_1fr_auto] overflow-hidden pt-[var(--content-top-offset)]"
467467
>
468468
<EditorHeader v-if="isShowHeader" />
469469
<Resizable.ResizablePanelGroup

src/renderer/components/layout/TwoColumn.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const gridTemplateColumns = computed(() => {
3030
3131
const leftHeaderStyle = computed(() => {
3232
return {
33-
paddingTop: `calc(var(--title-bar-height) + ${props.topSpace}px)`,
33+
paddingTop: `calc(var(--content-top-offset) + ${props.topSpace}px)`,
3434
}
3535
})
3636
</script>
@@ -62,7 +62,7 @@ const leftHeaderStyle = computed(() => {
6262
</div>
6363
</div>
6464
<div class="bg-border" />
65-
<div class="h-full min-h-0 overflow-auto pt-[var(--title-bar-height)]">
65+
<div class="h-full min-h-0 overflow-auto pt-[var(--content-top-offset)]">
6666
<slot name="right" />
6767
</div>
6868
</div>

src/renderer/components/sidebar/Sidebar.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { i18n } from '@/electron'
55
<template>
66
<div
77
data-sidebar
8-
class="flex h-full flex-col px-1 pt-[var(--title-bar-height)]"
8+
class="flex h-full flex-col px-1 pt-[var(--content-top-offset)]"
99
>
1010
<UiText
1111
as="div"

src/renderer/components/snippet/Header.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function onKeydown(event: KeyboardEvent) {
5151
</script>
5252

5353
<template>
54-
<div class="border-border mt-[var(--title-bar-height)] mb-2 border-b pb-1">
54+
<div class="border-border mt-[var(--content-top-offset)] mb-2 border-b pb-1">
5555
<div class="flex items-center px-1">
5656
<Search class="text-muted-foreground ml-1 h-4 w-4" />
5757
<div class="flex-grow">

src/renderer/components/space-rail/SpaceRail.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { useApp, useTheme } from '@/composables'
44
import { i18n, ipc } from '@/electron'
55
import { RouterName } from '@/router'
66
import { getSpaceDefinitions } from '@/spaceDefinitions'
7+
import { isMac } from '@/utils'
78
import { Settings } from 'lucide-vue-next'
89
import { RouterLink, useRoute } from 'vue-router'
910
import packageJson from '../../../../package.json'
@@ -26,7 +27,8 @@ const spaces = computed(() => {
2627

2728
<template>
2829
<nav
29-
class="flex h-full flex-col items-center px-2 pt-[calc(var(--title-bar-height)+8px)] pb-3"
30+
class="flex h-full flex-col items-center px-2 pb-3"
31+
:class="isMac ? 'pt-[calc(var(--content-top-offset)+8px)]' : 'pt-3'"
3032
:aria-label="i18n.t('spaces.label')"
3133
>
3234
<div class="flex w-full flex-col gap-1">

src/renderer/styles.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@custom-variant dark (&:is(.dark *));
55

66
:root {
7-
--title-bar-height: 10px;
7+
--content-top-offset: 8px;
88
--editor-tool-header-height: 28px;
99
--radius: 0.625rem;
1010

src/renderer/utils/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import { type ClassValue, clsx } from 'clsx'
22
import { twMerge } from 'tailwind-merge'
33

4+
export const isMac = navigator.userAgent.toLowerCase().includes('mac')
5+
46
export function cn(...inputs: ClassValue[]) {
57
return twMerge(clsx(inputs))
68
}

src/renderer/views/Preferences.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ import type { Component } from 'vue'
33
import { preferencesKeys } from '@/components/preferences/keys'
44
import { i18n } from '@/electron'
55
import { router, RouterName } from '@/router'
6+
import { isMac } from '@/utils'
67
import { Code, Globe, HardDrive, Palette, Plug } from 'lucide-vue-next'
78
import { RouterLink, useRoute } from 'vue-router'
89
9-
const isMac = navigator.userAgent.toLowerCase().includes('mac')
1010
const route = useRoute()
1111
1212
const scrollRef = useTemplateRef<HTMLElement>('scrollRef')
@@ -51,7 +51,7 @@ provide(preferencesKeys, {
5151
<template>
5252
<LayoutTwoColumn
5353
:title="i18n.t('preferences:label')"
54-
:top-space="isMac ? 16 : 0"
54+
:top-space="isMac ? 16 : 6"
5555
@back="() => router.push({ name: RouterName.main })"
5656
>
5757
<template #left>

0 commit comments

Comments
 (0)