diff options
author | PortableProgrammer <[email protected]> | 2025-01-14 17:10:26 +0000 |
---|---|---|
committer | PortableProgrammer <[email protected]> | 2025-01-14 17:10:26 +0000 |
commit | 24be4c6689e2d184147e53443ea79a7650835a9e (patch) | |
tree | c58bfa4222fa470a362afa22bd5fe50059917ecd /src | |
parent | 7bc78e3a51e862a86ba79465caada9093154fec8 (diff) |
More CSS cleanup and (hopefully) final tweaks.
* Further adjusted `--border-radius-*` vars to reduce egregious curvature.
* Adjusted `post-text` padding and max width in `card` view to reduce text overflow on smaller screens.
* Left `details` collapsed in `card` view when there is no media to preview.
* Corrected `.image-viewer` margins when `details` is collapsed in `card` view.
* Added `isPostMedia` function to `postUtils` to consolidate some `if` statements.
* Fixed links not showing in `card` view if there was no other media.
Diffstat (limited to 'src')
-rw-r--r-- | src/mixins/post.pug | 6 | ||||
-rw-r--r-- | src/mixins/postUtils.pug | 4 | ||||
-rw-r--r-- | src/public/styles.css | 41 |
3 files changed, 27 insertions, 24 deletions
diff --git a/src/mixins/post.pug b/src/mixins/post.pug index 472cab2..676b349 100644 --- a/src/mixins/post.pug +++ b/src/mixins/post.pug | |||
@@ -28,7 +28,7 @@ mixin post(p, currentUrl) | |||
28 | a(href=`/r/${p.subreddit}?sort=${sortQuery}&view=${viewQuery}`) r/#{p.subreddit} | 28 | a(href=`/r/${p.subreddit}?sort=${sortQuery}&view=${viewQuery}`) r/#{p.subreddit} |
29 | | · | 29 | | · |
30 | a(href=`/comments/${p.id}?from=${from}&sort=${sortQuery}&view=${viewQuery}`) #{fmtnum (p.num_comments)} ↩ | 30 | a(href=`/comments/${p.id}?from=${from}&sort=${sortQuery}&view=${viewQuery}`) #{fmtnum (p.num_comments)} ↩ |
31 | if (query.view == "card" && !isPostGallery(p) && !isPostImage(p) && !isPostVideo(p) && p.selftext_html) | 31 | if (query.view == "card" && !isPostMedia(p) && p.selftext_html) |
32 | div.self-text-overflow.card | 32 | div.self-text-overflow.card |
33 | if p.spoiler || p.over_18 | 33 | if p.spoiler || p.over_18 |
34 | div.spoiler(id=`spoiler_${p.id}`, onclick=`javascript:document.getElementById('spoiler_${p.id}').style.display = 'none';`) | 34 | div.spoiler(id=`spoiler_${p.id}`, onclick=`javascript:document.getElementById('spoiler_${p.id}').style.display = 'none';`) |
@@ -54,10 +54,10 @@ mixin post(p, currentUrl) | |||
54 | a(href=p.url) | 54 | a(href=p.url) |
55 | | ↗ | 55 | | ↗ |
56 | 56 | ||
57 | details(id=`${p.id}` open=(query.view == "card") class=`${query.view}`) | 57 | details(id=`${p.id}` open=(query.view == "card" && (isPostMedia(p) || isPostLink(p))) class=`${query.view}`) |
58 | summary.expand-post expand media | 58 | summary.expand-post expand media |
59 | div.image-viewer | 59 | div.image-viewer |
60 | if query.view == "card" && (p.spoiler || p.over_18) && (isPostGallery(p) || isPostImage(p) || isPostVideo(p)) | 60 | if query.view == "card" && (p.spoiler || p.over_18) && isPostMedia(p) |
61 | div.spoiler(id=`spoiler_${p.id}`, onclick=`javascript:document.getElementById('spoiler_${p.id}').style.display = 'none';`) | 61 | div.spoiler(id=`spoiler_${p.id}`, onclick=`javascript:document.getElementById('spoiler_${p.id}').style.display = 'none';`) |
62 | h2 | 62 | h2 |
63 | != p.over_18 ? 'nsfw' : 'spoiler' | 63 | != p.over_18 ? 'nsfw' : 'spoiler' |
diff --git a/src/mixins/postUtils.pug b/src/mixins/postUtils.pug index b96ff1e..7eef9b2 100644 --- a/src/mixins/postUtils.pug +++ b/src/mixins/postUtils.pug | |||
@@ -1,4 +1,8 @@ | |||
1 | - | 1 | - |
2 | function isPostMedia(p) { | ||
3 | return isPostImage(p) || isPostGallery(p) || isPostVideo(p); | ||
4 | } | ||
5 | - | ||
2 | function isPostGallery(p) { | 6 | function isPostGallery(p) { |
3 | return (p.is_gallery && p.is_gallery == true); | 7 | return (p.is_gallery && p.is_gallery == true); |
4 | } | 8 | } |
diff --git a/src/public/styles.css b/src/public/styles.css index 71ad878..580dbf9 100644 --- a/src/public/styles.css +++ b/src/public/styles.css | |||
@@ -11,9 +11,9 @@ | |||
11 | --link-visited-color: #999; | 11 | --link-visited-color: #999; |
12 | --accent: var(--link-color); | 12 | --accent: var(--link-color); |
13 | --error-text-color: red; | 13 | --error-text-color: red; |
14 | --border-radius-card: 4vmin; | 14 | --border-radius-card: 2vmin; |
15 | --border-radius-media: 3vmin; | 15 | --border-radius-media: 1.5vmin; |
16 | --border-radius-preview: 2vmin; | 16 | --border-radius-preview: 1vmin; |
17 | 17 | ||
18 | font-family: Inter, sans-serif; | 18 | font-family: Inter, sans-serif; |
19 | font-feature-settings: 'ss01' 1, 'kern' 1, 'liga' 1, 'cv05' 1, 'dlig' 1, 'ss01' 1, 'ss07' 1, 'ss08' 1; | 19 | font-feature-settings: 'ss01' 1, 'kern' 1, 'liga' 1, 'cv05' 1, 'dlig' 1, 'ss01' 1, 'ss07' 1, 'ss08' 1; |
@@ -174,7 +174,10 @@ nav { | |||
174 | 174 | ||
175 | .post-text.card { | 175 | .post-text.card { |
176 | padding: 0.9rem; | 176 | padding: 0.9rem; |
177 | padding-top: 0.3rem; | 177 | padding-top: 0.5rem; |
178 | padding-bottom: 0.5rem; | ||
179 | overflow-wrap: break-word; | ||
180 | max-width: 95%; | ||
178 | } | 181 | } |
179 | 182 | ||
180 | .self-text-overflow.card { | 183 | .self-text-overflow.card { |
@@ -185,6 +188,7 @@ nav { | |||
185 | overflow: hidden; | 188 | overflow: hidden; |
186 | overflow-wrap: break-word; | 189 | overflow-wrap: break-word; |
187 | display: block; | 190 | display: block; |
191 | max-width: 98%; | ||
188 | } | 192 | } |
189 | 193 | ||
190 | .self-text.card { | 194 | .self-text.card { |
@@ -200,11 +204,6 @@ nav { | |||
200 | .image-viewer { | 204 | .image-viewer { |
201 | position: relative; | 205 | position: relative; |
202 | margin: 0.9rem; | 206 | margin: 0.9rem; |
203 | margin-bottom: 0.3rem; | ||
204 | } | ||
205 | |||
206 | .image-viewer:not(:has(details)) { | ||
207 | margin: unset; | ||
208 | } | 207 | } |
209 | 208 | ||
210 | .image-viewer > img { | 209 | .image-viewer > img { |
@@ -314,6 +313,7 @@ summary::before { | |||
314 | .image-viewer a:has(img) { | 313 | .image-viewer a:has(img) { |
315 | font-size: 0rem; | 314 | font-size: 0rem; |
316 | padding: unset; | 315 | padding: unset; |
316 | margin: unset; | ||
317 | } | 317 | } |
318 | 318 | ||
319 | .media-preview a, | 319 | .media-preview a, |
@@ -363,7 +363,7 @@ form { | |||
363 | 363 | ||
364 | @media (min-width: 768px) { | 364 | @media (min-width: 768px) { |
365 | :root { | 365 | :root { |
366 | --border-radius-card: 2vmin; | 366 | --border-radius-card: 1vmin; |
367 | --border-radius-media: 1vmin; | 367 | --border-radius-media: 1vmin; |
368 | --border-radius-preview: 0.5vmin; | 368 | --border-radius-preview: 0.5vmin; |
369 | } | 369 | } |
@@ -387,9 +387,11 @@ form { | |||
387 | margin: 0.7rem; | 387 | margin: 0.7rem; |
388 | padding: initial; | 388 | padding: initial; |
389 | } | 389 | } |
390 | .self-text.card { | 390 | .post-text.card { |
391 | -webkit-line-clamp: 4; | 391 | max-width: 100%; |
392 | line-clamp: 4; | 392 | } |
393 | .self-text-overflow.card { | ||
394 | max-width: 100%; | ||
393 | } | 395 | } |
394 | .post-author { | 396 | .post-author { |
395 | display: inline | 397 | display: inline |
@@ -410,8 +412,9 @@ form { | |||
410 | 412 | ||
411 | @media (min-width: 1080px) { | 413 | @media (min-width: 1080px) { |
412 | :root { | 414 | :root { |
413 | --border-radius-card: 1vmin; | 415 | --border-radius-card: 0.5vmin; |
414 | --border-radius-media: 1vmin; | 416 | --border-radius-media: 0.5vmin; |
417 | --border-radius-preview: 0.3vmin; | ||
415 | } | 418 | } |
416 | .post, .comments-container, .hero, .header, .footer { | 419 | .post, .comments-container, .hero, .header, .footer { |
417 | flex: 1 1 60%; | 420 | flex: 1 1 60%; |
@@ -438,8 +441,8 @@ form { | |||
438 | padding: initial; | 441 | padding: initial; |
439 | } | 442 | } |
440 | .self-text.card { | 443 | .self-text.card { |
441 | -webkit-line-clamp: 6; | 444 | -webkit-line-clamp: 4; |
442 | line-clamp: 6; | 445 | line-clamp: 4; |
443 | } | 446 | } |
444 | .post-author { | 447 | .post-author { |
445 | display: inline | 448 | display: inline |
@@ -459,10 +462,6 @@ form { | |||
459 | } | 462 | } |
460 | 463 | ||
461 | @media (min-width: 2560px) { | 464 | @media (min-width: 2560px) { |
462 | :root { | ||
463 | --border-radius-card: 0.75vmin; | ||
464 | --border-radius-media: 0.75vmin; | ||
465 | } | ||
466 | .post, .comments-container, .hero, .header, .footer { | 465 | .post, .comments-container, .hero, .header, .footer { |
467 | flex: 1 1 40%; | 466 | flex: 1 1 40%; |
468 | width: 40%; | 467 | width: 40%; |