Migrate to a monorepo structure (#2909)

This commit is contained in:
Charles Bochet
2023-12-10 18:10:54 +01:00
committed by GitHub
parent a70a9281eb
commit 5bdca9de6c
2304 changed files with 37152 additions and 25869 deletions

View File

@ -0,0 +1,18 @@
import styled from '@emotion/styled';
import { CommentChip, CommentChipProps } from './CommentChip';
type CellCommentChipProps = CommentChipProps;
// TODO: tie those fixed values to the other components in the cell
const StyledCellWrapper = styled.div``;
export const CellCommentChip = ({ count, onClick }: CellCommentChipProps) => {
if (count === 0) return null;
return (
<StyledCellWrapper>
<CommentChip count={count} onClick={onClick} />
</StyledCellWrapper>
);
};

View File

@ -0,0 +1,61 @@
import { useTheme } from '@emotion/react';
import styled from '@emotion/styled';
import { IconComment } from '@/ui/display/icon';
export type CommentChipProps = {
count: number;
onClick?: (event: React.MouseEvent<HTMLDivElement>) => void;
};
const StyledChip = styled.div`
align-items: center;
backdrop-filter: blur(6px);
background: ${({ theme }) => theme.background.transparent.primary};
border-radius: ${({ theme }) => theme.border.radius.md};
color: ${({ theme }) => theme.font.color.light};
cursor: pointer;
display: flex;
flex-direction: row;
gap: 4px;
height: 26px;
justify-content: center;
max-width: 42px;
padding-left: 4px;
padding-right: 4px;
&:hover {
background: ${({ theme }) => theme.background.tertiary};
color: ${({ theme }) => theme.font.color.tertiary};
}
user-select: none;
`;
const StyledCount = styled.div`
align-items: center;
display: flex;
font-size: ${({ theme }) => theme.font.size.sm};
font-weight: ${({ theme }) => theme.font.weight.medium};
justify-content: center;
`;
export const CommentChip = ({ count, onClick }: CommentChipProps) => {
const theme = useTheme();
if (count === 0) return null;
const formattedCount = count > 99 ? '99+' : count;
return (
<StyledChip data-testid="comment-chip" onClick={onClick}>
<StyledCount>{formattedCount}</StyledCount>
<IconComment size={theme.icon.size.md} />
</StyledChip>
);
};

View File

@ -0,0 +1,74 @@
import styled from '@emotion/styled';
import { Meta, StoryObj } from '@storybook/react';
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
import { CommentChip } from '../CommentChip';
const meta: Meta<typeof CommentChip> = {
title: 'Modules/Comments/CommentChip',
component: CommentChip,
decorators: [ComponentDecorator],
args: { count: 1 },
};
export default meta;
type Story = StoryObj<typeof CommentChip>;
const StyledTestCellContainer = styled.div`
align-items: center;
background: ${({ theme }) => theme.background.primary};
display: flex;
height: fit-content;
justify-content: space-between;
max-width: 250px;
min-width: 250px;
overflow: hidden;
text-wrap: nowrap;
`;
const StyledFakeCellText = styled.div`
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;
export const OneComment: Story = {};
export const TenComments: Story = {
args: { count: 10 },
};
export const TooManyComments: Story = {
args: { count: 1000 },
};
export const InCellDefault: Story = {
args: { count: 12 },
decorators: [
(Story) => (
<StyledTestCellContainer>
<StyledFakeCellText>Fake short text</StyledFakeCellText>
<Story />
</StyledTestCellContainer>
),
],
};
export const InCellOverlappingBlur: Story = {
...InCellDefault,
decorators: [
(Story) => (
<StyledTestCellContainer>
<StyledFakeCellText>
Fake long text to demonstrate ellipsis
</StyledFakeCellText>
<Story />
</StyledTestCellContainer>
),
],
};