Skip to content

Commit f69ce57

Browse files
author
Meryem Kaftar
authored
fix(clerk-js): Expand Keyless UI if user is signed-in (#4969)
1 parent 183f2bf commit f69ce57

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@clerk/clerk-js': minor
3+
---
4+
5+
Expand Keyless popover when a user signs-in.

packages/clerk-js/src/ui/components/KeylessPrompt/index.tsx

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { useUser } from '@clerk/shared/react';
12
// eslint-disable-next-line no-restricted-imports
23
import { css } from '@emotion/react';
34
import type { PropsWithChildren } from 'react';
@@ -22,7 +23,15 @@ const buttonIdentifier = `${buttonIdentifierPrefix}-button`;
2223
const contentIdentifier = `${buttonIdentifierPrefix}-content`;
2324

2425
const _KeylessPrompt = (_props: KeylessPromptProps) => {
26+
const { isSignedIn } = useUser();
2527
const [isExpanded, setIsExpanded] = useState(false);
28+
29+
useEffect(() => {
30+
if (isSignedIn) {
31+
setIsExpanded(true);
32+
}
33+
}, [isSignedIn]);
34+
2635
const environment = useRevalidateEnvironment();
2736
const claimed = Boolean(environment.authConfig.claimedAt);
2837

@@ -387,9 +396,11 @@ const _KeylessPrompt = (_props: KeylessPromptProps) => {
387396
Dashboard.
388397
</>
389398
) : (
390-
<>
391-
We generated temporary API keys for you. Link this application to your Clerk account to configure it.
392-
</>
399+
<p>
400+
{isSignedIn
401+
? "You've created your first user! Link this application to your Clerk account to explore the Dashboard."
402+
: 'We generated temporary API keys for you. Link this application to your Clerk account to configure it.'}
403+
</p>
393404
)}
394405
</p>
395406
</div>
@@ -420,7 +431,10 @@ const _KeylessPrompt = (_props: KeylessPromptProps) => {
420431
data-expanded={isForcedExpanded}
421432
css={css`
422433
${mainCTAStyles};
423-
animation: ${isForcedExpanded && 'show-button 600ms ease-in forwards'};
434+
animation: ${isForcedExpanded && isSignedIn
435+
? 'show-button 800ms ease forwards'
436+
: 'show-button 650ms ease-in forwards'};
437+
424438
@keyframes show-button {
425439
0%,
426440
5% {

0 commit comments

Comments
 (0)