Skip to content

Commit

Permalink
Add better fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
NickGerleman committed Oct 20, 2023
1 parent 4451340 commit b496008
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 10 deletions.
2 changes: 1 addition & 1 deletion javascript/just.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ function babelTransformTask(opts) {
env: {
// Trigger distribution-specific Babel transforms
NODE_ENV: 'dist',
}
},
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion javascript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion javascript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
}
},
"include": [
"src/**/*"
"src/**/*",
"tests/**/*"
]
}
26 changes: 26 additions & 0 deletions website-next/src/pages/index.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
20 changes: 13 additions & 7 deletions website-next/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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>
);
Expand Down

0 comments on commit b496008

Please sign in to comment.