Skip to content
This repository was archived by the owner on May 8, 2025. It is now read-only.

Commit 23c25ec

Browse files
committed
chore: update structure with latest changes
1 parent 875af38 commit 23c25ec

File tree

9 files changed

+60
-64
lines changed

9 files changed

+60
-64
lines changed

packages/@vuetify/presets/generator/templates/base/src/components/README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,12 @@
11
# Components
2+
23
> Create your regular and base components here
34
45
This folder is for organizing your project's components. It is structured to support the official Vue [**style-guide**](https://vuejs.org/v2/style-guide/#Component-files-strongly-recommended).
5-
Below are _examples_ of varoius project structures for **components**.
6-
7-
### Custom
8-
A custom component is one that is used in more than one place but is not generic enough to used as a _app_ component.
96

107
```bash
11-
.
12-
└── components
13-
├── CustomComponent.vue
14-
└── CustomComponentTwo.vue
15-
```
16-
178
### App
9+
1810
[**App components**](https://vuejs.org/v2/style-guide/#Base-component-names-strongly-recommended) are global components that should always be in the root of the `/app` folder. These components will be automatically bootstrapped into Vue via the **app.js** plugin.
1911

2012
```bash
@@ -30,7 +22,8 @@ A custom component is one that is used in more than one place but is not generic
3022
└── vuetify.js
3123
```
3224

33-
**Example usage**
25+
## Example usage
26+
3427
This is an example of how to use **app components**; global components that can be used in any other component.
3528

3629
```vue
@@ -71,3 +64,14 @@ This is an example of how to use **app components**; global components that can
7164
```
7265

7366
> The component's **name** property is automatically prefixed with the word `App`. For example, a name of `Btn` would yield `AppBtn`.
67+
68+
## Custom
69+
70+
A custom component is one that is used in more than one place but is not generic enough to used as a _app_ component.
71+
72+
```bash
73+
.
74+
└── components
75+
├── CustomComponent.vue
76+
└── CustomComponentTwo.vue
77+
```

packages/@vuetify/presets/generator/templates/base/src/components/app/Btn.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<script>
1313
export default {
14-
name: 'Btn',
14+
name: 'AppBtn',
1515
1616
props: {
1717
color: {
@@ -23,5 +23,6 @@
2323
</script>
2424

2525
<style lang="sass">
26-
// .v-btn--app
26+
.v-btn--app
27+
//
2728
</style>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Layouts
2+
23
> Accommodate multiple page structures with dynamic layouts.
34
45
Use layouts to make large visual changes between different views.

packages/@vuetify/presets/generator/templates/base/src/layouts/default/AppBar.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,5 @@
55
</template>
66

77
<script>
8-
export default {
9-
name: 'AppBar',
10-
}
8+
export default { name: 'DefaultAppBar' }
119
</script>

packages/@vuetify/presets/generator/templates/base/src/layouts/default/View.vue

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,5 @@
77
</template>
88

99
<script>
10-
export default {
11-
name: 'AppView',
12-
}
10+
export default { name: 'DefaultView' }
1311
</script>

packages/@vuetify/presets/generator/templates/base/src/layouts/default/Index.vue renamed to packages/@vuetify/presets/generator/templates/base/src/layouts/default/index.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-app>
3-
<default-bar />
3+
<default-app-bar />
44

55
<default-view />
66
</v-app>
@@ -11,7 +11,7 @@
1111
name: 'DefaultLayout',
1212
1313
components: {
14-
DefaultBar: () => import('./AppBar'),
14+
DefaultAppBar: () => import('./AppBar'),
1515
DefaultView: () => import('./View'),
1616
},
1717
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Plugins
2+
23
> Additions to Vue and/or Vuetify
34
45
For new plugins, create a JavaScript file, perform your logic, and import it into `./srcs/plugins/index.js`

packages/@vuetify/presets/generator/templates/base/src/plugins/app.js

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,19 @@
22
* plugins/app.js
33
*
44
* Automatically loads and bootstraps files
5-
* in the `./src/components/app` folder.
5+
* in the `./src/components/` folder.
66
*/
77

8-
// Imports
9-
import Vue from 'vue'
10-
import {
11-
camelCase,
12-
upperFirst,
13-
} from 'lodash'
8+
export function registerComponents (app) {
9+
// Get all .vue files within `src/components/app`
10+
const requireComponent = require.context('@/components', true, /\.vue$/)
1411

15-
// Get all .vue files within `src/components/app`
16-
const requireComponent = require.context('@/components/app', true, /\.vue$/)
12+
for (const file of requireComponent.keys()) {
13+
const componentConfig = requireComponent(file)
1714

18-
for (const file of requireComponent.keys()) {
19-
const componentConfig = requireComponent(file)
20-
const name = file
21-
.replace(/index.js/, '')
22-
.replace(/^\.\//, '')
23-
.replace(/\.\w+$/, '')
24-
const componentName = upperFirst(camelCase(name))
25-
26-
Vue.component(`App${componentName}`, componentConfig.default || componentConfig)
15+
app.component(
16+
componentConfig.default.name,
17+
componentConfig.default || componentConfig,
18+
)
19+
}
2720
}

packages/@vuetify/presets/generator/templates/base/src/router/index.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ import Router from 'vue-router'
1010

1111
Vue.use(Router)
1212

13-
const router = new Router({
14-
mode: 'history',
15-
base: process.env.BASE_URL,
16-
scrollBehavior: (to, from, savedPosition) => {
17-
if (to.hash) return { selector: to.hash }
18-
if (savedPosition) return savedPosition
13+
export function createRouter () {
14+
return new Router({
15+
mode: 'history',
16+
base: process.env.BASE_URL,
17+
scrollBehavior: (to, from, savedPosition) => {
18+
if (to.hash) return { selector: to.hash }
19+
if (savedPosition) return savedPosition
1920

20-
return { x: 0, y: 0 }
21-
},
22-
routes: [
23-
{
24-
path: '/',
25-
// Layouts allow you to define different
26-
// structures for different view
27-
component: () => import('@/layouts/default/Index.vue'),
28-
children: [
29-
{
30-
path: '',
31-
name: 'Home',
32-
component: () => import('@/views/home/Index.vue'),
33-
},
34-
],
21+
return { x: 0, y: 0 }
3522
},
36-
],
37-
})
38-
39-
export default router
23+
routes: [
24+
{
25+
path: '/',
26+
// Layouts allow you to define different
27+
// structures for different view
28+
component: () => import('@/layouts/default'),
29+
children: [
30+
{
31+
path: '',
32+
name: 'Home',
33+
component: () => import('@/views/home'),
34+
},
35+
],
36+
},
37+
],
38+
})
39+
}

0 commit comments

Comments
 (0)