Skip to content

Commit 3802384

Browse files
committed
feat(settings): create wrapper component
1 parent 1ad86b3 commit 3802384

File tree

7 files changed

+158
-8
lines changed

7 files changed

+158
-8
lines changed

src/components/AppComponent.vue

+1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ header {
137137
138138
main {
139139
display: flex;
140+
flex-direction: column;
140141
align-items: center;
141142
justify-content: center;
142143
min-height: calc(100% - #{layout.$header-navbar-height});

src/components/common/navbar/NavbarSettingsDopdown.vue

+2-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { computed, defineProps, h, ref } from 'vue';
66
import { useRouter } from 'vue-router';
77
88
import type { DropdownProps } from 'naive-ui';
9-
109
import type { Component } from 'vue';
1110
1211
import type { ArrayElement } from '~/utils/typescript.utils';
@@ -15,7 +14,7 @@ import IconAccount from '~/components/icons/IconAccount.vue';
1514
import IconAccountAdd from '~/components/icons/IconAccountAdd.vue';
1615
import IconCog from '~/components/icons/IconCog.vue';
1716
import IconExternalLink from '~/components/icons/IconExternalLink.vue';
18-
import IconLightbulb from '~/components/icons/IconLightbulb.vue';
17+
import IconLightBulb from '~/components/icons/IconLightBulb.vue';
1918
import IconLogOut from '~/components/icons/IconLogOut.vue';
2019
2120
import { Route } from '~/router';
@@ -80,7 +79,7 @@ const toOption = (
8079
const options = computed<DropdownProps['options']>(() => {
8180
const baseOptions: DropdownProps['options'] = [
8281
toOption('settings', IconCog),
83-
toOption('about', IconLightbulb),
82+
toOption('about', IconLightBulb),
8483
{ type: 'divider', key: 'external-links' },
8584
toOption('trakt', IconExternalLink),
8685
{ type: 'divider', key: 'session-divider' },

src/components/container/ContainerComponent.ce.vue

+10
Original file line numberDiff line numberDiff line change
@@ -202,4 +202,14 @@ const root = ref<HTMLElement>();
202202
color: var(--black);
203203
}
204204
}
205+
206+
.n-layout-sider {
207+
.n-layout-toggle-bar {
208+
right: -15px;
209+
}
210+
211+
.n-anchor .n-anchor-link .n-anchor-link__title {
212+
padding-right: 0;
213+
}
214+
}
205215
</style>

src/components/icons/IconLightbulb.vue src/components/icons/IconLightBulb.vue

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
>
1313
<animate fill="freeze" attributeName="stroke-dashoffset" dur="0.4s" values="46;0" />
1414
</path>
15-
<rect width="6" height="0" x="9" y="20"
16-
fill="currentColor" rx="1">
15+
<rect width="6" height="0" x="9" y="20" fill="currentColor"
16+
rx="1">
1717
<animate
1818
fill="freeze"
1919
attributeName="height"
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,126 @@
11
<script lang="ts" setup>
2-
// TODO
2+
import { NAnchor, NAnchorLink, NCard, NLayout, NLayoutSider } from 'naive-ui';
3+
4+
import { onDeactivated, type Ref, ref } from 'vue';
5+
6+
import { useI18n } from '~/utils';
7+
8+
const i18n = useI18n('settings');
9+
10+
type Section = {
11+
title: string;
12+
reference: Ref<[InstanceType<typeof NCard>] | undefined>;
13+
};
14+
15+
const sections: Section[] = [
16+
{ title: 'menu__account', reference: ref() },
17+
{ title: 'menu__cache', reference: ref() },
18+
{ title: 'menu__tabs', reference: ref() },
19+
{ title: 'menu__logs', reference: ref() },
20+
{ title: 'menu__links', reference: ref() },
21+
];
22+
23+
const focus = ref(false);
24+
const target = ref();
25+
26+
const scrollTo = (section: Section) => {
27+
target.value = section;
28+
focus.value = true;
29+
section.reference?.value?.[0]?.$el?.scrollIntoView({
30+
behavior: 'smooth',
31+
block: 'center',
32+
});
33+
};
34+
35+
onDeactivated(() => {
36+
target.value = undefined;
37+
focus.value = false;
38+
});
339
</script>
440

541
<template>
6-
<span>This is a settings component</span>
42+
<NLayout class="container" has-sider>
43+
<NLayoutSider
44+
class="menu"
45+
bordered
46+
collapse-mode="width"
47+
width="5.125rem"
48+
:collapsed-width="0"
49+
:native-scrollbar="false"
50+
show-trigger="bar"
51+
inverted
52+
>
53+
<NAnchor :show-rail="false" type="block">
54+
<NAnchorLink
55+
v-for="section in sections"
56+
:key="section.title"
57+
:title="i18n(section.title)"
58+
:class="{ 'n-anchor-link--active': target?.title === section.title }"
59+
@click="scrollTo(section)"
60+
/>
61+
</NAnchor>
62+
</NLayoutSider>
63+
<NLayout
64+
class="content"
65+
:native-scrollbar="false"
66+
:content-style="{
67+
padding: '1rem 1rem',
68+
}"
69+
>
70+
<NCard
71+
v-for="section in sections"
72+
:id="section.title"
73+
:ref="section.reference"
74+
:key="section.title"
75+
class="card"
76+
:class="{ target: focus && target?.title === section.title }"
77+
:title="i18n(section.title)"
78+
@mouseenter="target = section"
79+
@mouseleave="focus = false"
80+
>
81+
card Content
82+
</NCard>
83+
</NLayout>
84+
</NLayout>
785
</template>
886

987
<style lang="scss" scoped>
10-
// TODO
88+
@use '~/styles/mixin' as mixin;
89+
@use '~/styles/layout' as layout;
90+
91+
.container {
92+
width: 100%;
93+
height: 100dvh;
94+
margin-top: -#{layout.$header-navbar-height};
95+
background: transparent;
96+
97+
.card {
98+
@include mixin.hover-background($from: var(--bg-black-50), $to: var(--bg-color-80));
99+
100+
min-height: 20rem;
101+
102+
&:not(:last-child) {
103+
margin-bottom: 1rem;
104+
}
105+
106+
&.target {
107+
border-color: var(--n-color-target);
108+
}
109+
}
110+
111+
.menu {
112+
@include mixin.hover-background;
113+
114+
padding: 0.5rem;
115+
}
116+
117+
.content {
118+
background: transparent;
119+
}
120+
121+
.menu,
122+
.content .card:first-child {
123+
margin-top: layout.$header-navbar-height;
124+
}
125+
}
11126
</style>
+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"settings__menu__account": {
3+
"message": "Account",
4+
"description": "Account menu item"
5+
},
6+
"settings__menu__cache": {
7+
"message": "Cache",
8+
"description": "Cache menu item"
9+
},
10+
"settings__menu__tabs": {
11+
"message": "Tabs",
12+
"description": "Tabs menu item"
13+
},
14+
"settings__menu__logs": {
15+
"message": "Logs",
16+
"description": "Logs menu item"
17+
},
18+
"settings__menu__links": {
19+
"message": "Links",
20+
"description": "Links menu item"
21+
}
22+
}

src/styles/base.scss

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
--bg-black: rgba(0 0 0);
2525
--bg-black-20: rgba(0 0 0 / 20%);
2626
--bg-black-30: rgba(0 0 0 / 30%);
27+
--bg-black-50: rgba(0 0 0 / 50%);
2728
--bg-black-60: rgba(0 0 0 / 60%);
2829
--bg-black-70: rgba(0 0 0 / 70%);
2930
--bg-black-80: rgba(0 0 0 / 80%);
@@ -100,6 +101,7 @@
100101
/* ui color variables */
101102
--bg-color-20: var(--bg-black-20);
102103
--bg-color-30: var(--bg-black-30);
104+
--bg-color-50: var(--bg-black-50);
103105
--bg-color-60: var(--bg-black-60);
104106
--bg-color-70: var(--bg-black-70);
105107
--bg-color-80: var(--bg-black-80);
@@ -120,6 +122,7 @@
120122
/* Dark theme override for ui color variables */
121123
--bg-color-20: var(--bg-black-20);
122124
--bg-color-30: var(--bg-black-30);
125+
--bg-color-50: var(--bg-black-50);
123126
--bg-color-60: var(--bg-black-60);
124127
--bg-color-70: var(--bg-black-70);
125128
--bg-color-80: var(--bg-black-80);

0 commit comments

Comments
 (0)