@mapomodule/uikit 1.0.0-alpha.1 → 1.0.0-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,58 +1,80 @@
1
1
  <template>
2
2
  <v-navigation-drawer
3
3
  v-model="drawerSetter"
4
- :mini-variant="miniVariant"
4
+ :mini-variant.sync="miniVariant"
5
+ width="300"
5
6
  :clipped="this.$store.getters['mapo/app/clipped']"
6
7
  fixed
7
8
  app
8
9
  >
9
- <div class="sidebar__core">
10
- <SidebarList />
11
- <SidebarFooter />
10
+ <div class="menu_container">
11
+ <div>
12
+ <v-list-item>
13
+ <v-list-item-avatar v-if="avatar">
14
+ <v-img :src="avatar"></v-img>
15
+ </v-list-item-avatar>
16
+ <v-list-item-icon v-else>
17
+ <v-icon>mdi-account</v-icon>
18
+ </v-list-item-icon>
19
+ <v-list-item-title>{{
20
+ this.$mapo.$auth.user.username
21
+ }}</v-list-item-title>
22
+ <v-btn icon @click.stop="miniVariant = !miniVariant">
23
+ <v-icon>mdi-chevron-left</v-icon>
24
+ </v-btn>
25
+ </v-list-item>
26
+ <v-divider></v-divider>
27
+ </div>
28
+ <div class="menu_container">
29
+ <SidebarList :force-collapse="miniVariant" />
30
+ <SidebarFooter :force-collapse="miniVariant" />
31
+ </div>
12
32
  </div>
13
33
  </v-navigation-drawer>
14
34
  </template>
15
35
 
16
36
  <style lang="scss" scoped>
17
- @import '@mapomodule/uikit/assets/variables.scss';
18
-
19
- .sidebar {
20
- &__core {
21
- display: flex;
22
- flex-direction: column;
23
- height: 100%;
24
- // background: $b-1;
25
- // color: $white;
26
- }
37
+ @import "@mapomodule/uikit/assets/variables.scss";
38
+ .menu_container {
39
+ display: flex;
40
+ flex-direction: column;
41
+ height: 100%;
42
+ justify-content: space-between;
43
+ flex: 1;
27
44
  }
28
45
  </style>
29
46
 
30
47
  <script>
31
- import { mapMutations } from 'vuex'
32
48
  // @vuese
33
49
  export default {
34
50
  name: "Sidebar",
35
- data () {
51
+ data() {
36
52
  return {
37
- miniVariant: false,
38
- }
53
+ miniVariant: false
54
+ };
39
55
  },
40
56
  computed: {
41
57
  drawerSetter: {
42
58
  get() {
43
- return this.$store.getters['mapo/app/drawer'];
59
+ return this.$store.getters["mapo/app/drawer"];
44
60
  },
45
61
  set(value) {
46
- if (this.$store.getters['mapo/app/drawer'] !== value)
62
+ if (this.$store.getters["mapo/app/drawer"] !== value)
47
63
  this.$store.dispatch("mapo/app/toggleSidebarDrawer");
48
64
  return value;
49
65
  }
66
+ },
67
+ username() {
68
+ return this.$mapo.$auth.user.username;
69
+ },
70
+ avatar() {
71
+ return this.$mapo.$auth.user.avatar;
50
72
  }
51
73
  },
52
74
  methods: {
53
- drawerReverse () {
54
- return this.drawer = !this.drawer
55
- },
75
+ drawerReverse() {
76
+ return (this.drawer = !this.drawer);
77
+ }
56
78
  }
57
- }
79
+ };
58
80
  </script>
@@ -1,68 +1,60 @@
1
1
  <template>
