Skip to content

Commit b2998c0

Browse files
committed
Merge remote-tracking branch 'origin/dev'
* origin/dev: docs: add sponsorship docs: add sponsorship (vuematerial#1246) Fix missing commas in Theme configuration (vuematerial#1244) chore: remove code sponsor :( feat(MdSelect): add md-selected event (vuematerial#1234) feat(MdSelect): add md-opened, md-closed events (vuematerial#1235) docs: improve Codepen examples by transpile all scripts and styles fix(MdApp): fix styles after ssr support
2 parents ddb7ff0 + 7299edf commit b2998c0

File tree

19 files changed

+271
-106
lines changed

19 files changed

+271
-106
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ before_script:
2323
- chmod +x ./cc-test-reporter
2424
- ./cc-test-reporter before-build
2525
script:
26+
- npm rebuild node-sass
2627
- yarn lint
2728
- yarn coverage
2829
- yarn build

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,13 @@ Vue Material is Simple, lightweight and built exactly according to the Google <a
2828

2929
Build well-designed apps that can fit on every screen with support to all modern Web Browsers with dynamic themes, components on demand and all with an ease-to-use API
3030

31-
<a target='_blank' rel='nofollow' href='https://app.codesponsor.io/link/265KRzahMKDQEQEzoo9BxRiH/vuematerial/vue-material'>
32-
<img alt='Sponsor' width='888' height='68' src='https://app.codesponsor.io/embed/265KRzahMKDQEQEzoo9BxRiH/vuematerial/vue-material.svg' />
33-
</a>
31+
## Sponsorship
32+
33+
Vue Material is proudly sponsored by [Rollbar](https://cs.berry.sh/c/c0597778-f465-4788-abe3-8711cc087774
34+
). They provide real-time error monitoring, alerting, and analytics for developers.
35+
36+
You can try Rollbar for free at [https://rollbar.com](https://cs.berry.sh/c/c0597778-f465-4788-abe3-8711cc087774
37+
) <img src="https://cs.berry.sh/l/c0597778-f465-4788-abe3-8711cc087774/pixel.png" />
3438

3539
## Demo and Documentation
3640

build/loaders/component-example-loader.js

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,36 @@
1+
const sass = require('node-sass')
2+
const pretty = require('pretty')
3+
const prettier = require('prettier')
14
const path = require('path')
25
const compiler = require('vue-template-compiler')
36
const transpile = require('vue-template-es2015-compiler')
7+
const { resolvePath } = require('../config')
8+
const { getIndentedSource } = require('../../docs/app/mixins/codeSource')
49

510
function camelCaseToDash (str) {
611
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase()
712
}
813

14+
function getComponentScript (script) {
15+
return getIndentedSource(`
16+
Vue.use(VueMaterial.default)
17+
18+
${script}
19+
20+
const app = new Vue(example)
21+
22+
app.$mount('#app')
23+
`)
24+
}
25+
26+
function getComponentTemplate (template) {
27+
return pretty(`
28+
<div id="app">
29+
${template}
30+
</div>
31+
`)
32+
}
33+
934
module.exports = function (source) {
1035
this.cacheable && this.cacheable()
1136

@@ -31,8 +56,36 @@ module.exports = function (source) {
3156

3257
let { script, template, style } = parsedTags
3358

59+
if (style) {
60+
style = style.replace(/~vue-material/g, '.')
61+
62+
const { css } = sass.renderSync({
63+
data: style,
64+
includePaths: [resolvePath('src')],
65+
outputStyle: 'expanded'
66+
})
67+
68+
style = css.toString('utf8')
69+
}
70+
71+
if (template) {
72+
template = template.replace(/src="\/assets/g, 'src="https://vuematerial.io/assets')
73+
template = getComponentTemplate(template)
74+
}
75+
3476
if (script) {
35-
script = script.replace('export default ', '')
77+
let newScript = null
78+
79+
script = script.replace('export default ', 'const example = ')
80+
script = getComponentScript(script)
81+
82+
try {
83+
newScript = transpile(script)
84+
} catch (e) {
85+
newScript = script
86+
}
87+
88+
script = prettier.format(newScript, { semi: false })
3689
}
3790

3891
const code = `

docs/app/components/CodepenEdit.vue

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,27 @@
2222
component: Object
2323
},
2424
computed: {
25-
/* eslint-disable */
2625
styles () {
2726
return this.component.style ? this.component.style : ''
2827
},
2928
html () {
30-
return `
31-
<div id="app">
32-
${this.component.template}
33-
</div>
34-
`
29+
return this.component.template
3530
},
3631
script () {
37-
return `
38-
Vue.use(VueMaterial.default)
39-
40-
const example = ${this.component.script}
41-
42-
new Vue({
43-
name: 'root',
44-
el: '#app',
45-
...example
46-
})
47-
`
32+
return this.component.script
4833
},
4934
externalScripts () {
5035
return [
51-
'https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.6.15/browser.js',
52-
'https://unpkg.com/vue',
36+
'https://unpkg.com/babel-standalone/babel.min.js',
37+
'https://unpkg.com/vue/dist/vue.min.js',
5338
`${vueMaterialUrl}`
5439
].join(';')
5540
},
5641
externalStyles () {
5742
return [
58-
`https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic`,
59-
`https://fonts.googleapis.com/icon?family=Material+Icons`,
43+
'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700,400italic|Material+Icons',
6044
`${vueMaterialUrl}/dist/vue-material.min.css`,
61-
'https://unpkg.com/vue-material@beta/dist/theme/default.css'
45+
`${vueMaterialUrl}/dist/theme/default.css`
6246
].join(';')
6347
},
6448
apiJson () {
@@ -72,11 +56,9 @@ new Vue({
7256
html: `${this.html}`,
7357
html_pre_processor: 'none',
7458
css: `${this.styles}`,
75-
css_pre_processor: 'scss',
7659
css_starter: 'neither',
7760
css_prefix: 'autoprefixer',
7861
js: `${this.script}`,
79-
js_pre_processor: 'babel',
8062
html_classes: '',
8163
head: '<meta name="viewport" content="width=device-width, initial-scale=1, minimal-ui">',
8264
css_external: `${this.externalStyles}`,
@@ -87,7 +69,6 @@ new Vue({
8769
apiContent () {
8870
return JSON.stringify(this.apiJson).replace(/"/g, '&​quot;').replace(/'/g, '&apos;');
8971
}
90-
/* eslint-enable */
9172
}
9273
}
9374
</script>

docs/app/mixins/codeSource.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export const getIndentedSource = source => {
2+
let lines = source.split('\n')
3+
let matches
4+
5+
if (lines[0] === '') {
6+
lines.shift()
7+
}
8+
9+
let indentation = (matches = (/^[\s\t]+/).exec(lines[0])) !== null ? matches[0] : null
10+
11+
if (indentation) {
12+
lines = lines.map(line => {
13+
line = line.replace(indentation, '')
14+
15+
return line.replace(/\t/g, ' ')
16+
})
17+
18+
return lines.join('\n').trim()
19+
}
20+
21+
return source
22+
}
23+
24+
export default {
25+
getIndentedSource,
26+
reindentSource () {
27+
const block = this.$refs.block
28+
29+
block.textContent = getIndentedSource(block.textContent)
30+
}
31+
}

docs/app/pages/Components/Button/examples/RegularButtons.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</style>
3434

3535
<script>
36-
export default {
37-
name: 'RegularButtons'
38-
}
36+
export default {
37+
name: 'RegularButtons'
38+
}
3939
</script>

docs/app/pages/Components/Datepicker/examples/DisabledDatesDatepicker.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,15 @@
55
</template>
66

77
<script>
8-
function isWeekend (date) {
9-
const day = date.getDay()
10-
11-
return day === 6 || day === 0
12-
}
13-
148
export default {
159
name: 'DisabledDatesDatepicker',
1610
data: () => ({
1711
selectedDate: null,
18-
disabledDates: date => isWeekend(date)
12+
disabledDates: date => {
13+
const day = date.getDay()
14+
15+
return day === 6 || day === 0
16+
}
1917
})
2018
}
2119
</script>

docs/app/pages/Components/Form/examples/FormValidation.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
</template>
7272

7373
<script>
74-
import Vue from 'vue'
7574
import { validationMixin } from 'vuelidate'
7675
import {
7776
required,

docs/app/pages/Components/Select/Select.vue

Lines changed: 75 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
<api-item title="API - md-select">
3333
<p>The following options can be applied to any select:</p>
3434

35-
<api-table :headings="select.headings" :props="select.props" slot="props" />
35+
<api-table :headings="select.props.headings" :props="select.props.props" slot="props" />
36+
<api-table :headings="select.events.headings" :props="select.events.props" slot="events" />
3637
</api-item>
3738

3839
<api-item title="API - md-option">
@@ -58,57 +59,79 @@
5859
mixins: [examples],
5960
data: () => ({
6061
select: {
61-
headings: ['Name', 'Description', 'Default'],
62-
props: [
63-
{
64-
name: 'v-model',
65-
type: 'String|Number|Boolean|Array',
66-
description: 'The model variable to bind the select value',
67-
defaults: 'null'
68-
},
69-
{
70-
name: 'placeholder',
71-
type: 'String',
72-
description: 'The select placeholder. Similar to HTML5 placeholder attribute.',
73-
defaults: 'null'
74-
},
75-
{
76-
name: 'required',
77-
type: 'String',
78-
description: 'The select required. Similar to HTML5 required attribute.',
79-
defaults: 'null'
80-
},
81-
{
82-
name: 'id',
83-
type: 'String',
84-
description: 'The select id. Similar to HTML5 id attribute.',
85-
defaults: 'null'
86-
},
87-
{
88-
name: 'name',
89-
type: 'String',
90-
description: 'The select name. Similar to HTML5 name attribute.',
91-
defaults: 'null'
92-
},
93-
{
94-
name: 'disabled',
95-
type: 'Boolean',
96-
description: 'Disable the select and prevent it selection.',
97-
defaults: 'false'
98-
},
99-
{
100-
name: 'multiple',
101-
type: 'Boolean',
102-
description: 'Create a multi selection with checkboxes inside. Only works with a <code>v-model</code> with an <code>Array</code>',
103-
defaults: 'false'
104-
},
105-
{
106-
name: 'md-dense',
107-
type: 'Boolean',
108-
description: 'Enable the dense layout',
109-
defaults: 'false'
110-
}
111-
]
62+
props: {
63+
headings: ['Name', 'Description', 'Default'],
64+
props: [
65+
{
66+
name: 'v-model',
67+
type: 'String|Number|Boolean|Array',
68+
description: 'The model variable to bind the select value',
69+
defaults: 'null'
70+
},
71+
{
72+
name: 'placeholder',
73+
type: 'String',
74+
description: 'The select placeholder. Similar to HTML5 placeholder attribute.',
75+
defaults: 'null'
76+
},
77+
{
78+
name: 'required',
79+
type: 'String',
80+
description: 'The select required. Similar to HTML5 required attribute.',
81+
defaults: 'null'
82+
},
83+
{
84+
name: 'id',
85+
type: 'String',
86+
description: 'The select id. Similar to HTML5 id attribute.',
87+
defaults: 'null'
88+
},
89+
{
90+
name: 'name',
91+
type: 'String',
92+
description: 'The select name. Similar to HTML5 name attribute.',
93+
defaults: 'null'
94+
},
95+
{
96+
name: 'disabled',
97+
type: 'Boolean',
98+
description: 'Disable the select and prevent it selection.',
99+
defaults: 'false'
100+
},
101+
{
102+
name: 'multiple',
103+
type: 'Boolean',
104+
description: 'Create a multi selection with checkboxes inside. Only works with a <code>v-model</code> with an <code>Array</code>',
105+
defaults: 'false'
106+
},
107+
{
108+
name: 'md-dense',
109+
type: 'Boolean',
110+
description: 'Enable the dense layout',
111+
defaults: 'false'
112+
}
113+
],
114+
},
115+
events: {
116+
headings: ['Name', 'Description', 'Value'],
117+
props: [
118+
{
119+
name: 'md-selected',
120+
description: 'Triggered when model changes.',
121+
value: 'Value of v-model'
122+
},
123+
{
124+
name: 'md-opened',
125+
description: 'Triggered when select is opened.',
126+
value: 'none'
127+
},
128+
{
129+
name: 'md-closed',
130+
description: 'Triggered when select is closed.',
131+
value: 'none'
132+
}
133+
]
134+
}
112135
},
113136
option: {
114137
headings: ['Name', 'Description', 'Default'],

0 commit comments

Comments
 (0)