Skip to content

Commit 424bfab

Browse files
committed
feat: 🎸 windows topbar
1 parent a1dcd2b commit 424bfab

File tree

13 files changed

+647
-475
lines changed

13 files changed

+647
-475
lines changed

src-tauri/Cargo.lock

Lines changed: 253 additions & 311 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src-tauri/capabilities/migrated.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"path:default",
88
"event:default",
99
"window:default",
10+
"window:allow-start-dragging",
1011
"webview:allow-print",
1112
"app:default",
1213
"image:default",
@@ -35,6 +36,9 @@
3536
"os:allow-hostname",
3637
"window:allow-start-dragging",
3738
"window:allow-set-fullscreen",
39+
"window:allow-minimize",
40+
"window:allow-close",
41+
"window:allow-maximize",
3842
"updater:default",
3943
"process:default",
4044
"clipboard-manager:default",

src-tauri/gen/schemas/acl-manifests.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","webview:allow-print","app:default","image:default","resources:default","menu:default","tray:default","shell:allow-open","fs:default","fs:write-all",{"identifier":"fs:scope","allow":[{"path":"**"}]},"shell:default","dialog:allow-save","dialog:allow-message","dialog:allow-open","dialog:allow-confirm","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","window:allow-start-dragging","window:allow-set-fullscreen","updater:default","process:default","clipboard-manager:default","clipboard-manager:allow-write-text"]}}
1+
{"migrated":{"identifier":"migrated","description":"permissions that were migrated from v1","local":true,"windows":["main"],"permissions":["path:default","event:default","window:default","window:allow-start-dragging","webview:allow-print","app:default","image:default","resources:default","menu:default","tray:default","shell:allow-open","fs:default","fs:write-all",{"identifier":"fs:scope","allow":[{"path":"**"}]},"shell:default","dialog:allow-save","dialog:allow-message","dialog:allow-open","dialog:allow-confirm","os:allow-platform","os:allow-version","os:allow-os-type","os:allow-family","os:allow-arch","os:allow-exe-extension","os:allow-locale","os:allow-hostname","window:allow-start-dragging","window:allow-set-fullscreen","window:allow-minimize","window:allow-close","window:allow-maximize","updater:default","process:default","clipboard-manager:default","clipboard-manager:allow-write-text"]}}

src-tauri/gen/schemas/desktop-schema.json

Lines changed: 127 additions & 63 deletions
Large diffs are not rendered by default.

src-tauri/gen/schemas/macOS-schema.json

Lines changed: 127 additions & 63 deletions
Large diffs are not rendered by default.

src-tauri/tauri.conf.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@
6565
"hiddenTitle": true,
6666
"width": 1200,
6767
"titleBarStyle": "Overlay",
68-
"dragDropEnabled": true
68+
"dragDropEnabled": true,
69+
"decorations": false
6970
}
7071
],
7172
"security": {

src-tauri/tauri.macos.conf.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"app": {
3+
"windows": [
4+
{
5+
"fullscreen": false,
6+
"height": 780,
7+
"resizable": true,
8+
"title": "MDX Editor",
9+
"hiddenTitle": true,
10+
"width": 1200,
11+
"titleBarStyle": "Overlay",
12+
"dragDropEnabled": true,
13+
"decorations": true
14+
}
15+
]
16+
}
17+
}

