Skip to content

Commit

Permalink
feat: add spin property
Browse files Browse the repository at this point in the history
  • Loading branch information
therufa committed Apr 25, 2020
1 parent 8201385 commit 38df4ec
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 3 deletions.
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,13 @@ Example.vue:
```vue
<template>
<div>
My hand is a <hook-icon />
My hand is a <HookIcon />
</div>
</template>
<script>
import HookIcon from 'mdi-vue/Hook' // works without an extension too
import HookIcon from 'mdi-vue/Hook.vue' // raw vue component
// import HookIcon from 'mdi-vue/Hook[.js]' // transpiled component
export {
components: [
Expand All @@ -47,6 +48,21 @@ export {
</script>
```

## Props
### width and height (Numeric)
```
<Icon :width="30" :height="30 />
```

### spin (boolean; default: false)
Applies a css spin animation to the icon
```
<CogIcon spin />
// or
<CogIcon :spin="true" />
```


## Global imports

Just as any component, icons can be registered globally using `Vue.component` as in the following example.
Expand Down
31 changes: 31 additions & 0 deletions dist/icons.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,34 @@
.mdi > svg {
vertical-align: middle;
}

.mdi.mdi-spin > svg {
-webkit-animation: mdi-spin 2s infinite linear;
-moz-animation: mdi-spin 2s infinite linear;
animation: mdi-spin 2s infinite linear;
}

@-webkit-keyframes mdi-spin {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
}
@keyframes mdi-spin {
0% {
-webkit-transform: rotate(0deg);
-moz-transform: rotate(0deg);
transform: rotate(0deg);
}
100% {
-webkit-transform: rotate(360deg);
-moz-transform: rotate(360deg);
transform: rotate(360deg);
}
}
6 changes: 5 additions & 1 deletion template.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module.exports = (name, path, ariaLabel) => `<template functional>
<span
:class="[data.staticClass, 'mdi', 'mdi-${name}']"
:class="[data.staticClass, 'mdi', 'mdi-${name}', props.spin ? 'mdi-spin' : undefined]"
:role="props.role"
:aria-label="props.ariaLabel"
>
Expand Down Expand Up @@ -50,6 +50,10 @@ export default {
title: {
type: String,
required: false
},
spin: {
type: Boolean,
default: false
}
}
}
Expand Down

0 comments on commit 38df4ec

Please sign in to comment.