Skip to content

Commit

Permalink
feat(ui): Add logoVisibility prop functionality (#4202)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcarpenter authored Sep 23, 2024
1 parent cac25e0 commit 11ebd02
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 2 additions & 0 deletions .changeset/orange-scissors-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
8 changes: 6 additions & 2 deletions packages/ui/src/contexts/AppearanceContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ export type ParsedElementsFragment = Partial<PartialTheme>;
* the main type interacted with within components.
*/
export type ParsedElements = Record<DescriptorIdentifier, ParsedDescriptor>;
export type ParsedLayout = Required<Layout>;
export type ParsedLayout = Required<
Omit<Layout, 'logoPlacement'> & {
logoVisibility: 'visible' | 'hidden';
}
>;

type ElementsAppearanceConfig = string | (React.CSSProperties & { className?: string });

Expand Down Expand Up @@ -224,7 +228,7 @@ export const defaultAppearance: ParsedAppearance = {
theme: fullTheme,
elements: fullTheme,
layout: {
logoPlacement: 'inside',
logoVisibility: 'visible',
socialButtonsPlacement: 'top',
socialButtonsVariant: 'auto',
logoImageUrl: '',
Expand Down
13 changes: 8 additions & 5 deletions packages/ui/src/hooks/use-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,14 @@ export function useCard() {
const { layout } = useAppearance().parsedAppearance;
const { applicationName, branded, logoImageUrl, homeUrl } = useDisplayConfig();

const logoProps = {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
};
const logoProps =
layout?.logoVisibility === 'visible'
? {
href: layout?.logoLinkUrl || homeUrl,
src: layout?.logoImageUrl || logoImageUrl,
alt: applicationName,
}
: null;

const footerProps = {
branded,
Expand Down

0 comments on commit 11ebd02

Please sign in to comment.