Skip to content

Commit e12f795

Browse files
committed
feat: add comment or add post
1 parent 4174680 commit e12f795

File tree

27 files changed

+136
-58
lines changed

27 files changed

+136
-58
lines changed

apps/frontend/src/components/new-launch/add.post.button.tsx

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,45 @@
33
import { Button } from '@gitroom/react/form/button';
44
import React, { FC } from 'react';
55
import { useT } from '@gitroom/react/translation/get.transation.service.client';
6+
import { PostComment } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
67
export const AddPostButton: FC<{
78
onClick: () => void;
89
num: number;
10+
postComment: PostComment;
911
}> = (props) => {
1012
const { onClick, num } = props;
1113
const t = useT();
1214

1315
return (
14-
<Button
15-
onClick={onClick}
16-
className="!h-[24px] rounded-[3px] flex gap-[4px] w-[102px] text-[12px] font-[500]"
17-
>
18-
<div>
19-
<svg
20-
xmlns="http://www.w3.org/2000/svg"
21-
width="14"
22-
height="14"
23-
viewBox="0 0 14 14"
24-
fill="none"
25-
>
26-
<path
27-
d="M7 1.3125C5.87512 1.3125 4.7755 1.64607 3.8402 2.27102C2.90489 2.89597 2.17591 3.78423 1.74544 4.82349C1.31496 5.86274 1.20233 7.00631 1.42179 8.10958C1.64124 9.21284 2.18292 10.2263 2.97833 11.0217C3.77374 11.8171 4.78716 12.3588 5.89043 12.5782C6.99369 12.7977 8.13726 12.685 9.17651 12.2546C10.2158 11.8241 11.104 11.0951 11.729 10.1598C12.3539 9.2245 12.6875 8.12488 12.6875 7C12.6859 5.49207 12.0862 4.04636 11.0199 2.98009C9.95365 1.91382 8.50793 1.31409 7 1.3125ZM7 11.8125C6.04818 11.8125 5.11773 11.5303 4.32632 11.0014C3.53491 10.4726 2.91808 9.72103 2.55383 8.84166C2.18959 7.96229 2.09428 6.99466 2.27997 6.06113C2.46566 5.12759 2.92401 4.27009 3.59705 3.59705C4.27009 2.92401 5.1276 2.46566 6.06113 2.27997C6.99466 2.09428 7.9623 2.18958 8.84167 2.55383C9.72104 2.91808 10.4726 3.53491 11.0015 4.32632C11.5303 5.11773 11.8125 6.04818 11.8125 7C11.8111 8.27591 11.3036 9.49915 10.4014 10.4014C9.49915 11.3036 8.27591 11.8111 7 11.8125ZM9.625 7C9.625 7.11603 9.57891 7.22731 9.49686 7.30936C9.41481 7.39141 9.30353 7.4375 9.1875 7.4375H7.4375V9.1875C7.4375 9.30353 7.39141 9.41481 7.30936 9.49686C7.22731 9.57891 7.11603 9.625 7 9.625C6.88397 9.625 6.77269 9.57891 6.69064 9.49686C6.6086 9.41481 6.5625 9.30353 6.5625 9.1875V7.4375H4.8125C4.69647 7.4375 4.58519 7.39141 4.50314 7.30936C4.4211 7.22731 4.375 7.11603 4.375 7C4.375 6.88397 4.4211 6.77269 4.50314 6.69064C4.58519 6.60859 4.69647 6.5625 4.8125 6.5625H6.5625V4.8125C6.5625 4.69647 6.6086 4.58519 6.69064 4.50314C6.77269 4.42109 6.88397 4.375 7 4.375C7.11603 4.375 7.22731 4.42109 7.30936 4.50314C7.39141 4.58519 7.4375 4.69647 7.4375 4.8125V6.5625H9.1875C9.30353 6.5625 9.41481 6.60859 9.49686 6.69064C9.57891 6.77269 9.625 6.88397 9.625 7Z"
28-
fill="white"
29-
/>
30-
</svg>
31-
</div>
32-
<div className="!text-white">{t('add_comment', 'Add comment')}</div>
33-
</Button>
16+
<div>
17+
<Button
18+
onClick={onClick}
19+
className="!h-[24px] rounded-[3px] flex gap-[4px] text-[12px] font-[500]"
20+
>
21+
<div>
22+
<svg
23+
xmlns="http://www.w3.org/2000/svg"
24+
width="14"
25+
height="14"
26+
viewBox="0 0 14 14"
27+
fill="none"
28+
>
29+
<path
30+
d="M7 1.3125C5.87512 1.3125 4.7755 1.64607 3.8402 2.27102C2.90489 2.89597 2.17591 3.78423 1.74544 4.82349C1.31496 5.86274 1.20233 7.00631 1.42179 8.10958C1.64124 9.21284 2.18292 10.2263 2.97833 11.0217C3.77374 11.8171 4.78716 12.3588 5.89043 12.5782C6.99369 12.7977 8.13726 12.685 9.17651 12.2546C10.2158 11.8241 11.104 11.0951 11.729 10.1598C12.3539 9.2245 12.6875 8.12488 12.6875 7C12.6859 5.49207 12.0862 4.04636 11.0199 2.98009C9.95365 1.91382 8.50793 1.31409 7 1.3125ZM7 11.8125C6.04818 11.8125 5.11773 11.5303 4.32632 11.0014C3.53491 10.4726 2.91808 9.72103 2.55383 8.84166C2.18959 7.96229 2.09428 6.99466 2.27997 6.06113C2.46566 5.12759 2.92401 4.27009 3.59705 3.59705C4.27009 2.92401 5.1276 2.46566 6.06113 2.27997C6.99466 2.09428 7.9623 2.18958 8.84167 2.55383C9.72104 2.91808 10.4726 3.53491 11.0015 4.32632C11.5303 5.11773 11.8125 6.04818 11.8125 7C11.8111 8.27591 11.3036 9.49915 10.4014 10.4014C9.49915 11.3036 8.27591 11.8111 7 11.8125ZM9.625 7C9.625 7.11603 9.57891 7.22731 9.49686 7.30936C9.41481 7.39141 9.30353 7.4375 9.1875 7.4375H7.4375V9.1875C7.4375 9.30353 7.39141 9.41481 7.30936 9.49686C7.22731 9.57891 7.11603 9.625 7 9.625C6.88397 9.625 6.77269 9.57891 6.69064 9.49686C6.6086 9.41481 6.5625 9.30353 6.5625 9.1875V7.4375H4.8125C4.69647 7.4375 4.58519 7.39141 4.50314 7.30936C4.4211 7.22731 4.375 7.11603 4.375 7C4.375 6.88397 4.4211 6.77269 4.50314 6.69064C4.58519 6.60859 4.69647 6.5625 4.8125 6.5625H6.5625V4.8125C6.5625 4.69647 6.6086 4.58519 6.69064 4.50314C6.77269 4.42109 6.88397 4.375 7 4.375C7.11603 4.375 7.22731 4.42109 7.30936 4.50314C7.39141 4.58519 7.4375 4.69647 7.4375 4.8125V6.5625H9.1875C9.30353 6.5625 9.41481 6.60859 9.49686 6.69064C9.57891 6.77269 9.625 6.88397 9.625 7Z"
31+
fill="white"
32+
/>
33+
</svg>
34+
</div>
35+
<div className="!text-white">
36+
{t(
37+
...(props.postComment === PostComment.ALL
38+
? ['add_comment_or_post', 'Add comment or post']
39+
: props.postComment === PostComment.POST
40+
? ['add_post', 'Add post']
41+
: ['add_comment', 'Add comment'])
42+
)}
43+
</div>
44+
</Button>
45+
</div>
3446
);
3547
};

