Skip to content

Commit 282987b

Browse files
authored
Merge pull request #83 from stamford-syntax-club/ana/card-fixes
Review Cards update
2 parents 7d7ae49 + 6026a98 commit 282987b

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

apps/web/components/ui/cards/course-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function CourseCard({
2727
{/* <Badge className="min-w-fit" color="blue">
2828
IT
2929
</Badge> */}
30-
<IconBook />
30+
<IconBook className="flex-shrink-0" />
3131

3232
<Text title={full_name} component="div" truncate="end">
3333
{full_name}

apps/web/components/ui/cards/my-review-card.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function MyReviewCard({ cardData }: { cardData: Review }): JSX.Element {
1414
<div className="col-span-12 sm:col-span-6 xl:col-span-4">
1515
<Card
1616
bg="dark.7"
17-
className="bg-transparent shadow-sm transition-colors duration-150 hover:border-gray-400"
17+
className="bg-transparent shadow-sm transition-colors duration-150 hover:border-gray-400 h-full "
1818
padding="md"
1919
radius="md"
2020
withBorder

apps/web/components/ui/review-card.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,22 @@ const getStatusColor = (status: string): string => {
3535
}
3636
};
3737

38+
//in case the desciption contian no space, to break long words
39+
const breakLongWords = (text: string, maxLength: number = 18): string => {
40+
return text
41+
.split(" ")
42+
.map((word) => {
43+
if (word.length > maxLength) {
44+
return word.match(new RegExp(".{1," + maxLength + "}", "g"))?.join(" ") ?? word;
45+
}
46+
return word;
47+
})
48+
.join(" ");
49+
};
50+
3851
export function ReviewCard({ review }: ReviewCardProps): JSX.Element {
52+
const formattedDescription = breakLongWords(review.description);
53+
3954
return (
4055
<Card radius="md" shadow="sm">
4156
<Flex direction="row" gap="lg" justify="center">
@@ -60,7 +75,7 @@ export function ReviewCard({ review }: ReviewCardProps): JSX.Element {
6075
</Text>
6176
<Spoiler maxHeight={75} showLabel="Show more" hideLabel="Hide">
6277
<TypographyStylesProvider mt="md">
63-
<ReactMarkdown>{review.description}</ReactMarkdown>
78+
<ReactMarkdown>{formattedDescription}</ReactMarkdown>
6479
</TypographyStylesProvider>
6580
</Spoiler>
6681
</Flex>
@@ -75,14 +90,16 @@ export function MyReviewCard({ review, onEditReview, onDeleteReview }: ReviewCar
7590
const [openedEdit, { open: openEdit, close: closeEdit }] = useDisclosure(false);
7691
const [openedDelete, { open: openDelete, close: closeDelete }] = useDisclosure(false);
7792

93+
const formattedDescription = breakLongWords(review.description);
94+
7895
return (
7996
<>
8097
<Card
8198
bg="gray.9"
8299
padding="md"
83100
radius="md"
84101
withBorder
85-
className={`border-${getStatusColor(review.status)}-500`}
102+
className={`border-${getStatusColor(review.status)}-500 break-words`}
86103
>
87104
<Flex direction="row" gap="md" justify="center">
88105
{/* user profile and badges */}
@@ -118,7 +135,7 @@ export function MyReviewCard({ review, onEditReview, onDeleteReview }: ReviewCar
118135
</Text>
119136
<Spoiler maxHeight={75} showLabel="Show more" hideLabel="Hide">
120137
<TypographyStylesProvider mt="sm">
121-
<ReactMarkdown>{review.description}</ReactMarkdown>
138+
<ReactMarkdown>{formattedDescription}</ReactMarkdown>
122139
</TypographyStylesProvider>
123140
</Spoiler>
124141
</Flex>

apps/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "web",
3-
"version": "1.2.0",
3+
"version": "1.2.1",
44
"private": true,
55
"scripts": {
66
"dev": "next dev --turbo",

0 commit comments

Comments
 (0)