diff --git a/front/src/components/comments/CellCommentChip.tsx b/front/src/components/comments/CellCommentChip.tsx new file mode 100644 index 000000000..7b85f675c --- /dev/null +++ b/front/src/components/comments/CellCommentChip.tsx @@ -0,0 +1,18 @@ +import styled from '@emotion/styled'; +import { CommentChip, CommentChipProps } from './CommentChip'; + +const StyledCellWrapper = styled.div` + position: relative; + right: 38px; + top: -14px; + width: 0; + height: 0; +`; + +export function CellCommentChip(props: CommentChipProps) { + return ( + + + + ); +} diff --git a/front/src/components/comments/CommentChip.tsx b/front/src/components/comments/CommentChip.tsx new file mode 100644 index 000000000..31f835e1e --- /dev/null +++ b/front/src/components/comments/CommentChip.tsx @@ -0,0 +1,57 @@ +import styled from '@emotion/styled'; +import { IconComment } from '../icons'; + +export type CommentChipProps = { + count: number; + onClick?: () => void; +}; + +const StyledChip = styled.div` + height: 26px; + min-width: 34px; + + padding-left: 2px; + padding-right: 2px; + + display: flex; + align-items: center; + justify-content: center; + flex-direction: row; + gap: 2px; + + background: ${(props) => props.theme.secondaryBackgroundTransparent}; + backdrop-filter: blur(6px); + + border-radius: ${(props) => props.theme.borderRadius}; + + cursor: pointer; + + color: ${(props) => props.theme.text30}; + + &:hover { + background: ${(props) => props.theme.tertiaryBackground}; + color: ${(props) => props.theme.text40}; + } + + user-select: none; +`; + +const StyledCount = styled.div` + display: flex; + align-items: center; + justify-content: center; + + font-size: 12px; + font-weight: 500; +`; + +export function CommentChip({ count, onClick }: CommentChipProps) { + const formattedCount = count > 99 ? '99+' : count; + + return ( + + {formattedCount} + + + ); +} diff --git a/front/src/components/comments/__stories__/CommentChip.stories.tsx b/front/src/components/comments/__stories__/CommentChip.stories.tsx new file mode 100644 index 000000000..c49b16064 --- /dev/null +++ b/front/src/components/comments/__stories__/CommentChip.stories.tsx @@ -0,0 +1,66 @@ +import type { Meta, StoryObj } from '@storybook/react'; +import { getRenderWrapperForComponent } from '../../../testing/renderWrappers'; +import { CellCommentChip } from '../CellCommentChip'; +import styled from '@emotion/styled'; +import { CellBaseContainer } from '../../editable-cell/CellBaseContainer'; +import { CommentChip } from '../CommentChip'; + +const meta: Meta = { + title: 'Components/CellCommentChip', + component: CellCommentChip, +}; + +export default meta; +type Story = StoryObj; + +const TestCellContainer = styled.div` + display: flex; + align-items: center; + justify-content: flex-end; + + min-width: 250px; + height: fit-content; + + background: ${(props) => props.theme.primaryBackground}; +`; + +const StyledFakeCellText = styled.div` + display: flex; + width: 100%; +`; + +export const OneComment: Story = { + render: getRenderWrapperForComponent(), +}; + +export const TenComments: Story = { + render: getRenderWrapperForComponent(), +}; + +export const TooManyComments: Story = { + render: getRenderWrapperForComponent(), +}; + +export const InCellDefault: Story = { + render: getRenderWrapperForComponent( + + + Fake short text + + + , + ), +}; + +export const InCellOverlappingBlur: Story = { + render: getRenderWrapperForComponent( + + + + Fake long text to demonstrate blur effect + + + + , + ), +}; diff --git a/front/src/components/icons/components/IconComment.tsx b/front/src/components/icons/components/IconComment.tsx new file mode 100644 index 000000000..ab6a866f1 --- /dev/null +++ b/front/src/components/icons/components/IconComment.tsx @@ -0,0 +1 @@ +export { IconMessageCircle as IconComment } from '@tabler/icons-react'; diff --git a/front/src/components/icons/index.ts b/front/src/components/icons/index.ts index c5c4dd207..96c4e70af 100644 --- a/front/src/components/icons/index.ts +++ b/front/src/components/icons/index.ts @@ -1,2 +1,3 @@ export { IconAward } from '@tabler/icons-react'; export { IconAddressBook } from './components/IconAddressBook'; +export { IconComment } from './components/IconComment'; diff --git a/front/src/layout/styles/themes.ts b/front/src/layout/styles/themes.ts index 5024885a8..34a456f3e 100644 --- a/front/src/layout/styles/themes.ts +++ b/front/src/layout/styles/themes.ts @@ -20,6 +20,8 @@ const commonTheme = { table: { horizontalCellMargin: '8px', }, + + borderRadius: '4px', }; const lightThemeSpecific = {