Skip to content

Commit ade2357

Browse files
docs(website): add loader to pages
1 parent 24d5279 commit ade2357

File tree

5 files changed

+76
-0
lines changed

5 files changed

+76
-0
lines changed

packages/overmind-website/src/components/Guides/index.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
import { createElement, SFC } from 'react'
22
import { useOvermind } from '../../overmind'
33
import * as styles from './styles'
4+
import Loader from '../Loader'
45

56
const Guides: SFC = () => {
67
const { state } = useOvermind()
78

9+
if (state.isLoadingGuides) {
10+
return <Loader />
11+
}
12+
813
return (
914
<div className={styles.wrapper}>
1015
{state.guides.map((guide) => (
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { createElement, SFC } from 'react'
2+
import * as styles from './styles'
3+
4+
const Loader: SFC = () => (
5+
<div className={styles.wrapper}>
6+
<div className={styles.circle} />
7+
<div className={styles.innerCircle} />
8+
<div className={styles.block} />
9+
<div className={styles.text}>loading</div>
10+
</div>
11+
)
12+
13+
export default Loader
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { css } from 'emotion'
2+
3+
export const wrapper = css`
4+
position: fixed;
5+
width: 100%;
6+
height: 200px;
7+
display: flex;
8+
align-items: center;
9+
justify-content: center;
10+
font-family: monospace;
11+
color: var(--color-dark-1);
12+
top: calc(50vh - 100px);
13+
`
14+
15+
export const circle = css`
16+
position: absolute;
17+
background-color: #eaeaea;
18+
border-radius: 50%;
19+
width: 125px;
20+
height: 125px;
21+
box-shadow: 0 0 0 rgba(206, 206, 206, 0.4);
22+
animation: pulse 2s infinite 0.5s;
23+
`
24+
25+
export const innerCircle = css`
26+
position: absolute;
27+
background-color: var(--color-white-1);
28+
border-radius: 50%;
29+
width: 100px;
30+
height: 100px;
31+
`
32+
33+
export const block = css`
34+
position: absolute;
35+
background-color: var(--color-white-1);
36+
height: 25px;
37+
width: 125px;
38+
`
39+
40+
export const text = css`
41+
position: absolute;
42+
color: #eaeaea;
43+
text-transform: uppercase;
44+
letter-spacing: 10px;
45+
text-indent: 10px;
46+
`

packages/overmind-website/src/overmind/actions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@ export const openHome: Action<RouteContext> = async ({ state, request }) => {
1212
export const openGuides: Action<RouteContext> = async ({ state, request }) => {
1313
state.page = Page.GUIDES
1414
if (!state.guides.length) {
15+
state.isLoadingGuides = true
1516
state.guides = await request('/backend/guides')
17+
state.isLoadingGuides = false
1618
}
1719
}
1820

1921
export const openVideos: Action<RouteContext> = async ({ state, request }) => {
2022
state.page = Page.VIDEOS
2123
if (!state.videos.length) {
24+
state.isLoadingVideos = true
2225
state.videos = await request('/backend/videos')
26+
state.isLoadingVideos = false
2327
}
2428
}
2529

@@ -47,7 +51,9 @@ export const openApi: Action<RouteContext<VideoParams>> = async ({
4751
state.page = Page.API
4852
state.currentApi = routeContext.params.title
4953
if (!state.apis.length) {
54+
state.isLoadingApis = true
5055
state.apis = await request('/backend/apis')
56+
state.isLoadingApis = false
5157
}
5258
}
5359

packages/overmind-website/src/overmind/state.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ type State = {
2424
isLoadingSearchResult: boolean
2525
searchResult: SearchResult[]
2626
showSearchResult: boolean
27+
isLoadingGuides: boolean
28+
isLoadingApis: boolean
29+
isLoadingVideos: boolean
2730
}
2831

2932
const state: State = {
@@ -42,6 +45,9 @@ const state: State = {
4245
isLoadingSearchResult: false,
4346
searchResult: [],
4447
showSearchResult: false,
48+
isLoadingGuides: false,
49+
isLoadingApis: false,
50+
isLoadingVideos: false,
4551
}
4652

4753
export default state

0 commit comments

Comments
 (0)