Skip to content

Commit 800a54a

Browse files
committed
chore: improve suspense demo UI
1 parent 1cbd4f4 commit 800a54a

File tree

5 files changed

+92
-24
lines changed

5 files changed

+92
-24
lines changed

examples/query/react/suspense/src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ export default function App() {
1818

1919
return (
2020
<div className="App">
21-
<div>
21+
<div className='fixed-toolbar'>
22+
<h1>Suspense</h1>
2223
<form action="#" className="global-controls">
2324
<label htmlFor="error-rate-input">
2425
fetch error rate: {errorRate}

examples/query/react/suspense/src/PokemonParallelQueries.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const PokemonParallelQueries = React.memo(
1616

1717
return (
1818
<article className="parallel-queries">
19-
<h2>Suspense: indipendent parallel queries</h2>
19+
<h2>Indipendent parallel queries</h2>
2020
<form
2121
className="select-pokemon-form"
2222
action="#"
@@ -35,14 +35,14 @@ export const PokemonParallelQueries = React.memo(
3535
}}
3636
>
3737
<label htmlFor="addBulbasaurandEvolution">
38-
addBulbasaur
38+
add bulbasaur
3939
<input
4040
type="checkbox"
4141
name="addBulbasaur"
4242
id="addBulbasaurandEvolution"
4343
/>
4444
</label>
45-
<button type="submit">Add pokemon + evolution</button>
45+
<button className="btn" type="submit">Add pokemon + evolution</button>
4646
</form>
4747
<div className="pokemon-list">
4848
{evolutions.map((name, idx) => (

examples/query/react/suspense/src/PokemonSingleQueries.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { SuspenseQueryError } from '@reduxjs/toolkit/dist/query/react'
21
import * as React from 'react'
32
import { ErrorBoundary } from 'react-error-boundary'
43
import { Pokemon, PokemonProps } from './Pokemon'
@@ -15,7 +14,7 @@ export const PokemonSingleQueries = React.memo(function PokemonSingleQueries() {
1514

1615
return (
1716
<article className="pokemon-article">
18-
<h2>Suspense: single query</h2>
17+
<h2>Single queries</h2>
1918
<form
2019
className="select-pokemon-form"
2120
action="#"
@@ -35,7 +34,7 @@ export const PokemonSingleQueries = React.memo(function PokemonSingleQueries() {
3534
}}
3635
>
3736
<label htmlFor="addBulbasaur">
38-
addBulbasaur
37+
add bulbasaur
3938
<input type="checkbox" name="addBulbasaur" id="addBulbasaur" />
4039
</label>
4140
<button className="btn">Add pokemon</button>

examples/query/react/suspense/src/PokemonWithEvolution.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import * as React from 'react'
21
import { PokemonName } from './pokemon.data'
32
import { useGetPokemonByNameQuery } from './services/pokemon'
43
import { useSuspendAll } from '@reduxjs/toolkit/query/react'
@@ -20,7 +19,7 @@ export function PokemonWithEvolution({
2019
return (
2120
<>
2221
{[baseDataQuery, evolutionQuery].map(
23-
({ data, isFetching, refetch }, idx) => (
22+
({ data, isFetching, refetch, }, idx) => (
2423
<section className="pokemon-card" key={idx}>
2524
<h3>{data.species.name}</h3>
2625
<img

examples/query/react/suspense/src/styles.css

Lines changed: 84 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,49 @@
1+
:root {
2+
--pokemon-card-height: 200px;
3+
--danger: #842029;
4+
--danger-bg: #f5c2c7;
5+
--info: #084298;
6+
--info-bg: #cfe2ff;
7+
--success: #0f5132;
8+
--success-bg: #d1e7dd;
9+
--card-width: 160px;
10+
--toolbar-height: 50px;
11+
--primary: #6c3eb7;
12+
}
13+
14+
body {
15+
margin: 0;
16+
}
17+
18+
.fixed-toolbar {
19+
position: fixed;
20+
z-index: 30;
21+
top: 0;
22+
left: 0;
23+
right: 0;
24+
margin: 0;
25+
height: var(--toolbar-height);
26+
overflow: hidden;
27+
background: #fff;
28+
box-shadow: 0 1px 4px 0 rgb(123 101 161);
29+
display: flex;
30+
justify-content: space-between;
31+
padding: 0 4px;
32+
align-items: center;
33+
color: var(--primary);
34+
}
35+
36+
.fixed-toolbar > h1 {
37+
margin: 0;
38+
font-size: 1.2rem;
39+
}
40+
141
.App {
242
font-family: sans-serif;
343
text-align: center;
44+
max-width: 100%;
45+
overflow-x: hidden;
46+
padding-top: var(--toolbar-height);
447
}
548

649
.pokemon-article {
@@ -14,33 +57,59 @@ article {
1457
padding: 8px;
1558
}
1659

60+
h1, h2, h3, h4, h5 ,h6, form {
61+
color: #764abc;
62+
}
63+
64+
h2 {
65+
margin: 0.3rem 0;
66+
}
67+
1768
h3 {
1869
margin: 0.2rem 0;
1970
}
2071

2172
.pokemon-list {
2273
display: grid;
23-
grid-template-columns: repeat(auto-fill, 180px);
24-
grid-gap: 20px;
74+
grid-template-columns: repeat(auto-fill, var(--card-width));
75+
grid-gap: 12px;
2576
width: 100%;
2677
}
2778

2879
.select-pokemon-form {
80+
display: flex;
81+
align-items: center;
82+
justify-content: center;
2983
padding: 8px 0;
84+
gap: 4px;
85+
}
86+
87+
.select-pokemon-form > label {
88+
display: inline-flex;
89+
align-items: center;
3090
}
3191

3292
.global-controls {
93+
display: flex;
94+
align-items: center;
95+
justify-content: center;
3396
padding: 8px 0;
97+
gap: 4px;
98+
}
99+
100+
.global-controls > label {
101+
display: inline-flex;
102+
align-items: center;
34103
}
35104

36105
.pokemon-card {
37106
display: flex;
38107
flex-flow: column nowrap;
39108
align-items: center;
40109
justify-content: space-evenly;
41-
min-height: 280px;
42-
color: #202020;
43-
border: 2px solid currentColor;
110+
min-height: var( --pokemon-card-height);
111+
color: var(--primary);
112+
border: 2px solid var(--primary);
44113
font-size: 1rem;
45114
border-radius: 8px;
46115
padding: 0 4px;
@@ -51,35 +120,34 @@ h3 {
51120
}
52121

53122
.pokemon-card__pic {
54-
width: 80px;
55-
height: 80px;
123+
width: 60px;
124+
height: 60px;
56125
}
57126

58127
.pokemon-card--placeholder {
59128
background: #e0e0e0;
60-
min-height: 280px;
61129
}
62130

63131
.alert--danger {
64-
color: #842029;
132+
color: var(--danger);
65133
border-color: #f5c2c7;
66-
background: #f8d7da;
134+
background: var(--danger-bg);
67135
}
68136

69137
.alert--info {
70-
color: #084298;
71-
background-color: #cfe2ff;
138+
color: var(--info);
139+
background-color: var(--info-bg);
72140
border-color: #b6d4fe;
73141
}
74142

75143
.alert--success {
76-
color: #0f5132;
77-
background-color: #d1e7dd;
144+
color: var(--success);
145+
background-color: var(--success-bg);
78146
border-color: #badbcc;
79147
}
80148

81149
.btn {
82-
color: inherit;
150+
color: var(--primary);
83151
background: transparent;
84152
border: 2px solid currentColor;
85153
padding: 0 8px;
@@ -89,6 +157,7 @@ h3 {
89157
display: inline-flex;
90158
align-items: center;
91159
justify-content: center;
160+
92161
}
93162

94163
.btn:active:not(:disabled) {

0 commit comments

Comments
 (0)