Files
twenty_crm/packages/twenty-front/src/modules/auth/components/Logo.tsx
nitin 52c38c3082 Correct default fallback logo path in Logo component (#12053)
closes #11849
The Logo component’s fallback URL was pointing to
`/icons/android/android-launchericon-192-192.png`, but the asset lives
under `/images/icons/....`. This updates defaultPrimaryLogoUrl to use
the correct `/images/icons/android/android-launchericon-192-192.png`
path, restoring the default logo display when no primaryLogo prop is
provided.
2025-05-15 09:44:37 +02:00

88 lines
2.7 KiB
TypeScript

import styled from '@emotion/styled';
import { isNonEmptyString } from '@sniptt/guards';
import { getImageAbsoluteURI } from 'twenty-shared/utils';
import { UndecoratedLink } from 'twenty-ui/navigation';
import { REACT_APP_SERVER_BASE_URL } from '~/config';
import { useRedirectToDefaultDomain } from '~/modules/domain-manager/hooks/useRedirectToDefaultDomain';
import { AppPath } from '~/modules/types/AppPath';
type LogoProps = {
primaryLogo?: string | null;
secondaryLogo?: string | null;
};
const StyledContainer = styled.div`
height: ${({ theme }) => theme.spacing(12)};
margin-bottom: ${({ theme }) => theme.spacing(4)};
margin-top: ${({ theme }) => theme.spacing(4)};
position: relative;
width: ${({ theme }) => theme.spacing(12)};
`;
const StyledSecondaryLogo = styled.img`
border-radius: ${({ theme }) => theme.border.radius.xs};
height: ${({ theme }) => theme.spacing(6)};
width: ${({ theme }) => theme.spacing(6)};
`;
const StyledSecondaryLogoContainer = styled.div`
align-items: center;
background-color: ${({ theme }) => theme.background.primary};
border-radius: ${({ theme }) => theme.border.radius.sm};
bottom: ${({ theme }) => `-${theme.spacing(3)}`};
display: flex;
height: ${({ theme }) => theme.spacing(7)};
justify-content: center;
position: absolute;
right: ${({ theme }) => `-${theme.spacing(3)}`};
width: ${({ theme }) => theme.spacing(7)};
`;
const StyledPrimaryLogo = styled.div<{ src: string }>`
background: url(${(props) => props.src});
background-size: cover;
height: 100%;
width: 100%;
`;
export const Logo = (props: LogoProps) => {
const { redirectToDefaultDomain } = useRedirectToDefaultDomain();
const defaultPrimaryLogoUrl = `${window.location.origin}/images/icons/android/android-launchericon-192-192.png`;
const primaryLogoUrl = getImageAbsoluteURI({
imageUrl: props.primaryLogo ?? defaultPrimaryLogoUrl,
baseUrl: REACT_APP_SERVER_BASE_URL,
});
const secondaryLogoUrl = isNonEmptyString(props.secondaryLogo)
? getImageAbsoluteURI({
imageUrl: props.secondaryLogo,
baseUrl: REACT_APP_SERVER_BASE_URL,
})
: null;
const isUsingDefaultLogo = !props.primaryLogo;
return (
<StyledContainer>
{isUsingDefaultLogo ? (
<UndecoratedLink
to={AppPath.SignInUp}
onClick={redirectToDefaultDomain}
>
<StyledPrimaryLogo src={primaryLogoUrl ?? ''} />
</UndecoratedLink>
) : (
<StyledPrimaryLogo src={primaryLogoUrl ?? ''} />
)}
{secondaryLogoUrl && (
<StyledSecondaryLogoContainer>
<StyledSecondaryLogo src={secondaryLogoUrl} />
</StyledSecondaryLogoContainer>
)}
</StyledContainer>
);
};