From 4b7e3990a762deefc9be734f8e1fe3fdd93f36a4 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sun, 7 Jul 2024 23:40:44 -0400 Subject: [PATCH 01/12] feat: add styles for author avatar --- src/components/Avatar/styles.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/components/Avatar/styles.css b/src/components/Avatar/styles.css index ac8e9f3..36188be 100644 --- a/src/components/Avatar/styles.css +++ b/src/components/Avatar/styles.css @@ -1,12 +1,15 @@ .user-avatar { - --image-size: var(--avatar-size); + --image-size: var(--size-13); display: block; width: var(--image-size); height: var(--image-size); - border-radius: 100vmax; + aspect-ratio: var(--ratio-square); + border-radius: var(--radius-round); overflow: hidden; + border: solid var(--tjs-red-6) var(--size-2); + box-shadow: var(--size-1) var(--size-1) var(--gray-12); } .user-avatar img { @@ -17,5 +20,5 @@ } @media (max-width: 768px) { - .user-avatar { --image-size: var(--avatar-small-size); } + .user-avatar { --image-size: var(--size-12); } } From 4a76960b6ffd017e7e6cdf9034ef70a2cefa3946 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sun, 7 Jul 2024 23:53:18 -0400 Subject: [PATCH 02/12] fix: resolve css side effects --- src/components/SiteFooter/styles.css | 2 +- src/components/SiteNav/styles.css | 27 +++++++-------------------- src/layouts/Base/base.css | 5 ++++- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/src/components/SiteFooter/styles.css b/src/components/SiteFooter/styles.css index d06f73d..8254e8d 100644 --- a/src/components/SiteFooter/styles.css +++ b/src/components/SiteFooter/styles.css @@ -1,4 +1,4 @@ -ul { +#bottom-nav ul { display: flex; gap: 0.5rem; justify-content: center; diff --git a/src/components/SiteNav/styles.css b/src/components/SiteNav/styles.css index 25c7867..e0fe2d6 100644 --- a/src/components/SiteNav/styles.css +++ b/src/components/SiteNav/styles.css @@ -1,25 +1,12 @@ -nav { - padding: .5rem; - --tw-bg-opacity: 1; - background-color: rgb(19 17 11 / var(--tw-bg-opacity)); +#site-nav { + padding: var(--size-2); + background-color: rgb(19 17 11); font-weight: bold; - --tw-text-opacity: 1; - color: rgb(255 255 255 / var(--tw-text-opacity)) - -} - -ul { - display: flex; - gap: 0.5rem; - justify-content: center; - align-items: center; - padding: 0.75rem; + color: white; } -a { - display: inline-flex; +#site-nav ul { + gap: var(--size-2); align-items: center; - gap: 1rem; - overflow-wrap: break-word; - margin-left: 0.75rem + padding: var(--size-3); } diff --git a/src/layouts/Base/base.css b/src/layouts/Base/base.css index cc8a7d4..7801c2f 100644 --- a/src/layouts/Base/base.css +++ b/src/layouts/Base/base.css @@ -53,5 +53,8 @@ iframe { width: 100%; height: auto; max-height: 100%; - aspect-ratio: 3 / 2; +} + +a { + overflow-wrap: break-word; } From c958dabb861204ad84a0aaa0038c82f7490fdefd Mon Sep 17 00:00:00 2001 From: madcampos Date: Sun, 7 Jul 2024 23:53:40 -0400 Subject: [PATCH 03/12] fix: update aspect ratio to reference open props --- src/layouts/Base/base.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/layouts/Base/base.css b/src/layouts/Base/base.css index 7801c2f..1d3abf6 100644 --- a/src/layouts/Base/base.css +++ b/src/layouts/Base/base.css @@ -53,6 +53,7 @@ iframe { width: 100%; height: auto; max-height: 100%; + aspect-ratio: var(--ratio-landscape); } a { From a974a15029f8616e6875acccd559fad0c5c3ce05 Mon Sep 17 00:00:00 2001 From: madcampos Date: Sun, 7 Jul 2024 23:56:36 -0400 Subject: [PATCH 04/12] feat: implement styles for author card --- src/components/AuthorCard/styles.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/AuthorCard/styles.css b/src/components/AuthorCard/styles.css index 90244e8..d29f704 100644 --- a/src/components/AuthorCard/styles.css +++ b/src/components/AuthorCard/styles.css @@ -1,17 +1,21 @@ .author-card { display: grid; - padding-inline: var(--spacing-large); + padding-inline: var(--size-3); grid-template-columns: 1fr auto; grid-template-rows: 1fr auto; - gap: var(--spacing-large); + gap: var(--size-3); place-items: center; grid-template-areas: "avatar name" "avatar bio"; - margin: var(--spacing-large) 0; + margin: var(--size-3) 0; } -.author-card .author-name * { margin: 0; } +.author-card .author-name * { + margin: 0; + color: var(--tjs-red-6); + text-shadow: var(--size-1) var(--size-1) var(--gray-12); +} .author-card .author-picture { grid-area: avatar; From f0dfa24895c896320c543521be2866989a0ff090 Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 00:56:38 -0400 Subject: [PATCH 05/12] feat: implement styles for post header --- src/components/PostHeader/index.astro | 36 +++++++------ src/components/PostHeader/styles.css | 73 ++++++++++++++------------- src/layouts/Base/variables.css | 3 ++ 3 files changed, 62 insertions(+), 50 deletions(-) diff --git a/src/components/PostHeader/index.astro b/src/components/PostHeader/index.astro index 0ca0eef..a8c35ee 100644 --- a/src/components/PostHeader/index.astro +++ b/src/components/PostHeader/index.astro @@ -53,32 +53,36 @@ const formatter = new Intl.DateTimeFormat('en-US', { dateStyle: 'long', timeStyl diff --git a/src/components/PostHeader/styles.css b/src/components/PostHeader/styles.css index e9860aa..6da119d 100644 --- a/src/components/PostHeader/styles.css +++ b/src/components/PostHeader/styles.css @@ -8,23 +8,11 @@ justify-self: stretch; display: grid; place-items: end center; - gap: var(--spacing-large); + gap: var(--size-3); grid-template-rows: 1fr auto auto auto; - grid-template-columns: 1fr 1fr; + grid-template-columns: 100%; grid-template-areas: - 'title hero-image' - 'summary hero-image' - 'metadata metadata' - 'share share'; - padding: var(--spacing-large); - margin: var(--spacing-large); -} - -#post-header-wrapper:not(:has(#hero-image)) { - grid-template-rows: 1fr auto auto auto; - grid-template-columns: 1fr; - grid-template-areas: - 'title' + 'hero-title' 'summary' 'metadata' 'share'; @@ -32,7 +20,7 @@ #post-header h1 { height: auto; - font-size: clamp(2rem, 5vmax, 4rem); + font-size: var(--font-size-fluid-3); font-weight: bold; overflow-wrap: break-word; @@ -53,13 +41,27 @@ padding: 0; } -#post-header #post-title { grid-area: title; } +#post-header #post-title { + grid-area: hero-title; + z-index: 1; + place-self: end end; + + background-color: white; + color: var(--tjs-red-6); + text-decoration-color: currentcolor; + padding: var(--size-3) var(--size-4); + border-start-start-radius: var(--radius-4); + border-end-start-radius: var(--radius-4); + border: var(--tjs-red-6) solid var(--size-2); + border-inline-end: none; + margin-block-end: var(--size-7); +} #post-header #hero-image { width: 100%; height: 100%; object-fit: contain; - grid-area: hero-image; + grid-area: hero-title; overflow: hidden; } @@ -67,7 +69,8 @@ border: none; font-size: smaller; margin: 0; - padding: var(--spacing-large); + padding: var(--size-1); + font-style: italic; grid-area: summary; } @@ -76,17 +79,8 @@ } #post-metadata { - width: 100%; grid-area: metadata; text-align: center; - display: flex; - flex-flow: column wrap; - justify-content: center; - gap: var(--spacing-medium); -} - -#post-metadata a { - vertical-align: middle; } #post-share { @@ -95,28 +89,28 @@ flex-wrap: wrap; justify-content: center; align-items: center; - gap: var(--spacing-large); + gap: var(--size-3); } #post-share button { display: flex; align-items: center; justify-content: center; - width: var(--button-size); - height: var(--button-size); - padding: var(--spacing-medium); + height: var(--size-7); + padding: var(--size-1) var(--size-2); } #post-share button svg { - width: 100%; height: 100%; + aspect-ratio: var(--ratio-square); pointer-events: none; } + @media (max-width: 650px) { #post-header-wrapper { grid-template-rows: 1fr auto auto auto auto; - grid-template-columns: 1fr; + grid-template-columns: 100%; grid-template-areas: 'hero-image' 'title' @@ -124,4 +118,15 @@ 'metadata' 'share'; } + + #post-header #post-title { + grid-area: title; + margin-block: calc(var(--size-3) * -1) 0; + border-inline: none; + border-radius: 0; + } + + #post-header #hero-image { + grid-area: hero-image; + } } diff --git a/src/layouts/Base/variables.css b/src/layouts/Base/variables.css index a005776..f2c58b4 100644 --- a/src/layouts/Base/variables.css +++ b/src/layouts/Base/variables.css @@ -2,6 +2,9 @@ /* Base size */ --body-text: 20px; + /* Max width for part of the page to grow */ + --max-width: 1024px; + /* Theme colors */ --tjs-red-0: #fec2b8; --tjs-red-1: #ffad9e; From 2ddae6d33a164012a6557ca2bdc57ddf6bbc24a5 Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:13:42 -0400 Subject: [PATCH 06/12] feat: add style for posts without images --- src/components/PostHeader/styles.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/PostHeader/styles.css b/src/components/PostHeader/styles.css index 6da119d..a52d053 100644 --- a/src/components/PostHeader/styles.css +++ b/src/components/PostHeader/styles.css @@ -2,6 +2,7 @@ width: 100%; max-width: var(--max-width); margin-inline: auto; + margin-block-end: var(--size-8); } #post-header-wrapper { @@ -57,6 +58,13 @@ margin-block-end: var(--size-7); } +#post-header-wrapper:not(:has(#hero-image)) #post-title { + margin-block: 0; + border-inline: none; + border-radius: 0; + width: 100%; +} + #post-header #hero-image { width: 100%; height: 100%; From 7380e38a63ce5ab3bddb3055846e28db5ed618fb Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:13:53 -0400 Subject: [PATCH 07/12] feat: add styles for refresh banner --- src/components/RefreshBanner/index.astro | 9 ++--- src/components/RefreshBanner/script.ts | 42 ++++++++++++++++++++---- src/components/RefreshBanner/styles.css | 21 ++++++------ 3 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/components/RefreshBanner/index.astro b/src/components/RefreshBanner/index.astro index d55a2fc..9ab1bde 100644 --- a/src/components/RefreshBanner/index.astro +++ b/src/components/RefreshBanner/index.astro @@ -9,14 +9,15 @@ import './styles.css'; id="pwa-toast" role="alert" aria-labelledby="toast-message" + aria-live="polite" >
- - diff --git a/src/components/RefreshBanner/script.ts b/src/components/RefreshBanner/script.ts index 482ad5c..5599d7b 100644 --- a/src/components/RefreshBanner/script.ts +++ b/src/components/RefreshBanner/script.ts @@ -1,18 +1,32 @@ import { registerSW } from 'virtual:pwa-register'; -window.addEventListener('DOMContentLoaded', () => { +const params = new URLSearchParams(document.location.search.substring(1)); + +function setPwaMessage(type: 'offline' | 'refresh') { const pwaToast = document.querySelector('#pwa-toast') as HTMLDivElement; const pwaToastMessage = pwaToast.querySelector('#toast-message') as HTMLDivElement; + switch (type) { + case 'refresh': + pwaToastMessage.innerHTML = 'New content available, click on reload button to update.'; + pwaToast.dataset['refresh'] = 'true'; + break; + case 'offline': + pwaToastMessage.innerHTML = 'App ready to work offline.'; + pwaToast.dataset['offline'] = 'true'; + break; + default: + } +} + +window.addEventListener('DOMContentLoaded', () => { const refreshSW = registerSW({ immediate: true, onOfflineReady() { - pwaToastMessage.innerHTML = 'Blog ready to work offline.'; - pwaToast.dataset['offline'] = 'true'; + setPwaMessage('offline'); }, onNeedRefresh() { - pwaToastMessage.innerHTML = 'New content available, click on reload button to update.'; - pwaToast.dataset['refresh'] = 'true'; + setPwaMessage('refresh'); }, onRegisteredSW(swScriptUrl) { // eslint-disable-next-line no-console @@ -26,14 +40,30 @@ window.addEventListener('DOMContentLoaded', () => { if (target.matches('#pwa-close')) { requestAnimationFrame(() => { document.body.removeEventListener('click', pwaEventListener); - pwaToast.remove(); + document.querySelector('#pwa-toast')?.remove(); + + params.delete('debug'); + + if (params.size > 0) { + document.location.search = params.toString(); + } }); } if (target.matches('#pwa-refresh')) { + params.delete('debug'); + + if (params.size > 0) { + document.location.search = params.toString(); + } + requestAnimationFrame(async () => refreshSW(true)); } }; + if (params.get('debug')?.startsWith('pwa-')) { + setPwaMessage((params.get('debug')?.replace('pwa-', '') ?? '') as 'offline' | 'refresh'); + } + document.body.addEventListener('click', pwaEventListener); }); diff --git a/src/components/RefreshBanner/styles.css b/src/components/RefreshBanner/styles.css index 60ab7c0..1407e1c 100644 --- a/src/components/RefreshBanner/styles.css +++ b/src/components/RefreshBanner/styles.css @@ -2,17 +2,20 @@ visibility: hidden; position: fixed; display: flex; - gap: var(--spacing-medium); + gap: var(--size-2); align-items: center; justify-content: space-between; - width: clamp(var(--min-width), 100%, var(--medium-width)); + width: clamp(320px, (100% - var(--size-2) * 2), var(--max-width)); inset-inline: 0; - inset-block-end: var(--spacing-small); - margin-inline: auto; - padding: var(--spacing-medium) var(--spacing-large); + inset-block-end: 0; + margin: var(--size-2); + padding: var(--size-2) var(--size-3); + border-radius: var(--radius-3); - z-index: 1; + background-color: var(--gray-12); + + z-index: calc(1 * infinity); } #pwa-toast:is([data-offline], [data-refresh]) { @@ -27,15 +30,13 @@ #pwa-toast button { display: none; place-items: center; - padding: var(--spacing-small); - width: var(--button-size); - height: var(--button-size); - cursor: pointer; + padding: var(--size-1); } #pwa-toast button svg { width: 100%; height: 100%; + aspect-ratio: var(--ratio-square); pointer-events: none; } From 5a0c986ef517c1d6e0590e79d04a23a7af8fe6a8 Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:17:41 -0400 Subject: [PATCH 08/12] feat: implement skip to content style --- src/components/SkipToContent/styles.css | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/SkipToContent/styles.css b/src/components/SkipToContent/styles.css index 1ef6228..0c1cb6c 100644 --- a/src/components/SkipToContent/styles.css +++ b/src/components/SkipToContent/styles.css @@ -1,18 +1,22 @@ #skip-to-main { position: absolute; - inset-inline: var(--spacing-medium); + inset-inline: var(--size-3); inset-block-start: -100%; text-align: center; - padding: var(--spacing-medium); + padding: var(--size-3); z-index: calc(infinity * 1); display: block; + background-color: var(--gray-0); + color: var(--gray-12); + font-size: var(--font-size-3); + font-weight: bold; } #skip-to-main:focus { - inset-block-start: var(--spacing-medium); + inset-block-start: var(--size-3); } :target { scroll-snap-align: start; - scroll-margin: var(--spacing-large); + scroll-margin: var(--size-5); } From 9e11820a21bbfa7b13816d57eaa02f6d06236fac Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:25:23 -0400 Subject: [PATCH 09/12] feat: implement tag list styles --- src/components/TagList/index.astro | 6 ++++-- src/components/TagList/styles.css | 11 +++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 src/components/TagList/styles.css diff --git a/src/components/TagList/index.astro b/src/components/TagList/index.astro index 8f663e6..41f19d9 100644 --- a/src/components/TagList/index.astro +++ b/src/components/TagList/index.astro @@ -1,4 +1,6 @@ --- +import './styles.css'; + interface Props { title?: string, tags: Record, @@ -9,9 +11,9 @@ const { title, tags, isOpen } = Astro.props; ---
{title ?? 'Tags'} -
    +
      {Object.entries(tags).map(([tag, url]) => ( -
    • {tag}
    • +
    • {tag}
    • ))}
diff --git a/src/components/TagList/styles.css b/src/components/TagList/styles.css new file mode 100644 index 0000000..c5ba187 --- /dev/null +++ b/src/components/TagList/styles.css @@ -0,0 +1,11 @@ +.tag-list, .tag-list summary { + background: none; +} + +.tag-list ul { + display: flex; + margin: 0; + padding-inline-start: 0; + list-style: none; + gap: var(--size-2); +} From 87f01497dceb00562745065958351281fa843155 Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:28:51 -0400 Subject: [PATCH 10/12] fix: resolve weird positioning on author card --- src/components/AuthorCard/styles.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/AuthorCard/styles.css b/src/components/AuthorCard/styles.css index d29f704..6c8b1a3 100644 --- a/src/components/AuthorCard/styles.css +++ b/src/components/AuthorCard/styles.css @@ -1,8 +1,8 @@ .author-card { display: grid; padding-inline: var(--size-3); - grid-template-columns: 1fr auto; - grid-template-rows: 1fr auto; + grid-template-columns: auto 1fr; + grid-template-rows: auto 1fr; gap: var(--size-3); place-items: center; grid-template-areas: From ca198e2a2f649ed935f2e3098ebb3dfce74f7661 Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:34:40 -0400 Subject: [PATCH 11/12] fix: resolve display issues with author card --- src/components/AuthorCard/index.astro | 6 ++---- src/components/AuthorCard/styles.css | 7 ++++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/components/AuthorCard/index.astro b/src/components/AuthorCard/index.astro index a6927c4..b58f9f0 100644 --- a/src/components/AuthorCard/index.astro +++ b/src/components/AuthorCard/index.astro @@ -28,9 +28,7 @@ const description = await parseMarkdown(body);
- - {/* eslint-disable-next-line astro/no-set-html-directive */} - - + {/* eslint-disable-next-line astro/no-set-html-directive */} +
diff --git a/src/components/AuthorCard/styles.css b/src/components/AuthorCard/styles.css index 6c8b1a3..1a4a01b 100644 --- a/src/components/AuthorCard/styles.css +++ b/src/components/AuthorCard/styles.css @@ -26,7 +26,12 @@ grid-area: name; justify-self: start; } -.author-card .author-bio { grid-area: bio; } + +.author-card .author-bio { + grid-area: bio; + width: 100%; + place-self: start start; +} @media (max-width: 768px) { .author-card { From a200694077fca588b78d44c02fa892569654269f Mon Sep 17 00:00:00 2001 From: madcampos Date: Mon, 8 Jul 2024 01:44:44 -0400 Subject: [PATCH 12/12] fix: readd border for post header if it is too big --- src/components/PostHeader/styles.css | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/components/PostHeader/styles.css b/src/components/PostHeader/styles.css index a52d053..bc9b6d2 100644 --- a/src/components/PostHeader/styles.css +++ b/src/components/PostHeader/styles.css @@ -138,3 +138,10 @@ grid-area: hero-image; } } + +@media (min-width: 1025px) { + #post-header #post-title, + #post-header-wrapper:not(:has(#hero-image)) #post-title { + border: var(--tjs-red-6) solid var(--size-2); + } +}