0.8.2 • Published 6 months ago

@dzangolab/vue3-layout v0.8.2

Weekly downloads
-
License
-
Repository
-
Last release
6 months ago

Dzangolab Vue3 Layout Plugin

Requirements

  • @dzangolab/vue3-config: >= 0.6.5
  • vue: >= 3.2
  • vue-router: >= 4.0

Installation

npm

npm install @dzangolab/vue3-layout @dzangolab/vue3-config`

yarn

yarn add @dzangolab/vue3-layout @dzangolab/vue3-config

PNPM

pnpm add @dzangolab/vue3-layout @dzangolab/vue3-config

Usage

main.ts

Import and register the plugin in main.ts.

import layoutPlugin from "@dzangolab/vue3-layout";
import "@dzangolab/vue3-layout/dist/DzangolabVue3Layout.css";

app.use(layoutPlugin);

...

app.mount("#app");

App.vue

  • Wrap your router view in the Layout component.
  • Optionnally, set a default layout. You can use one of our built-in layouts, or create your own. The default layout will be applied to all routes for which no layout is set.
<template>
  <Layout :default-layout="defaultLayout">
    <router-view />
  </Layout>
  <notifications />
</template>

<script setup lang="ts">
import { BasicLayout } from "@dzangolab/vue3-layout";
import { computed } from "vue";

const defaultLayout = computed(() => {
  return BasicLayout;
});
</script>

Set the layout for an individual route

The default layout set as the default-layout prop on the Layout component will apply by default to all routes, except those for which an explicit route is declared.

You can also customize the layout for individual routes by adding a meta.layout attribute to the route. The value of the attribute is the layout component you wish to use.

import { createRouter, createWebHistory } from "vue-router";

import CustomLayout from "@/layouts/CustomLayout.vue";
import Home from "@/views/Home.vue";
import ViewWithCustomLayout from "@/views/ViewWithCustomLayout.vue";

import type { RouteMeta, Router, RouterOptions } from "vue-router";

const router: Router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      component: HomeView,
      name: "home",
      path: "/",
    },
    {
      component: AboutView,
      meta: {
        layout: CustomLayout,
      },
      name: "custom",
      path: "/custom",
    },
  ],
} as RouterOptions);

export default router;

Configuration

NameTypeDescriptionDefault value
homeRoutestringThe name of the "home" route, ie the route that points to your app's home pagehome
logo stringThe path to the logo/logo.png
mainMenu{ name: string; route: string; }[]An array of items to display in the app header's main menunone

CSS Variables

Basic layout

NameDescriptionDefault value
layout-basic-gapSize of basic layout flex-box gap1rem
layout-basic-max-widthMaximum width of header, main and footer elements1200px
layout-basic-padding-leftLeft padding for header, main and footer elements0.8rem
layout-basic-padding-rightRight padding for header, main and footer elements0.8rem

AppHeader

NameDescriptionDefault value
header-bg-colorColor of header backgroundtransparent
header-border-colorColor of header (bottom) border#4169e1
header-font-sizeFont size of header text1rem
header-padding-bottomBottom padding for header0.8rem
header-padding-topTop padding for header0.8rem

App footer

NameDescriptionDefault value
footer-bg-colorColor of footer backgroundtransparent
footer-border-colorColor of footer (top) border#4169e1
footer-font-sizeFont size of footer text1rem
footer-gapSize of footer flex-box gap0.5rem
footer-padding-bottomBottom padding for footer0.8rem
footer-padding-topTop padding for footer0.8rem
0.8.1

8 months ago

0.8.0

9 months ago

0.8.2

6 months ago

0.7.10

1 year ago

0.7.9

1 year ago

0.7.6

1 year ago

0.6.7

1 year ago

0.7.5

1 year ago

0.7.8

1 year ago

0.6.9

1 year ago

0.7.7

1 year ago

0.6.8

1 year ago

0.6.10

1 year ago

0.7.2

1 year ago

0.7.1

1 year ago

0.7.4

1 year ago

0.7.3

1 year ago

0.7.0

1 year ago

0.6.5

1 year ago

0.6.4

1 year ago

0.6.3

1 year ago

0.6.2

1 year ago

0.6.1

1 year ago

0.6.0

1 year ago

0.5.1

1 year ago

0.5.0

1 year ago