2
- <div class="sidebar__ender">
3
- <sidebar-list-item
4
- class="sidebar__ender__item"
5
- v-for="(item, i) in routes"
6
- :key="i"
7
- :link="item.link"
8
- :label="item.label"
9
- :childrens="item.childrens"
10
- :icon="item.icon"
11
- />
12
- <logout-button class="sidebar__ender__item sidebar__ender__item--logout" />
2
+ <div>
3
+ <v-divider></v-divider>
4
+ <v-list dense class="py-0">
5
+ <SidebarListItem
6
+ v-for="(item, i) in routes"
7
+ :key="i"
8
+ :link="item.link"
9
+ :label="item.label"
10
+ :childrens="item.childrens"
11
+ :icon="item.icon"
12
+ :force-collapse="forceCollapse"
13
+ />
14
+ </v-list>
15
+ <v-divider></v-divider>
16
+ <v-list-item dense class="logout__button" link @click.native="logout">
17
+ <v-list-item-icon>
18
+ <v-icon>mdi-logout</v-icon>
19
+ </v-list-item-icon>
20
+ <v-list-item-title> Logout </v-list-item-title>
21
+ </v-list-item>
13
22
  </div>
14
23
  </template>
15
24
 
16
25
  <style lang="scss" scoped>
17
- @import "@mapomodule/uikit/assets/variables.scss";
18
-
19
- .sidebar {
20
- &__ender {
21
- margin-top: auto;
22
- display: flex;
23
- flex-direction: column;
24
- &__icon {
25
- font-size: 1rem;
26
- margin-right: 0.5rem;
27
- }
28
- &__item {
29
- display: block;
30
- width: 100%;
31
- text-decoration: none;
32
- color: white;
33
- background: $b-2;
34
- transition: all linear 0.25s;
35
- border-radius: 0;
36
- &:hover {
37
- background: rgba($b-2, 0.25);
38
- }
39
- &--logout {
40
- background: $black !important;
41
- &:hover {
42
- background: rgba($black, 0.25) !important;
43
- }
44
- }
45
- }
26
+ .logout__button{
27
+ &.theme--light{
28
+ background: #ffffffd6;
29
+ filter: invert(1);
30
+ }
31
+ &.theme--dark{
32
+ background: #121212;
46
33
  }
47
34
  }
48
35
  </style>
49
-
50
36
  <script>
51
37
  import { buildRoutes } from "../routebuilder";
52
38
 
53
39
  // @vuese
54
40
  export default {
55
41
  name: "SidebarFooter",
42
+ props: {
43
+ forceCollapse: {
44
+ type: Boolean,
45
+ default: false
46
+ }
47
+ },
56
48
  data() {
57
49
  return {
58
- defaultIcon: ({label}) => `mdi-alpha-${label[0]}-box`.toLowerCase(),
59
- routes: this.routes,
50
+ defaultIcon: ({ label }) => `mdi-alpha-${label[0]}-box`.toLowerCase(),
51
+ routes: this.routes
60
52
  };
61
53
  },
62
- mounted: function () {
54
+ mounted() {
63
55
  this.routes = this.buildRoutes(
64
56
  this.$router.options.routes.filter(
65
- (route) => route.meta && route.meta.sidebarFooter === true
57
+ route => route.meta && route.meta.sidebarFooter === true
66
58
  )
67
59
  );
68
60
  },
@@ -70,6 +62,9 @@ export default {
70
62
  buildRoutes(routes) {
71
63
  return buildRoutes(routes, this.defaultIcon);
72
64
  },
73
- },
65
+ logout() {
66
+ this.$store.dispatch("mapo/user/logout");
67
+ }
68
+ }
74
69
  };
75
70
  </script>
@@ -1,39 +1,36 @@
1
1
  <template>
2
- <div class="sidebar__list">
2
+ <v-list dense class="py-0 overflow-y-auto">
3
3
  <SidebarListItem
4
- class="sidebar__list__item"
5
4
  v-for="(item, i) in routes"
6
5
  :key="i"
7
6
  :link="item.link"
8
7
  :label="item.label"
9
8
  :childrens="item.childrens"
10
9
  :icon="item.icon"
10
+ :force-collapse="forceCollapse"
11
11
  />
12
- </div>
12
+ </v-list>
13
13
  </template>
14
14
 
15
- <style lang="scss" scoped>
16
- .sidebar {
17
- &__list {
18
- display: flex;
19
- flex-direction: column;
20
- }
21
- }
22
- </style>
23
-
24
15
  <script>
25
16
  import { buildRoutes } from "../routebuilder";
26
17
 
27
18
  // @vuese
28
19
  export default {
29
20
  name: "SidebarList",
21
+ props: {
22
+ forceCollapse: {
23
+ type: Boolean,
24
+ default: false
25
+ }
26
+ },
30
27
  data() {
31
28
  return {
32
29
  defaultIcon: ({label}) => `mdi-alpha-${label[0]}-circle`.toLowerCase(),
33
30
  routes: this.routes,
34
31
  };
35
32
  },
36
- mounted: function () {
33
+ mounted() {
37
34
  this.routes = this.buildRoutes(this.$router.options.routes.filter(route => !route.meta || !route.meta.sidebarFooter));
38
35
  },
39
36
  methods: {
@@ -1,36 +1,37 @@
1
1
  <template>
2
- <div :style="indent" class="sidebar__link__wrapper">
3
- <NuxtLink v-if="link" class="sidebar__link" :to="link">
4
- <v-icon v-if="icon" class="sidebar__link__icon">{{ icon }}</v-icon>
5
- {{ label }}
2
+ <div>
3
+ <v-list-item
4
+ :style="indent"
5
+ :exact-path="expanded"
6
+ @click.native="!link && (expanded = !expanded)"
7
+ link
8
+ :to="link"
9
+ >
10
+ <v-list-item-icon v-if="icon">
11
+ <v-icon>{{ icon }}</v-icon>
12
+ </v-list-item-icon>
13
+ <v-list-item-title>
14
+ {{ label }}
15
+ </v-list-item-title>
6
16
  <v-icon
7
17
  class="expand-icon"
8
18
  v-if="childrens.length"
9
19
  :style="rotate"
10
- @click.native.prevent="expanded = !expanded"
11
- >mdi-chevron-down</v-icon
12
- >
13
- </NuxtLink>
14
- <span
15
- @click.prevent="expanded = !expanded"
16
- v-if="!link"
17
- class="sidebar__link"
18
- >
19
- <v-icon v-if="icon" class="sidebar__link__icon">{{ icon }}</v-icon>
20
- {{ label }}
21
- <v-icon :style="rotate" class="expand-icon" v-if="childrens.length"
20
+ @click.native.prevent="link && (expanded = !expanded)"
22
21
  >mdi-chevron-down</v-icon
23
22
  >
24
- </span>
25
- <div v-if="childrens.length && expanded">
23
+ </v-list-item>
24
+
25
+ <div :style="indent" v-if="childrens.length && expanded && !forceCollapse">
26
26
  <SidebarListItem
27
27
  class="sidebar__list__item"
28
28
  v-for="(item, i) in childrens"
29
29
  :key="i"
30
+ :force-collapse="forceCollapse"
30
31
  :link="item.link"
31
32
  :label="item.label"
32
33
  :childrens="item.childrens"
33
- :depth="depth || 0 + 1"
34
+ :depth="(depth || 0) + 1"
34
35
  :icon="item.icon"
35
36
  />
36
37
  </div>
@@ -48,27 +49,6 @@
48
49
  border-radius: 50%;
49
50
  }
50
51
  }
51
-
52
- .sidebar {
53
- &__link {
54
- display: flex;
55
- align-items: center;
56
- justify-content: flex-start;
57
- width: 100%;
58
- padding: 0.5rem 1rem;
59
- text-decoration: none;
60
- color: $white;
61
- background: rgba(0, 0, 0, 0);
62
- transition: all linear 0.25s;
63
- text-transform: capitalize;
64
- &:hover {
65
- background: rgba(0, 0, 0, 0.25);
66
- }
67
- &__icon {
68
- margin-right: 0.5rem;
69
- }
70
- }
71
- }
72
52
  </style>
73
53
 
74
54
  <script>
@@ -76,19 +56,22 @@ export default {
76
56
  name: "SidebarListItem",
77
57
  data() {
78
58
  return {
79
- expanded: false,
59
+ expanded: false
80
60
  };
81
61
  },
82
62
  computed: {
83
63
  indent() {
84
- return { marginLeft: `${+this.depth * 10}px` };
64
+ return {
65
+ paddingLeft: `calc(1rem + ${+this.depth * 14}px)`,
66
+ marginLeft: this.depth > 1 && `calc(-1rem - ${(this.depth - 1) * 14}px)`
67
+ };
85
68
  },
86
69
  rotate() {
87
70
  return {
88
71
  transform: this.expanded ? "rotate(180deg)" : "rotate(0deg)",
89
- transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1)",
72
+ transition: "transform 225ms cubic-bezier(0.4, 0, 0.2, 1)"
90
73
  };
91
- },
74
+ }
92
75
  },
93
76
  props: {
94
77
  link: String,
@@ -96,6 +79,7 @@ export default {
96
79
  icon: String,
97
80
  childrens: Array,
98
81
  depth: Number,
99
- },
82
+ forceCollapse: Boolean
83
+ }
100
84
  };
101
85
  </script>
@@ -5,46 +5,13 @@
5
5
  app
6
6
  flat
7
7
  dense
8
- class="topbar__wrapper"
9
8
  >
10
9
  <v-app-bar-nav-icon @click.stop="drawerReverse()" />
11
10
  <v-toolbar-title v-text="title" />
12
- <v-spacer />
13
-
14
- <div class="topbar__user">
15
- <span class="topbar__user__name">
16
- Ciao, {{ this.$mapo.$auth.user.username }}
17
- </span>
18
- <v-btn
19
- class="topbar__user__btn"
20
- icon
21
- >
22
- <v-icon>mdi-account</v-icon>
23
- </v-btn>
24
- </div>
25
11
  </v-app-bar>
26
12
  </template>
27
13
 
28
- <style lang="scss" scoped>
29
- @import '@mapomodule/uikit/assets/variables.scss';
30
-
31
- .topbar {
32
- &__wrapper {
33
- // background: $black!important;
34
- // color: $white;
35
- }
36
- &__user {
37
- display: flex;
38
- align-items: center;
39
- &__name {
40
- margin-right: 0.5rem;
41
- }
42
- }
43
- }
44
- </style>
45
-
46
14
  <script>
47
- import { mapMutations } from 'vuex'
48
15
 
49
16
  export default {
50
17
  name: "Topbar",
@@ -52,9 +19,9 @@ export default {
52
19
  title: String
53
20
  },
54
21
  methods: {
55
- drawerReverse () {
22
+ drawerReverse() {
56
23
  this.$store.dispatch("mapo/app/toggleSidebarDrawer");
57
- },
58
- },
24
+ }
25
+ }
59
26
  };
