From d371320ce81b228eb1ca75b155b1edd862fdb91d Mon Sep 17 00:00:00 2001 From: kiosion Date: Thu, 29 Feb 2024 21:00:58 -0500 Subject: [PATCH] fix: A11y issues, list styles, colour contrast issues --- .../src/components/about/timeline-item.svelte | 62 ++++++++--------- .../components/about/timeline-section.svelte | 2 +- svelte-app/src/components/code-block.svelte | 3 + .../components/document/content/header.svelte | 6 +- svelte-app/src/components/footer.svelte | 5 +- svelte-app/src/components/header.svelte | 4 +- .../components/headings/headed-block.svelte | 8 +-- .../src/components/lists/document-list.svelte | 19 +++++ .../src/components/lists/list-item.svelte | 69 +++++++++++++------ .../src/components/lists/year-list.svelte | 52 -------------- .../src/components/tooltips/inner.svelte | 27 +++++++- .../routes/[[lang=lang]]/blog/+page.svelte | 4 +- .../routes/[[lang=lang]]/work/+page.svelte | 4 +- svelte-app/src/styles/_colors.scss | 4 +- svelte-app/tailwind.config.cjs | 4 +- 15 files changed, 144 insertions(+), 129 deletions(-) create mode 100644 svelte-app/src/components/lists/document-list.svelte delete mode 100644 svelte-app/src/components/lists/year-list.svelte diff --git a/svelte-app/src/components/about/timeline-item.svelte b/svelte-app/src/components/about/timeline-item.svelte index 1b94469ab..0dd544b53 100644 --- a/svelte-app/src/components/about/timeline-item.svelte +++ b/svelte-app/src/components/about/timeline-item.svelte @@ -30,10 +30,12 @@ diff --git a/svelte-app/src/components/about/timeline-section.svelte b/svelte-app/src/components/about/timeline-section.svelte index c102a6bfe..19fe9e668 100644 --- a/svelte-app/src/components/about/timeline-section.svelte +++ b/svelte-app/src/components/about/timeline-section.svelte @@ -34,7 +34,7 @@ diff --git a/svelte-app/src/components/lists/list-item.svelte b/svelte-app/src/components/lists/list-item.svelte index 965260e56..40711595e 100644 --- a/svelte-app/src/components/lists/list-item.svelte +++ b/svelte-app/src/components/lists/list-item.svelte @@ -19,38 +19,63 @@ -
+

- {$formatDate(document.date || document._createdAt, small ? 'med' : 'short')} + {$formatDate(document.date || document._createdAt, 'med')}

{#if document.tags?.length} - {document.tags[0].title.toLowerCase()} + {document.tags[0].title.toLowerCase()} {/if}

{$t('{views} views', { views: $parseViews((document.views ?? 0) + 1) })}

-

- {document.title} -

- {#if document.desc?.length && !small} -

{document.desc}

- {/if} +

{document.title}

+ + diff --git a/svelte-app/src/components/lists/year-list.svelte b/svelte-app/src/components/lists/year-list.svelte deleted file mode 100644 index d13011ae4..000000000 --- a/svelte-app/src/components/lists/year-list.svelte +++ /dev/null @@ -1,52 +0,0 @@ - - -
- {#each sortedDocuments as object} -
-

{object.year}

-
- {#each object.items as item} - - {/each} -
-
- {/each} -
- - diff --git a/svelte-app/src/components/tooltips/inner.svelte b/svelte-app/src/components/tooltips/inner.svelte index a3e1182dd..2c1eb1f1a 100644 --- a/svelte-app/src/components/tooltips/inner.svelte +++ b/svelte-app/src/components/tooltips/inner.svelte @@ -7,6 +7,9 @@ import type { Tooltip } from '$lib/tooltips'; + const PADDING_PX = 8, + MAX_LENGTH = 72; + export let id: Tooltip['id'], content: Tooltip['content'], duration: Tooltip['duration'], @@ -111,6 +114,20 @@ break; } + // if x-pos will result in tooltip being off-screen, adjust it + if (x + tooltipRect.width > innerWidth + pageScroll.x - PADDING_PX) { + x = innerWidth + pageScroll.x - tooltipRect.width - PADDING_PX; + } else if (x < PADDING_PX) { + x = PADDING_PX; + } + + // same for height + if (y + tooltipRect.height > innerHeight + pageScroll.y - PADDING_PX) { + y = innerHeight + pageScroll.y - tooltipRect.height - PADDING_PX; + } else if (y < PADDING_PX) { + y = PADDING_PX; + } + position = { x: Math.max(0, Math.min(innerWidth + pageScroll.x, x + offset[0])), y: Math.max(0, Math.min(innerHeight + pageScroll.y, y + offset[1])) @@ -123,19 +140,23 @@
- {content} + {content.trim().length >= MAX_LENGTH + ? `${content.trim().slice(0, MAX_LENGTH - 3)}...` + : content.trim()}