π A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!
Vue awesomedashboarddockerhomelabhomepagemitnodejsorganizationproductivitypwaself-hostedstartpagevue
π± Responsive burger menu for mobile navbar
Alicia Sykesbddfb9f43357
diff --git a/.github/pr-auto-comments.yml b/.github/pr-auto-comments.ymldeleted file mode 100644index b4a62ab1..00000000--- a/.github/pr-auto-comments.yml+++ /dev/null@@ -1,135 +0,0 @@-comment:- on-update: edit- header: |- Hi {{ prAuthor }}! Thank you for contributing to Dashy! β¨- footer: |- ---- > I'm a bot, and this is an automated comment π€- snippets:- - id: docs-changes- files:- - docs/**.md- body: |- When making changes to the documentation, be sure to double check that:- - Link and images URLs properly resolve- - Your spelling and grammar is correct- - Any markdown formatting is valid-- - id: vite-config- files:- - vite.config.mjs- body: >- You're making changes to the main Vite build config. Please test the app thoroughly,- as any misconfigurations here may cause the app to stop functioning.-- - id: server-entry- files:- - server.js- body: >- You're making changes to the main server entry point. Please test the app thoroughly,- as any misconfigurations here may cause the app to stop functioning.-- - id: dependency-changes- files:- - yarn.lock- body: >- When updating dependencies, take a moment to verify that there are not security- issues associated with any added or modified packages. If adding a new dependency,- ensure that it is totally necessary, and check the packages size is not too large,- as this will increase overall bundle size.-- - id: environmental-vars- files: [ '.env', '*.env', '.env*' ]- body: >- You're making changes to the main server entry point. Please test the app thoroughly,- as any misconfigurations here may cause the app to stop functioning.-- - id: license- files: [ 'LICENSE', '**/**/LICENSE*' ]- body: >- Dashy is licensed under MIT. Your modifying the license file, which shouldn't usually- need to be changed. Please ensure that you intended to make this update before continuing.-- - id: cname-file- files:- - CNAME- body: >- Are you sure you want to modify the CNAME file? This may stop the documentation- website hosted on GitHub pages from working.-- - id: git-ignore- files:- - .gitignore- body: >- When modifying the .gitignore, please do not remove any of the existing paths,- as this may cause files and directories to be unintentionally committed to git-- - id: netlify-file- files:- - netlify.toml- body: >- Please ensure you've tested the app on Netlify, so that the 1-Click deployment- does not break, before merging these changes-- - id: heroku-ignore- files:- - Procfile- body: >- Please ensure you've tested the app on Heroku, so that the 1-Click deployment- does not break, before merging these changes-- - id: ignored-dist- files:- - dist/**/*- body: >- Please do not commit the built application to git. The contents of the dist- directory will be generated after the app is compiled-- - id: ignored-dependencies- files:- - node_modules/**/*- body: >- Please do not commit dependencies to git. Node modules will be pulled down- when yarn is run, prior to building the app-- - id: user-themes- files:- - src/styles/user-defined-themes.scss- body: >- Please do not commit changes to this file, as it is intended to be overridden with Docker.- You can instead add your styles to the color-themes file, or for element-specific styles- put it within the appropriate component. Thank you-- - id: code-owners- files:- - .github/CODEOWNERS- body: >- Are you adding yourself as a code owner? Please specify the file path as specific- as possible, and only assign yourself to files that you created and wish to help- maintain (such as a language file, specific feature or widget).- If the above is not met, your PR will be declined or modified.-- - id: config-schema- files:- - src/utils/ConfigSchema.json- body: >- Don't forget to verify they the config validator script responds correctly to- your new attribute.-- - id: showcase- files:- - docs/showcase.md- body: >- Thank you for adding your dashboard to the showcase! π-- - id: translations- files:- - src/assets/locales/**.json- body: >- Thank you for contributing to Dashy's translations π-- - id: themes- files:- - src/styles/color-themes.scss- body: >- Thank you for contributing to Dashy's themes π¨diff --git a/src/assets/locales/en.json b/src/assets/locales/en.jsonindex d4f5439a..d5faec85 100644--- a/src/assets/locales/en.json+++ b/src/assets/locales/en.json@@ -135,6 +135,7 @@"config-launcher-label": "Config","config-launcher-tooltip": "Update Configuration","nav-links-tooltip": "Navigation and Configs",+ "toggle-nav-aria": "Toggle navigation menu","sign-out-tooltip": "Sign Out","sign-in-tooltip": "Log In","sign-in-welcome": "Hello {username}!",diff --git a/src/components/PageStrcture/Header.vue b/src/components/PageStrcture/Header.vueindex cc765772..10f76664 100644--- a/src/components/PageStrcture/Header.vue+++ b/src/components/PageStrcture/Header.vue@@ -6,7 +6,7 @@:description="pageInfo.description":logo="pageInfo.logo"/>- <Nav v-if="navVisible" :links="pageInfo.navLinks" class="nav" />+ <Nav :links="pageInfo.navLinks" :user-hidden="!navVisible" class="nav" /></header></template>@@ -46,6 +46,7 @@ export default {@import '@/styles/media-queries.scss';header {+ position: relative;margin: 0;padding: 0.5rem;display: flex;@@ -54,7 +55,7 @@ export default {align-items: center;align-content: flex-start;@include phone {- flex-direction: column-reverse;+ flex-direction: column;}}</style>diff --git a/src/components/PageStrcture/Nav.vue b/src/components/PageStrcture/Nav.vueindex ff129281..c76adae6 100644--- a/src/components/PageStrcture/Nav.vue+++ b/src/components/PageStrcture/Nav.vue@@ -1,62 +1,92 @@<template>- <div class="nav-outer" v-if="allLinks && allLinks.length > 0">- <IconBurger- :class="`burger ${!navVisible ? 'visible' : ''}`"- @click="navVisible = !navVisible"- />- <nav id="nav" v-if="navVisible">- <!-- Render either router-link or anchor, depending if internal / external link -->- <template v-for="(link, index) in allLinks" :key="index">- <router-link v-if="!isHttpUrl(link.path)"- :to="link.path"- :title="link.title"- class="nav-item"- >{{link.title}}- </router-link>- <a v-else- :href="link.path"- :target="resolveLinkTarget(link)"- :title="link.title"- class="nav-item"- rel="noopener noreferrer"- >{{link.title}}- </a>- </template>- </nav>- </div>+ <div class="nav-outer" :class="{ floating: showBurger }" v-if="allLinks.length">+ <button+ v-if="showBurger"+ type="button"+ class="burger"+ :aria-expanded="isOpen"+ aria-controls="nav"+ :aria-label="$t('settings.toggle-nav-aria')"+ @click="isOpen = !isOpen"+ >+ <IconBurger />+ </button>+ <nav id="nav" v-show="isOpen" :class="{ 'as-menu': showBurger }">+ <template v-for="(link, index) in allLinks" :key="index">+ <router-link+ v-if="!isHttpUrl(link.path)"+ :to="link.path"+ :title="link.title"+ class="nav-item"+ @click="closeIfBurger"+ >{{ link.title }}</router-link>+ <a+ v-else+ :href="link.path"+ :target="resolveLinkTarget(link)"+ :title="link.title"+ class="nav-item"+ rel="noopener noreferrer"+ @click="closeIfBurger"+ >{{ link.title }}</a>+ </template>+ </nav>+ </div></template><script>import IconBurger from '@/assets/interface-icons/burger-menu.svg';import { buildAllLinks, isHttpUrl, resolveLinkTarget } from '@/utils/NavLinks';+const MOBILE_QUERY = '(max-width: 599px)';+export default {name: 'Nav',- components: {- IconBurger,- },+ components: { IconBurger },props: {links: { type: Array, default: () => [] },+ userHidden: { type: Boolean, default: false },+ },+ data() {+ const isMobile = typeof window !== 'undefined'+ && window.matchMedia(MOBILE_QUERY).matches;+ return {+ isMobile,+ isOpen: !isMobile && !this.userHidden,+ mql: null,+ };},- data: () => ({- navVisible: true,- isMobile: false,- }),computed: {allLinks() {- void this.$store.state.authRevision; // Re-filter pages when auth state changes+ void this.$store.state.authRevision;return buildAllLinks(this.$store, this.$route, this.links);},+ showBurger() {+ return this.isMobile || this.userHidden;+ },+ },+ watch: {+ showBurger(v) { this.isOpen = !v; },+ },+ mounted() {+ this.mql = window.matchMedia(MOBILE_QUERY);+ this.mql.addEventListener('change', this.onMqlChange);+ document.addEventListener('keydown', this.onKey);+ document.addEventListener('click', this.onDocClick);},- created() {- this.navVisible = !this.detectMobile();- this.isMobile = this.detectMobile();+ beforeUnmount() {+ this.mql?.removeEventListener('change', this.onMqlChange);+ document.removeEventListener('keydown', this.onKey);+ document.removeEventListener('click', this.onDocClick);},methods: {- detectMobile() {- const screenWidth = document.body.clientWidth;- return screenWidth && screenWidth < 600;+ onMqlChange(e) { this.isMobile = e.matches; },+ onKey(e) { if (e.key === 'Escape' && this.showBurger) this.isOpen = false; },+ onDocClick(e) {+ if (!this.showBurger || !this.isOpen) return;+ if (!this.$el.contains(e.target)) this.isOpen = false;},+ closeIfBurger() { if (this.showBurger) this.isOpen = false; },isHttpUrl,resolveLinkTarget,},@@ -68,7 +98,36 @@ export default {@import '@/styles/media-queries.scss';.nav-outer {+ position: relative;min-width: 0;++ &.floating {+ position: absolute;+ top: 0.5rem;+ right: 0.5rem;+ z-index: 5;+ }++ .burger {+ display: flex;+ align-items: center;+ justify-content: center;+ padding: 0.4rem;+ background: none;+ border: 1px solid transparent;+ border-radius: var(--curve-factor);+ color: var(--settings-text-color);+ cursor: pointer;+ transition: background 0.15s, color 0.15s, border-color 0.15s;+ &:hover, &:focus-visible, &[aria-expanded="true"] {+ background: var(--background);+ border-color: var(--primary);+ color: var(--primary);+ }+ &:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }+ svg { width: 1.5rem; height: 1.5rem; }+ }+nav {display: flex;align-items: center;@@ -76,6 +135,7 @@ export default {max-width: 100%;overflow-x: auto;@extend .scroll-bar;+.nav-item {display: inline-block;padding: 0.75rem 0.5rem;@@ -88,7 +148,6 @@ export default {text-overflow: ellipsis;text-align: center;outline: none;- border: none;border-radius: var(--curve-factor);box-shadow: var(--nav-link-shadow);color: var(--nav-link-text-color);@@ -98,22 +157,31 @@ export default {&.router-link-active, &:hover {color: var(--nav-link-text-color-hover);background: var(--nav-link-background-color-hover);- border: 1px solid var(--nav-link-border-color-hover);+ border-color: var(--nav-link-border-color-hover);box-shadow: var(--nav-link-shadow-hover);}}++ &.as-menu {+ position: absolute;+ top: calc(100% + 0.25rem);+ right: 0;+ z-index: 10;+ flex-direction: column;+ align-items: stretch;+ min-width: 12rem;+ max-width: calc(100vw - 1rem);+ max-height: calc(100vh - 6rem);+ padding: 0.25rem;+ overflow-x: hidden;+ overflow-y: auto;+ background: var(--background-darker);+ border: 1px solid var(--primary);+ border-radius: var(--curve-factor);+ box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);+ .nav-item { margin: 0.25rem 0; max-width: none; min-width: 0; }+ }}- /* Mobile and Burger-Menu Styles */- @extend .svg-button;- @include phone {- width: 100%;- nav { flex-wrap: wrap; overflow-x: visible; }- }- .burger {- display: none;- &.visible { display: block; }- @include phone { display: block; }- }-}+}</style>