# Introduction closes https://github.com/twentyhq/core-team-issues/issues/591 Same than for `twenty-shared` made in https://github.com/twentyhq/twenty/pull/11083. ## TODO - [x] Manual migrate twenty-website twenty-ui imports ## What's next: - Generate barrel and migration script factorization within own package + tests - Refactoring using preconstruct ? TimeBox - Lint circular dependencies - Lint import from barrel and forbid them ### Preconstruct We need custom rollup plugins addition, but preconstruct does not expose its rollup configuration. It might be possible to handle this using the babel overrides. But was a big tunnel. We could give it a try afterwards ! ( allowing cjs interop and stuff like that ) Stuck to vite lib app Closed related PRs: - https://github.com/twentyhq/twenty/pull/11294 - https://github.com/twentyhq/twenty/pull/11203
110 lines
2.7 KiB
TypeScript
110 lines
2.7 KiB
TypeScript
import { useTheme } from '@emotion/react';
|
|
import styled from '@emotion/styled';
|
|
|
|
import { ReactNode } from 'react';
|
|
import { Card, CardContent } from 'twenty-ui/layout';
|
|
import { IconChevronRight } from 'twenty-ui/display';
|
|
import { Pill } from 'twenty-ui/components';
|
|
|
|
type SettingsCardProps = {
|
|
description?: string;
|
|
disabled?: boolean;
|
|
soon?: boolean;
|
|
Icon: ReactNode;
|
|
onClick?: () => void;
|
|
title: string;
|
|
className?: string;
|
|
Status?: ReactNode;
|
|
};
|
|
|
|
const StyledCard = styled(Card)<{
|
|
disabled?: boolean;
|
|
onClick?: () => void;
|
|
}>`
|
|
color: ${({ disabled, theme }) =>
|
|
disabled ? theme.font.color.extraLight : theme.font.color.tertiary};
|
|
cursor: ${({ disabled, onClick }) =>
|
|
disabled ? 'not-allowed' : onClick ? 'pointer' : 'default'};
|
|
width: 100%;
|
|
`;
|
|
|
|
const StyledCardContent = styled(CardContent)<object>`
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
padding: ${({ theme }) => theme.spacing(2, 2)};
|
|
|
|
&:hover {
|
|
background-color: ${({ theme }) => theme.background.quaternary};
|
|
cursor: pointer;
|
|
}
|
|
`;
|
|
|
|
const StyledHeader = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
`;
|
|
|
|
const StyledTitle = styled.div<{ disabled?: boolean }>`
|
|
color: ${({ disabled, theme }) =>
|
|
disabled ? 'inherit' : theme.font.color.secondary};
|
|
display: flex;
|
|
flex: 1 0 auto;
|
|
font-weight: ${({ theme }) => theme.font.weight.medium};
|
|
gap: ${({ theme }) => theme.spacing(2)};
|
|
justify-content: flex-start;
|
|
`;
|
|
|
|
const StyledIconChevronRight = styled(IconChevronRight)`
|
|
color: ${({ theme }) => theme.font.color.light};
|
|
`;
|
|
|
|
const StyledDescription = styled.div`
|
|
padding-bottom: ${({ theme }) => theme.spacing(2)};
|
|
padding-left: ${({ theme }) => theme.spacing(7)};
|
|
`;
|
|
|
|
const StyledIconContainer = styled.div`
|
|
align-items: center;
|
|
display: flex;
|
|
height: 24px;
|
|
justify-content: center;
|
|
width: 24px;
|
|
`;
|
|
|
|
export const SettingsCard = ({
|
|
description,
|
|
soon,
|
|
disabled = soon,
|
|
Icon,
|
|
onClick,
|
|
title,
|
|
className,
|
|
Status,
|
|
}: SettingsCardProps) => {
|
|
const theme = useTheme();
|
|
|
|
return (
|
|
<StyledCard
|
|
disabled={disabled}
|
|
onClick={disabled ? undefined : onClick}
|
|
className={className}
|
|
rounded={true}
|
|
>
|
|
<StyledCardContent>
|
|
<StyledHeader>
|
|
<StyledIconContainer>{Icon}</StyledIconContainer>
|
|
<StyledTitle disabled={disabled}>
|
|
{title}
|
|
{soon && <Pill label="Soon" />}
|
|
</StyledTitle>
|
|
{Status && Status}
|
|
<StyledIconChevronRight size={theme.icon.size.sm} />
|
|
</StyledHeader>
|
|
{description && <StyledDescription>{description}</StyledDescription>}
|
|
</StyledCardContent>
|
|
</StyledCard>
|
|
);
|
|
};
|