60
27
  </script>
@@ -13,7 +13,7 @@ function buildRoutes(routes, defaultIcon) {
13
13
  .map((route) => {
14
14
  const { meta, path, name } = route
15
15
  const label = (route.meta && route.meta.label) || (path.split("/").pop() || "").replaceAll(':', '').replaceAll('-', ' ') || 'home'
16
- const icon = (route.meta && route.meta.icon) || getDefaultIcon({ route, label }, defaultIcon)
16
+ const icon = route.meta && route.meta.icon !== undefined ? route.meta.icon : getDefaultIcon({ route, label }, defaultIcon)
17
17
  return { label, icon, meta, name, link: path, relPath: path.slice(1), childrens: [] };
18
18
  }),
19
19
  defaultIcon
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <v-app class="app__wrapper">
2
+ <v-app>
3
3
  <Sidebar />
4
4
  <Topbar :title="title" :drawer="this.$store.getters['mapo/app/drawer']" />
5
5
  <v-main>
6
- <v-container>
6
+ <v-container fluid>
7
7
  <nuxt />
8
8
  <root-components />
9
9
  </v-container>
@@ -11,15 +11,6 @@
11
11
  </v-app>
12
12
  </template>
13
13
 
14
- <style lang="scss" scoped>
15
- @import "@mapomodule/uikit/assets/variables.scss";
16
-
17
- .app {
18
- &__wrapper {
19
- // background: $w-1;
20
- }
21
- }
22
- </style>
23
14
 
24
15
  <script>
25
16
  export default {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mapomodule/uikit",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.6",
4
4
  "license": "MIT",
5
5
  "description": "This is part of Mapo nuxt module. Injects Mapo ui components in the nuxt component discovery system.",
6
6
  "author": "bnznamco <gabriele.baldi.01@gmail.com>",
@@ -13,5 +13,5 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "gitHead": "a480dac2e2e78e66e0b5b35bd2f03bc3e1575246"
16
+ "gitHead": "c30717d018606a1393f3a1f680276b1817d1d7a8"
17
17
  }
package/pages/index.vue CHANGED
@@ -1,81 +1,18 @@
1
1
  <template>
2
2
  <v-row justify="center" align="center">
3
3
  <v-col cols="12" sm="8" md="12">
4
-
5
- <v-btn
6
- class="elevation-0 rounded-0"
7
- color="primary"
8
- nuxt
9
- to="/login"
10
- style="margin-top: 1rem"
11
- >
12
- Test Login Page
13
- </v-btn>
14
- <hr />
15
-
16
4
  <div class="mapo-info">
17
- <h1 id="mapo">Mapo</h1>
18
- <h2 id="build-setup">Build Setup</h2>
19
- <h3 id="install-dependencies">install dependencies</h3>
20
- <p>$ yarn bootstrap</p>
21
- <h3 id="serve-with-hot-reload-at-localhost-3000">
22
- serve with hot reload at localhost:3000
23
- </h3>
24
- <p>$ yarn dev</p>
25
- <h3 id="to-install-this-module-in-a-nuxt-project">
26
- to install this module in a nuxt project
27
- </h3>
28
- <p>$ yarn add mapomodule</p>
29
- <h2 id="working-on-the-project">Working on the project</h2>
30
- <h3 id="how-to-contribute">How to contribute</h3>
31
- <p>
32
- Feel free to contribute to the project by making a
33
- <a
34
- href="https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request"
35
- >Pull Request</a
36
- >. Here&#39;s an example for a branch naming:
37
- </p>
38
- <p><code>feature/&lt;branch name&gt;</code></p>
39
- <p>
40
- Once you&#39;re done with your work and are ready to make a Pull
41
- Request, set the reviewers to Gabriele Baldi (bnznamco) and Andrea
42
- Morosi (andreamorosi).
43
- </p>
44
- <h3 id="documenting-components">Documenting components</h3>
45
- <p>
46
- Always write some documentation regarding the components you&#39;re
47
- developing. We are working on a StorybookJS implementation, which is
48
- going to help in this regard.
49
- </p>
50
- <h3 id="how-to-edit-and-add-configurations-and-settings">
51
- How to edit and add configurations and settings
52
- </h3>
53
- <p>
54
- Our library doesn&#39;t have a standard nuxt.config.js file, so in
55
- order to add the stuff which usually goes there you&#39;re going to
56
- either work on the defaults.js file, for configurations and such, or
57
- on the module.js file for modules and plugins. Both files are located
58
- in the root of the project.
59
- </p>
60
- <h3 id="urls-and-accessing-resources">URLs and accessing resources</h3>
61
- <p>
62
- We are using an alias (mapo) to access resources and files. Here&#39;s
63
- an example featuring a SCSS import in a component file:
64
- </p>
65
- <p>
66
- <code>@import &quot;@mapomodule/uikit/assets/custom-style.scss&quot;;</code>
67
- </p>
68
- <h2 id="external-resources">External resources</h2>
69
- <p>
70
- For detailed explanation on how things work, check out
71
- <a href="https://nuxtjs.org">Nuxt.js docs</a>.
72
- </p>
73
- <p>
74
- <a
75
- href="https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request"
76
- >https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request</a
77
- >
78
- </p>
5
+ <h1 id="mapo">
6
+ <code>mapomodule {{ version }}</code>
7
+ </h1>
8
+ <br>
9
+ <br>
10
+ <code>Congratulations!! 🥳 You succesfully installed Mapo! </code>
11
+ <br>
12
+ <br>
13
+ <code>
14
+ ## TODO INSERT HERE A LITTLE TUTORIAL.
15
+ </code>
79
16
  </div>
80
17
  </v-col>
81
18
  </v-row>
@@ -83,16 +20,16 @@
83
20
 
84
21
  <style scoped>
85
22
  .mapo-info {
86
- background: #333333;
87
23
  border-radius: 8px;
88
24
  margin: 10px 5%;
89
25
  padding: 10px;
90
26
  }
91
27
  </style>
92
28
  <script>
29
+ import { version } from "mapomodule/package.json";
93
30
  export default {
94
- data() {
95
- return {};
96
- },
31
+ data: () => ({
32
+ version: version
33
+ }),
97
34
  };
98
35
  </script>