From c631c16711b83f064c153df76e356af10363f7b2 Mon Sep 17 00:00:00 2001 From: developomp Date: Tue, 14 Dec 2021 22:18:30 +0900 Subject: [PATCH] converted Loading.tsx to functional component --- source/src/components/Loading.tsx | 181 +++++++++++++++--------------- 1 file changed, 90 insertions(+), 91 deletions(-) diff --git a/source/src/components/Loading.tsx b/source/src/components/Loading.tsx index 62195d4..4f8759d 100644 --- a/source/src/components/Loading.tsx +++ b/source/src/components/Loading.tsx @@ -2,46 +2,18 @@ * inspired by https://codepen.io/avstorm/pen/RwNzPNN */ -import React from "react" -import styled, { keyframes } from "styled-components" +import styled from "styled-components" + import theming from "../theming" -const swing = keyframes` -50% { - transform: rotate(-3deg); -} -` - -const steamLarge = keyframes` -0% { - stroke-dashoffset: 13; - opacity: .6; -} -100% { - stroke-dashoffset: 39; - opacity: 0; -} -` - -const steamSmall = keyframes` -10% { - stroke-dashoffset: 9; - opacity: .6; -} -80% { - stroke-dashoffset: 27; - opacity: 0; -} -100% { - stroke-dashoffset: 27; - opacity: 0; -} -` - const StyledContainer = styled.div` + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; text-align: center; - animation: fadein 2s; + animation: fadein 2s; @keyframes fadein { from { opacity: 0; @@ -55,87 +27,114 @@ const StyledContainer = styled.div` } ` -const StyledBox = styled.div` - display: flex; - justify-content: center; - align-items: center; -` - const StyledSVG = styled.svg` - --secondary: ${(props) => + --color: ${(props) => theming.theme(props.theme.currentTheme, { light: theming.light.color1, dark: theming.dark.color1, })}; - transform: scale(1.5); + display: block; + margin: 1rem; + margin-bottom: 2rem; + + transform: scale(2); #teabag { transform-origin: top center; transform: rotate(3deg); - animation: ${swing} 2s infinite; + animation: swingAnimation 2s infinite; } #steamL { stroke-dasharray: 13; stroke-dashoffset: 13; - animation: ${steamLarge} 2s infinite; + animation: steamLargeAnimation 2s infinite; } #steamR { stroke-dasharray: 9; stroke-dashoffset: 9; - animation: ${steamSmall} 2s infinite; + animation: steamSmallAnimation 2s infinite; + } + + @keyframes swingAnimation { + 50% { + transform: rotate(-3deg); + } + } + + @keyframes steamLargeAnimation { + 0% { + stroke-dashoffset: 13; + opacity: 0.6; + } + 100% { + stroke-dashoffset: 39; + opacity: 0; + } + } + + @keyframes steamSmallAnimation { + 10% { + stroke-dashoffset: 9; + opacity: 0.6; + } + 80% { + stroke-dashoffset: 27; + opacity: 0; + } + 100% { + stroke-dashoffset: 27; + opacity: 0; + } } ` -const Spinner: React.FC = () => { +const Spinner = () => { return ( - - - - - - - - - -
+ + + + + + +

Loading...

)