Skip to content

Commit 014e38d

Browse files
authored
comp(MdDialog): create dialog component (#24)
* comp(MdDialog): add initial files for dialogs * test(MdDialog): fix broken tests * comp(MdDialog): crate initial styles for dialog * fix(MdDialog): fix overlay not being rendered on the correct place * test(MdDialog): add initial tests * fix(MdDialog): fix wrong imports * fix(MdDialog): move file to its right place * chore: fix conflict * fix(MdDialog): remove blurry text * docs(Core): add global page loading * chore: improve webpack build time by removing eslint-loader * feat(MdDialog): create close and focus events * feat(MdDialog): create alert, confirm, and prompt dialogs * docs(Core): fix navigation close not triggering the correct mutation * feat(MdDialog): create responsive full screen dialogs * feat(MdDialog): start the creation of animation source
1 parent c421630 commit 014e38d

File tree

21 files changed

+482
-96
lines changed

21 files changed

+482
-96
lines changed

build/local/webpack.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import webpack from 'webpack'
22
import HtmlWebpackPlugin from 'html-webpack-plugin'
33
import FriendlyErrorsPlugin from 'friendly-errors-webpack-plugin'
4-
import eslintFormatter from 'eslint-friendly-formatter'
54
import { config, resolvePath } from '../config'
65

76
const componentExampleLoader = require.resolve('./loaders/component-example-loader')
7+
const cssLoaders = 'vue-style-loader!css-loader'
8+
const scssLoaders = 'vue-style-loader!css-loader!sass-loader?outputStyle=compressed'
9+
const babelLoader = 'babel-loader?cacheDirectory=true'
810

911
export default {
1012
devtool: '#cheap-module-eval-source-map',
@@ -26,38 +28,30 @@ export default {
2628
},
2729
module: {
2830
rules: [
29-
{
30-
test: /\.(js|vue)$/,
31-
loader: 'eslint-loader',
32-
enforce: 'pre',
33-
options: {
34-
fix: true,
35-
formatter: eslintFormatter
36-
}
37-
},
3831
{
3932
test: /\.vue$/,
4033
loader: 'vue-loader',
4134
options: {
4235
loaders: {
43-
css: 'vue-style-loader!css-loader',
44-
scss: 'vue-style-loader!css-loader!sass-loader?outputStyle=compressed',
36+
css: cssLoaders,
37+
scss: scssLoaders,
38+
js: babelLoader,
4539
example: componentExampleLoader
4640
}
4741
}
4842
},
4943
{
5044
test: /\.js$/,
51-
loader: 'babel-loader',
45+
loader: babelLoader,
5246
exclude: /node_modules/
5347
},
5448
{
5549
test: /\.css$/,
56-
use: ['vue-style-loader', 'css-loader']
50+
loader: cssLoaders
5751
},
5852
{
5953
test: /\.scss$/,
60-
use: ['vue-style-loader', 'css-loader', 'sass-loader']
54+
loader: scssLoaders
6155
},
6256
{
6357
test: /\.(png|jpe?g|gif|svg)(\?.*)?$/,

docs/app/App.vue

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,41 @@
11
<template>
22
<div class="container" :class="containerClass">
3-
<main-header></main-header>
3+
<main-header />
44

55
<div class="container-wrapper md-layout-row" :class="containerClass">
6-
<main-nav :is-splash="isSplash"></main-nav>
6+
<main-nav :is-splash="isSplash" />
77

8-
<router-view></router-view>
8+
<keep-alive>
9+
<router-view v-if="!loading" />
10+
</keep-alive>
11+
12+
<div class="main-container" v-if="loading">
13+
<code-loading />
14+
</div>
915
</div>
1016

11-
<main-footer></main-footer>
17+
<main-footer />
1218
</div>
1319
</template>
1420

1521
<script>
1622
import { mapState } from 'vuex'
23+
import CodeLoading from './components/CodeLoading'
1724
import MainHeader from './template/MainHeader'
1825
import MainNav from './template/MainNav'
1926
import MainFooter from './template/MainFooter'
2027
2128
export default {
2229
name: 'App',
2330
components: {
31+
CodeLoading,
2432
MainHeader,
2533
MainNav,
2634
MainFooter
2735
},
36+
data: () => ({
37+
loading: false
38+
}),
2839
computed: {
2940
...mapState({
3041
isSplash: 'splashPage'
@@ -34,6 +45,19 @@
3445
splash: this.isSplash
3546
}
3647
}
48+
},
49+
methods: {
50+
beforeRouteRender (to, from, next) {
51+
this.loading = true
52+
next()
53+
},
54+
afterRouteRender () {
55+
this.loading = false
56+
}
57+
},
58+
created () {
59+
this.$router.beforeEach(this.beforeRouteRender)
60+
this.$router.afterEach(this.afterRouteRender)
3761
}
3862
}
3963
</script>
@@ -92,4 +116,12 @@
92116
position: relative;
93117
z-index: 1;
94118
}
119+
120+
.code-loading {
121+
position: absolute;
122+
top: 0;
123+
right: 0;
124+
bottom: 0;
125+
left: 0;
126+
}
95127
</style>

docs/app/pages/Components/Dialog/Dialog.vue

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,27 @@
1-
<example src="./examples/Example.vue" />
1+
<example src="./examples/Custom.vue" />
2+
<example src="./examples/Presets.vue" />
23

34
<template>
45
<page-container centered :title="$t('pages.dialog.title')">
56
<div class="page-container-section">
6-
<p>Lorem ipsum</p>
7+
<p>Dialogs inform users about a specific task and may contain critical information, require decisions, or involve multiple tasks. The dialog component works with any plain html content. You can have tabs, all form components and more.</p>
8+
<p>The component can be used with a custom markup, using the auxiliary components, or with presets by Vue Material. Those presets emulates the default Dialogs from Javascript, like confirm, alert and prompt.</p>
79
</div>
810

911
<div class="page-container-section">
1012
<h2>Dialog</h2>
1113

12-
<code-example title="Example" :component="examples['example']" />
14+
<code-example title="Custom Dialog Markup" :component="examples['custom']" />
15+
16+
<api-item title="API - md-dialog">
17+
<p>This component do not have any extra option.</p>
18+
</api-item>
19+
</div>
20+
21+
<div class="page-container-section">
22+
<h2>Presets</h2>
23+
24+
<code-example title="Alert, Confirm and Prompt" :component="examples['presets']" />
1325

1426
<api-item title="API - md-dialog">
1527
<p>This component do not have any extra option.</p>

docs/app/pages/Components/Dialog/examples/Example.vue renamed to docs/app/pages/Components/Dialog/examples/Custom.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<div>
3-
<md-dialog :md-active.sync="showDialog" md-animate-from-source md-open-from="#custom" md-close-to="#custom">
3+
<md-dialog :md-active.sync="showDialog">
44
<md-dialog-title>Lorem ipsum dolor sit amet</md-dialog-title>
55

66
<md-dialog-content>Nemo, nobis necessitatibus ut illo, ducimus ex.</md-dialog-content>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<template>
2+
<div>
3+
<div class="row">
4+
<md-dialog-alert
5+
:md-active.sync="alert.one"
6+
md-content="Your post has been deleted!"
7+
md-confirm-text="Cool!" />
8+
9+
<md-dialog-alert
10+
:md-active.sync="alert.two"
11+
md-title="Post created!"
12+
md-content="Your post <strong>Material Design is awesome</strong> has been created." />
13+
14+
<md-button class="md-accent md-raised" @click="alert.one = true">Alert</md-button>
15+
<md-button class="md-primary md-raised" @click="alert.two = true">Alert</md-button>
16+
</div>
17+
18+
<div class="row">
19+
<md-dialog-confirm
20+
:md-active.sync="confirm.active"
21+
md-title="Use Google's location service?"
22+
md-content="Let Google help apps determine location. <br> This means sending <strong>anonymous</strong> location data to Google, even when no apps are running."
23+
md-confirm-text="Agree"
24+
md-cancel-text="Disagree"
25+
@md-cancel="onCancel"
26+
@md-confirm="onConfirm" />
27+
28+
<md-button class="md-primary md-raised" @click="confirm.active = true">Confirm</md-button>
29+
<span v-if="confirm.value">Value: {{ confirm.value }}</span>
30+
</div>
31+
32+
<div class="row">
33+
<md-dialog-prompt
34+
:md-active.sync="prompt.active"
35+
v-model="prompt.value"
36+
md-title="What's your name?"
37+
md-input-maxlength="30"
38+
md-input-placeholder="Type your name..."
39+
md-confirm-text="Done" />
40+
41+
<md-button class="md-primary md-raised" @click="prompt.active = true">Prompt</md-button>
42+
<span v-if="prompt.value">Value: {{ prompt.value }}</span>
43+
</div>
44+
</div>
45+
</template>
46+
47+
<script>
48+
export default {
49+
name: 'Example',
50+
data: () => ({
51+
alert: {
52+
one: false,
53+
two: false
54+
},
55+
confirm: {
56+
active: false,
57+
value: null
58+
},
59+
prompt: {
60+
active: false,
61+
value: null
62+
}
63+
}),
64+
methods: {
65+
onConfirm () {
66+
this.confirm.value = 'Agreed'
67+
},
68+
onCancel () {
69+
this.confirm.value = 'Disagreed'
70+
}
71+
}
72+
}
73+
</script>
74+
75+
<style lang="scss" scoped>
76+
.row {
77+
display: flex;
78+
align-items: center;
79+
}
80+
</style>

docs/app/template/MainNav.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</md-content>
77
</transition>
88

9-
<md-drawer md-fixed :md-visible.sync="menuVisible" @md-closed="hideMenu">
9+
<md-drawer md-fixed :md-visible.sync="isMenuVisible" @md-closed="hideMenu">
1010
<md-toolbar class="md-transparent" md-elevation="0">
1111
<logo-vue-material class="md-icon" animated :blending="false" />
1212
<span class="md-title">Vue material</span>
@@ -29,12 +29,20 @@ export default {
2929
components: {
3030
MainNavContent
3131
},
32+
data: () => ({
33+
isMenuVisible: false
34+
}),
3235
computed: {
3336
...mapState({
3437
isSplash: 'splashPage',
3538
menuVisible: 'menuVisible'
3639
})
3740
},
41+
watch: {
42+
menuVisible (isMenuVisible) {
43+
this.isMenuVisible = isMenuVisible
44+
}
45+
},
3846
methods: {
3947
...mapMutations({
4048
hideMenu: types.HIDE_MENU

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@
6868
"cz-conventional-changelog": "^2.0.0",
6969
"eslint": "^4.8.0",
7070
"eslint-config-standard": "^10.2.1",
71-
"eslint-friendly-formatter": "^3.0.0",
72-
"eslint-loader": "^1.9.0",
7371
"eslint-plugin-import": "^2.7.0",
7472
"eslint-plugin-jest": "^21.2.0",
7573
"eslint-plugin-node": "^5.2.0",

src/components/MdDialog/MdDialog.test.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,3 @@ test('should render the dialog', async () => {
77

88
expect(wrapper.hasClass('md-dialog')).toBe(true)
99
})
10-
11-
test('should render the theme class', async () => {
12-
const template = '<md-dialog md-theme="alt"></md-dialog>'
13-
const wrapper = await mountTemplate(MdDialog, template)
14-
15-
expect(wrapper.hasClass('md-theme-alt')).toBe(true)
16-
})

0 commit comments

Comments
 (0)