11import { useUser } from '@clerk/shared/react' ;
2- import type { ComponentProps } from 'react' ;
32import { useState } from 'react' ;
43
54import { useEnvironment , useOAuthConsentContext } from '@/ui/contexts' ;
6- import { Box , Button , Flex , Flow , Grid , Icon , Text } from '@/ui/customizables' ;
5+ import { Box , Button , Flow , Grid , Text } from '@/ui/customizables' ;
76import { ApplicationLogo } from '@/ui/elements/ApplicationLogo' ;
87import { Card } from '@/ui/elements/Card' ;
98import { withCardStateProvider } from '@/ui/elements/contexts' ;
109import { Header } from '@/ui/elements/Header' ;
1110import { Modal } from '@/ui/elements/Modal' ;
1211import { Tooltip } from '@/ui/elements/Tooltip' ;
13- import { LockDottedCircle } from '@/ui/icons' ;
1412import { Alert , Textarea } from '@/ui/primitives' ;
15- import type { ThemableCssProp } from '@/ui/styledSystem' ;
1613import { common } from '@/ui/styledSystem' ;
1714import { colors } from '@/ui/utils/colors' ;
18-
15+ import { LogoGroup , LogoGroupItem , LogoGroupIcon , LogoGroupSeparator } from './LogoGroup' ;
1916import { OrgSelect } from './OrgSelect' ;
2017
2118const OFFLINE_ACCESS_SCOPE = 'offline_access' ;
@@ -61,24 +58,24 @@ export function OAuthConsentInternal() {
6158 < Header . Root >
6259 { /* both have avatars */ }
6360 { oAuthApplicationLogoUrl && logoImageUrl && (
64- < ConnectionHeader >
65- < ConnectionItem justify = 'end' >
61+ < LogoGroup >
62+ < LogoGroupItem justify = 'end' >
6663 < ApplicationLogo
6764 src = { oAuthApplicationLogoUrl }
6865 alt = { oAuthApplicationName }
6966 href = { oAuthApplicationUrl }
7067 isExternal
7168 />
72- </ ConnectionItem >
73- < ConnectionSeparator />
74- < ConnectionItem justify = 'start' >
69+ </ LogoGroupItem >
70+ < LogoGroupSeparator />
71+ < LogoGroupItem justify = 'start' >
7572 < ApplicationLogo />
76- </ ConnectionItem >
77- </ ConnectionHeader >
73+ </ LogoGroupItem >
74+ </ LogoGroup >
7875 ) }
7976 { /* only OAuth app has an avatar */ }
8077 { oAuthApplicationLogoUrl && ! logoImageUrl && (
81- < ConnectionHeader >
78+ < LogoGroup >
8279 < Box
8380 sx = { {
8481 position : 'relative' ,
@@ -90,7 +87,7 @@ export function OAuthConsentInternal() {
9087 href = { oAuthApplicationUrl }
9188 isExternal
9289 />
93- < ConnectionIcon
90+ < LogoGroupIcon
9491 size = 'sm'
9592 sx = { t => ( {
9693 position : 'absolute' ,
@@ -99,25 +96,25 @@ export function OAuthConsentInternal() {
9996 } ) }
10097 />
10198 </ Box >
102- </ ConnectionHeader >
99+ </ LogoGroup >
103100 ) }
104101 { /* only Clerk application has an avatar */ }
105102 { ! oAuthApplicationLogoUrl && logoImageUrl && (
106- < ConnectionHeader >
107- < ConnectionItem justify = 'end' >
108- < ConnectionIcon />
109- </ ConnectionItem >
110- < ConnectionSeparator />
111- < ConnectionItem justify = 'start' >
103+ < LogoGroup >
104+ < LogoGroupItem justify = 'end' >
105+ < LogoGroupIcon />
106+ </ LogoGroupItem >
107+ < LogoGroupSeparator />
108+ < LogoGroupItem justify = 'start' >
112109 < ApplicationLogo />
113- </ ConnectionItem >
114- </ ConnectionHeader >
110+ </ LogoGroupItem >
111+ </ LogoGroup >
115112 ) }
116113 { /* no avatars */ }
117114 { ! oAuthApplicationLogoUrl && ! logoImageUrl && (
118- < ConnectionHeader >
119- < ConnectionIcon />
120- </ ConnectionHeader >
115+ < LogoGroup >
116+ < LogoGroupIcon />
117+ </ LogoGroup >
121118 ) }
122119 < Header . Title localizationKey = { oAuthApplicationName } />
123120 < Header . Subtitle localizationKey = { `wants to access ${ applicationName } on behalf of ${ primaryIdentifier } ` } />
@@ -325,93 +322,4 @@ function RedirectUriModal({ onOpen, onClose, isOpen, redirectUri, oAuthApplicati
325322 ) ;
326323}
327324
328- function ConnectionHeader ( { children } : { children : React . ReactNode } ) {
329- return (
330- < Flex
331- justify = 'center'
332- align = 'center'
333- gap = { 4 }
334- sx = { t => ( {
335- marginBlockEnd : t . space . $6 ,
336- } ) }
337- >
338- { children }
339- </ Flex >
340- ) ;
341- }
342-
343- function ConnectionItem ( { children, sx, ...props } : ComponentProps < typeof Flex > ) {
344- return (
345- < Flex
346- { ...props }
347- sx = { [ { flex : 1 } , sx ] }
348- >
349- { children }
350- </ Flex >
351- ) ;
352- }
353-
354- function ConnectionIcon ( { size = 'md' , sx } : { size ?: 'sm' | 'md' ; sx ?: ThemableCssProp } ) {
355- const scale : ThemableCssProp = t => {
356- const value = size === 'sm' ? t . space . $6 : t . space . $12 ;
357- return {
358- width : value ,
359- height : value ,
360- } ;
361- } ;
362-
363- return (
364- < Box
365- sx = { t => [
366- {
367- background : common . mergedColorsBackground (
368- colors . setAlpha ( t . colors . $colorBackground , 1 ) ,
369- t . colors . $neutralAlpha50 ,
370- ) ,
371- borderRadius : t . radii . $circle ,
372- borderWidth : t . borderWidths . $normal ,
373- borderStyle : t . borderStyles . $solid ,
374- borderColor : t . colors . $borderAlpha100 ,
375- display : 'flex' ,
376- alignItems : 'center' ,
377- justifyContent : 'center' ,
378- } ,
379- scale ,
380- sx ,
381- ] }
382- >
383- < Icon
384- icon = { LockDottedCircle }
385- sx = { t => ( {
386- color : t . colors . $primary500 ,
387- } ) }
388- />
389- </ Box >
390- ) ;
391- }
392-
393- function ConnectionSeparator ( ) {
394- return (
395- < Box
396- as = 'svg'
397- // @ts -ignore - valid SVG attribute
398- fill = 'none'
399- viewBox = '0 0 16 2'
400- height = { 2 }
401- aria-hidden
402- sx = { t => ( {
403- color : t . colors . $colorMutedForeground ,
404- } ) }
405- >
406- < path
407- stroke = 'currentColor'
408- strokeDasharray = '0.1 4'
409- strokeLinecap = 'round'
410- strokeWidth = '2'
411- d = 'M1 1h14'
412- />
413- </ Box >
414- ) ;
415- }
416-
417325export const OAuthConsent = withCardStateProvider ( OAuthConsentInternal ) ;
0 commit comments