Skip to content

Commit

Permalink
fix(login): fix issue where logo is not shown on custom auth providers (
Browse files Browse the repository at this point in the history
#5002)

* doc(sanity): add TS-doc for block content related types (#4674)

* chore(core/form/inputs): remove outdated workshop case

Remove this non-working workshop left over from v2

* refactor(core/form/inputs): deprecate block marker callbacks and support

* doc(types): add ts doc comments to block schema types

* doc(sanity): add TS-doc for block content related types

* fix(login): fix issue where logo is not shown on custom auth providers

---------

Co-authored-by: Per-Kristian Nordnes <per.kristian.nordnes@gmail.com>
  • Loading branch information
binoy14 and skogsmaskin committed Oct 20, 2023
1 parent a0f2c27 commit 744bfdf
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, {useEffect, useState} from 'react'
import type {Observable} from 'rxjs'
import type {AuthConfig} from '../../../config'
import {createHookFromObservableFactory} from '../../../util'
import {providerLogos} from './providerLogos'
import {CustomLogo, providerLogos} from './providerLogos'
import type {LoginComponentProps} from './types'

interface GetProvidersOptions extends AuthConfig {
Expand Down Expand Up @@ -156,7 +156,7 @@ export function createLoginComponent({
// eslint-disable-next-line react/no-array-index-key
key={`${provider.url}_${index}`}
as="a"
icon={providerLogos[provider.name]}
icon={providerLogos[provider.name] || <CustomLogo provider={provider} />}
href={createHrefForProvider({
loginMethod,
projectId,
Expand Down
15 changes: 10 additions & 5 deletions packages/sanity/src/core/store/_legacy/authStore/providerLogos.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ const GithubRoot = styled.svg(({theme}: {theme: Theme}) => {
`
})

const CustomImage = styled.img`
height: 19px;
width: 19px;
object-fit: contain;
`

const GithubLogo = () => (
<GithubRoot
// data-sanity-icon="google-logo"
Expand Down Expand Up @@ -50,17 +56,16 @@ const GoogleLogo = () => (
</svg>
)

function CustomLogo(props: {provider: AuthProvider}) {
export function CustomLogo(props: {provider: AuthProvider}) {
const {provider} = props

return (
provider.logo ? <img src={provider.logo} alt={`Logo for ${provider.name}`} /> : undefined
) as any
return provider.logo ? (
<CustomImage src={provider.logo} alt={`Logo for ${provider.name}`} />
) : undefined
}

export const providerLogos: Record<string, React.ComponentType<{provider: AuthProvider}>> = {
google: GoogleLogo,
github: GithubLogo,
custom: CustomLogo,
// sanity: () => <SanityMonogram data-sanity-icon="" />,
}

2 comments on commit 744bfdf

@vercel
Copy link

@vercel vercel bot commented on 744bfdf Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

performance-studio – ./

performance-studio-git-next.sanity.build
performance-studio.sanity.build

@vercel
Copy link

@vercel vercel bot commented on 744bfdf Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

test-studio – ./

test-studio-git-next.sanity.build
test-studio.sanity.build

Please sign in to comment.