Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chip right height according to view #7976

Merged
merged 4 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { useGetStandardObjectIcon } from '@/object-metadata/hooks/useGetStandardObjectIcon';
import { useRecordChipData } from '@/object-record/hooks/useRecordChipData';
import { RecordIndexRootPropsContext } from '@/object-record/record-index/contexts/RecordIndexRootPropsContext';
import { recordIndexViewTypeState } from '@/object-record/record-index/states/recordIndexViewTypeState';
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
import { ViewType } from '@/views/types/ViewType';
import { useContext } from 'react';
import { AvatarChip, AvatarChipVariant } from 'twenty-ui';
import { useRecoilValue } from 'recoil';
import { AvatarChip, AvatarChipVariant, ChipSize } from 'twenty-ui';

export type RecordIdentifierChipProps = {
objectNameSingular: string;
Expand All @@ -17,6 +20,7 @@ export const RecordIdentifierChip = ({
variant,
}: RecordIdentifierChipProps) => {
const { onIndexIdentifierClick } = useContext(RecordIndexRootPropsContext);
const recordIndexViewType = useRecoilValue(recordIndexViewTypeState);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It feels like it would be cleaner to pass introduce size in this component and pass the chip size from the level right above, similar what we probably do with variant no? Can't tell exactly why but it feels a bit odd here

const { recordChipData } = useRecordChipData({
objectNameSingular,
record,
Expand All @@ -38,6 +42,11 @@ export const RecordIdentifierChip = ({
variant={variant}
LeftIcon={LeftIcon}
LeftIconColor={LeftIconColor}
size={
recordIndexViewType === ViewType.Kanban
? ChipSize.Large
: ChipSize.Small
}
/>
);
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { styled } from '@linaria/react';
import { Avatar } from '@ui/display/avatar/components/Avatar';
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 { ThemeContext } from '@ui/theme';
import { isDefined } from '@ui/utilities/isDefined';
Expand All @@ -13,6 +13,7 @@ export type AvatarChipProps = {
avatarUrl?: string;
avatarType?: Nullable<AvatarType>;
variant?: AvatarChipVariant;
size?: ChipSize;
LeftIcon?: IconComponent;
LeftIconColor?: string;
isIconInverted?: boolean;
Expand Down Expand Up @@ -47,6 +48,7 @@ export const AvatarChip = ({
className,
placeholderColorSeed,
onClick,
size = ChipSize.Small,
}: AvatarChipProps) => {
const { theme } = useContext(ThemeContext);

Expand All @@ -60,6 +62,7 @@ export const AvatarChip = ({
: ChipVariant.Regular
: ChipVariant.Transparent
}
size={size}
leftComponent={
isDefined(LeftIcon) ? (
isIconInverted === true ? (
Expand Down
8 changes: 3 additions & 5 deletions packages/twenty-ui/src/display/chip/components/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ const StyledContainer = withTheme(styled.div<
display: inline-flex;
justify-content: center;
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 }) =>
maxWidth
? `calc(${maxWidth}px - 2 * var(--chip-horizontal-padding))`
Expand Down Expand Up @@ -141,10 +142,7 @@ export const Chip = ({
className={className}
>
{leftComponent}
<OverflowingTextWithTooltip
size={size === ChipSize.Large ? 'large' : 'small'}
text={label}
/>
<OverflowingTextWithTooltip size={size} text={label} />
{rightComponent}
</StyledContainer>
);
Expand Down
Loading