Add better fallback

This commit is contained in:
Nick Gerleman
2023-10-19 21:04:33 -07:00
parent 4451340610
commit b4960085c6
5 changed files with 43 additions and 10 deletions

View File

@@ -110,7 +110,7 @@ function babelTransformTask(opts) {
env: {
// Trigger distribution-specific Babel transforms
NODE_ENV: 'dist',
}
},
});
};
}

View File

@@ -9,7 +9,7 @@
// @ts-ignore untyped from Emscripten
import loadYoga from '../binaries/web.js';
import wrapAssembly from './wrapAssembly.js';
import wrapAssembly from './wrapAssembly.ts';
export type {
Config,

View File

@@ -17,6 +17,7 @@
}
},
"include": [
"src/**/*"
"src/**/*",
"tests/**/*"
]
}

View File

@@ -28,3 +28,29 @@
align-items: center;
justify-content: center;
}
.playgroundFallback {
height: 500px;
width: 100%;
background: linear-gradient(-90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px),
linear-gradient(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
linear-gradient(-90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
linear-gradient(rgba(0, 0, 0, 0.03) 1px, transparent 1px),
linear-gradient(
transparent 4px,
#f5f5f5 4px,
#f5f5f5 97px,
transparent 97px
),
linear-gradient(-90deg, #e5e5e5 1px, transparent 1px),
linear-gradient(
-90deg,
transparent 4px,
#f5f5f5 4px,
#f5f5f5 97px,
transparent 97px
),
linear-gradient(#e5e5e5 1px, transparent 1px), #f5f5f5;
background-size: 10px 10px, 10px 10px, 100px 100px, 100px 100px, 100px 100px,
100px 100px, 100px 100px, 100px 100px;
}

View File

@@ -36,6 +36,18 @@ function HomepageHeader() {
const LazyPlayground = React.lazy(() => import('../components/Playground'));
function ClientPlayground() {
const fallback = <div className={styles.playgroundFallback} />;
return <BrowserOnly fallback={fallback}>
{() => (
<Suspense fallback={fallback}>
<LazyPlayground />
</Suspense>
)}
</BrowserOnly>;
}
export default function Home(): JSX.Element {
const {siteConfig} = useDocusaurusContext();
return (
@@ -45,13 +57,7 @@ export default function Home(): JSX.Element {
<HomepageHeader />
<main>
<HomepageFeatures />
<BrowserOnly fallback={null}>
{() => (
<Suspense fallback={null}>
<LazyPlayground />
</Suspense>
)}
</BrowserOnly>
<ClientPlayground />
</main>
</Layout>
);