Skip to content

Commit 31fa708

Browse files
rmnpptRoman Popat
andauthored
feat: Enhance styling and layout of post card component for tighter spacing (#35)
Co-authored-by: Roman Popat <roman.popat@proton.me>
1 parent 120cec4 commit 31fa708

File tree

1 file changed

+53
-21
lines changed

1 file changed

+53
-21
lines changed

bs3/src/components/post-card.js

Lines changed: 53 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,26 @@ export default function BasicCard({ post, extended = false}) {
114114
minWidth: 275,
115115
maxHeight: extended ? 'none' : 275,
116116
my: 2,
117-
mx: 2,
117+
mx: 2,
118118
wordBreak: "break-word",
119119
border: post.userId === userId ? '1px solid' : 'none',
120120
borderColor: 'secondary.main' }}>
121-
<CardContent>
121+
<CardContent sx={{
122+
my: 0,
123+
mx: 0,
124+
padding: 1,
125+
paddingBottom: 0,
126+
margin: 0,
127+
marginBottom: 0,
128+
gutterBottom: 0,
129+
display: 'flex',
130+
flexDirection: 'column',
131+
justifyContent: 'space-between',
132+
height: '100%',
133+
width: '100%',
134+
overflow: 'hidden',
135+
textOverflow: 'ellipsis',
136+
}}>
122137
{post.userId === userId && extended && (
123138
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
124139
<IconButton onClick={handleEdit}>
@@ -155,38 +170,55 @@ export default function BasicCard({ post, extended = false}) {
155170
{timeAgo(post.timestamp)}
156171
</Typography>
157172
</Box>
158-
<Stack direction="row" alignItems="flex-start">
173+
<Stack direction="row" alignItems="flex-start" sx={{
174+
my: 0,
175+
mx: 0,
176+
padding: 1,
177+
paddingBottom: 0,
178+
}}>
159179
<CardActions sx={{ pl: 0, ml: 0}}>
160-
<Stack direction="column" alignItems="flex-start">
161-
<Button onClick={handleUpVote} disabled={!location.local}>
162-
<Stack direction="column">
180+
<Stack direction="column" alignItems="flex-start" spacing={0.5}>
181+
<Button
182+
onClick={handleUpVote}
183+
disabled={!location.local}
184+
sx={{ minWidth: 'auto', padding: '4px' }}
185+
>
186+
<Stack direction="column" spacing={0.5}>
163187
<Typography
164188
color={location.local ? "primary" : "disabled"}
165189
fontSize={11}
166-
textAlign={"center"}>
167-
{post.upVoted.length}
190+
textAlign={"center"}
191+
>
192+
{post.upVoted.length}
168193
</Typography>
169194
<ArrowCircleUpIcon
170-
color={thisPost.userUpVoted ? "primary" : "disabled"}>
171-
</ArrowCircleUpIcon>
195+
color={thisPost.userUpVoted ? "primary" : "disabled"}
196+
fontSize="small"
197+
/>
172198
</Stack>
173199
</Button>
174-
<Button onClick={handleDownVote} disabled={!location.local}>
175-
<Stack direction="column">
176-
<ArrowCircleDownIcon
177-
color={thisPost.userDownVoted ? "secondary" : "disabled"}>
178-
</ArrowCircleDownIcon>
179-
<Typography
180-
color={location.local ? "secondary" : "disabled"}
181-
fontSize={11}
182-
textAlign={"center"}>
200+
<Button
201+
onClick={handleDownVote}
202+
disabled={!location.local}
203+
sx={{ minWidth: 'auto', padding: '4px' }}
204+
>
205+
<Stack direction="column" spacing={0.5}>
206+
<ArrowCircleDownIcon
207+
color={thisPost.userDownVoted ? "secondary" : "disabled"}
208+
fontSize="small"
209+
/>
210+
<Typography
211+
color={location.local ? "secondary" : "disabled"}
212+
fontSize={11}
213+
textAlign={"center"}
214+
>
183215
{post.downVoted.length}
184-
</Typography>
216+
</Typography>
185217
</Stack>
186218
</Button>
187219
</Stack>
188220
</CardActions>
189-
<ConditionalLink condition={!extended} to={`p/${post.id}`}>
221+
<ConditionalLink condition={!extended} to={`p/${post.id}`} sx={{ width: '100%' }}>
190222
<CardActionArea>
191223
<Stack direction="row" spacing={1}>
192224
<Typography sx={{ fontSize: 14 }} color="text.secondary" gutterBottom>

0 commit comments

Comments
 (0)