* Fix front Co-authored-by: v1b3m <vibenjamin6@gmail.com> * Fix according to PR * Fix tests --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
70 lines
1.7 KiB
TypeScript
70 lines
1.7 KiB
TypeScript
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import { useDropdownButton } from '@/ui/dropdown/hooks/useDropdownButton';
|
|
import { ViewFieldMetadata } from '@/ui/editable-field/types/ViewField';
|
|
|
|
import { ColumnDefinition } from '../types/ColumnDefinition';
|
|
|
|
import { EntityTableHeaderOptions } from './EntityTableHeaderOptions';
|
|
|
|
type OwnProps = {
|
|
column: ColumnDefinition<ViewFieldMetadata>;
|
|
isFirstColumn: boolean;
|
|
isLastColumn: boolean;
|
|
};
|
|
|
|
const StyledTitle = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
flex-direction: row;
|
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
|
gap: ${({ theme }) => theme.spacing(1)};
|
|
height: ${({ theme }) => theme.spacing(8)};
|
|
padding-left: ${({ theme }) => theme.spacing(2)};
|
|
padding-right: ${({ theme }) => theme.spacing(2)};
|
|
`;
|
|
|
|
const StyledIcon = styled.div`
|
|
display: flex;
|
|
|
|
& > svg {
|
|
height: ${({ theme }) => theme.icon.size.md}px;
|
|
width: ${({ theme }) => theme.icon.size.md}px;
|
|
}
|
|
`;
|
|
|
|
const StyledText = styled.span`
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
`;
|
|
|
|
export const ColumnHead = ({
|
|
column,
|
|
isFirstColumn,
|
|
isLastColumn,
|
|
}: OwnProps) => {
|
|
const theme = useTheme();
|
|
|
|
const { openDropdownButton } = useDropdownButton({
|
|
dropdownId: column.key + '-header',
|
|
});
|
|
|
|
return (
|
|
<>
|
|
<StyledTitle onClick={openDropdownButton}>
|
|
<StyledIcon>
|
|
{column.Icon && <column.Icon size={theme.icon.size.md} />}
|
|
</StyledIcon>
|
|
<StyledText>{column.name}</StyledText>
|
|
</StyledTitle>
|
|
<EntityTableHeaderOptions
|
|
column={column}
|
|
isFirstColumn={isFirstColumn}
|
|
isLastColumn={isLastColumn}
|
|
/>
|
|
</>
|
|
);
|
|
};
|