2022-04-04 00:24:45 +02:00
|
|
|
<script lang="ts" setup>
|
|
|
|
import { NIcon } from 'naive-ui';
|
|
|
|
import { h, ref, type Component } from 'vue';
|
|
|
|
import { RouterLink, useRoute } from 'vue-router';
|
2022-04-15 12:21:09 +02:00
|
|
|
import { Heart, BrandGithub, BrandTwitter, Moon, Sun, Menu2, Home2 } from '@vicons/tabler'
|
2022-04-06 00:49:56 +02:00
|
|
|
import { toolsByCategory } from '@/tools';
|
2022-04-04 01:03:06 +02:00
|
|
|
import SearchBar from '../components/SearchBar.vue';
|
2022-04-04 01:52:59 +02:00
|
|
|
import { useStyleStore } from '@/stores/style.store';
|
2022-04-14 22:41:51 +02:00
|
|
|
import HeroGradient from '../assets/hero-gradient.svg?component'
|
|
|
|
import { useThemeVars } from 'naive-ui'
|
2022-04-15 12:21:09 +02:00
|
|
|
import MenuLayout from '../components/MenuLayout.vue'
|
2022-04-04 00:24:45 +02:00
|
|
|
|
2022-04-14 22:41:51 +02:00
|
|
|
const themeVars = useThemeVars()
|
2022-04-04 00:24:45 +02:00
|
|
|
const activeKey = ref(null)
|
|
|
|
const route = useRoute()
|
2022-04-04 01:52:59 +02:00
|
|
|
const styleStore = useStyleStore()
|
2022-04-04 00:24:45 +02:00
|
|
|
|
|
|
|
const makeLabel = (text: string, to: string) => () => h(RouterLink, { to }, { default: () => text })
|
|
|
|
const makeIcon = (icon: Component) => () => h(NIcon, null, { default: () => h(icon) })
|
|
|
|
|
2022-04-06 00:49:56 +02:00
|
|
|
const m = toolsByCategory.map(category => ({
|
|
|
|
label: category.name,
|
|
|
|
key: category.name,
|
|
|
|
type: 'group',
|
|
|
|
children: category.components.map(({ name, path, icon }) => ({
|
|
|
|
label: makeLabel(name, path),
|
2022-04-07 22:14:18 +02:00
|
|
|
icon: makeIcon(icon),
|
|
|
|
key: name
|
2022-04-06 00:49:56 +02:00
|
|
|
}))
|
2022-04-04 00:24:45 +02:00
|
|
|
}))
|
2022-04-06 00:49:56 +02:00
|
|
|
|
2022-03-31 00:33:29 +02:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2022-04-15 12:21:09 +02:00
|
|
|
<menu-layout class="menu-layout" :class="{ isSmallScreen: styleStore.isSmallScreen }">
|
2022-04-14 22:41:51 +02:00
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
<template v-slot:sider>
|
2022-04-15 10:11:53 +02:00
|
|
|
<router-link to="/" class="hero-wrapper">
|
|
|
|
<hero-gradient class="gradient" />
|
|
|
|
<div class="text-wrapper">
|
|
|
|
<div class="title">IT - TOOLS</div>
|
|
|
|
<div class="divider" />
|
|
|
|
<div class="subtitle">Handy tools for developers</div>
|
|
|
|
</div>
|
|
|
|
</router-link>
|
2022-04-04 00:24:45 +02:00
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
<div class="sider-content">
|
|
|
|
<n-space v-if="styleStore.isSmallScreen" justify="center">
|
|
|
|
<n-button size="large" circle quaternary tag="a" href="https://github.com/CorentinTh/it-tools"
|
|
|
|
rel="noopener" target="_blank">
|
|
|
|
<n-icon size="25" :component="BrandGithub" />
|
|
|
|
</n-button>
|
|
|
|
<n-button size="large" circle quaternary tag="a" href="https://twitter.com/cthmsst" rel="noopener"
|
|
|
|
target="_blank">
|
|
|
|
<n-icon size="25" :component="BrandTwitter" />
|
|
|
|
</n-button>
|
|
|
|
<n-button size="large" circle quaternary @click="styleStore.isDarkTheme = !styleStore.isDarkTheme">
|
|
|
|
<n-icon size="25" v-if="styleStore.isDarkTheme" :component="Sun" />
|
|
|
|
<n-icon size="25" v-else :component="Moon" />
|
|
|
|
</n-button>
|
|
|
|
</n-space>
|
|
|
|
|
|
|
|
<n-menu :value="route.name" class="menu" :collapsed-width="64" :collapsed-icon-size="22" :options="m"
|
|
|
|
v-model:value="activeKey" :indent="20" />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template v-slot:content>
|
|
|
|
<div class="navigation">
|
|
|
|
<n-button :size="styleStore.isSmallScreen ? 'medium' : 'large'" circle quaternary
|
|
|
|
@click="styleStore.isMenuCollapsed = !styleStore.isMenuCollapsed">
|
|
|
|
<n-icon size="25" :component="Menu2" />
|
|
|
|
</n-button>
|
|
|
|
|
|
|
|
<router-link to="/" #="{ navigate, href }" custom>
|
|
|
|
<n-button tag="a" :href="href" @click="navigate"
|
|
|
|
:size="styleStore.isSmallScreen ? 'medium' : 'large'" circle quaternary>
|
|
|
|
<n-icon size="25" :component="Home2" />
|
|
|
|
</n-button>
|
|
|
|
</router-link>
|
2022-04-14 18:45:47 +02:00
|
|
|
|
2022-04-04 01:03:06 +02:00
|
|
|
<search-bar />
|
2022-04-15 12:21:09 +02:00
|
|
|
|
|
|
|
|
2022-04-14 22:41:51 +02:00
|
|
|
<n-button type="primary" tag="a" href="https://github.com/sponsors/CorentinTh" rel="noopener"
|
|
|
|
target="_blank">
|
2022-04-15 12:21:09 +02:00
|
|
|
<n-icon :component="Heart" style="margin-right: 5px;" v-if="!styleStore.isSmallScreen" />
|
2022-04-14 22:41:51 +02:00
|
|
|
Sponsor
|
|
|
|
</n-button>
|
2022-04-14 23:45:03 +02:00
|
|
|
<n-button size="large" circle quaternary tag="a" href="https://github.com/CorentinTh/it-tools"
|
2022-04-15 12:21:09 +02:00
|
|
|
rel="noopener" target="_blank" v-if="!styleStore.isSmallScreen">
|
2022-04-14 23:45:03 +02:00
|
|
|
<n-icon size="25" :component="BrandGithub" />
|
2022-04-14 23:26:19 +02:00
|
|
|
</n-button>
|
2022-04-14 23:45:03 +02:00
|
|
|
<n-button size="large" circle quaternary tag="a" href="https://twitter.com/cthmsst" rel="noopener"
|
2022-04-15 12:21:09 +02:00
|
|
|
target="_blank" v-if="!styleStore.isSmallScreen">
|
2022-04-14 23:45:03 +02:00
|
|
|
<n-icon size="25" :component="BrandTwitter" />
|
2022-04-14 23:34:56 +02:00
|
|
|
</n-button>
|
2022-04-15 12:21:09 +02:00
|
|
|
<n-button size="large" circle quaternary @click="styleStore.isDarkTheme = !styleStore.isDarkTheme"
|
|
|
|
v-if="!styleStore.isSmallScreen">
|
2022-04-14 23:45:03 +02:00
|
|
|
<n-icon size="25" v-if="styleStore.isDarkTheme" :component="Sun" />
|
|
|
|
<n-icon size="25" v-else :component="Moon" />
|
2022-04-04 00:24:45 +02:00
|
|
|
</n-button>
|
2022-04-15 12:21:09 +02:00
|
|
|
|
2022-04-04 00:24:45 +02:00
|
|
|
</div>
|
|
|
|
<slot />
|
2022-04-15 12:21:09 +02:00
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</menu-layout>
|
2022-03-31 00:33:29 +02:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<style lang="less" scoped>
|
2022-04-14 23:12:36 +02:00
|
|
|
// ::v-deep(.n-layout-scroll-container) {
|
|
|
|
// @percent: 4%;
|
|
|
|
// @position: 25px;
|
|
|
|
// @size: 50px;
|
|
|
|
// @color: #eeeeee25;
|
|
|
|
// background-image: radial-gradient(@color @percent, transparent @percent),
|
|
|
|
// radial-gradient(@color @percent, transparent @percent);
|
|
|
|
// background-position: 0 0, @position @position;
|
|
|
|
// background-size: @size @size;
|
|
|
|
// }
|
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
.sider-content {
|
2022-04-14 22:41:51 +02:00
|
|
|
padding-top: 160px;
|
|
|
|
padding-bottom: 200px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.hero-wrapper {
|
|
|
|
position: absolute;
|
|
|
|
display: block;
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
z-index: 10;
|
2022-04-15 12:21:09 +02:00
|
|
|
overflow: hidden;
|
2022-04-14 22:41:51 +02:00
|
|
|
|
|
|
|
.gradient {
|
2022-04-15 12:21:09 +02:00
|
|
|
margin-top: -65px;
|
2022-04-14 22:41:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
.text-wrapper {
|
|
|
|
position: absolute;
|
|
|
|
left: 0;
|
|
|
|
width: 100%;
|
|
|
|
text-align: center;
|
|
|
|
top: 16px;
|
|
|
|
color: #fff;
|
|
|
|
|
|
|
|
.title {
|
|
|
|
font-size: 25px;
|
|
|
|
font-weight: 600;
|
|
|
|
}
|
|
|
|
|
|
|
|
.divider {
|
|
|
|
width: 50px;
|
|
|
|
height: 2px;
|
|
|
|
border-radius: 4px;
|
|
|
|
background-color: v-bind('themeVars.primaryColor');
|
|
|
|
margin: 0 auto 5px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.subtitle {
|
|
|
|
font-size: 16px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
.navigation {
|
2022-04-04 00:24:45 +02:00
|
|
|
display: flex;
|
2022-04-14 22:41:51 +02:00
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2022-04-15 12:21:09 +02:00
|
|
|
flex-direction: row;
|
2022-04-14 18:45:47 +02:00
|
|
|
|
|
|
|
&>*:not(:first-child) {
|
2022-04-15 12:21:09 +02:00
|
|
|
margin-left: 10px;
|
2022-04-14 18:45:47 +02:00
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
.isSmallScreen & {
|
|
|
|
margin-left: 5px;
|
|
|
|
}
|
2022-04-04 00:24:45 +02:00
|
|
|
}
|
|
|
|
|
2022-04-14 18:45:47 +02:00
|
|
|
|
2022-04-15 12:21:09 +02:00
|
|
|
.search-bar {
|
|
|
|
// width: 100%;
|
|
|
|
flex-grow: 1;
|
2022-04-04 00:24:45 +02:00
|
|
|
}
|
|
|
|
}
|
2022-03-31 00:33:29 +02:00
|
|
|
</style>
|