Skip to content

Commit 3f438ba

Browse files
zehfernandesgabrielmfern
authored andcommitted
feat: new loading sate (#2000)
1 parent f6e67c4 commit 3f438ba

File tree

2 files changed

+43
-15
lines changed

2 files changed

+43
-15
lines changed

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

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,51 +206,45 @@ const ToolbarInner = ({
206206
<div className="flex-grow transition-opacity opacity-100 group-data-[toggled=false]/toolbar:opacity-0 overflow-y-auto px-2 pt-3">
207207
<Tabs.Content value="linter">
208208
{lintLoading ? (
209-
<div className="animate-pulse text-slate-11 text-sm pt-1">
210-
Running linting...
211-
</div>
209+
<LoadingState message="Analyzing your code for linting issues..." />
212210
) : lintingRows?.length === 0 ? (
213-
<div className="flex flex-col items-center justify-center pt-8">
211+
<SuccessWrapper>
214212
<SuccessIcon />
215213
<SuccessTitle>All good</SuccessTitle>
216214
<SuccessDescription>
217215
No linting issues found.
218216
</SuccessDescription>
219-
</div>
217+
</SuccessWrapper>
220218
) : (
221219
<Linter rows={lintingRows ?? []} />
222220
)}
223221
</Tabs.Content>
224222
<Tabs.Content value="compatibility">
225223
{compatibilityLoading ? (
226-
<div className="animate-pulse text-slate-11 text-sm pt-1">
227-
Running compatibility check...
228-
</div>
224+
<LoadingState message="Checking email compatibility..." />
229225
) : compatibilityCheckingResults?.length === 0 ? (
230-
<div className="flex flex-col items-center justify-center pt-8">
226+
<SuccessWrapper>
231227
<SuccessIcon />
232228
<SuccessTitle>Great compatibility</SuccessTitle>
233229
<SuccessDescription>
234230
Template should render properly everywhere.
235231
</SuccessDescription>
236-
</div>
232+
</SuccessWrapper>
237233
) : (
238234
<Compatibility results={compatibilityCheckingResults ?? []} />
239235
)}
240236
</Tabs.Content>
241237
<Tabs.Content value="spam-assassin">
242238
{spamLoading ? (
243-
<div className="animate-pulse text-slate-11 text-sm pt-1">
244-
Running spam check...
245-
</div>
239+
<LoadingState message="Evaluating your email for spam indicators..." />
246240
) : spamCheckingResult?.isSpam === false ? (
247-
<div className="flex flex-col items-center justify-center pt-8">
241+
<SuccessWrapper>
248242
<SuccessIcon />
249243
<SuccessTitle>10/10</SuccessTitle>
250244
<SuccessDescription>
251245
Your email is clean of abuse indicators.
252246
</SuccessDescription>
253-
</div>
247+
</SuccessWrapper>
254248
) : (
255249
<SpamAssassin result={spamCheckingResult} />
256250
)}
@@ -262,6 +256,32 @@ const ToolbarInner = ({
262256
);
263257
};
264258

259+
const LoadingState = ({ message }: { message: string }) => {
260+
return (
261+
<div className="flex flex-col items-center justify-center pt-8">
262+
<div className="relative mb-8 flex items-center justify-center">
263+
<div className="h-12 w-12 rounded-full bg-gradient-to-br from-cyan-400/80 to-cyan-600/80 opacity-10 blur-xl absolute m-auto left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 animate-pulse" />
264+
<div className="h-12 w-12 rounded-full border border-slate-4 absolute m-auto left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2" />
265+
<div className="h-10 w-10 rounded-full flex items-center justify-center absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2">
266+
<div className="h-5 w-5 rounded-full border-2 border-white/50 border-t-transparent animate-spin-fast" />
267+
</div>
268+
</div>
269+
<h3 className="text-slate-12 font-medium text-base mb-1">Processing</h3>
270+
<p className="text-slate-11 text-sm text-center max-w-[320px]">
271+
{message}
272+
</p>
273+
</div>
274+
);
275+
};
276+
277+
const SuccessWrapper = ({ children }: { children: React.ReactNode }) => {
278+
return (
279+
<div className="flex flex-col items-center justify-center pt-8">
280+
{children}
281+
</div>
282+
);
283+
};
284+
265285
const SuccessIcon = () => {
266286
return (
267287
<div className="relative mb-8 flex items-center justify-center">

packages/react-email/tailwind.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,14 @@ const config: Config = {
8282
'0%': { strokeDashoffset: '1000' },
8383
'100%': { strokeDashoffset: '0' },
8484
},
85+
spin: {
86+
'0%': { transform: 'rotate(0deg)' },
87+
'100%': { transform: 'rotate(360deg)' },
88+
},
89+
},
90+
animation: {
91+
'spin-slow': 'spin 3s linear infinite',
92+
'spin-fast': 'spin 1.5s linear infinite',
8593
},
8694
},
8795
},

0 commit comments

Comments
 (0)