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

245 lines
6.3 KiB
Vue
Raw Normal View History

2022-04-04 00:24:45 +02:00
<script lang="ts" setup>
import { NIcon, useThemeVars, type MenuGroupOption } from 'naive-ui';
2022-06-02 00:09:21 +02:00
import { h } from 'vue';
2022-04-04 00:24:45 +02:00
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:52:59 +02:00
import { useStyleStore } from '@/stores/style.store';
import { config } from '@/config';
import MenuIconItem from '@/components/MenuIconItem.vue';
import type { ITool } from '@/tools/tool';
2022-08-04 22:46:50 +02:00
import SearchBar from '../components/SearchBar.vue';
import HeroGradient from '../assets/hero-gradient.svg?component';
import MenuLayout from '../components/MenuLayout.vue';
import NavbarButtons from '../components/NavbarButtons.vue';
2022-04-22 23:31:40 +02:00
const themeVars = useThemeVars();
const route = useRoute();
const styleStore = useStyleStore();
const version = config.app.version;
const commitSha = config.app.lastCommitSha.slice(0, 7);
2022-04-16 11:45:50 +02:00
const makeLabel = (tool: ITool) => () => h(RouterLink, { to: tool.path }, { default: () => tool.name });
const makeIcon = (tool: ITool) => () => h(MenuIconItem, { tool });
2022-04-04 00:24:45 +02:00
const menuOptions: MenuGroupOption[] = toolsByCategory.map((category) => ({
2022-04-16 11:13:30 +02:00
label: category.name,
key: category.name,
type: 'group',
children: category.components.map((tool) => ({
label: makeLabel(tool),
icon: makeIcon(tool),
key: tool.name,
2022-04-22 23:31:40 +02:00
})),
}));
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
class="menu"
:value="(route.name as string)"
2022-04-16 21:01:31 +02:00
:collapsed-width="64"
:collapsed-icon-size="22"
:options="menuOptions"
2022-04-16 21:01:31 +02:00
: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
2022-07-24 10:38:28 +02:00
aria-label="Toggle 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 />
<navbar-buttons v-if="!styleStore.isSmallScreen" />
2022-04-16 11:13:30 +02:00
<n-tooltip trigger="hover">
<template #trigger>
2022-04-16 21:01:31 +02:00
<n-button
round
2022-04-16 21:01:31 +02:00
type="primary"
tag="a"
href="https://github.com/sponsors/CorentinTh"
rel="noopener"
target="_blank"
>
Buy me a coffee
<n-icon v-if="!styleStore.isSmallScreen" :component="Heart" style="margin-left: 5px" />
2022-04-16 11:13:30 +02:00
</n-button>
</template>
2022-07-24 10:38:28 +02:00
Support IT Tools development !
2022-04-16 11:13:30 +02:00
</n-tooltip>
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
}
// ::v-deep(.n-menu-item-content-header) {
// overflow: visible !important;
// // overflow-x: hidden !important;
// }
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>