Feat/harmonize chips cell fields (#724)

* Wip

* Finished

* Fix lint
This commit is contained in:
Lucas Bordeau
2023-07-18 02:14:09 +02:00
committed by GitHub
parent 8b7314cd39
commit 5b21657c4e
21 changed files with 347 additions and 217 deletions

View File

@ -1,70 +1,21 @@
import { Link } from 'react-router-dom';
import { Theme } from '@emotion/react';
import styled from '@emotion/styled';
import { EntityChip } from '@/ui/chip/components/EntityChip';
import { Avatar } from '@/users/components/Avatar';
export type CompanyChipPropsType = {
type OwnProps = {
id: string;
name: string;
picture?: string;
clickable?: boolean;
};
const baseStyle = ({ theme }: { theme: Theme }) => `
align-items: center;
background-color: ${theme.background.tertiary};
border-radius: ${theme.spacing(1)};
color: ${theme.font.color.primary};
display: inline-flex;
gap: ${theme.spacing(1)};
height: calc(20px - 2 * ${theme.spacing(1)});
overflow: hidden;
padding: ${theme.spacing(1)};
text-decoration: none;
user-select: none;
:hover {
filter: brightness(95%);
}
img {
height: 14px;
object-fit: cover;
width: 14px;
}
`;
const StyledName = styled.span`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
const StyledContainerLink = styled(Link)`
${baseStyle}
`;
const StyledContainerNoLink = styled.div`
${baseStyle}
`;
export function CompanyChip({ id, name, picture }: CompanyChipPropsType) {
const ContainerComponent = id ? StyledContainerLink : StyledContainerNoLink;
export function CompanyChip({ id, name, picture, clickable }: OwnProps) {
return (
<ContainerComponent data-testid="company-chip" to={`/companies/${id}`}>
{picture && (
<Avatar
avatarUrl={picture?.toString()}
colorId={id}
placeholder={name}
type="squared"
size={14}
/>
)}
<StyledName>{name}</StyledName>
</ContainerComponent>
<EntityChip
entityId={id}
linkToEntity={`/companies/${id}`}
name={name}
avatarType="squared"
clickable={clickable}
picture={picture}
/>
);
}

View File

@ -29,10 +29,15 @@ export function CompanyEditableNameChipCell({ company }: OwnProps) {
<EditableCellChip
value={internalValue}
placeholder="Name"
picture={getLogoUrlFromDomainName(company.domainName)}
id={company.id}
changeHandler={setInternalValue}
ChipComponent={CompanyChip}
ChipComponent={
<CompanyChip
id={company.id}
name={company.name}
clickable
picture={getLogoUrlFromDomainName(company.domainName)}
/>
}
onSubmit={() =>
updateCompany({
variables: {