Skip to content

Commit 4d862b4

Browse files
committed
feat(navbar): adds picker & search to history tab
1 parent a433d98 commit 4d862b4

File tree

7 files changed

+100
-14
lines changed

7 files changed

+100
-14
lines changed

src/components/AppComponent.vue

+10-4
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,16 @@ const { isAuthenticated } = useAuthSettingsStoreRefs();
1414
<header>
1515
<RouterView v-slot="{ Component, route }" name="navbar">
1616
<NavbarComponent v-if="isAuthenticated">
17-
<template v-if="Component" #drawer>
18-
<KeepAlive>
19-
<component :is="Component" :key="route.path" />
20-
</KeepAlive>
17+
<template v-if="Component" #drawer="{ parentElement }">
18+
<Transition name="scale" mode="out-in">
19+
<KeepAlive>
20+
<component
21+
:is="Component"
22+
:key="route.path"
23+
:parent-element="parentElement"
24+
/>
25+
</KeepAlive>
26+
</Transition>
2127
</template>
2228
</NavbarComponent>
2329
</RouterView>

src/components/common/navbar/NavbarComponent.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const navElement = ref<HTMLElement>();
5555
</NTab>
5656
</NTabs>
5757
<div class="drawer" :class="{ visible: showDrawer }">
58-
<slot name="drawer"></slot>
58+
<slot name="drawer" :parent-element="navElement"></slot>
5959
</div>
6060
</nav>
6161
</template>

src/components/common/navbar/NavbarSettingsDopdown.vue

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script setup lang="ts">
2-
import { NAvatar, NDropdown, NEllipsis, NIcon, NSpace } from 'naive-ui';
2+
import { NAvatar, NDropdown, NEllipsis, NFlex, NIcon } from 'naive-ui';
33
44
import { computed, defineProps, h, ref } from 'vue';
55
@@ -143,16 +143,15 @@ const onSelect: DropdownProps['onSelect'] = async (key: string, { label }) => {
143143
class="dropdown"
144144
:style="{
145145
'margin-top': '0.75rem',
146-
'margin-right': '-0.25rem',
147146
'text-align': 'left',
148-
'min-width': 'max(calc(100vw / 6), 9rem)',
147+
'min-width': 'max(calc(100vw / 6), 8rem)',
149148
'max-width': '20rem',
150149
'background-color': Colors.bgBlurBlackHover,
151150
'backdrop-filter': Blurs.blur,
152151
}"
153152
@select="onSelect"
154153
>
155-
<NSpace justify="space-around" align="center" :wrap="false">
154+
<NFlex justify="space-around" align="center" :wrap="false">
156155
<NEllipsis
157156
style="
158157
max-width: calc(100vw / 6 - 0.25rem - 3px - 1.75rem);
@@ -180,6 +179,6 @@ const onSelect: DropdownProps['onSelect'] = async (key: string, { label }) => {
180179
<NIcon v-else style="position: absolute; top: 0.4rem; right: 0.75rem" size="1.5em">
181180
<IconAccount />
182181
</NIcon>
183-
</NSpace>
182+
</NFlex>
184183
</NDropdown>
185184
</template>

src/components/icons/IconLoop.vue

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<template>
2+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24">
3+
<g fill="none" stroke="currentColor" stroke-linecap="round" stroke-width="2">
4+
<path stroke-dasharray="16" stroke-dashoffset="16" d="M10.5 13.5L3 21">
5+
<animate
6+
fill="freeze"
7+
attributeName="stroke-dashoffset"
8+
begin="0.4s"
9+
dur="0.2s"
10+
values="16;0"
11+
/>
12+
</path>
13+
<path
14+
stroke-dasharray="40"
15+
stroke-dashoffset="40"
16+
d="M10.7574 13.2426C8.41421 10.8995 8.41421 7.10051 10.7574 4.75736C13.1005 2.41421 16.8995 2.41421 19.2426 4.75736C21.5858 7.10051 21.5858 10.8995 19.2426 13.2426C16.8995 15.5858 13.1005 15.5858 10.7574 13.2426Z"
17+
>
18+
<animate
19+
fill="freeze"
20+
attributeName="stroke-dashoffset"
21+
dur="0.4s"
22+
values="40;0"
23+
/>
24+
</path>
25+
</g>
26+
</svg>
27+
</template>
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,59 @@
1-
<script setup lang="ts"></script>
1+
<script setup lang="ts">
2+
import { NDatePicker, NFlex, NIcon, NInput } from 'naive-ui';
3+
import { defineProps } from 'vue';
4+
5+
import IconLoop from '~/components/icons/IconLoop.vue';
6+
7+
defineProps({
8+
parentElement: HTMLElement,
9+
});
10+
</script>
211

312
<template>
4-
<div>History Navbar</div>
13+
<NFlex class="row" align="center" justify="center" :vertical="false">
14+
<NDatePicker
15+
class="picker"
16+
type="daterange"
17+
:to="parentElement"
18+
:default-value="[Date.now(), Date.now()]"
19+
placement="bottom"
20+
update-value-on-close
21+
close-on-select
22+
clearable
23+
:on-clear="() => console.log('clear')"
24+
:on-confirm="value => console.log('confirm', value)"
25+
/>
26+
<NInput class="input" placeholder="Search" autosize clearable>
27+
<template #prefix>
28+
<NIcon :component="IconLoop" />
29+
</template>
30+
</NInput>
31+
</NFlex>
532
</template>
33+
34+
<style lang="scss" scoped>
35+
@use '~/styles/mixin' as mixin;
36+
37+
.row {
38+
width: 100%;
39+
40+
.picker {
41+
flex: 0 1 48%;
42+
}
43+
44+
.input {
45+
flex: 0 1 48%;
46+
}
47+
}
48+
</style>
49+
50+
<style lang="scss">
51+
@use '~/styles/mixin' as mixin;
52+
53+
.n-date-panel {
54+
@include mixin.hover-background(rgb(0 0 0 / 80%), rgb(0 0 0 / 90%));
55+
56+
margin-top: 12px;
57+
margin-left: -16px;
58+
}
59+
</style>

src/styles/layout.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
$header-navbar-height: 2.75rem;
2-
$header-drawer-height: 2.75rem;
2+
$header-drawer-height: 3.5rem;

src/styles/layout.style.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
export const Header = {
22
navbarHeight: 44,
3-
drawerHeight: 44,
3+
drawerHeight: 56,
44
} as const;

0 commit comments

Comments
 (0)