Skip to content

Commit f68f9db

Browse files
committed
feat(notification): update styling and adjust based on navbar state
1 parent 3c0a342 commit f68f9db

File tree

5 files changed

+104
-16
lines changed

5 files changed

+104
-16
lines changed

src/components/common/navbar/NavbarComponent.vue

+22-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useRoute, useRouter } from 'vue-router';
66
import NavbarSettingsDropdown from '~/components/common/navbar/NavbarSettingsDopdown.vue';
77
88
import { Route } from '~/router';
9+
import { NavbarService } from '~/services/navbar.service';
910
import { useI18n } from '~/utils';
1011
1112
const i18n = useI18n('route');
@@ -27,9 +28,18 @@ const routes = [
2728
2829
const isHover = ref(false);
2930
const isFocus = ref(false);
30-
const showDrawer = computed(
31-
() => route.name && !!slots.drawer && (isHover.value || isFocus.value),
32-
);
31+
32+
const hasDrawer = computed(() => {
33+
const drawer = !!route.name && !!slots.drawer;
34+
NavbarService.drawer.value = drawer;
35+
return drawer;
36+
});
37+
38+
const showDrawer = computed(() => {
39+
const show = hasDrawer.value && (isHover.value || isFocus.value);
40+
NavbarService.open.value = show;
41+
return show;
42+
});
3343
3444
const navElement = ref<HTMLElement>();
3545
</script>
@@ -69,7 +79,13 @@ const navElement = ref<HTMLElement>();
6979
<NavbarSettingsDropdown v-if="navElement" :parent-element="navElement" />
7080
</NTab>
7181
</NTabs>
72-
<div class="drawer" :class="{ visible: showDrawer }">
82+
<div
83+
class="drawer"
84+
:class="{
85+
'has-drawer': hasDrawer,
86+
'drawer-visible': showDrawer,
87+
}"
88+
>
7389
<slot name="drawer" :parent-element="navElement"></slot>
7490
</div>
7591
</nav>
@@ -84,19 +100,13 @@ nav {
84100
text-align: center;
85101
86102
.drawer {
103+
@include layout.navbar-transition;
104+
87105
display: flex;
88106
align-items: center;
89107
justify-content: center;
90108
height: 0;
91109
overflow: hidden;
92-
transition: height 0.5s var(--n-bezier);
93-
transition-delay: 0.2s;
94-
95-
&.visible {
96-
height: layout.$header-drawer-height;
97-
transition: height 0.25s var(--n-bezier);
98-
transition-delay: 0s;
99-
}
100110
}
101111
102112
a {

src/components/container/ContainerComponent.ce.vue

+54-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import { computed, ref } from 'vue';
1414
import LoadingBarProvider from '~/components/container/LoadingBarProvider.vue';
1515
import MessageProvider from '~/components/container/MessageProvider.vue';
1616
import NotificationProvider from '~/components/container/NotificationProvider.vue';
17+
import { NavbarService } from '~/services/navbar.service';
1718
import { lazyComponent } from '~/utils/lazy.utils';
1819
1920
const AppComponent = lazyComponent(() => import('~/components/AppComponent.vue'));
@@ -25,6 +26,9 @@ const override: GlobalThemeOverrides = {
2526
// TODO red palette
2627
};
2728
29+
const { drawer } = NavbarService;
30+
const drawerOpen = NavbarService.open;
31+
2832
const root = ref<HTMLElement>();
2933
</script>
3034

@@ -35,16 +39,40 @@ const root = ref<HTMLElement>();
3539

3640
<NLoadingBarProvider
3741
:to="root"
38-
:loading-bar-style="{ loading: { '--n-color-loading': 'white' } }"
42+
:loading-bar-style="{ loading: { '--n-color-loading': 'var(--vt-c-white)' } }"
3943
>
4044
<LoadingBarProvider />
4145
</NLoadingBarProvider>
4246

43-
<NMessageProvider :to="root">
47+
<NMessageProvider
48+
:to="root"
49+
:max="2"
50+
:container-class="
51+
[
52+
'message-container',
53+
drawer ? 'has-drawer' : '',
54+
drawerOpen ? 'drawer-visible' : '',
55+
]
56+
.filter(Boolean)
57+
.join(' ')
58+
"
59+
>
4460
<MessageProvider />
4561
</NMessageProvider>
4662

47-
<NNotificationProvider :to="root">
63+
<NNotificationProvider
64+
:to="root"
65+
:max="2"
66+
:container-class="
67+
[
68+
'notification-container',
69+
drawer ? 'has-drawer' : '',
70+
drawerOpen ? 'drawer-visible' : '',
71+
]
72+
.filter(Boolean)
73+
.join(' ')
74+
"
75+
>
4876
<NotificationProvider />
4977
</NNotificationProvider>
5078
</NConfigProvider>
@@ -54,6 +82,7 @@ const root = ref<HTMLElement>();
5482
<style lang="scss">
5583
@use '~/styles/base.scss';
5684
@use '~/styles/mixin' as mixin;
85+
@use '~/styles/layout' as layout;
5786
5887
:host {
5988
display: flex;
@@ -88,6 +117,26 @@ const root = ref<HTMLElement>();
88117
height: 100%;
89118
}
90119
120+
.notification-container.n-notification-container.n-notification-container {
121+
@include layout.navbar-transition($transition: top);
122+
123+
top: layout.$header-navbar-height;
124+
125+
&.drawer-visible {
126+
top: layout.$header-open-drawer-height;
127+
}
128+
}
129+
130+
.message-container.n-message-container.n-message-container {
131+
@include layout.navbar-transition($transition: top);
132+
133+
top: calc(#{layout.$header-navbar-height} + 12px);
134+
135+
&.drawer-visible {
136+
top: calc(#{layout.$header-open-drawer-height} + 12px);
137+
}
138+
}
139+
91140
.n-dropdown-menu,
92141
.n-date-panel,
93142
.n-virtual-list {
@@ -119,6 +168,8 @@ const root = ref<HTMLElement>();
119168
backdrop-filter: blur(var(--bg-blur));
120169
}
121170
171+
.n-message-wrapper .n-message,
172+
.n-notification-container .n-notification,
122173
.n-tooltip.n-tooltip,
123174
.n-popover-arrow.n-popover-arrow.n-popover-arrow {
124175
background: var(--bg-color-60);

src/index.html

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
<style>
1515
body {
16+
overscroll-behavior: none;
1617
display: flex;
1718
margin: 0;
1819
color: rgb(235 235 235 / 64%);

src/services/navbar.service.ts

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ref } from 'vue';
2+
3+
export class NavbarService {
4+
static readonly open = ref(false);
5+
static readonly drawer = ref(false);
6+
}

src/styles/layout.scss

+21-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,22 @@
11
$header-navbar-height: 2.75rem;
2-
$header-drawer-height: 3.5rem;
2+
$header-drawer-height: 3.5rem;
3+
$header-open-drawer-height: calc(#{$header-navbar-height} + #{$header-drawer-height});
4+
$navbar-transition: 0.5s var(--n-bezier);
5+
$navbar-transition-visible: 0.25s var(--n-bezier);
6+
$navbar-transition-delay: 0.5s;
7+
$navbar-transition-delay-visible: 0s;
8+
9+
@mixin navbar-transition($transition: height) {
10+
transition: $transition $navbar-transition;
11+
transition-delay: $navbar-transition-delay;
12+
13+
&.drawer-visible {
14+
height: $header-drawer-height;
15+
transition: $transition $navbar-transition-visible;
16+
transition-delay: $navbar-transition-delay-visible;
17+
}
18+
19+
&:not(.has-drawer) {
20+
transition-delay: $navbar-transition-delay-visible;
21+
}
22+
}

0 commit comments

Comments
 (0)