Skip to content

Commit

Permalink
beat animation
Browse files Browse the repository at this point in the history
  • Loading branch information
RaresAil committed Mar 27, 2024
1 parent e66cdfd commit a8c4fdd
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,25 @@ function Component() {
| strokeWidth | number \| string | 32 or 16 |
| className | string | |
| ... | Other SVG Props | |

### Animations

#### Spin

To spin a icon add the `spin` prop, if you want to adjust the speed, use the `animation-duration` css property

```tsx
function() {
return <SyncOutline spin />;
}
```

#### Beat

To spin a icon add the `beat` prop, if you want to adjust the speed, use the `animation-duration` css property

```tsx
function() {
return <SyncOutline beat />;
}
```
19 changes: 19 additions & 0 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@
}
}

@keyframes raresail-react-ionicon-beat {
0%,
50%,
100% {
transform: scale(1);
}
30%,
80% {
transform: scale(1.1);
}
}

.raresail-react-ionicon {
box-sizing: content-box;
}
Expand All @@ -17,3 +29,10 @@
animation-timing-function: linear;
animation-duration: 2500ms;
}

.raresail-react-ionicon[data-animation='beat'] {
animation-name: raresail-react-ionicon-beat;
animation-iteration-count: infinite;
animation-timing-function: ease;
animation-duration: 1.5s;
}
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ import { SVGProps } from 'react';
export interface IonIconProps
extends Omit<SVGProps<SVGSVGElement>, 'fill' | 'stroke'> {
spin?: true;
beat?: true;
}
5 changes: 5 additions & 0 deletions templates/svg.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,18 @@ function ${componentName}({
strokeWidth,
className,
spin,
beat,
...props
}: IonIconProps) {
const animation = useMemo(() => {
if (spin) {
return 'spin';
}
if (beat) {
return 'beat';
}
return '';
}, [spin]);
Expand Down

0 comments on commit a8c4fdd

Please sign in to comment.