Skip to content

Commit b48b2ea

Browse files
fix: polish accessibility, routing, and feed semantics
1 parent ecdacd8 commit b48b2ea

7 files changed

Lines changed: 41 additions & 18 deletions

File tree

.github/workflows/tests.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI
1+
name: CI
22

33
on:
44
pull_request:
@@ -31,4 +31,4 @@ jobs:
3131
run: pnpm install --frozen-lockfile
3232

3333
- name: Run CI pipeline
34-
run: pnpm run ci
34+
run: pnpm run ci

app/components/blog/DownloadPdfButton.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export function DownloadPdfButton({
1616
const pdfTitle = title || 'Blog post'
1717
const fileName = `${slug || 'post'}.pdf`
1818

19-
const handleDownloadPdf = () => {
19+
const handlePrintPdf = () => {
2020
const article = document.getElementById(articleId)
2121

2222
if (!article) return
@@ -123,10 +123,10 @@ export function DownloadPdfButton({
123123
return (
124124
<button
125125
type='button'
126-
onClick={handleDownloadPdf}
126+
onClick={handlePrintPdf}
127127
className='btn btn-ghost btn-md w-full flex-1 gap-2 rounded-xl font-semibold sm:btn-square sm:btn-lg sm:w-auto sm:flex-none sm:rounded-lg md:p-4'
128-
aria-label='Download PDF'
129-
title={`Download ${fileName}`}
128+
aria-label='Print or save as PDF'
129+
title='Print or save as PDF'
130130
>
131131
<FaFilePdf aria-hidden='true' className='h-7 w-7' />
132132
</button>

app/components/core/Skill.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export const Skill: React.FC<SkillProps> = ({ title }) => {
2727
href={url}
2828
target='_blank'
2929
rel='noopener noreferrer'
30-
aria-label={`${label} official website`}
3130
className={className}
3231
>
3332
{content}

app/components/sections/About.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ export const About: React.FC = () => {
121121
rel='noopener noreferrer'
122122
className='btn btn-outline flex w-full items-center justify-center gap-3 border-base-content/20 bg-base-100 hover:bg-base-content/5'
123123
>
124-
<AiOutlineFilePdf className='h-5 w-5 text-error' />
124+
<AiOutlineFilePdf
125+
aria-hidden='true'
126+
className='h-5 w-5 text-error'
127+
/>
125128

126129
<span className='font-semibold'>
127130
CV in English
@@ -134,7 +137,10 @@ export const About: React.FC = () => {
134137
rel='noopener noreferrer'
135138
className='btn btn-outline flex w-full items-center justify-center gap-3 border-base-content/20 bg-base-100 hover:bg-base-content/5'
136139
>
137-
<AiOutlineFilePdf className='h-5 w-5 text-error' />
140+
<AiOutlineFilePdf
141+
aria-hidden='true'
142+
className='h-5 w-5 text-error'
143+
/>
138144

139145
<span className='font-semibold'>
140146
CV in Polish

app/feed/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export async function GET() {
7676

7777
return new Response(feed.rss2(), {
7878
headers: {
79-
'Content-Type': 'application/xml; charset=utf-8',
79+
'Content-Type': 'application/rss+xml; charset=utf-8',
8080
'Cache-Control':
8181
'public, max-age=0, s-maxage=3600, stale-while-revalidate=86400'
8282
}

app/projects/[project]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Metadata } from 'next'
2-
import { notFound, redirect } from 'next/navigation'
2+
import { notFound, permanentRedirect } from 'next/navigation'
33
import type { ReactNode } from 'react'
44
import { AiFillGithub, AiOutlineStar } from 'react-icons/ai'
55
import { TbGitFork, TbLicense, TbLicenseOff } from 'react-icons/tb'
@@ -270,7 +270,7 @@ export default async function ProjectPage({ params }: ProjectPageProps) {
270270
}
271271

272272
if (routeSlug !== project.slug) {
273-
redirect(`/projects/${project.slug}`)
273+
permanentRedirect(`/projects/${project.slug}`)
274274
}
275275

276276
const githubResult = await getGitHubRepository(project.repository)

app/projects/color.ts

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1+
function toLinearRgb(channel: number): number {
2+
const srgb = channel / 255
3+
4+
return srgb <= 0.04045 ? srgb / 12.92 : ((srgb + 0.055) / 1.055) ** 2.4
5+
}
6+
17
export function getContrastTextColor(hex: string): string {
2-
const normalizedHex = hex.replace('#', '')
3-
const red = Number.parseInt(normalizedHex.substring(0, 2), 16)
4-
const green = Number.parseInt(normalizedHex.substring(2, 4), 16)
5-
const blue = Number.parseInt(normalizedHex.substring(4, 6), 16)
6-
const luminance = (0.299 * red + 0.587 * green + 0.114 * blue) / 255
8+
const normalizedHex = hex.trim().replace(/^#/, '')
9+
10+
if (!/^[0-9a-fA-F]{6}$/.test(normalizedHex)) {
11+
return '#000000'
12+
}
13+
14+
const red = Number.parseInt(normalizedHex.slice(0, 2), 16)
15+
const green = Number.parseInt(normalizedHex.slice(2, 4), 16)
16+
const blue = Number.parseInt(normalizedHex.slice(4, 6), 16)
17+
18+
const luminance =
19+
0.2126 * toLinearRgb(red) +
20+
0.7152 * toLinearRgb(green) +
21+
0.0722 * toLinearRgb(blue)
22+
23+
const contrastWithBlack = (luminance + 0.05) / 0.05
24+
const contrastWithWhite = 1.05 / (luminance + 0.05)
725

8-
return luminance > 0.5 ? '#000000' : '#ffffff'
26+
return contrastWithBlack >= contrastWithWhite ? '#000000' : '#ffffff'
927
}

0 commit comments

Comments
 (0)