Skip to content
This repository has been archived by the owner on Feb 5, 2022. It is now read-only.

Commit

Permalink
Step 3: creating placeholder content for loading state
Browse files Browse the repository at this point in the history
  • Loading branch information
colbyfayock committed May 3, 2020
1 parent f0cada8 commit 5b7b1c4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@ import { useState, useEffect } from 'react';

export default function Home() {
const [loadingState, updateLoadingState] = useState(true);
const [contentState, updateContentState] = useState({})
const [contentState, updateContentState] = useState({
header: 'Loading',
intro: 'Loading',
list: [
'Loading',
'Loading',
'Loading'
]
})
const content = {
header: `So, how 'bout them Knicks?`,
intro: `What are their names? I'm Santa Claus! This opera's as lousy as it is brilliant! Your lyrics lack subtlety. You can't just have your characters announce how they feel. That makes me feel angry! Good news, everyone! I've taught the toaster to feel love!`,
Expand All @@ -20,20 +28,22 @@ export default function Home() {
}, [])
return (
<div className="container">
<main>
<main className={loadingState ? 'loading' : ''}>
<h1>{ contentState.header }</h1>
<p>{ contentState.intro }</p>
<ul>
{ Array.isArray(contentState.list) && contentState.list.map((item, i) => {
return (
<li>{ item }</li>
<li key={i}>{ item }</li>
)
})}
</ul>
</main>

<style jsx>{`
.loading {
.loading h1,
.loading p,
.loading li {
color: transparent;
background: linear-gradient(100deg, #eceff1 30%, #f6f7f8 50%, #eceff1 70%);
background-size: 400%;
Expand Down

0 comments on commit 5b7b1c4

Please sign in to comment.