Skip to content

Commit

Permalink
feat(toolbar): add support for custom icons
Browse files Browse the repository at this point in the history
BREAKING CHANGE:
- mdc-toolbar-menu replaces mdc-toolbar-icon-menu
- use icon prop instead of slot to set the icon
  • Loading branch information
stasson committed Sep 30, 2017
1 parent 4322914 commit d975a18
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 29 deletions.
2 changes: 1 addition & 1 deletion components/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

### Custom Icons

> You can ommit the icon prop to render your custom icons
> do not set the icon prop to render your custom icons
**Font Awsome**

Expand Down
2 changes: 1 addition & 1 deletion components/icon/mdc-icon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export default {
name: 'mdc-icon',
props: {
icon: String
},
}
}
</script>
18 changes: 17 additions & 1 deletion components/toolbar/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<mdc-toolbar-title>Title</mdc-toolbar-title>
</mdc-toolbar-section>
<mdc-toolbar-section align-end>
<mdc-toolbar-icon event="show-help">help</mdc-toolbar-icon>
<mdc-toolbar-icon event="show-help" icon="help"></mdc-toolbar-icon>
</mdc-toolbar-section>
</mdc-toolbar-row>
</mdc-toolbar>
Expand Down Expand Up @@ -88,11 +88,27 @@ mdc-toolbar.

| props | Type | Default | Description |
|-------|------|---------|-------------|
|`icon`|String| | the material icon name. |
|`event`|String| optional | optional event to emit on click |
|`event-target`|Object| vm.$root | optional event target, defaults to root bus |

> if the `event` property is not specified, use @click to cactch click events
> do not set the icon prop to render your custom icons
**Font Awsome**

```html
<mdc-icon class="fa fa-star"></mdc-icon>
```

**SVG Icons**

```html
<mdc-icon>
<svg ...>
</mdc-icon>
```

### Fixed toolbars

Expand Down
6 changes: 3 additions & 3 deletions components/toolbar/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import VueMDCToolbar from './mdc-toolbar.vue'
import VueMDCToolbarRow from './mdc-toolbar-row.vue'
import VueMDCToolbarSection from './mdc-toolbar-section.vue'
import VueMDCToolbarTIconMenu from './mdc-toolbar-icon-menu.vue'
import VueMDCToolbarMenu from './mdc-toolbar-menu.vue'
import VueMDCToolbarTitle from './mdc-toolbar-title.vue'
import VueMDCToolbarIcon from './mdc-toolbar-icon.vue'

export {
VueMDCToolbar,
VueMDCToolbarRow,
VueMDCToolbarSection,
VueMDCToolbarTIconMenu,
VueMDCToolbarMenu,
VueMDCToolbarTitle,
VueMDCToolbarIcon
}
Expand All @@ -19,7 +19,7 @@ export default {
vm.component('mdc-toolbar', VueMDCToolbar)
vm.component('mdc-toolbar-row', VueMDCToolbarRow)
vm.component('mdc-toolbar-section', VueMDCToolbarSection)
vm.component('mdc-toolbar-icon-menu', VueMDCToolbarTIconMenu)
vm.component('mdc-toolbar-menu', VueMDCToolbarMenu)
vm.component('mdc-toolbar-title', VueMDCToolbarTitle)
vm.component('mdc-toolbar-icon', VueMDCToolbarIcon)
}
Expand Down
16 changes: 0 additions & 16 deletions components/toolbar/mdc-toolbar-icon-menu.vue

This file was deleted.

13 changes: 8 additions & 5 deletions components/toolbar/mdc-toolbar-icon.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<template>
<a class="material-icons mdc-toolbar__icon"
@click="dispatchEvent"
>
<slot></slot>
<a class="mdc-toolbar__icon"
:class="{'material-icons':!!icon}"
@click="dispatchEvent">
<slot>{{icon}}</slot>
</a>
</template>

Expand All @@ -11,6 +11,9 @@ import {DispatchEventMixin} from '../util'
export default {
name: 'mdc-toolbar-icon',
mixins: [DispatchEventMixin]
mixins: [DispatchEventMixin],
props: {
icon: String
}
}
</script>
19 changes: 19 additions & 0 deletions components/toolbar/mdc-toolbar-menu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<a class="mdc-toolbar__icon--menu"
:class="{'material-icons':!!icon}"
@click="dispatchEvent">
<slot>{{icon}}</slot>
</a>
</template>

<script lang="babel">
import {DispatchEventMixin} from '../util'
export default {
name: 'mdc-toolbar-menu',
mixins: [DispatchEventMixin],
props: {
icon: {type: String, 'default': "menu"}
}
}
</script>
6 changes: 6 additions & 0 deletions components/toolbar/mdc-toolbar.scss
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
@import "@material/toolbar/mdc-toolbar";

.mdc-toolbar {
.mdc-icon {
@extend .mdc-toolbar__icon;
}
}
3 changes: 1 addition & 2 deletions src/Doc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
<mdc-toolbar waterfall>
<mdc-toolbar-row>
<mdc-toolbar-section align-start >
<mdc-toolbar-icon-menu event="toggle-drawer">
</mdc-toolbar-icon-menu>
<mdc-toolbar-menu event="toggle-drawer"></mdc-toolbar-menu>
<mdc-toolbar-title href="#">Vue MDC Adapter</mdc-toolbar-title>
</mdc-toolbar-section>
<mdc-toolbar-section align-end>
Expand Down

0 comments on commit d975a18

Please sign in to comment.