diff --git a/components/ripple/README.md b/components/ripple/README.md
index 72480261b..67097aa04 100644
--- a/components/ripple/README.md
+++ b/components/ripple/README.md
@@ -1,5 +1,75 @@
## Ripple
+Material Components Vue provides a customized directive `v-ripple` to provide any components with ripple effect.
+
+### Minimal Usage
+
+```html
+Button
+```
+
+### Use primary color as ripple color
+
+```html
+Button
+```
+
+### Use secondary color as ripple color
+
+```html
+Button
+```
+
+### Customized your ripple using SASS
+
+```html
+
+ Button
+
+
+
+```
+
+### CSS-Only ripple
+
+```html
+Button
+```
+
+### Activate or deactivate using binding value
+
+Notice that this usage can only be applied to Vue components instead of native elements like `
`, `
`.
+
+```html
+
+ Button
+
+
+
+```
+
+Content below is deprecated, which means they may be removed in the future versions.
+
### Markup
```html
diff --git a/components/ripple/index.js b/components/ripple/index.js
index 4feef6e40..c66f4a712 100644
--- a/components/ripple/index.js
+++ b/components/ripple/index.js
@@ -1,11 +1,36 @@
import Ripple from './Ripple.vue'
+import { MDCRipple } from '@material/ripple'
import './styles.scss'
import { initPlugin } from '../'
+function setup (el, binding) {
+ const mod = binding.modifiers
+ mod.customized ? el.classList.remove('mdc-ripple-surface') : el.classList.add('mdc-ripple-surface')
+ mod.primary ? el.classList.add('mdc-ripple-surface--primary') : el.classList.remove('mdc-ripple-surface--primary')
+ if (mod.accent) {
+ el.classList.add('mdc-ripple-surface--accent')
+ }
+ return MDCRipple.attachTo(el)
+}
+
const plugin = {
install (vm) {
vm.component('m-ripple', Ripple)
+ vm.directive('ripple', {
+ bind: function (el, binding, vnode) {
+ const mdcRipple = setup(el, binding)
+ if (vnode.componentInstance && !binding.modifiers['css-only']) vnode.componentInstance.mdcRipple = mdcRipple
+ },
+ componentUpdated: function (el, binding, vnode) {
+ vnode.componentInstance && typeof binding.oldValue === 'boolean' && typeof binding.value === 'boolean' && binding.oldValue !== binding.value && binding.value
+ ? vnode.componentInstance.mdcRipple.activate()
+ : vnode.componentInstance.mdcRipple.deactivate()
+ },
+ unbind: function (el, binding, vnode) {
+ if (vnode.componentInstance && vnode.componentInstance.mdcRipple) vnode.componentInstance.mdcRipple.destroy()
+ }
+ })
}
}
export default plugin
diff --git a/docs/.vuepress/components/RippleDemo.vue b/docs/.vuepress/components/RippleDemo.vue
new file mode 100644
index 000000000..be32f264b
--- /dev/null
+++ b/docs/.vuepress/components/RippleDemo.vue
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/.vuepress/components/ripple/MyButton.vue b/docs/.vuepress/components/ripple/MyButton.vue
new file mode 100644
index 000000000..1fd045afe
--- /dev/null
+++ b/docs/.vuepress/components/ripple/MyButton.vue
@@ -0,0 +1,13 @@
+
+ BUTTON
+
+
+
+
+
\ No newline at end of file
diff --git a/docs/.vuepress/enhanceApp.js b/docs/.vuepress/enhanceApp.js
index bd1ac6b2a..2133a7b1f 100644
--- a/docs/.vuepress/enhanceApp.js
+++ b/docs/.vuepress/enhanceApp.js
@@ -27,6 +27,7 @@ import Switch from '../../components/switch'
import LinearProgress from '../../components/linear-progress'
import Snackbar from '../../components/snackbar'
import Tabs from '../../components/tabs'
+import Ripple from '../../components/ripple'
export default ({
Vue, // the version of Vue being used in the VuePress app
@@ -61,4 +62,5 @@ export default ({
Vue.use(LinearProgress)
Vue.use(Snackbar)
Vue.use(Tabs)
+ Vue.use(Ripple)
}
diff --git a/docs/components/README.md b/docs/components/README.md
index 7a390eb97..3716ba6e8 100644
--- a/docs/components/README.md
+++ b/docs/components/README.md
@@ -144,6 +144,10 @@ The demonstration in this page is a work in progress..
+## Ripple
+
+
+
## Snackbar