update ui consistent for cross platform

This commit is contained in:
Ren Amamiya
2023-09-03 07:43:38 +07:00
parent 37668393f1
commit a4cf65e7c2
17 changed files with 67 additions and 23 deletions

View File

@@ -37,7 +37,7 @@ export function ComposerModal() {
</button>
</Dialog.Trigger>
<Dialog.Portal className="relative z-10">
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-xl" />
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-2xl" />
<Dialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center">
<div
className={twMerge(

29
src/shared/frame.tsx Normal file
View File

@@ -0,0 +1,29 @@
import { HTMLProps, ReactNode, useCallback } from 'react';
import { twMerge } from 'tailwind-merge';
import { useStorage } from '@libs/storage/provider';
export function Frame({
children,
className,
lighter,
}: {
children: ReactNode;
className: HTMLProps<HTMLElement>['className'];
lighter?: boolean;
}) {
const { db } = useStorage();
const platformStyles = useCallback(() => {
switch (db.platform) {
case 'darwin':
case 'win32':
if (lighter) return 'bg-black/80';
return 'bg-black/90';
default:
return 'bg-black';
}
}, []);
return <div className={twMerge(className, platformStyles())}>{children}</div>;
}

View File

@@ -1,5 +1,6 @@
import { Outlet, ScrollRestoration } from 'react-router-dom';
import { Frame } from '@shared/frame';
import { Navigation } from '@shared/navigation';
export function AppLayout() {
@@ -8,14 +9,14 @@ export function AppLayout() {
<div className="shrink-0">
<Navigation />
</div>
<div className="h-full w-full flex-1 bg-black/90 backdrop-blur-xl">
<Frame className="h-full w-full flex-1">
<Outlet />
<ScrollRestoration
getKey={(location) => {
return location.pathname;
}}
/>
</div>
</Frame>
</div>
);
}

View File

@@ -1,10 +1,12 @@
import { Outlet } from 'react-router-dom';
import { Frame } from '@shared/frame';
export function AuthLayout() {
return (
<div className="relative h-screen w-screen bg-black/90 backdrop-blur-xl">
<Frame className="relative h-screen w-screen">
<div className="absolute left-0 top-0 z-50 h-16 w-full" data-tauri-drag-region />
<Outlet />
</div>
</Frame>
);
}

View File

@@ -1,10 +1,12 @@
import { Outlet } from 'react-router-dom';
import { Frame } from '@shared/frame';
export function NoteLayout() {
return (
<div className="relative h-screen w-screen bg-black/90 backdrop-blur-xl">
<Frame className="relative h-screen w-screen">
<div className="absolute left-0 top-0 z-50 h-16 w-full" data-tauri-drag-region />
<Outlet />
</div>
</Frame>
);
}

View File

@@ -1,12 +1,13 @@
import { Link, NavLink, Outlet, ScrollRestoration } from 'react-router-dom';
import { twMerge } from 'tailwind-merge';
import { Frame } from '@shared/frame';
import { ArrowLeftIcon, SecureIcon, SettingsIcon } from '@shared/icons';
export function SettingsLayout() {
return (
<div className="flex h-screen w-screen">
<div className="relative flex h-full w-[232px] flex-col bg-black/80">
<Frame className="relative flex h-full w-[232px] flex-col" lighter>
<div data-tauri-drag-region className="h-11 w-full shrink-0" />
<div className="scrollbar-hide flex h-full flex-1 flex-col gap-2 overflow-y-auto pb-32">
<div className="inline-flex items-center gap-2 border-l-2 border-transparent pl-4">
@@ -55,7 +56,7 @@ export function SettingsLayout() {
</NavLink>
</div>
</div>
</div>
</Frame>
<div className="h-full w-full flex-1 bg-black/90 backdrop-blur-xl">
<Outlet />
<ScrollRestoration

View File

@@ -6,6 +6,7 @@ import { ChatsList } from '@app/chats/components/list';
import { ActiveAccount } from '@shared/accounts/active';
import { ComposerModal } from '@shared/composer';
import { Frame } from '@shared/frame';
import { BellIcon, NavArrowDownIcon, SpaceIcon } from '@shared/icons';
import { useSidebar } from '@stores/sidebar';
@@ -14,7 +15,7 @@ export function Navigation() {
const [chats, toggleChats] = useSidebar((state) => [state.chats, state.toggleChats]);
return (
<div className="relative flex h-full w-[232px] flex-col bg-black/80">
<Frame className="relative flex h-full w-[232px] flex-col" lighter>
<div data-tauri-drag-region className="h-11 w-full shrink-0" />
<div className="scrollbar-hide flex h-full flex-1 flex-col gap-6 overflow-y-auto pb-32">
<div className="flex flex-col pr-2">
@@ -80,6 +81,6 @@ export function Navigation() {
<div className="shrink-0">
<ActiveAccount />
</div>
</div>
</Frame>
);
}

View File

@@ -44,7 +44,7 @@ export function NoteRepost({ id, pubkey }: { id: string; pubkey: string }) {
</Tooltip.Portal>
</Tooltip.Root>
<AlertDialog.Portal className="relative z-10">
<AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-xl" />
<AlertDialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-2xl" />
<AlertDialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center">
<div className="relative h-min w-full max-w-xl rounded-xl bg-white/10 backdrop-blur-xl">
<div className="flex flex-col gap-2 border-b border-white/5 px-5 py-4">

View File

@@ -38,7 +38,7 @@ export function NoteZap({ id }: { id: string }) {
</button>
</Dialog.Trigger>
<Dialog.Portal className="relative z-10">
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-xl" />
<Dialog.Overlay className="fixed inset-0 z-50 bg-black/80 backdrop-blur-2xl" />
<Dialog.Content className="fixed inset-0 z-50 flex min-h-full items-center justify-center">
<div className="relative h-min w-full max-w-xl rounded-xl bg-white/10 backdrop-blur-xl">
<div className="relative h-min w-full shrink-0 border-b border-white/5 bg-white/5 px-5 py-5">