Skip to content

Commit

Permalink
fix(fab): fix fab accessibility issue
Browse files Browse the repository at this point in the history
mdc-fab should not render <a> tag. align api on mdc-icon

BREAKING CHANGE: use icon prop instead vs slot to set material icon content
  • Loading branch information
stasson committed Sep 30, 2017
1 parent d613339 commit 4322914
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 20 deletions.
29 changes: 24 additions & 5 deletions components/fab/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
## Floating Action Buttons

```html
<mdc-fab>favorite</mdc-fab>
<mdc-fab mini>favorite</mdc-fab>
<mdc-fab plain>favorite</mdc-fab>
<mdc-fab mini plain>favorite</mdc-fab>
<mdc-fab plain fixed @click="scrollToTop">home</mdc-fab>
<mdc-fab icon="favorite"></mdc-fab>
<mdc-fab mini icon="favorite"></mdc-fab>
<mdc-fab fixed icon="favorite" @click="scrollToTop">home</mdc-fab>
```

> refer to [Material Design Icon Font](https://material.io/icons/) for the list of icons
Expand All @@ -26,6 +24,7 @@

| prop | Type | Default | Description |
|-------|------|---------|-------------|
|`icon`|String || material-icon content (*)|
|`mini`|Boolean|| mini style (40x40 pixels) (*)|
|`absolute`| Boolean|| set bottom right absolute position (*)|
|`fixed`| Boolean|| set bottom right fixed position (*)|
Expand All @@ -36,5 +35,25 @@
> (*) initializer attribute, not dynamic propertie

### Custom Icons

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

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


**SVG Icons**

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


### Reference
- https://material.io/components/web/catalog/buttons/floating-action-buttons/
19 changes: 8 additions & 11 deletions components/fab/mdc-fab.vue
Original file line number Diff line number Diff line change
@@ -1,31 +1,28 @@
<template>
<a>
<button class="mdc-fab material-icons" :class="classes" :style="styles"
@click="dispatchEvent" >
<span class="mdc-fab__icon">
<slot>
</slot>
</span>
</button>
</a>
<button class="mdc-fab" :class="classes" :style="styles"
@click="dispatchEvent" >
<span class="mdc-fab__icon">
<slot>{{ icon }}</slot>
</span>
</button>
</template>



<script>
import {RippleBase, DispatchEventMixin} from '../util'
export default {
name: 'mdc-fab',
mixins: [DispatchEventMixin],
props: {
icon: String,
mini: Boolean,
absolute: Boolean,
fixed: Boolean
},
data () {
return {
classes: {
'material-icons': this.icon,
'mdc-fab--mini': this.mini,
'mdc-fab--absolute': this.absolute,
'mdc-fab--fixed': this.fixed
Expand Down
2 changes: 1 addition & 1 deletion components/icon/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

| prop | Type | Description |
|-------|------|-------------|
|`icon`|string| material-icon content |
|`icon`|String| material-icon content |

### Custom Icons

Expand Down
6 changes: 3 additions & 3 deletions src/Doc.vue
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,9 @@

<mdc-subheading>Floating Action Button</mdc-subheading>
<div class="doc-center">
<mdc-fab>favorite</mdc-fab>
<mdc-fab mini>favorite</mdc-fab>
<mdc-fab fixed href="#">home</mdc-fab>
<mdc-fab icon="favorite"></mdc-fab>
<mdc-fab mini icon="favorite"></mdc-fab>
<mdc-fab fixed icon="home" @click="scrollToTop"></mdc-fab>
</div>

<mdc-subheading>Icon Toggle</mdc-subheading>
Expand Down

0 comments on commit 4322914

Please sign in to comment.