Better async loading behavior

This commit is contained in:
Nick Gerleman
2023-10-19 22:36:48 -07:00
parent b4960085c6
commit 1acbd2e85a
3 changed files with 82 additions and 61 deletions

View File

@@ -12,12 +12,7 @@
width: 100%; width: 100%;
} }
.Playground { .playground-background {
display: flex;
flex-grow: 1;
position: relative;
width: 100%;
overflow: hidden;
background: linear-gradient(-90deg, rgba(0, 0, 0, 0.02) 1px, transparent 1px), 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(rgba(0, 0, 0, 0.02) 1px, transparent 1px),
linear-gradient(-90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px), linear-gradient(-90deg, rgba(0, 0, 0, 0.03) 1px, transparent 1px),
@@ -41,6 +36,15 @@
100px 100px, 100px 100px, 100px 100px; 100px 100px, 100px 100px, 100px 100px;
} }
.Playground {
display: flex;
flex-grow: 1;
position: relative;
width: 100%;
overflow: hidden;
animation: playground-content-fade-in-frames 50ms ease-in;
}
.Playground > .YogaNode { .Playground > .YogaNode {
margin: auto; margin: auto;
position: static; position: static;
@@ -72,3 +76,12 @@
.ant-modal-content { .ant-modal-content {
overflow: hidden; overflow: hidden;
} }
@keyframes playground-content-fade-in-frames {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}

View File

@@ -235,8 +235,11 @@ export default class Playground extends Component<Props, State> {
: null; : null;
const playground = ( const playground = (
<div className="playground-background">
<div <div
className={`Playground ${this.props.renderSidebar ? '' : 'standalone'}`} className={`Playground ${
this.props.renderSidebar ? '' : 'standalone'
}`}
onMouseDown={this.onMouseDown} onMouseDown={this.onMouseDown}
style={{height, maxHeight: height}} style={{height, maxHeight: height}}
ref={ref => { ref={ref => {
@@ -260,7 +263,9 @@ export default class Playground extends Component<Props, State> {
} }
onChangeLayout={this.onChangeLayout} onChangeLayout={this.onChangeLayout}
// @ts-ignore // @ts-ignore
onChangeSetting={(key, value) => this.setState({[key]: value})} onChangeSetting={(key, value) =>
this.setState({[key]: value})
}
direction={direction} direction={direction}
onRemove={ onRemove={
selectedNodePath && selectedNodePath.length > 0 selectedNodePath && selectedNodePath.length > 0
@@ -282,6 +287,7 @@ export default class Playground extends Component<Props, State> {
</Sidebar> </Sidebar>
)} )}
</div> </div>
</div>
); );
if (this.props.renderSidebar) { if (this.props.renderSidebar) {

View File

@@ -38,16 +38,18 @@ const LazyPlayground = React.lazy(() => import('../components/Playground'));
function ClientPlayground() { function ClientPlayground() {
const fallback = <div className={styles.playgroundFallback} />; const fallback = <div className={styles.playgroundFallback} />;
return <BrowserOnly fallback={fallback}>
return (
<BrowserOnly fallback={fallback}>
{() => ( {() => (
<Suspense fallback={fallback}> <Suspense fallback={fallback}>
<LazyPlayground /> <LazyPlayground />
</Suspense> </Suspense>
)} )}
</BrowserOnly>; </BrowserOnly>
);
} }
export default function Home(): JSX.Element { export default function Home(): JSX.Element {
const {siteConfig} = useDocusaurusContext(); const {siteConfig} = useDocusaurusContext();
return ( return (