Skip to content

Commit

Permalink
Use CSS keyframe animation for spinner on web (#3411)
Browse files Browse the repository at this point in the history
* Use css keyframe animation for spinner on web

* duplicate css to index.html
  • Loading branch information
mozzius authored Apr 4, 2024
1 parent 575f390 commit 93b606e
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 2 deletions.
15 changes: 15 additions & 0 deletions bskyweb/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@
.nativeDropdown-item:focus {
outline: none;
}

/* Spinner component */
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.rotate-500ms {
position: absolute;
inset:0;
animation: rotate 500ms linear infinite;
}
</style>
{% include "scripts.html" %}
<link rel="apple-touch-icon" sizes="180x180" href="/static/apple-touch-icon.png">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Loader.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import React from 'react'
import Animated, {
Easing,
useSharedValue,
useAnimatedStyle,
useSharedValue,
withRepeat,
withTiming,
} from 'react-native-reanimated'

import {atoms as a, useTheme, flatten} from '#/alf'
import {atoms as a, flatten, useTheme} from '#/alf'
import {Props, useCommonSVGProps} from '#/components/icons/common'
import {Loader_Stroke2_Corner0_Rounded as Icon} from '#/components/icons/Loader'

Expand Down
34 changes: 34 additions & 0 deletions src/components/Loader.web.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react'
import {View} from 'react-native'

import {atoms as a, flatten, useTheme} from '#/alf'
import {Props, useCommonSVGProps} from '#/components/icons/common'
import {Loader_Stroke2_Corner0_Rounded as Icon} from '#/components/icons/Loader'

export function Loader(props: Props) {
const t = useTheme()
const common = useCommonSVGProps(props)

return (
<View
style={[
a.relative,
a.justify_center,
a.align_center,
{width: common.size, height: common.size},
]}>
{/* css rotation animation - /bskyweb/templates/base.html */}

This comment has been minimized.

Copy link
@estrattonbailey

estrattonbailey Apr 5, 2024

Member

Love this comment

<div className="rotate-500ms">
<Icon
{...props}
style={[
a.absolute,
a.inset_0,
t.atoms.text_contrast_high,
flatten(props.style),
]}
/>
</div>
</View>
)
}
15 changes: 15 additions & 0 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,21 @@
.nativeDropdown-item:focus {
outline: none;
}

/* Spinner component */
@keyframes rotate {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.rotate-500ms {
position: absolute;
inset:0;
animation: rotate 500ms linear infinite;
}
</style>
</head>

Expand Down

0 comments on commit 93b606e

Please sign in to comment.