apps/frontend/src/components/new-launch/editor.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const EditorWrapper: FC<{
6363
setInternalValue,
6464
internalFromAll,
6565
totalChars,
66+
postComment,
6667
} = useLaunchStore(
6768
useShallow((state) => ({
6869
internal: state.internal.find((p) => p.integration.id === state.current),
@@ -86,6 +87,7 @@ export const EditorWrapper: FC<{
8687
totalChars: state.totalChars,
8788
appendInternalValueMedia: state.appendInternalValueMedia,
8889
appendGlobalValueMedia: state.appendGlobalValueMedia,
90+
postComment: state.postComment,
8991
}))
9092
);
9193

@@ -346,7 +348,13 @@ export const EditorWrapper: FC<{
346348
</div>
347349
</div>
348350

349-
{canEdit && <AddPostButton num={index} onClick={addValue(index)} />}
351+
{canEdit ? (
352+
<AddPostButton
353+
num={index}
354+
onClick={addValue(index)}
355+
postComment={postComment}
356+
/>
357+
) : <div className="h-[25px]" />}
350358
</div>
351359
));
352360
};
@@ -467,7 +475,6 @@ export const Editor: FC<{
467475
</div>
468476
</div>
469477
<div className="relative">
470-
{/*<ProgressBar id={`prog-${num}`} uppy={uppy} />*/}
471478
<div {...getRootProps()}>
472479
<div
473480
className={clsx(
@@ -544,16 +551,18 @@ export const Editor: FC<{
544551
/>
545552
)}
546553
</div>
547-
{(props?.totalChars || 0) > 0 && (
548-
<div
549-
className={clsx(
550-
'text-end text-sm mt-1',
551-
props?.value?.length > props.totalChars && '!text-red-500'
552-
)}
553-
>
554-
{props?.value?.length}/{props.totalChars}
555-
</div>
556-
)}
554+
<div className="absolute bottom-10px end-[25px]">
555+
{(props?.totalChars || 0) > 0 && (
556+
<div
557+
className={clsx(
558+
'text-end text-sm mt-1',
559+
props?.value?.length > props.totalChars && '!text-red-500'
560+
)}
561+
>
562+
{props?.value?.length}/{props.totalChars}
563+
</div>
564+
)}
565+
</div>
557566
</div>
558567
);
559568
};

apps/frontend/src/components/new-launch/providers/bluesky/bluesky.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
'use client';
22

