Skip to content

Commit

Permalink
Accessibility issues for text and navbar in light mode (#1858)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Khang <brew4k@gmail.com>
Co-authored-by: Dimitri POSTOLOV <en3m@ya.ru>
Co-authored-by: Dimitri POSTOLOV <dmytropostolov@gmail.com>
  • Loading branch information
5 people committed May 22, 2023
1 parent 2d79e20 commit 9d9bc23
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/little-mirrors-push.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'nextra-theme-blog': patch
---

accessibility issues for text and navbar in light mode
13 changes: 10 additions & 3 deletions packages/nextra-theme-blog/src/nav.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,36 @@
import type { ReactElement } from 'react'
import Link from 'next/link'
import ThemeSwitch from './theme-switch'
import { useTheme } from 'next-themes'
import { useBlogContext } from './blog-context'
import { collectPostsAndNavs } from './utils/collect'

export default function Nav(): ReactElement {
const { opts, config } = useBlogContext()
const { navPages } = collectPostsAndNavs({ opts, config })
const { resolvedTheme } = useTheme()
return (
<div className="nx-mb-8 nx-flex nx-items-center nx-gap-3">
<div className="nx-flex nx-grow nx-flex-wrap nx-items-center nx-justify-end nx-gap-3">
{navPages.map(page => {
const name = page.frontMatter?.title || page.name
if (page.active) {
return (
<span
key={page.route}
className="nx-cursor-default nx-text-gray-400"
className={`nx-cursor-default ${
resolvedTheme === 'dark'
? 'nx-text-gray-400'
: 'nx-text-gray-600'
}`}
>
{page.frontMatter?.title || page.name}
{name}
</span>
)
}
return (
<Link key={page.route} href={page.route} passHref legacyBehavior>
<a>{page.frontMatter?.title || page.name}</a>
<a>{name}</a>
</Link>
)
})}
Expand Down
8 changes: 6 additions & 2 deletions packages/nextra-theme-blog/src/posts-layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MDXTheme } from './mdx-theme'
import Nav from './nav'
import { collectPostsAndNavs } from './utils/collect'
import getTags from './utils/get-tags'
import { useTheme } from 'next-themes'

export const PostsLayout = ({
children
Expand All @@ -18,6 +19,9 @@ export const PostsLayout = ({
const router = useRouter()
const { type } = opts.frontMatter
const tagName = type === 'tag' ? router.query.tag : null
const { resolvedTheme } = useTheme()
const textColor =
resolvedTheme === 'dark' ? 'nx-text-gray-400' : 'nx-text-gray-600'
const postList = posts.map(post => {
if (tagName) {
const tags = getTags(post)
Expand All @@ -42,7 +46,7 @@ export const PostsLayout = ({
</Link>
</h3>
{description && (
<p className="nx-mb-2 nx-text-gray-400">
<p className={'nx-mb-2 ' + textColor}>
{description}
{config.readMore && (
<Link href={post.route} passHref legacyBehavior>
Expand All @@ -53,7 +57,7 @@ export const PostsLayout = ({
)}
{date && (
<time
className="nx-text-sm nx-text-gray-300"
className={'nx-text-sm ' + textColor}
dateTime={date.toISOString()}
>
{date.toDateString()}
Expand Down

1 comment on commit 9d9bc23

@vercel
Copy link

@vercel vercel bot commented on 9d9bc23 May 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.