Skip to content

Commit

Permalink
feat: allow overriding OIDC logos
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-jonas committed Nov 27, 2024
1 parent 60bc748 commit 59a6866
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,5 @@ export function DefaultMessage({ message }: OryMessageContentProps) {
</span>
)
}

export { DefaultButtonSocial } from "./social"
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import {
uiTextToFormattedMessage,
useOryFlow,
} from "@ory/elements-react"
import logos from "../../provider-logos"
import defaultLogos from "../../provider-logos"
import { cn } from "../../utils/cn"
import { useIntl } from "react-intl"
import { ElementType } from "react"

export function extractProvider(
context: object | undefined,
Expand All @@ -27,14 +28,17 @@ export function extractProvider(

type DefaultSocialButtonProps = OryNodeOidcButtonProps & {
showLabel?: boolean
logos?: Record<string, ElementType>
}

export function DefaultButtonSocial({
attributes,
node,
onClick,
showLabel: _showLabel,
logos: providedLogos,
}: DefaultSocialButtonProps) {
const logos = { ...defaultLogos, ...providedLogos }
const {
node_type: _ignoredNodeType,
type: _ignoredType,
Expand Down Expand Up @@ -73,7 +77,7 @@ export function DefaultButtonSocial({
<Logo
size={20}
// alt={node.meta.label?.text || attributes.value}
className="object-fill w-full h-full"
// className="object-fill w-full h-full"
/>
) : (
<span className="rounded-full aspect-square border flex items-center justify-center text-xs">
Expand All @@ -90,6 +94,17 @@ export function DefaultButtonSocial({
)
}

/**
* Returns a variant of DefaultButtonSocial that can use your own logos
*
* @param logos - a record of provider names and their respective logos
* @returns a variant of DefaultButtonSocial that uses the provided logos
*/
DefaultButtonSocial.WithLogos =
(logos: Record<string, ElementType>) => (props: DefaultSocialButtonProps) => (
<DefaultButtonSocial {...props} logos={logos} />
)

export function DefaultSocialButtonContainer({
children,
nodes,
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 59a6866

Please sign in to comment.