3-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
3+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
44
import { ThreadFinisher } from '@gitroom/frontend/components/new-launch/finisher/thread.finisher';
55

66
const SettingsComponent = () => {
77
return <ThreadFinisher />;
88
};
99

1010
export default withProvider(
11+
PostComment.POST,
1112
SettingsComponent,
1213
undefined,
1314
undefined,

apps/frontend/src/components/new-launch/providers/devto/devto.provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { FC } from 'react';
4-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
4+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
55
import { DevToSettingsDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/dev.to.settings.dto';
66
import { Input } from '@gitroom/react/form/input';
77
import { MediaComponent } from '@gitroom/frontend/components/media/media.component';
@@ -83,4 +83,4 @@ const DevtoSettings: FC = () => {
8383
</>
8484
);
8585
};
86-
export default withProvider(DevtoSettings, DevtoPreview, DevToSettingsDto);
86+
export default withProvider(PostComment.COMMENT, DevtoSettings, DevtoPreview, DevToSettingsDto);

apps/frontend/src/components/new-launch/providers/discord/discord.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
3+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
44
import { FC } from 'react';
55
import { DiscordDto } from '@gitroom/nestjs-libraries/dtos/posts/providers-settings/discord.dto';
66
import { DiscordChannelSelect } from '@gitroom/frontend/components/new-launch/providers/discord/discord.channel.select';
@@ -14,6 +14,7 @@ const DiscordComponent: FC = () => {
1414
);
1515
};
1616
export default withProvider(
17+
PostComment.COMMENT,
1718
DiscordComponent,
1819
undefined,
1920
DiscordDto,

apps/frontend/src/components/new-launch/providers/dribbble/dribbble.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { FC } from 'react';
4-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
4+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
55
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
66
import { Input } from '@gitroom/react/form/input';
77
import { DribbbleTeams } from '@gitroom/frontend/components/new-launch/providers/dribbble/dribbble.teams';
@@ -16,6 +16,7 @@ const DribbbleSettings: FC = () => {
1616
);
1717
};
1818
export default withProvider(
19+
PostComment.COMMENT,
1920
DribbbleSettings,
2021
undefined,
2122
DribbbleDto,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
'use client';
22

3-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
4-
export default withProvider(null, undefined, undefined, undefined, 63206);
3+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
4+
export default withProvider(PostComment.COMMENT,null, undefined, undefined, undefined, 63206);

apps/frontend/src/components/new-launch/providers/hashnode/hashnode.provider.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client';
22

33
import { FC } from 'react';
4-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
4+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
55
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
66
import { Input } from '@gitroom/react/form/input';
77
import { HashnodePublications } from '@gitroom/frontend/components/new-launch/providers/hashnode/hashnode.publications';
@@ -86,6 +86,7 @@ const HashnodeSettings: FC = () => {
8686
);
8787
};
8888
export default withProvider(
89+
PostComment.COMMENT,
8990
HashnodeSettings,
9091
HashnodePreview,
9192
HashnodeSettingsDto

apps/frontend/src/components/new-launch/providers/high.order.provider.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ class Empty {
2727
empty: string;
2828
}
2929

30+
export enum PostComment {
31+
ALL,
32+
POST,
33+
COMMENT
34+
}
35+
3036
export const withProvider = function <T extends object>(
37+
postComment: PostComment,
3138
SettingsComponent: FC<{
3239
values?: any;
3340
}> | null,
@@ -63,6 +70,7 @@ export const withProvider = function <T extends object>(
6370
setTotalChars,
6471
justCurrent,
6572
allIntegrations,
73+
setPostComment,
6674
} = useLaunchStore(
6775
useShallow((state) => ({
6876
date: state.date,
@@ -77,6 +85,7 @@ export const withProvider = function <T extends object>(
7785
isGlobal: state.current === 'global',
7886
setCurrent: state.setCurrent,
7987
setTotalChars: state.setTotalChars,
88+
setPostComment: state.setPostComment,
8089
selectedIntegration: state.selectedIntegrations.find(
8190
(p) => p.integration.id === props.id
8291
),
@@ -89,10 +98,12 @@ export const withProvider = function <T extends object>(
8998
}
9099

91100
if (isGlobal) {
101+
setPostComment(PostComment.ALL);
92102
setTotalChars(0);
93103
}
94104

95105
if (current) {
106+
setPostComment(postComment);
96107
setTotalChars(
97108
typeof maximumCharacters === 'number'
98109
? maximumCharacters

apps/frontend/src/components/new-launch/providers/instagram/instagram.collaborators.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use client';
22

3-
import { withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
3+
import { PostComment, withProvider } from '@gitroom/frontend/components/new-launch/providers/high.order.provider';
44
import { FC } from 'react';
55
import { Select } from '@gitroom/react/form/select';
66
import { useSettings } from '@gitroom/frontend/components/launches/helpers/use.values';
@@ -51,6 +51,7 @@ const InstagramCollaborators: FC<{
5151
);
5252
};
5353
export default withProvider<InstagramDto>(
54+
PostComment.COMMENT,
5455
InstagramCollaborators,
5556
undefined,
5657
InstagramDto,

0 commit comments

Comments
 (0)