Add Twenty Shared & Fix profile image rendering (#8841)
PR Summary: 1. Added `Twenty Shared` Package to centralize utilitiies as mentioned in #8942 2. Optimization of `getImageAbsoluteURI.ts` to handle edge cases  --------- Co-authored-by: Antoine Moreaux <moreaux.antoine@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
committed by
GitHub
parent
4e329d08b0
commit
08a9db2df6
@ -1,6 +1,8 @@
|
||||
import styled from '@emotion/styled';
|
||||
import { isNonEmptyString } from '@sniptt/guards';
|
||||
import { getImageAbsoluteURI } from 'twenty-ui';
|
||||
|
||||
import { getImageAbsoluteURI } from 'twenty-shared';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
|
||||
type LogoProps = {
|
||||
primaryLogo?: string | null;
|
||||
@ -46,16 +48,21 @@ const StyledPrimaryLogo = styled.div<{ src: string }>`
|
||||
export const Logo = (props: LogoProps) => {
|
||||
const defaultPrimaryLogoUrl = `${window.location.origin}/icons/android/android-launchericon-192-192.png`;
|
||||
|
||||
const primaryLogoUrl = getImageAbsoluteURI(
|
||||
props.primaryLogo ?? defaultPrimaryLogoUrl,
|
||||
);
|
||||
const primaryLogoUrl = getImageAbsoluteURI({
|
||||
imageUrl: props.primaryLogo ?? defaultPrimaryLogoUrl,
|
||||
baseUrl: REACT_APP_SERVER_BASE_URL,
|
||||
});
|
||||
|
||||
const secondaryLogoUrl = isNonEmptyString(props.secondaryLogo)
|
||||
? getImageAbsoluteURI(props.secondaryLogo)
|
||||
? getImageAbsoluteURI({
|
||||
imageUrl: props.secondaryLogo,
|
||||
baseUrl: REACT_APP_SERVER_BASE_URL,
|
||||
})
|
||||
: null;
|
||||
|
||||
return (
|
||||
<StyledContainer>
|
||||
<StyledPrimaryLogo src={primaryLogoUrl} />
|
||||
<StyledPrimaryLogo src={primaryLogoUrl ?? ''} />
|
||||
{secondaryLogoUrl && (
|
||||
<StyledSecondaryLogoContainer>
|
||||
<StyledSecondaryLogo src={secondaryLogoUrl} />
|
||||
|
||||
Reference in New Issue
Block a user