feat(ui): subtle rounded corners and shadow when window is floating
Detect maximized state via Tauri window API. When the window is not maximized (floating), apply 8px border-radius and a soft box-shadow. Body/html backgrounds set to transparent so corners show through the Tauri transparent window.
This commit is contained in:
3 files changed
+25
-4
No files matched your search
+1
-1
@@ -1272,7 +1272,7 @@ body {
|
|||||||
font-family: var(--font-sans);
|
font-family: var(--font-sans);
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 1.5;
|
line-height: 1.5;
|
||||||
background-color: var(--bg-primary);
|
background-color: transparent;
|
||||||
color: var(--text-primary);
|
color: var(--text-primary);
|
||||||
-webkit-font-smoothing: antialiased;
|
-webkit-font-smoothing: antialiased;
|
||||||
-moz-osx-font-smoothing: grayscale;
|
-moz-osx-font-smoothing: grayscale;
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="en" style="background-color: #0f0f0f;">
|
<html lang="en" style="background-color: transparent;">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
|
||||||
@@ -7,7 +7,7 @@
|
|||||||
<title>QBZ</title>
|
<title>QBZ</title>
|
||||||
%sveltekit.head%
|
%sveltekit.head%
|
||||||
</head>
|
</head>
|
||||||
<body data-sveltekit-preload-data="hover" style="background-color: #0f0f0f; margin: 0;">
|
<body data-sveltekit-preload-data="hover" style="background-color: transparent; margin: 0;">
|
||||||
<script>
|
<script>
|
||||||
// Apply system titlebar state before first render to prevent flash
|
// Apply system titlebar state before first render to prevent flash
|
||||||
// of custom title bar when system decorations are enabled.
|
// of custom title bar when system decorations are enabled.
|
||||||
|
|||||||
+22
-1
@@ -2,6 +2,7 @@
|
|||||||
import { onMount, onDestroy, tick } from 'svelte';
|
import { onMount, onDestroy, tick } from 'svelte';
|
||||||
import { ChevronUp } from 'lucide-svelte';
|
import { ChevronUp } from 'lucide-svelte';
|
||||||
import { invoke, convertFileSrc } from '@tauri-apps/api/core';
|
import { invoke, convertFileSrc } from '@tauri-apps/api/core';
|
||||||
|
import { getCurrentWindow } from '@tauri-apps/api/window';
|
||||||
import { listen, emitTo, type UnlistenFn } from '@tauri-apps/api/event';
|
import { listen, emitTo, type UnlistenFn } from '@tauri-apps/api/event';
|
||||||
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
import { writeText } from '@tauri-apps/plugin-clipboard-manager';
|
||||||
|
|
||||||
@@ -424,6 +425,9 @@
|
|||||||
// Window Controls State
|
// Window Controls State
|
||||||
let windowControlsConfig = $state<WindowControlsConfig>(getWindowControls());
|
let windowControlsConfig = $state<WindowControlsConfig>(getWindowControls());
|
||||||
|
|
||||||
|
// Window floating state (not maximized/tiled — for rounded corners + shadow)
|
||||||
|
let isWindowFloating = $state(false);
|
||||||
|
|
||||||
// View State (from navigationStore subscription)
|
// View State (from navigationStore subscription)
|
||||||
let activeView = $state<ViewType>('home');
|
let activeView = $state<ViewType>('home');
|
||||||
let selectedPlaylistId = $state<number | null>(null);
|
let selectedPlaylistId = $state<number | null>(null);
|
||||||
@@ -3144,6 +3148,16 @@
|
|||||||
windowControlsConfig = getWindowControls();
|
windowControlsConfig = getWindowControls();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Detect floating window state (not maximized) for rounded corners + shadow
|
||||||
|
let unlistenResize: (() => void) | undefined;
|
||||||
|
(async () => {
|
||||||
|
const appWindow = getCurrentWindow();
|
||||||
|
isWindowFloating = !(await appWindow.isMaximized());
|
||||||
|
unlistenResize = await appWindow.onResized(async () => {
|
||||||
|
isWindowFloating = !(await appWindow.isMaximized());
|
||||||
|
});
|
||||||
|
})();
|
||||||
|
|
||||||
// Sync titlebar search query with search state store
|
// Sync titlebar search query with search state store
|
||||||
const unsubscribeTitlebarSearch = subscribeSearchQuery((query) => {
|
const unsubscribeTitlebarSearch = subscribeSearchQuery((query) => {
|
||||||
titlebarSearchQuery = query;
|
titlebarSearchQuery = query;
|
||||||
@@ -3528,6 +3542,7 @@
|
|||||||
unsubscribeTitleBar();
|
unsubscribeTitleBar();
|
||||||
unsubscribeSearchBarLocation();
|
unsubscribeSearchBarLocation();
|
||||||
unsubscribeWindowControls();
|
unsubscribeWindowControls();
|
||||||
|
unlistenResize?.();
|
||||||
unsubscribeTitlebarSearch();
|
unsubscribeTitlebarSearch();
|
||||||
unsubscribeOffline();
|
unsubscribeOffline();
|
||||||
unsubscribeNav();
|
unsubscribeNav();
|
||||||
@@ -3625,7 +3640,7 @@
|
|||||||
{#if !isLoggedIn}
|
{#if !isLoggedIn}
|
||||||
<LoginView onLoginSuccess={handleLoginSuccess} onStartOffline={handleStartOffline} />
|
<LoginView onLoginSuccess={handleLoginSuccess} onStartOffline={handleStartOffline} />
|
||||||
{:else}
|
{:else}
|
||||||
<div class="app" class:no-titlebar={!showTitleBar}>
|
<div class="app" class:no-titlebar={!showTitleBar} class:floating={isWindowFloating}>
|
||||||
<!-- Custom Title Bar (CSD) -->
|
<!-- Custom Title Bar (CSD) -->
|
||||||
{#if showTitleBar}
|
{#if showTitleBar}
|
||||||
<TitleBar
|
<TitleBar
|
||||||
@@ -4617,6 +4632,12 @@
|
|||||||
background-color: var(--bg-primary);
|
background-color: var(--bg-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.app.floating {
|
||||||
|
border-radius: 8px;
|
||||||
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4), 0 0 1px rgba(0, 0, 0, 0.3);
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
.app-body {
|
.app-body {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
|
|||||||
Reference in new issue
Block a user