Skip to content

Commit 2efb3e3

Browse files
committed
updates
1 parent ba6ca1e commit 2efb3e3

1 file changed

Lines changed: 54 additions & 12 deletions

File tree

  • packages/clerk-js/src/ui/components/devPrompts/KeylessPrompt

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

Lines changed: 54 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ const KeylessPromptInternal = (_props: KeylessPromptProps) => {
440440
};
441441

442442
const WIDTH_OPEN = '18rem';
443-
const WIDTH_CLOSED = '15rem';
443+
const WIDTH_CLOSED = '14.25rem';
444444
const DURATION_OPEN = '220ms';
445445
const DURATION_CLOSE = '180ms';
446446
const EASE_BEZIER = 'cubic-bezier(0.2, 0, 0, 1)';
@@ -481,13 +481,15 @@ type STATES = 'idle' | 'userCreated' | 'completed';
481481
* Each state maps to UI content including title, description, and button text.
482482
*/
483483
type ContentItem = {
484+
triggerWidth: string;
484485
title: string;
485486
description: React.ReactNode | ((...args: any[]) => React.ReactNode);
486487
buttonText: string;
487488
};
488489

489490
const CONTENT: Record<STATES, ContentItem> = {
490491
idle: {
492+
triggerWidth: '14.25rem',
491493
title: 'Configure your application',
492494
description: (
493495
<>
@@ -503,14 +505,37 @@ const CONTENT: Record<STATES, ContentItem> = {
503505
buttonText: 'Confirgure your application',
504506
},
505507
userCreated: {
506-
title: 'Clerk is in keyless mode',
507-
description: <p>TODO</p>,
508-
buttonText: 'Claim application',
508+
triggerWidth: '15.75rem',
509+
title: "You've created your first user!",
510+
description: (
511+
<>
512+
<p>Head to the dashboard to customize authentication settings, view user info, and explore more features.</p>
513+
<ul>
514+
{['Add SSO connections (eg. GitHub)', 'Set up B2B authentication', 'Enable MFA'].map(item => (
515+
<li key={item}>{item}</li>
516+
))}
517+
</ul>
518+
</>
519+
),
520+
buttonText: 'Configure your application',
509521
},
510522
completed: {
511-
title: 'Claim completed',
512-
description: (_appName: string, _instanceUrlToDashboard: string) => <p>TODO</p>,
513-
buttonText: 'TODO',
523+
triggerWidth: '10.5rem',
524+
title: 'Your app is ready',
525+
description: (appName: string, instanceUrlToDashboard: string) => (
526+
<p>
527+
Your application{' '}
528+
<a
529+
href={instanceUrlToDashboard}
530+
target='_blank'
531+
rel='noopener noreferrer'
532+
>
533+
{appName}
534+
</a>{' '}
535+
has been configured. You may now customize your settings in the Clerk dashboard.
536+
</p>
537+
),
538+
buttonText: 'Dismiss',
514539
},
515540
};
516541

@@ -519,6 +544,7 @@ const CONTENT: Record<STATES, ContentItem> = {
519544
* You can modify this logic to match your state management needs.
520545
*/
521546
const getCurrentState = (claimed: boolean, success: boolean, isSignedIn: boolean): STATES => {
547+
return 'completed';
522548
if (success) {
523549
return 'completed';
524550
}
@@ -557,7 +583,13 @@ function Keyless() {
557583
const instanceUrlToDashboard = 'https://dashboard.clerk.com';
558584

559585
const [isOpen, setIsOpen] = useState(false);
560-
const [currentState, setCurrentState] = useState<STATES>(getCurrentState(claimed, success, isSignedIn));
586+
const currentState = getCurrentState(claimed, success, isSignedIn);
587+
588+
const title = getContent(currentState).title;
589+
const description = renderDescription(getContent(currentState).description, appName, instanceUrlToDashboard);
590+
const buttonText = getContent(currentState).buttonText;
591+
const triggerWidth = getContent(currentState).triggerWidth;
592+
561593
return (
562594
<div
563595
data-expanded={isOpen}
@@ -579,7 +611,7 @@ function Keyless() {
579611
isolation: isolate;
580612
transform: translateZ(0);
581613
backface-visibility: hidden;
582-
width: ${isOpen ? WIDTH_OPEN : WIDTH_CLOSED};
614+
width: ${isOpen ? WIDTH_OPEN : triggerWidth};
583615
transition:
584616
border-radius ${getDuration(isOpen)} cubic-bezier(0.2, 0, 0, 1),
585617
width ${getDuration(isOpen)} ${EASE_BEZIER};
@@ -656,7 +688,7 @@ function Keyless() {
656688
white-space: nowrap;
657689
`}
658690
>
659-
{getContent(currentState).title}
691+
{title}
660692
</span>
661693
<svg
662694
css={css`
@@ -684,6 +716,7 @@ function Keyless() {
684716
</button>
685717
<div
686718
id={id}
719+
{...(!isOpen && { inert: '' as any })}
687720
css={css`
688721
${CSS_RESET};
689722
display: grid;
@@ -730,9 +763,18 @@ function Keyless() {
730763
line-height: 1rem;
731764
text-wrap: pretty;
732765
}
766+
& a {
767+
color: #fde047;
768+
font-weight: 500;
769+
outline: none;
770+
&:focus-visible {
771+
outline: 2px solid #6c47ff;
772+
outline-offset: 2px;
773+
}
774+
}
733775
`}
734776
>
735-
{renderDescription(getContent(currentState).description, appName, instanceUrlToDashboard)}
777+
{description}
736778

737779
<a
738780
href='https://clerk.com/dashboard'
@@ -775,7 +817,7 @@ function Keyless() {
775817
}
776818
`}
777819
>
778-
{getContent(currentState).buttonText}
820+
{buttonText}
779821
</a>
780822
</div>
781823
</div>

0 commit comments

Comments
 (0)