Skip to content
This repository was archived by the owner on Nov 30, 2020. It is now read-only.

Commit b2cad7f

Browse files
committed
feat(fab): Synchronise with mdc-web
BREAKING CHANGES: Introduced icon slot and replaced default slot for extended fab label.
1 parent fdf4224 commit b2cad7f

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

components/fab/Fab.vue

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
:class="classes"
44
class="mdc-fab"
55
v-on="$listeners">
6-
<slot />
6+
<slot name="icon"/>
7+
<div
8+
v-if="extended"
9+
class="mdc-fab__label">
10+
<slot />
11+
</div>
712
</button>
813
</template>
914

@@ -26,6 +31,10 @@ export default {
2631
exited: {
2732
type: Boolean,
2833
default: false
34+
},
35+
extended: {
36+
type: Boolean,
37+
default: false
2938
}
3039
},
3140
data () {
@@ -39,7 +48,8 @@ export default {
3948
return {
4049
'mdc-fab--mini': this.mini,
4150
'mdc-fab--absolute-right': this.absoluteRight,
42-
'mdc-fab--exited': this.exited
51+
'mdc-fab--exited': this.exited,
52+
'mdc-fab--extended': this.extended
4353
}
4454
}
4555
},
@@ -68,8 +78,8 @@ export default {
6878
},
6979
methods: {
7080
updateSlot () {
71-
if (this.$slots.default) {
72-
this.$slots.default.map(n => {
81+
if (this.$slots.icon) {
82+
this.$slots.icon.map(n => {
7383
if (n.elm.tagName.toUpperCase() !== 'SVG') {
7484
n.elm.classList.add('mdc-fab__icon')
7585
}

components/fab/README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,18 @@
33
### Markup
44

55
```html
6-
<m-fab mini absoluteRight>
7-
<m-icon icon="favorite" @click="..."/>
6+
<m-fab
7+
mini
8+
absoluteRight>
9+
<m-icon
10+
slot="icon"
11+
icon="favorite"
12+
@click="..."/>
813
</m-fab>
914
<m-fab>
10-
<svg @click="..."/>
15+
<svg
16+
slot="icon"
17+
@click="..."/>
1118
</m-fab>
1219
```
1320
### Props
@@ -17,14 +24,16 @@
1724
| mini | Boolean | false | mini fab button |
1825
| absoluteRight | Boolean | false | whether the fab should be rendered on the bottom right |
1926
| exited | Boolean | false | animates the fab out of view |
27+
| extended | Boolean | false | extended fab with label |
2028

2129
Events are mapped to the inner button element.
2230

2331
### Slots
2432

2533
| Slot | Description |
2634
|------|-------------|
27-
| default | icon component |
35+
| default | extended fab label |
36+
| icon | icon component |
2837

2938
### Reference
3039

docs/.vuepress/components/FabDemo.vue

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,14 @@
22
<div>
33
<ComponentSection>
44
<m-fab
5-
:mini="checkboxProps[0].value"
6-
:absoluteRight="checkboxProps[1].value"
7-
:exited="checkboxProps[2].value">
8-
<m-icon icon="create"/>
5+
:mini="radioProps[2].value"
6+
:absoluteRight="checkboxProps[0].value"
7+
:exited="checkboxProps[1].value"
8+
:extended="radioProps[1].value">
9+
<m-icon
10+
slot="icon"
11+
icon="create"/>
12+
<span v-if="radioProps[1].value">Write something</span>
913
</m-fab>
1014
</ComponentSection>
1115
<ComponentProps
@@ -19,10 +23,11 @@ export default {
1923
data () {
2024
return {
2125
radioProps: [
22-
{ prop: 'baseline', value: true}
26+
{ prop: 'baseline', value: true},
27+
{ prop: 'extended', value: false},
28+
{ prop: 'mini', value: false }
2329
],
2430
checkboxProps: [
25-
{ prop: 'mini', value: false },
2631
{ prop: 'absoluteRight', value: false },
2732
{ prop: 'exited', value: false }
2833
]

0 commit comments

Comments
 (0)