Skip to content

Commit 5c6557d

Browse files
feat: empty state toolbar (#1991)
Co-authored-by: Zeno Rocha <[email protected]>
1 parent 931540f commit 5c6557d

File tree

1 file changed

+60
-9
lines changed

1 file changed

+60
-9
lines changed

packages/react-email/src/components/toolbar.tsx

Lines changed: 60 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { isBuilding } from '../app/env';
88
import { PreviewContext } from '../contexts/preview';
99
import { cn } from '../utils';
1010
import { IconArrowDown } from './icons/icon-arrow-down';
11+
import { IconCheck } from './icons/icon-check';
1112
import { IconInfo } from './icons/icon-info';
1213
import { IconReload } from './icons/icon-reload';
1314
import { Compatibility, useCompatibility } from './toolbar/compatibility';
@@ -215,26 +216,50 @@ const ToolbarInner = ({
215216
<div className="animate-pulse text-slate-11 text-sm pt-1">
216217
Running linting...
217218
</div>
219+
) : lintingRows?.length === 0 ? (
220+
<div className="flex flex-col items-center justify-center pt-8">
221+
<SuccessIcon />
222+
<SuccessTitle>All good</SuccessTitle>
223+
<SuccessDescription>
224+
No linting issues found.
225+
</SuccessDescription>
226+
</div>
218227
) : (
219-
<Linter rows={lintingRows} />
228+
<Linter rows={lintingRows ?? []} />
220229
)}
221230
</Tabs.Content>
222-
<Tabs.Content value="spam-assassin">
223-
{spamLoading ? (
231+
<Tabs.Content value="compatibility">
232+
{compatibilityLoading ? (
224233
<div className="animate-pulse text-slate-11 text-sm pt-1">
225-
Running spam check...
234+
Running compatibility check...
235+
</div>
236+
) : compatibilityCheckingResults?.length === 0 ? (
237+
<div className="flex flex-col items-center justify-center py-8 px-4 my-4">
238+
<SuccessIcon />
239+
<SuccessTitle>Great compatibility</SuccessTitle>
240+
<SuccessDescription>
241+
It should render properly everywhere.
242+
</SuccessDescription>
226243
</div>
227244
) : (
228-
<SpamAssassin result={spamCheckingResult} />
245+
<Compatibility results={compatibilityCheckingResults ?? []} />
229246
)}
230247
</Tabs.Content>
231-
<Tabs.Content value="compatibility">
232-
{compatibilityLoading ? (
248+
<Tabs.Content value="spam-assassin">
249+
{spamLoading ? (
233250
<div className="animate-pulse text-slate-11 text-sm pt-1">
234-
Running compatibility check...
251+
Running spam check...
252+
</div>
253+
) : spamCheckingResult?.isSpam === false ? (
254+
<div className="flex flex-col items-center justify-center py-4 px-4 my-4">
255+
<SuccessIcon />
256+
<SuccessTitle>10/10</SuccessTitle>
257+
<SuccessDescription>
258+
Your email is clean of abuse indicators.
259+
</SuccessDescription>
235260
</div>
236261
) : (
237-
<Compatibility results={compatibilityCheckingResults} />
262+
<SpamAssassin result={spamCheckingResult} />
238263
)}
239264
</Tabs.Content>
240265
</div>
@@ -244,6 +269,32 @@ const ToolbarInner = ({
244269
);
245270
};
246271

272+
const SuccessIcon = () => {
273+
return (
274+
<div className="relative mb-8 flex items-center justify-center">
275+
<div className="h-16 w-16 rounded-full bg-gradient-to-br from-green-300/20 opacity-80 to-emerald-500/30 blur-md absolute m-auto left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
276+
<div className="h-12 w-12 rounded-full bg-gradient-to-br from-green-400/80 opacity-10 to-emerald-600/80 absolute m-auto left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 shadow-lg" />
277+
<div className="h-10 w-10 rounded-full bg-gradient-to-br from-green-400 to-emerald-600 flex items-center justify-center absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 shadow-[inset_0_1px_1px_rgba(255,255,255,0.4)]">
278+
<IconCheck size={24} className="text-white drop-shadow-sm" />
279+
</div>
280+
</div>
281+
);
282+
};
283+
284+
const SuccessTitle = ({ children }) => {
285+
return (
286+
<h3 className="text-slate-12 font-medium text-base mb-1">{children}</h3>
287+
);
288+
};
289+
290+
const SuccessDescription = ({ children }) => {
291+
return (
292+
<p className="text-slate-11 text-sm text-center max-w-[300px]">
293+
{children}
294+
</p>
295+
);
296+
};
297+
247298
interface ToolbarProps {
248299
serverSpamCheckingResult: SpamCheckingResult | undefined;
249300
serverLintingRows: LintingRow[] | undefined;

0 commit comments

Comments
 (0)