src/components/FileTree.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import React, {
77
useRef,
88
memo,
99
useMemo,
10-
useContext,
1110
} from 'react'
1211
import {
1312
isMdFile,
@@ -16,6 +15,7 @@ import {
1615
renamePath,
1716
getCurrentFolderName,
1817
findPathInTree,
18+
isMacOS,
1919
} from './utils/file-tree-util'
2020

2121
import { useToast } from '@/components/ui/use-toast'
@@ -49,7 +49,6 @@ import {
4949
} from 'lucide-react'
5050
import dayjs from 'dayjs'
5151
import { useLocalStorage } from 'react-use'
52-
import { Context } from './Layout'
5352
import { useHotkeys } from 'react-hotkeys-hook'
5453
import { useConfirm } from './ui/confirm'
5554

@@ -97,7 +96,6 @@ const FileTree = forwardRef<TreeRef, Props>(
9796
) => {
9897
const { toast } = useToast()
9998
const { confirm } = useConfirm()
100-
const { isMacOS } = useContext(Context)
10199
const { t } = useTranslation()
102100
const [scrollLine, setScrollLine] = useState(1)
103101
const [toc, setToc] = useState<string[]>([])
@@ -564,11 +562,15 @@ title: ${file}
564562

565563
return (
566564
<div className="relative w-full overflow-auto h-screen flex flex-col">
565+
{isMacOS ? (
566+
<div data-tauri-drag-region className="h-6" />
567+
) : (
568+
<div data-tauri-drag-region className="h-[30px]" />
569+
)}
567570
<div
568571
data-tauri-drag-region
569572
className={clsx(
570-
'px-4 pb-3 bg-white dark:bg-gray-900 sticky top-0 left-0 z-10 border-b flex-none dark:shadow-highlight/4',
571-
isMacOS ? 'pt-6' : 'pt-4'
573+
'pb-3 px-3 bg-white dark:bg-gray-900 sticky top-0 left-0 z-10 border-b flex-none dark:shadow-highlight/4'
572574
)}
573575
>
574576
<div className="h-9 flex items-center">

src/components/Header.js

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,33 @@
11
import { Logo } from './Logo'
22
import clsx from 'clsx'
33
import { toggleTheme } from '../utils/theme'
4-
import React, { useContext } from 'react'
4+
import React from 'react'
55
import { Sun, MoonStar } from 'lucide-react'
66
import { Button } from '@/components/ui/button'
7-
import { Context } from './Layout'
7+
import TopBar from './TopBar'
88

99
export default function Header({ children, logo }) {
10-
const { isMacOS } = useContext(Context)
1110
return (
12-
<div
13-
data-tauri-drag-region
14-
className={clsx(
15-
'sticky top-0 z-20 flex-none pb-3 px-5 flex items-center justify-between antialiased select-none border-b dark:shadow-lg',
16-
isMacOS ? 'pt-6' : 'pt-4'
17-
)}
18-
style={{ fontFeatureSettings: '"cv02", "cv03", "cv04", "cv11"' }}
19-
>
20-
<div className="flex items-center min-w-0 space-x-2">
21-
{logo || <Logo className="flex-none text-black dark:text-white" />}
22-
</div>
23-
<div className="flex items-center space-x-2">
24-
{children}
25-
<div className="block mx-2 w-px h-6 bg-gray-200 dark:bg-gray-700" />
26-
<Button size="icon" onClick={toggleTheme} variant="outline">
27-
<Sun className="w-5 h-5 stroke-primary fill-sky-100 dark:fill-sky-400/50 hidden dark:block" />
28-
<MoonStar className="w-5 h-5 stroke-primary fill-sky-100 dark:fill-sky-400/50 dark:hidden" />
29-
</Button>
11+
<div>
12+
<TopBar />
13+
<div
14+
data-tauri-drag-region
15+
className={clsx(
16+
'relative top-0 z-20 flex-none pb-3 px-5 flex items-center justify-between antialiased select-none border-b dark:shadow-lg'
17+
)}
18+
style={{ fontFeatureSettings: '"cv02", "cv03", "cv04", "cv11"' }}
19+
>
20+
<div className="flex items-center min-w-0 space-x-2">
21+
{logo || <Logo className="flex-none text-black dark:text-white" />}
22+
</div>
23+
<div className="flex items-center space-x-2">
24+
{children}
25+
<div className="block mx-2 w-px h-6 bg-gray-200 dark:bg-gray-700" />
26+
<Button size="icon" onClick={toggleTheme} variant="outline">
27+
<Sun className="w-5 h-5 stroke-primary fill-sky-100 dark:fill-sky-400/50 hidden dark:block" />
28+
<MoonStar className="w-5 h-5 stroke-primary fill-sky-100 dark:fill-sky-400/50 dark:hidden" />
29+
</Button>
30+
</div>
3031
</div>
3132
</div>
3233
)

0 commit comments

Comments
 (0)