Chip right height according to view (#7976)

This commit is contained in:
nitin 2024-10-24 01:03:35 +05:30 committed by GitHub
parent d9429b1a83
commit a35d888c12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 15 additions and 7 deletions

View File

@ -30,6 +30,7 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil';
import { import {
AnimatedEaseInOut, AnimatedEaseInOut,
AvatarChipVariant, AvatarChipVariant,
ChipSize,
IconEye, IconEye,
IconEyeOff, IconEyeOff,
} from 'twenty-ui'; } from 'twenty-ui';
@ -295,6 +296,7 @@ export const RecordBoardCard = ({
objectNameSingular={objectMetadataItem.nameSingular} objectNameSingular={objectMetadataItem.nameSingular}
record={record as ObjectRecord} record={record as ObjectRecord}
variant={AvatarChipVariant.Transparent} variant={AvatarChipVariant.Transparent}
size={ChipSize.Large}
/> />
)} )}

View File

@ -1,6 +1,7 @@
import { RecordChip } from '@/object-record/components/RecordChip'; import { RecordChip } from '@/object-record/components/RecordChip';
import { useChipFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useChipFieldDisplay'; import { useChipFieldDisplay } from '@/object-record/record-field/meta-types/hooks/useChipFieldDisplay';
import { RecordIdentifierChip } from '@/object-record/record-index/components/RecordIndexRecordChip'; import { RecordIdentifierChip } from '@/object-record/record-index/components/RecordIndexRecordChip';
import { ChipSize } from 'twenty-ui';
export const ChipFieldDisplay = () => { export const ChipFieldDisplay = () => {
const { recordValue, objectNameSingular, isLabelIdentifier } = const { recordValue, objectNameSingular, isLabelIdentifier } =
@ -14,6 +15,7 @@ export const ChipFieldDisplay = () => {
<RecordIdentifierChip <RecordIdentifierChip
objectNameSingular={objectNameSingular} objectNameSingular={objectNameSingular}
record={recordValue} record={recordValue}
size={ChipSize.Small}
/> />
) : ( ) : (
<RecordChip objectNameSingular={objectNameSingular} record={recordValue} /> <RecordChip objectNameSingular={objectNameSingular} record={recordValue} />

View File

@ -3,18 +3,20 @@ import { useRecordChipData } from '@/object-record/hooks/useRecordChipData';
import { RecordIndexRootPropsContext } from '@/object-record/record-index/contexts/RecordIndexRootPropsContext'; import { RecordIndexRootPropsContext } from '@/object-record/record-index/contexts/RecordIndexRootPropsContext';
import { ObjectRecord } from '@/object-record/types/ObjectRecord'; import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { useContext } from 'react'; import { useContext } from 'react';
import { AvatarChip, AvatarChipVariant } from 'twenty-ui'; import { AvatarChip, AvatarChipVariant, ChipSize } from 'twenty-ui';
export type RecordIdentifierChipProps = { export type RecordIdentifierChipProps = {
objectNameSingular: string; objectNameSingular: string;
record: ObjectRecord; record: ObjectRecord;
variant?: AvatarChipVariant; variant?: AvatarChipVariant;
size?: ChipSize;
}; };
export const RecordIdentifierChip = ({ export const RecordIdentifierChip = ({
objectNameSingular, objectNameSingular,
record, record,
variant, variant,
size,
}: RecordIdentifierChipProps) => { }: RecordIdentifierChipProps) => {
const { onIndexIdentifierClick } = useContext(RecordIndexRootPropsContext); const { onIndexIdentifierClick } = useContext(RecordIndexRootPropsContext);
const { recordChipData } = useRecordChipData({ const { recordChipData } = useRecordChipData({
@ -38,6 +40,7 @@ export const RecordIdentifierChip = ({
variant={variant} variant={variant}
LeftIcon={LeftIcon} LeftIcon={LeftIcon}
LeftIconColor={LeftIconColor} LeftIconColor={LeftIconColor}
size={size}
/> />
); );
}; };

View File

@ -1,7 +1,7 @@
import { styled } from '@linaria/react'; import { styled } from '@linaria/react';
import { Avatar } from '@ui/display/avatar/components/Avatar'; import { Avatar } from '@ui/display/avatar/components/Avatar';
import { AvatarType } from '@ui/display/avatar/types/AvatarType'; import { AvatarType } from '@ui/display/avatar/types/AvatarType';
import { Chip, ChipVariant } from '@ui/display/chip/components/Chip'; import { Chip, ChipSize, ChipVariant } from '@ui/display/chip/components/Chip';
import { IconComponent } from '@ui/display/icon/types/IconComponent'; import { IconComponent } from '@ui/display/icon/types/IconComponent';
import { ThemeContext } from '@ui/theme'; import { ThemeContext } from '@ui/theme';
import { isDefined } from '@ui/utilities/isDefined'; import { isDefined } from '@ui/utilities/isDefined';
@ -13,6 +13,7 @@ export type AvatarChipProps = {
avatarUrl?: string; avatarUrl?: string;
avatarType?: Nullable<AvatarType>; avatarType?: Nullable<AvatarType>;
variant?: AvatarChipVariant; variant?: AvatarChipVariant;
size?: ChipSize;
LeftIcon?: IconComponent; LeftIcon?: IconComponent;
LeftIconColor?: string; LeftIconColor?: string;
isIconInverted?: boolean; isIconInverted?: boolean;
@ -47,6 +48,7 @@ export const AvatarChip = ({
className, className,
placeholderColorSeed, placeholderColorSeed,
onClick, onClick,
size = ChipSize.Small,
}: AvatarChipProps) => { }: AvatarChipProps) => {
const { theme } = useContext(ThemeContext); const { theme } = useContext(ThemeContext);
@ -60,6 +62,7 @@ export const AvatarChip = ({
: ChipVariant.Regular : ChipVariant.Regular
: ChipVariant.Transparent : ChipVariant.Transparent
} }
size={size}
leftComponent={ leftComponent={
isDefined(LeftIcon) ? ( isDefined(LeftIcon) ? (
isIconInverted === true ? ( isIconInverted === true ? (

View File

@ -66,7 +66,8 @@ const StyledContainer = withTheme(styled.div<
display: inline-flex; display: inline-flex;
justify-content: center; justify-content: center;
gap: ${({ theme }) => theme.spacing(1)}; gap: ${({ theme }) => theme.spacing(1)};
height: ${({ theme }) => theme.spacing(4)}; height: ${({ theme, size }) =>
size === ChipSize.Large ? theme.spacing(4) : theme.spacing(3)};
max-width: ${({ maxWidth }) => max-width: ${({ maxWidth }) =>
maxWidth maxWidth
? `calc(${maxWidth}px - 2 * var(--chip-horizontal-padding))` ? `calc(${maxWidth}px - 2 * var(--chip-horizontal-padding))`
@ -141,10 +142,7 @@ export const Chip = ({
className={className} className={className}
> >
{leftComponent} {leftComponent}
<OverflowingTextWithTooltip <OverflowingTextWithTooltip size={size} text={label} />
size={size === ChipSize.Large ? 'large' : 'small'}
text={label}
/>
{rightComponent} {rightComponent}
</StyledContainer> </StyledContainer>
); );