diff --git a/app/soapbox/components/ui/spinner/spinner.css b/app/soapbox/components/ui/spinner/spinner.css index 177f9dad5..f048ee7fc 100644 --- a/app/soapbox/components/ui/spinner/spinner.css +++ b/app/soapbox/components/ui/spinner/spinner.css @@ -1,9 +1,9 @@ - /** * iOS style loading spinner. * Adapted from: https://loading.io/css/ * With some help scaling it: https://signalvnoise.com/posts/2577-loading-spinner-animation-using-css-and-webkit */ + .spinner { @apply inline-block relative w-20 h-20; } diff --git a/app/soapbox/components/ui/spinner/spinner.tsx b/app/soapbox/components/ui/spinner/spinner.tsx index c4b77a120..98c3eaae7 100644 --- a/app/soapbox/components/ui/spinner/spinner.tsx +++ b/app/soapbox/components/ui/spinner/spinner.tsx @@ -6,7 +6,7 @@ import Text from '../text/text'; import './spinner.css'; -interface ILoadingIndicator { +interface ISpinner { /** Width and height of the spinner in pixels. */ size?: number, /** Whether to display "Loading..." beneath the spinner. */ @@ -14,7 +14,7 @@ interface ILoadingIndicator { } /** Spinning loading placeholder. */ -const LoadingIndicator = ({ size = 30, withText = true }: ILoadingIndicator) => ( +const Spinner = ({ size = 30, withText = true }: ISpinner) => (
{Array.from(Array(12).keys()).map(i => ( @@ -30,4 +30,4 @@ const LoadingIndicator = ({ size = 30, withText = true }: ILoadingIndicator) => ); -export default LoadingIndicator; +export default Spinner; diff --git a/app/soapbox/containers/soapbox.tsx b/app/soapbox/containers/soapbox.tsx index cde450e65..d8ffd97d5 100644 --- a/app/soapbox/containers/soapbox.tsx +++ b/app/soapbox/containers/soapbox.tsx @@ -14,6 +14,7 @@ import { loadSoapboxConfig, getSoapboxConfig } from 'soapbox/actions/soapbox'; import { fetchVerificationConfig } from 'soapbox/actions/verification'; import * as BuildConfig from 'soapbox/build_config'; import Helmet from 'soapbox/components/helmet'; +import { Spinner } from 'soapbox/components/ui'; import AuthLayout from 'soapbox/features/auth_layout'; import OnboardingWizard from 'soapbox/features/onboarding/onboarding-wizard'; import PublicLayout from 'soapbox/features/public_layout'; @@ -115,10 +116,25 @@ const SoapboxMount = () => { return !(location.state?.soapboxModalKey && location.state?.soapboxModalKey !== prevRouterProps?.location?.state?.soapboxModalKey); }; - if (me === null) return null; - if (me && !account) return null; - if (!isLoaded) return null; - if (localeLoading) return null; + /** Whether to display a loading indicator. */ + const showLoading = [ + me === null, + me && !account, + !isLoaded, + localeLoading, + ].some(Boolean); + + if (showLoading) { + return ( +
+ + {themeCss && } + + + +
+ ); + } const waitlisted = account && !account.source.get('approved', true);