diff --git a/packages/berlin/src/App.tsx b/packages/berlin/src/App.tsx index f337c8c1..26f718a8 100644 --- a/packages/berlin/src/App.tsx +++ b/packages/berlin/src/App.tsx @@ -18,7 +18,7 @@ import Events from './pages/Events.tsx'; import Holding from './pages/Holding'; import Landing from './pages/Landing'; import Onboarding from './pages/Onboarding'; -import Option from './pages/Option.tsx'; +import Comments from './pages/Comments.tsx'; import PassportPopupRedirect from './pages/Popup'; import PublicGroupRegistration from './pages/PublicGroupRegistration.tsx'; import Register from './pages/Register'; @@ -215,7 +215,7 @@ const router = (queryClient: QueryClient) => }, { path: ':cycleId/options/:optionId', - Component: Option, + Component: Comments, }, ], }, diff --git a/packages/berlin/src/components/comment-card/CommentCard.styled.tsx b/packages/berlin/src/components/comment-card/CommentCard.styled.tsx index 94e994a6..e5f389c3 100644 --- a/packages/berlin/src/components/comment-card/CommentCard.styled.tsx +++ b/packages/berlin/src/components/comment-card/CommentCard.styled.tsx @@ -1,21 +1,31 @@ import styled from 'styled-components'; -import { FlexColumn } from '../containers/FlexColum.styled'; import { Body } from '../typography/Body.styled'; +import { Grid } from '../containers/Grid.styled'; -export const Card = styled(FlexColumn)` - border-radius: 1rem; - border: 1px solid var(--color-black); +export const Card = styled(Grid)` + align-items: flex-start; + border-bottom: 1px solid var(--color-black); overflow: hidden; - padding: 2rem; + padding: 1.5rem; width: 100%; - gap: 0.5rem; + grid-template-columns: minmax(200px, 600px) minmax(100px, 150px) 56px; + + @media (min-width: 600px) { + grid-template-columns: minmax(200px, 600px) minmax(100px, 150px) minmax(100px, 150px) 56px; + } `; -export const Username = styled(Body)` +export const Comment = styled(Body)``; + +export const Author = styled(Body)` font-weight: 600; `; export const FormattedDate = styled(Body)` color: #878787; + display: none; font-size: 14px; + @media (min-width: 600px) { + display: flex; + } `; diff --git a/packages/berlin/src/components/comment-card/CommentCard.tsx b/packages/berlin/src/components/comment-card/CommentCard.tsx index 56c03fb7..f8caaa61 100644 --- a/packages/berlin/src/components/comment-card/CommentCard.tsx +++ b/packages/berlin/src/components/comment-card/CommentCard.tsx @@ -13,14 +13,13 @@ import useUser from '../../hooks/useUser'; import { useAppStore } from '../../store'; // Components -import { Body } from '../typography/Body.styled'; import { FlexRow } from '../containers/FlexRow.styled'; import Button from '../button'; import Dialog from '../dialog'; import IconButton from '../icon-button'; // Styled Components -import { Card, FormattedDate, Username } from './CommentCard.styled'; +import { Author, Card, Comment, FormattedDate } from './CommentCard.styled'; type CommentCardProps = { comment: GetCommentsResponse[number]; @@ -102,30 +101,20 @@ function CommentCard({ comment }: CommentCardProps) { }; return ( - - - {comment.user?.username} - - } - title="Are you sure?" - description="This action cannot be undone. This will permanently delete your comment from our servers." - onActionClick={handleTrashClick} - actionButtonText="Delete comment" - /> + + + {comment.value} + @{comment.user?.username} {formattedDate} - {comment.value} - + - + {comment.user?.username === user?.username && ( + + } + title="Are you sure?" + description="This action cannot be undone. This will permanently delete your comment from our servers." + onActionClick={handleTrashClick} + actionButtonText="Delete comment" + /> + )} ); } diff --git a/packages/berlin/src/components/comments-columns/CommentsColumns.styled.tsx b/packages/berlin/src/components/comments-columns/CommentsColumns.styled.tsx new file mode 100644 index 00000000..bc12e7d7 --- /dev/null +++ b/packages/berlin/src/components/comments-columns/CommentsColumns.styled.tsx @@ -0,0 +1,30 @@ +import styled from 'styled-components'; +import { Grid } from '../containers/Grid.styled'; +import { Body } from '../typography/Body.styled'; + +export const Card = styled(Grid)` + border-bottom: 2px solid var(--color-black); + padding: 1.5rem; + grid-template-columns: minmax(200px, 600px) minmax(100px, 150px) 56px; + + @media (min-width: 600px) { + grid-template-columns: minmax(200px, 600px) minmax(100px, 150px) minmax(100px, 150px) 56px; + } +`; + +export const Comment = styled(Body)` + font-weight: bold; +`; + +export const Author = styled(Body)` + font-weight: bold; +`; +export const Date = styled(Body)` + font-weight: bold; + display: none; + @media (min-width: 600px) { + display: flex; + } +`; + +export const Likes = styled(Body)``; diff --git a/packages/berlin/src/components/comments-columns/CommentsColumns.tsx b/packages/berlin/src/components/comments-columns/CommentsColumns.tsx new file mode 100644 index 00000000..27a451c4 --- /dev/null +++ b/packages/berlin/src/components/comments-columns/CommentsColumns.tsx @@ -0,0 +1,14 @@ +import { Author, Card, Comment, Date, Likes } from './CommentsColumns.styled'; + +function CycleColumns() { + return ( + + Comment + Author + Date + Likes + + ); +} + +export default CycleColumns; diff --git a/packages/berlin/src/components/comments-columns/index.ts b/packages/berlin/src/components/comments-columns/index.ts new file mode 100644 index 00000000..26d6091a --- /dev/null +++ b/packages/berlin/src/components/comments-columns/index.ts @@ -0,0 +1 @@ +export { default } from './CommentsColumns'; diff --git a/packages/berlin/src/components/icon-button/IconButton.styled.tsx b/packages/berlin/src/components/icon-button/IconButton.styled.tsx index 15c040cd..c9b5eae1 100644 --- a/packages/berlin/src/components/icon-button/IconButton.styled.tsx +++ b/packages/berlin/src/components/icon-button/IconButton.styled.tsx @@ -1,8 +1,14 @@ -import styled from 'styled-components'; +import styled, { css } from 'styled-components'; -export const IconContainer = styled.div<{ $height: number; $width: number }>` +export const IconContainer = styled.div<{ $height: number; $width: number; $disabled: boolean }>` height: ${(props) => (props.$height && `${props.$height}px`) || '24px'}; width: ${(props) => (props.$width && `${props.$width}px`) || '24px'}; + + ${(props) => + props.$disabled && + css` + background-color: var(--color-white); + `} `; export const Icon = styled.img<{ $flipVertical?: boolean }>` diff --git a/packages/berlin/src/components/icon-button/IconButton.tsx b/packages/berlin/src/components/icon-button/IconButton.tsx index c70555a7..bb495e6a 100644 --- a/packages/berlin/src/components/icon-button/IconButton.tsx +++ b/packages/berlin/src/components/icon-button/IconButton.tsx @@ -26,7 +26,7 @@ const IconButton = React.forwardRef( disabled={disabled} {...props} > - + {option.user?.group?.name} - + {numOfVotes} - + {formattedPluralityScore} diff --git a/packages/berlin/src/pages/Option.tsx b/packages/berlin/src/pages/Comments.tsx similarity index 80% rename from packages/berlin/src/pages/Option.tsx rename to packages/berlin/src/pages/Comments.tsx index dc084c69..2a1cba26 100644 --- a/packages/berlin/src/pages/Option.tsx +++ b/packages/berlin/src/pages/Comments.tsx @@ -20,18 +20,19 @@ import { ResponseUserVotesType } from '../types/CycleType'; import { useAppStore } from '../store'; // Components +import { Bold } from '../components/typography/Bold.styled'; import { FlexColumn } from '../components/containers/FlexColum.styled'; import { FlexRow } from '../components/containers/FlexRow.styled'; import { Form } from '../components/containers/Form.styled'; -import { Title } from '../components/typography/Title.styled'; +import { Subtitle } from '../components/typography/Subtitle.styled'; import BackButton from '../components/back-button'; import Button from '../components/button'; import CommentCard from '../components/comment-card'; +import CommentsColumns from '../components/comments-columns'; import IconButton from '../components/icon-button'; import Textarea from '../components/textarea'; -import { Bold } from '../components/typography/Bold.styled'; -function Option() { +function Comments() { const theme = useAppStore((state) => state.theme); const queryClient = useQueryClient(); const { cycleId, optionId } = useParams(); @@ -140,32 +141,33 @@ function Option() { return ( - {option?.optionTitle} - - {localOptionHearts > 0 ? ( - Array.from({ length: localOptionHearts }).map((_, id) => ( - Full Heart - )) - ) : ( - Empty Heart - )} - - - handleUnvoteWrapper(option?.id ?? '')} - disabled={localOptionHearts === 0} - $padding={6} - $color="secondary" - icon={{ src: `/icons/unvote-${theme}.svg`, alt: 'Unvote icon' }} - /> - handleVoteWrapper(option?.id ?? '')} - disabled={availableHearts === 0} - $padding={6} - $color="primary" - icon={{ src: `/icons/vote-${theme}.svg`, alt: 'Vote icon' }} - /> + + + + handleVoteWrapper(option?.id ?? '')} + $width={16} + $height={16} + disabled={availableHearts === 0} + /> + handleUnvoteWrapper(option?.id ?? '')} + $width={16} + $height={16} + disabled={localOptionHearts === 0} + /> + + {localOptionHearts} + + {option?.optionTitle} + @@ -180,7 +182,7 @@ function Option() { {sortedComments.length > 0 && ( <> - Total comments ({sortedComments.length}) + Total comments ({sortedComments.length})
Sort
- {sortedComments.map((comment) => ( - - ))} + + + {sortedComments.map((comment) => ( + + ))} + )}
); } -export default Option; +export default Comments;