Skip to content

Commit b00d61f

Browse files
authored
fix: double truncating on comment section (#4437)
1 parent 15bb172 commit b00d61f

2 files changed

Lines changed: 93 additions & 11 deletions

File tree

packages/shared/src/components/comments/CommentContainer.tsx

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ import { VerifiedCompanyUserBadge } from '../VerifiedCompanyUserBadge';
2121
import { Separator } from '../cards/common/common';
2222
import { PlusUserBadge } from '../PlusUserBadge';
2323
import { ProfileImageSize } from '../ProfilePicture';
24-
import { Image } from '../image/Image';
2524
import { useHasAccessToCores } from '../../hooks/useCoresFeature';
25+
import { Image } from '../image/Image';
2626

2727
interface ClassName extends CommentClassName {
2828
content?: string;
@@ -124,7 +124,7 @@ export default function CommentContainer({
124124
{!!comment.author?.isPlus && (
125125
<PlusUserBadge user={comment.author} />
126126
)}
127-
<div className="flex items-center">
127+
<div className="flex min-w-0 shrink items-center">
128128
<ProfileLink href={comment.author.permalink}>
129129
<TruncateText
130130
className="text-text-tertiary typo-footnote"
@@ -133,6 +133,8 @@ export default function CommentContainer({
133133
@{comment.author.username}
134134
</TruncateText>
135135
</ProfileLink>
136+
</div>
137+
<div>
136138
<Separator className="!mx-0.5" />
137139
<CommentPublishDate comment={comment} />
138140
</div>
@@ -149,6 +151,15 @@ export default function CommentContainer({
149151
{comment.author.id === postScoutId && <UserBadge>Scout</UserBadge>}
150152
</FlexRow>
151153
</div>
154+
{hasAccessToCores && !!comment.award && (
155+
<div className="ml-2 flex size-7 items-center justify-center rounded-10 bg-surface-float">
156+
<Image
157+
src={comment.award.image}
158+
alt={comment.award.name}
159+
className="size-5 object-contain"
160+
/>
161+
</div>
162+
)}
152163
</header>
153164
<div
154165
className={classNames(
@@ -163,15 +174,6 @@ export default function CommentContainer({
163174
/>
164175
{actions}
165176
</div>
166-
{hasAccessToCores && !!comment.award && (
167-
<div className="absolute right-3 top-3 flex size-7 items-center justify-center rounded-10 bg-surface-float">
168-
<Image
169-
src={comment.award.image}
170-
alt={comment.award.name}
171-
className="size-8 object-contain"
172-
/>
173-
</div>
174-
)}
175177
</article>
176178
);
177179
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import type { Meta, StoryFn } from '@storybook/react';
2+
import CommentContainer, { CommentContainerProps } from '@dailydotdev/shared/src/components/comments/CommentContainer';
3+
import { action } from '@storybook/addon-actions';
4+
import { SourceType } from '@dailydotdev/shared/src/graphql/sources';
5+
import ExtensionProviders from '../../extension/_providers';
6+
7+
const meta: Meta<typeof CommentContainer> = {
8+
title: 'Components/Comments/CommentContainer',
9+
component: CommentContainer,
10+
argTypes: {
11+
className: { control: 'object' },
12+
children: { control: 'text' },
13+
linkToComment: { control: 'boolean' },
14+
showContextHeader: { control: 'boolean' },
15+
actions: { control: 'text' },
16+
onClick: { action: 'clicked' },
17+
},
18+
};
19+
20+
export default meta;
21+
22+
const Template: StoryFn<CommentContainerProps> = (args) => (
23+
<ExtensionProviders>
24+
<CommentContainer {...args} />
25+
</ExtensionProviders>
26+
);
27+
28+
export const Default = Template.bind({});
29+
Default.args = {
30+
post: {
31+
source: {
32+
id: 'source-1',
33+
name: 'Example Source',
34+
permalink: '/source/example',
35+
type: SourceType.Squad,
36+
active: true,
37+
public: true,
38+
membersCount: 100,
39+
description: 'An example squad',
40+
createdAt: new Date(),
41+
},
42+
title: 'Example Post Title',
43+
},
44+
comment: {
45+
id: '1',
46+
author: {
47+
id: 'author-1',
48+
username: 'exampleUser',
49+
name: 'Example User',
50+
image: '/path/to/image.jpg',
51+
permalink: '/user/exampleUser',
52+
isPlus: true,
53+
companies: [],
54+
coresRole: 3
55+
},
56+
award: {
57+
image: 'https://placehold.it/300x300',
58+
name: 'award name'
59+
},
60+
contentHtml: '<p>This is an example comment</p>',
61+
permalink: '/comment/1',
62+
parent: undefined,
63+
userState: { awarded: false, vote: 0 },
64+
createdAt: new Date().toISOString(),
65+
numUpvotes: 10,
66+
numAwards: 2,
67+
post: {
68+
title: 'Example Post Title',
69+
},
70+
},
71+
commentHash: 'hash-1',
72+
postAuthorId: 'author-1',
73+
postScoutId: 'scout-1',
74+
className: { container: 'example-class' },
75+
children: 'This is a child element',
76+
linkToComment: true,
77+
showContextHeader: true,
78+
actions: <button>Action</button>,
79+
onClick: action('Comment clicked'),
80+
};

0 commit comments

Comments
 (0)