Skip to content

Commit 6ff1910

Browse files
committed
feat: upgrade to new vuetify 2 spec
use `v-list-item` instead of `v-list-tile` remove `.eslintrc.js` in favor of `.eslintrc` fix typo use fibers for faster sass compilation assets option update example and refactor it as fixture upgrade dependencies update README.md BREAKING CHANGE: Removed `css`, implemented `assets` option
1 parent e3b6a52 commit 6ff1910

File tree

14 files changed

+963
-700
lines changed

14 files changed

+963
-700
lines changed

.eslintrc

Lines changed: 0 additions & 5 deletions
This file was deleted.

.eslintrc.js

100644100755
Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
11
module.exports = {
2-
root: true,
3-
parserOptions: {
4-
parser: 'babel-eslint',
5-
sourceType: 'module'
6-
},
72
extends: [
83
'@nuxtjs'
94
]

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Make sure you add the `vuetify-loader`, `stylus-loader` and `stylus` dependencie
4848

4949
- Clone this repository
5050
- Install dependencies using `yarn install` or `npm install`
51-
- Start development server using `npm run dev`
51+
- Start development server using `yarn dev` or `npm run dev`
5252

5353
## License
5454

commitlint.config.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

husky.config.js

Lines changed: 0 additions & 7 deletions
This file was deleted.

jest.config.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/module.js

Lines changed: 46 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,66 @@
11
const path = require('path')
2+
const merge = require('deepmerge')
23

34
const defaults = {
4-
css: true,
5-
materialIcons: true,
6-
treeShake: false
5+
assets: {
6+
font: true,
7+
icons: true
8+
},
9+
treeShake: process.env.NODE_ENV === 'production'
10+
}
11+
12+
// See https://github.com/vuetifyjs/vuetify/releases/tag/v2.0.0-alpha.12
13+
const sassLoaderOptions = {
14+
implementation: require('sass'),
15+
fiber: require('fibers')
716
}
817

918
module.exports = function (moduleOptions) {
1019
this.nuxt.hook('build:before', () => {
11-
const options = {
12-
...defaults,
13-
...this.options.vuetify,
14-
...moduleOptions
20+
const options = merge.all([
21+
defaults,
22+
this.options.vuetify,
23+
moduleOptions
24+
])
25+
26+
// User can disable all assets with ``
27+
if (options.assets === false) {
28+
options.assets = {
29+
font: false,
30+
icons: false
31+
}
1532
}
1633

34+
// Customize sass-loader options
35+
Object.assign(this.options.build.loaders.sass, sassLoaderOptions)
36+
Object.assign(this.options.build.loaders.scss, sassLoaderOptions)
37+
1738
// Add css
18-
if (options.css) {
19-
this.options.css.unshift('vuetify/dist/vuetify.css')
39+
if (options.treeShake) {
40+
this.options.css.push('vuetify/src/styles/main.sass')
41+
} else {
42+
this.options.css.push('vuetify/dist/vuetify.css')
43+
}
44+
45+
// Add Roboto font
46+
if (options.assets.font) {
47+
this.options.head.link.push({
48+
rel: 'stylesheet',
49+
type: 'text/css',
50+
href: '//fonts.googleapis.com/css?family=Roboto:300,400,500,700'
51+
})
2052
}
2153

22-
// Add Material Icons font
23-
if (options.materialIcons) {
54+
// Add Material Design Icons font
55+
if (options.assets.icons) {
2456
this.options.head.link.push({
2557
rel: 'stylesheet',
2658
type: 'text/css',
27-
href: '//fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons'
59+
href: '//cdn.materialdesignicons.com/3.5.95/css/materialdesignicons.min.css'
2860
})
2961
}
3062

63+
// Enable tree-shaking with VuetifyLoader (https://github.com/vuetifyjs/vuetify-loader)
3164
if (options.treeShake) {
3265
const VuetifyLoader = this.nuxt.resolver.requireModule('vuetify-loader/lib/plugin')
3366

@@ -40,8 +73,7 @@ module.exports = function (moduleOptions) {
4073

4174
// Remove module options
4275
const vuetifyOptions = { ...options }
43-
delete vuetifyOptions.css
44-
delete vuetifyOptions.materialIcons
76+
delete vuetifyOptions.assets
4577
delete vuetifyOptions.treeShake
4678

4779
// Register plugin

lib/plugin.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import Vue from 'vue'
22
<% if (options.treeShake) { %>
3-
import Vuetify from 'vuetify/lib';
3+
import Vuetify from 'vuetify/lib'
44
<% } else { %>
5-
import Vuetify from 'vuetify';
5+
import Vuetify from 'vuetify'
66
<% } %>
77

88
Vue.use(Vuetify)

package.json

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -14,39 +14,42 @@
1414
"access": "public"
1515
},
1616
"scripts": {
17-
"dev": "nuxt example",
18-
"lint": "eslint lib test",
19-
"test": "npm run lint && jest",
20-
"release": "standard-version && git push --follow-tags && npm publish"
17+
"dev": "nuxt test/fixture",
18+
"lint": "eslint .",
19+
"test": "yarn lint && jest",
20+
"release": "yarn test && standard-version && git push --follow-tags && npm publish"
2121
},
22-
"eslintIgnore": [
23-
"lib/plugin.js"
24-
],
2522
"files": [
2623
"lib"
2724
],
2825
"dependencies": {
29-
"vuetify": "^2.0.0-alpha.9"
30-
},
31-
"peerDependencies": {
26+
"deepmerge": "^3.2.0",
27+
"fibers": "^3.1.1",
28+
"sass": "^1.18.0",
29+
"sass-loader": "^7.1.0",
30+
"vuetify": "^2.0.0-alpha.12",
3231
"vuetify-loader": "^1.2.1"
3332
},
3433
"devDependencies": {
3534
"@nuxtjs/eslint-config": "^0.0.1",
36-
"babel-eslint": "^10.0.1",
37-
"codecov": "^3.2.0",
38-
"eslint": "^5.15.3",
35+
"codecov": "^3.3.0",
36+
"eslint": "^5.16.0",
3937
"eslint-config-standard": "^12.0.0",
4038
"eslint-plugin-import": "^2.16.0",
4139
"eslint-plugin-jest": "^22.4.1",
4240
"eslint-plugin-node": "^8.0.1",
43-
"eslint-plugin-promise": "^4.0.1",
41+
"eslint-plugin-promise": "^4.1.1",
4442
"eslint-plugin-standard": "^4.0.0",
4543
"eslint-plugin-vue": "^5.2.2",
46-
"jest": "^24.5.0",
47-
"nuxt-edge": "^2.5.1-25886888.5d7757bf",
44+
"jest": "^24.7.1",
45+
"nuxt-edge": "^2.6.2-25912807.87fcf556",
4846
"request": "^2.88.0",
4947
"request-promise-native": "^1.0.7",
5048
"standard-version": "^5.0.2"
49+
},
50+
"jest": {
51+
"testEnvironment": "node",
52+
"coverageDirectory": "./coverage/",
53+
"collectCoverage": true
5154
}
5255
}

example/layouts/default.vue renamed to test/fixture/layouts/default.vue

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
<template>
22
<v-app id="inspire" dark>
33
<v-navigation-drawer v-model="drawer" fixed clipped app>
4-
<v-list dense>
5-
<v-list-tile v-for="item in items" :key="item.text">
6-
<v-list-tile-action>
4+
<v-list>
5+
<v-list-item v-for="item in items" :key="item.text" link>
6+
<v-list-item-action>
77
<v-icon>{{ item.icon }}</v-icon>
8-
</v-list-tile-action>
8+
</v-list-item-action>
99
<v-list-item-content>
1010
<v-list-item-title>
1111
{{ item.text }}
1212
</v-list-item-title>
1313
</v-list-item-content>
14-
</v-list-tile>
15-
<v-subheader class="mt-3 grey--text text--darken-1">
16-
SUBSCRIPTIONS
14+
</v-list-item>
15+
<v-subheader class="mt-3 grey--text text--darken-1 text-uppercase">
16+
Subscriptions
1717
</v-subheader>
1818
<v-list>
19-
<v-list-tile v-for="item in items2" :key="item.text">
20-
<v-list-tile-avatar>
19+
<v-list-item v-for="item in items2" :key="item.text" link>
20+
<v-list-item-avatar>
2121
<img :src="`https://randomuser.me/api/portraits/men/${item.picture}.jpg`" alt="">
22-
</v-list-tile-avatar>
22+
</v-list-item-avatar>
2323
<v-list-item-title v-text="item.text" />
24-
</v-list-tile>
24+
</v-list-item>
2525
</v-list>
26-
<v-list-tile class="mt-3">
27-
<v-list-tile-action>
26+
<v-list-item class="mt-3">
27+
<v-list-item-action>
2828
<v-icon color="grey darken-1">
29-
add_circle_outline
29+
mdi-plus-circle-outline
3030
</v-icon>
31-
</v-list-tile-action>
31+
</v-list-item-action>
3232
<v-list-item-title class="grey--text text--darken-1">
3333
Browse Channels
3434
</v-list-item-title>
35-
</v-list-tile>
36-
<v-list-tile>
37-
<v-list-tile-action>
35+
</v-list-item>
36+
<v-list-item>
37+
<v-list-item-action>
3838
<v-icon color="grey darken-1">
39-
settings
39+
mdi-settings
4040
</v-icon>
41-
</v-list-tile-action>
41+
</v-list-item-action>
4242
<v-list-item-title class="grey--text text--darken-1">
4343
Manage Subscriptions
4444
</v-list-item-title>
45-
</v-list-tile>
45+
</v-list-item>
4646
</v-list>
4747
</v-navigation-drawer>
4848
<v-app-bar color="red" dense fixed clipped-left app>
4949
<v-app-bar-nav-icon @click.stop="drawer = !drawer" />
5050
<v-icon class="mx-3">
51-
fa-youtube
51+
mdi-youtube
5252
</v-icon>
5353
<v-toolbar-title class="mr-5 align-center">
5454
<span class="title">Youtube</span>
@@ -58,7 +58,7 @@
5858
<v-text-field
5959
placeholder="Search..."
6060
single-line
61-
append-icon="search"
61+
append-icon="mdi-magnify"
6262
color="white"
6363
hide-details
6464
/>
@@ -79,11 +79,13 @@ export default {
7979
return {
8080
drawer: true,
8181
items: [
82-
{ icon: 'trending_up', text: 'Most Popular' },
83-
{ icon: 'subscriptions', text: 'Subscriptions' },
84-
{ icon: 'history', text: 'History' },
85-
{ icon: 'featured_play_list', text: 'Playlists' },
86-
{ icon: 'watch_later', text: 'Watch Later' }
82+
{ icon: 'mdi-home', text: 'Home' },
83+
{ icon: 'mdi-fire', text: 'Trending' },
84+
{ icon: 'mdi-youtube-subscription', text: 'Subscriptions' },
85+
{ icon: 'mdi-folder', text: 'Library' },
86+
{ icon: 'mdi-history', text: 'History' },
87+
{ icon: 'mdi-clock', text: 'Watch Later' },
88+
{ icon: 'mdi-thumb-up', text: 'Liked videos' }
8789
],
8890
items2: [
8991
{ picture: 28, text: 'Joseph' },

0 commit comments

Comments
 (0)