From 01e50164959e7795dbd2524b463c2149d1056fe2 Mon Sep 17 00:00:00 2001 From: b1ek Date: Wed, 23 Aug 2023 22:33:13 +1000 Subject: [PATCH] make titlebar logo a home button --- src/store/RouteStore.ts | 10 ++++++++-- src/widget/Titlebar/Titlebar.svelte | 11 +++++++++-- src/widget/Titlebar/style.module.scss | 18 +++++++++++++++++- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/store/RouteStore.ts b/src/store/RouteStore.ts index 71cfde5..1cb166a 100644 --- a/src/store/RouteStore.ts +++ b/src/store/RouteStore.ts @@ -4,11 +4,17 @@ export interface RouteState { path: string } -export default configureStore({ +const store = configureStore({ reducer: { path: (state = '/load', action) => { if (action.type != 'setPath') return state; return action.path ?? state; } }, -}) \ No newline at end of file +}); + +export default store; + +export function route(path) { + store.dispatch({ type: 'setPath', path }); +} \ No newline at end of file diff --git a/src/widget/Titlebar/Titlebar.svelte b/src/widget/Titlebar/Titlebar.svelte index 62899e8..b377dad 100644 --- a/src/widget/Titlebar/Titlebar.svelte +++ b/src/widget/Titlebar/Titlebar.svelte @@ -10,6 +10,7 @@ import { appWindow } from '@tauri-apps/api/window' import Blek from '../../shared/blek.svelte'; + import { route } from '../../store/RouteStore';
@@ -19,8 +20,14 @@ - - nox + + + + {route('/')}}> + + nox + + diff --git a/src/widget/Titlebar/style.module.scss b/src/widget/Titlebar/style.module.scss index a06d7e0..3f2f05c 100644 --- a/src/widget/Titlebar/style.module.scss +++ b/src/widget/Titlebar/style.module.scss @@ -37,8 +37,24 @@ $corners: 16px; cursor: default; color: #b0b0b0; font-size: 12pt; - padding-left: 12px; width: 100%; + .home_btn { + color: #b0b0b0; + + height: fit-content; + width: fit-content; + padding: 6px 12px; + padding-right: 16px; + + display: block; + cursor: pointer; + text-decoration: none; + transition: 250ms ease; + + &:hover { + background: #0003; + } + } } .btns {