it-tools/src/layouts/base.layout.vue

238 lines
6.1 KiB
Vue
Raw Normal View History

2022-04-04 00:24:45 +02:00
<script lang="ts" setup>
2022-04-16 20:59:44 +02:00
import { NIcon, useThemeVars } from 'naive-ui';
2022-04-04 00:24:45 +02:00
import { h, ref, type Component } from 'vue';
import { RouterLink, useRoute } from 'vue-router';
2022-04-22 23:31:40 +02:00
import { Heart, 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-22 23:31:40 +02:00
import HeroGradient from '../assets/hero-gradient.svg?component';
import MenuLayout from '../components/MenuLayout.vue';
import NavbarButtons from '../components/NavbarButtons.vue';
const themeVars = useThemeVars();
const activeKey = ref(null);
const route = useRoute();
const styleStore = useStyleStore();
2022-04-16 11:45:50 +02:00
const version = import.meta.env.PACKAGE_VERSION;
2022-04-16 15:12:33 +02:00
const commitSha = import.meta.env.GIT_SHORT_SHA;
2022-04-16 11:45:50 +02:00
2022-04-22 23:31:40 +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-04 00:24:45 +02:00
2022-04-22 23:31:40 +02:00
const m = toolsByCategory.map((category) => ({
2022-04-16 11:13:30 +02:00
label: category.name,
key: category.name,
type: 'group',
children: category.components.map(({ name, path, icon }) => ({
label: makeLabel(name, path),
icon: makeIcon(icon),
2022-04-22 23:31:40 +02:00
key: name,
})),
}));
2022-03-31 00:33:29 +02:00
</script>
<template>
2022-04-22 23:31:40 +02:00
<menu-layout class="menu-layout" :class="{ isSmallScreen: styleStore.isSmallScreen }">
2022-04-15 23:10:47 +02:00
<template #sider>
2022-04-22 23:31:40 +02:00
<router-link to="/" class="hero-wrapper">
2022-04-15 23:10:47 +02:00
<hero-gradient class="gradient" />
<div class="text-wrapper">
2022-04-22 23:31:40 +02:00
<div class="title">IT - TOOLS</div>
2022-04-15 23:10:47 +02:00
<div class="divider" />
2022-04-22 23:31:40 +02:00
<div class="subtitle">Handy tools for developers</div>
2022-04-15 23:10:47 +02:00
</div>
</router-link>
<div class="sider-content">
2022-04-22 23:31:40 +02:00
<n-space v-if="styleStore.isSmallScreen" justify="center">
2022-04-16 11:13:30 +02:00
<navbar-buttons />
2022-04-15 23:10:47 +02:00
</n-space>
2022-04-16 21:01:31 +02:00
<n-menu
v-model:value="activeKey"
class="menu"
2022-04-22 23:31:40 +02:00
:value="route.name"
2022-04-16 21:01:31 +02:00
:collapsed-width="64"
:collapsed-icon-size="22"
:options="m"
:indent="20"
/>
2022-04-16 11:45:50 +02:00
<div class="footer">
<div>
2022-04-16 15:12:33 +02:00
IT-Tools
2022-04-16 21:01:31 +02:00
<n-button
text
tag="a"
target="_blank"
rel="noopener"
type="primary"
depth="3"
:href="`https://github.com/CorentinTh/it-tools/tree/v${version}`"
>
2022-04-16 11:45:50 +02:00
v{{ version }}
</n-button>
2022-04-16 15:12:33 +02:00
<template v-if="commitSha && commitSha.length > 0">
-
2022-04-16 21:01:31 +02:00
<n-button
text
tag="a"
target="_blank"
rel="noopener"
type="primary"
depth="3"
:href="`https://github.com/CorentinTh/it-tools/tree/${commitSha}`"
2022-04-16 21:01:31 +02:00
>
2022-04-16 15:12:33 +02:00
{{ commitSha }}
</n-button>
</template>
2022-04-16 11:45:50 +02:00
</div>
<div>
© {{ new Date().getFullYear() }}
2022-04-22 23:31:40 +02:00
<n-button text tag="a" target="_blank" rel="noopener" type="primary" href="https://github.com/CorentinTh">
2022-04-16 11:45:50 +02:00
Corentin Thomasset
</n-button>
</div>
</div>
2022-04-15 23:10:47 +02:00
</div>
</template>
<template #content>
<div class="navigation">
<n-button
:size="styleStore.isSmallScreen ? 'medium' : 'large'"
circle
quaternary
aria-label="Toogle menu"
@click="styleStore.isMenuCollapsed = !styleStore.isMenuCollapsed"
2022-04-16 21:01:31 +02:00
>
2022-04-22 23:31:40 +02:00
<n-icon size="25" :component="Menu2" />
</n-button>
2022-04-22 23:31:40 +02:00
<router-link to="/" #="{ navigate, href }" custom>
2022-04-16 11:13:30 +02:00
<n-tooltip trigger="hover">
<template #trigger>
2022-04-16 21:01:31 +02:00
<n-button
tag="a"
:href="href"
:size="styleStore.isSmallScreen ? 'medium' : 'large'"
circle
quaternary
aria-label="Home"
@click="navigate"
>
2022-04-22 23:31:40 +02:00
<n-icon size="25" :component="Home2" />
2022-04-16 11:13:30 +02:00
</n-button>
</template>
Home
</n-tooltip>
2022-04-15 23:10:47 +02:00
</router-link>
<search-bar />
2022-04-16 11:13:30 +02:00
<n-tooltip trigger="hover">
<template #trigger>
2022-04-16 21:01:31 +02:00
<n-button
type="primary"
tag="a"
href="https://github.com/sponsors/CorentinTh"
rel="noopener"
target="_blank"
>
2022-04-22 23:31:40 +02:00
<n-icon v-if="!styleStore.isSmallScreen" :component="Heart" style="margin-right: 5px" />
2022-04-16 11:13:30 +02:00
Sponsor
</n-button>
</template>
2022-04-16 15:12:33 +02:00
Support IT Tools developement !
2022-04-16 11:13:30 +02:00
</n-tooltip>
2022-04-15 23:10:47 +02:00
2022-04-16 11:13:30 +02:00
<navbar-buttons v-if="!styleStore.isSmallScreen" />
2022-04-15 23:10:47 +02:00
</div>
<slot />
</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-16 11:45:50 +02:00
.footer {
text-align: center;
color: #838587;
margin-top: 20px;
padding: 20px 0;
}
2022-04-15 12:21:09 +02:00
.sider-content {
2022-04-16 11:13:30 +02:00
padding-top: 160px;
padding-bottom: 200px;
2022-04-14 22:41:51 +02:00
}
.hero-wrapper {
2022-04-16 11:13:30 +02:00
position: absolute;
display: block;
left: 0;
width: 100%;
z-index: 10;
overflow: hidden;
.gradient {
margin-top: -65px;
}
.text-wrapper {
2022-04-14 22:41:51 +02:00
position: absolute;
left: 0;
width: 100%;
2022-04-16 11:13:30 +02:00
text-align: center;
top: 16px;
color: #fff;
2022-04-14 22:41:51 +02:00
2022-04-16 11:13:30 +02:00
.title {
font-size: 25px;
font-weight: 600;
2022-04-14 22:41:51 +02:00
}
2022-04-16 11:13:30 +02:00
.divider {
width: 50px;
height: 2px;
border-radius: 4px;
background-color: v-bind('themeVars.primaryColor');
margin: 0 auto 5px;
}
2022-04-14 22:41:51 +02:00
2022-04-16 11:13:30 +02:00
.subtitle {
font-size: 16px;
2022-04-14 22:41:51 +02:00
}
2022-04-16 11:13:30 +02:00
}
2022-04-14 22:41:51 +02:00
}
2022-04-15 12:21:09 +02:00
.navigation {
2022-04-16 11:13:30 +02:00
display: flex;
align-items: center;
justify-content: center;
flex-direction: row;
2022-04-14 18:45:47 +02:00
2022-04-22 23:31:40 +02:00
& > *:not(:last-child) {
2022-04-16 11:13:30 +02:00
margin-right: 5px;
}
2022-04-14 18:45:47 +02:00
2022-04-16 11:13:30 +02:00
.search-bar {
// width: 100%;
flex-grow: 1;
}
2022-04-04 00:24:45 +02:00
}
2022-04-22 23:31:40 +02:00
</style>