diff --git a/.changeset/chilly-ravens-cover.md b/.changeset/chilly-ravens-cover.md new file mode 100644 index 00000000000..f76a02f0b72 --- /dev/null +++ b/.changeset/chilly-ravens-cover.md @@ -0,0 +1,5 @@ +--- +'@clerk/clerk-js': patch +--- + +Refactor ApplicationLogo rendering logic to account for oAuth logos within OAuthConsent component. diff --git a/packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx b/packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx index 6841e39dc2a..dc7a55fac4c 100644 --- a/packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx +++ b/packages/clerk-js/src/ui/components/OAuthConsent/OAuthConsent.tsx @@ -1,10 +1,10 @@ import { useUser } from '@clerk/shared/react'; +import type { ComponentProps } from 'react'; import { useState } from 'react'; import { useEnvironment, useOAuthConsentContext } from '@/ui/contexts'; import { Box, Button, Flex, Flow, Grid, Icon, Text } from '@/ui/customizables'; import { ApplicationLogo } from '@/ui/elements/ApplicationLogo'; -import { Avatar } from '@/ui/elements/Avatar'; import { Card } from '@/ui/elements/Card'; import { withCardStateProvider } from '@/ui/elements/contexts'; import { Header } from '@/ui/elements/Header'; @@ -42,13 +42,16 @@ export function OAuthConsentInternal() { {/* both have avatars */} {oAuthApplicationLogoUrl && logoImageUrl && ( - t.space.$12} - rounded={false} - /> + + + - + + + )} {/* only OAuth app has an avatar */} @@ -59,10 +62,9 @@ export function OAuthConsentInternal() { position: 'relative', }} > - t.space.$12} - rounded={false} + ({ - marginBlockEnd: t.space.$6, - })} - > - + + + + - - + + + + )} {/* no avatars */} {!oAuthApplicationLogoUrl && !logoImageUrl && ( - ({ - marginBlockEnd: t.space.$6, - })} - > + - + )} ) { + return ( + + {children} + + ); +} + function ConnectionIcon({ size = 'md', sx }: { size?: 'sm' | 'md'; sx?: ThemableCssProp }) { const scale: ThemableCssProp = t => { const value = size === 'sm' ? t.space.$6 : t.space.$12; diff --git a/packages/clerk-js/src/ui/elements/ApplicationLogo.tsx b/packages/clerk-js/src/ui/elements/ApplicationLogo.tsx index 68f8905f267..f9125511ff3 100644 --- a/packages/clerk-js/src/ui/elements/ApplicationLogo.tsx +++ b/packages/clerk-js/src/ui/elements/ApplicationLogo.tsx @@ -21,15 +21,30 @@ const getContainerHeightForImageRatio = (imageRef: React.RefObject; +export type ApplicationLogoProps = PropsOfComponent & { + /** + * The URL of the image to display. + */ + src?: string; + /** + * The alt text for the image. + */ + alt?: string; + /** + * The URL to navigate to when the logo is clicked. + */ + href?: string; +}; -export const ApplicationLogo = (props: ApplicationLogoProps) => { +export const ApplicationLogo: React.FC = (props: ApplicationLogoProps): JSX.Element | null => { + const { src, alt, href, sx, ...rest } = props; const imageRef = React.useRef(null); const [loaded, setLoaded] = React.useState(false); const { logoImageUrl, applicationName, homeUrl } = useEnvironment().displayConfig; const { parsedLayout } = useAppearance(); - const imageSrc = parsedLayout.logoImageUrl || logoImageUrl; - const logoUrl = parsedLayout.logoLinkUrl || homeUrl; + const imageSrc = src || parsedLayout.logoImageUrl || logoImageUrl; + const imageAlt = alt || applicationName; + const logoUrl = href || parsedLayout.logoLinkUrl || homeUrl; if (!imageSrc) { return null; @@ -39,7 +54,7 @@ export const ApplicationLogo = (props: ApplicationLogoProps) => { {applicationName} setLoaded(true)} @@ -55,20 +70,18 @@ export const ApplicationLogo = (props: ApplicationLogoProps) => { return ( ({ height: getContainerHeightForImageRatio(imageRef, theme.sizes.$6), justifyContent: 'center', }), - props.sx, + sx, ]} > {logoUrl ? ( {image} diff --git a/packages/clerk-js/src/ui/primitives/Link.tsx b/packages/clerk-js/src/ui/primitives/Link.tsx index 136ef88fa1a..b57e89caef2 100644 --- a/packages/clerk-js/src/ui/primitives/Link.tsx +++ b/packages/clerk-js/src/ui/primitives/Link.tsx @@ -33,10 +33,19 @@ const { applyVariants, filterProps } = createVariants(theme => ({ }, inherit: { color: 'inherit' }, }, + focusRing: { + true: { + '&:focus': { + outline: 'none', + ...common.focusRing(theme), + }, + }, + }, }, defaultVariants: { colorScheme: 'primary', variant: 'body', + focusRing: false, }, }));