Chip untitled modification (#11498)
Fixes https://github.com/twentyhq/core-team-issues/issues/663
This commit is contained in:
@ -35,6 +35,10 @@ export type ChipProps = {
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const StyledDiv = withTheme(styled.div<{ theme: Theme }>`
|
||||
color: ${({ theme }) => theme.font.color.tertiary};
|
||||
`);
|
||||
|
||||
const StyledContainer = withTheme(styled.div<
|
||||
Pick<
|
||||
ChipProps,
|
||||
@ -147,8 +151,10 @@ export const Chip = ({
|
||||
maxWidth={maxWidth}
|
||||
>
|
||||
{leftComponent}
|
||||
{!isLabelHidden && (
|
||||
{!isLabelHidden && label.trim() ? (
|
||||
<OverflowingTextWithTooltip size={size} text={label} />
|
||||
) : (
|
||||
<StyledDiv>Untitled</StyledDiv>
|
||||
)}
|
||||
{rightComponent?.()}
|
||||
</StyledContainer>
|
||||
|
||||
@ -21,3 +21,9 @@ export default meta;
|
||||
type Story = StoryObj<typeof AvatarChip>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
export const Empty: Story = {
|
||||
args: {
|
||||
name: '',
|
||||
},
|
||||
};
|
||||
|
||||
@ -90,7 +90,10 @@ export const Avatar = ({
|
||||
})
|
||||
: null;
|
||||
|
||||
const placeholderChar = placeholder?.[0]?.toLocaleUpperCase();
|
||||
const placeholderFirstChar = placeholder?.trim()?.charAt(0);
|
||||
const isPlaceholderFirstCharEmpty =
|
||||
!placeholderFirstChar || placeholderFirstChar === '';
|
||||
const placeholderChar = placeholderFirstChar?.toUpperCase() || '-';
|
||||
|
||||
const showPlaceholder =
|
||||
isNull(avatarImageURI) || invalidAvatarUrls.includes(avatarImageURI);
|
||||
@ -101,10 +104,12 @@ export const Avatar = ({
|
||||
}
|
||||
};
|
||||
|
||||
const fixedColor =
|
||||
color ?? stringToHslColor(placeholderColorSeed ?? '', 75, 25);
|
||||
const fixedBackgroundColor =
|
||||
backgroundColor ?? stringToHslColor(placeholderColorSeed ?? '', 75, 85);
|
||||
const fixedColor = isPlaceholderFirstCharEmpty
|
||||
? theme.font.color.tertiary
|
||||
: (color ?? stringToHslColor(placeholderColorSeed ?? '', 75, 25));
|
||||
const fixedBackgroundColor = isPlaceholderFirstCharEmpty
|
||||
? theme.background.transparent.light
|
||||
: (backgroundColor ?? stringToHslColor(placeholderColorSeed ?? '', 75, 85));
|
||||
|
||||
const showBackgroundColor = showPlaceholder;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user