diff --git a/packages/app/src/Element/AsyncButton.css b/packages/app/src/Element/AsyncButton.css new file mode 100644 index 0000000..0f8fef5 --- /dev/null +++ b/packages/app/src/Element/AsyncButton.css @@ -0,0 +1,27 @@ +button { + position: relative; +} + +.spinner { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + display: flex; + justify-content: center; + align-items: center; + animation-name: spin; + animation-duration: 800ms; + animation-iteration-count: infinite; + animation-timing-function: linear; +} + +@keyframes spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} diff --git a/packages/app/src/Element/AsyncButton.tsx b/packages/app/src/Element/AsyncButton.tsx index 59bdaf8..34e6e10 100644 --- a/packages/app/src/Element/AsyncButton.tsx +++ b/packages/app/src/Element/AsyncButton.tsx @@ -1,3 +1,4 @@ +import "./AsyncButton.css"; import { useState } from "react"; interface AsyncButtonProps extends React.ButtonHTMLAttributes { @@ -5,6 +6,27 @@ interface AsyncButtonProps extends React.ButtonHTMLAttributes children?: React.ReactNode; } +interface LoaderProps { + className: string +} + +const Loader = ({ className }: LoaderProps ) => ( +
+ + + +
+) + export default function AsyncButton(props: AsyncButtonProps) { const [loading, setLoading] = useState(false); @@ -25,7 +47,8 @@ export default function AsyncButton(props: AsyncButtonProps) { return ( ); }