Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolves dark mode contrast problems in sidebar and breadcrumbs #1886

Merged
merged 6 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/warm-dingos-explain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextra-theme-docs": patch
---

Resolves dark mode contrast problems in sidebar and breadcrumbs
6 changes: 3 additions & 3 deletions packages/nextra-theme-docs/src/components/breadcrumb.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export function Breadcrumb({
activePath: Item[]
}): ReactElement {
return (
<div className="nextra-breadcrumb nx-mt-1.5 nx-flex nx-items-center nx-gap-1 nx-overflow-hidden nx-text-sm nx-text-gray-500 contrast-more:nx-text-current">
<div className="nextra-breadcrumb nx-mt-1.5 nx-flex nx-items-center nx-gap-1 nx-overflow-hidden nx-text-sm nx-text-gray-500 dark:nx-text-gray-400 contrast-more:nx-text-current">
{activePath.map((item, index) => {
const isLink = !item.children || item.withIndexPage
const isActive = index === activePath.length - 1
Expand All @@ -23,11 +23,11 @@ export function Breadcrumb({
className={cn(
'nx-whitespace-nowrap nx-transition-colors',
isActive
? 'nx-font-medium nx-text-gray-700 contrast-more:nx-font-bold contrast-more:nx-text-current dark:nx-text-gray-400 contrast-more:dark:nx-text-current'
? 'nx-font-medium nx-text-gray-700 contrast-more:nx-font-bold contrast-more:nx-text-current dark:nx-text-gray-100 contrast-more:dark:nx-text-current'
: [
'nx-min-w-[24px] nx-overflow-hidden nx-text-ellipsis',
isLink &&
'hover:nx-text-gray-900 dark:hover:nx-text-gray-200'
'hover:nx-text-gray-900 dark:hover:nx-text-gray-100'
]
)}
title={item.title}
Expand Down
2 changes: 1 addition & 1 deletion packages/nextra-theme-docs/src/components/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const classes = {
),
inactive: cn(
'nx-text-gray-500 hover:nx-bg-gray-100 hover:nx-text-gray-900',
'dark:nx-text-neutral-500 dark:hover:nx-bg-primary-100/5 dark:hover:nx-text-gray-50',
'dark:nx-text-neutral-400 dark:hover:nx-bg-primary-100/5 dark:hover:nx-text-gray-50',
'contrast-more:nx-text-gray-900 contrast-more:dark:nx-text-gray-50',
'contrast-more:nx-border-transparent contrast-more:hover:nx-border-gray-900 contrast-more:dark:hover:nx-border-gray-50'
),
Expand Down
10 changes: 5 additions & 5 deletions packages/nextra-theme-docs/src/components/toc.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ export type TOCProps = {
filePath: string
}

const linkClassName = cn(
'nx-text-xs nx-font-medium nx-text-gray-500 hover:nx-text-gray-900 dark:nx-text-gray-400 dark:hover:nx-text-gray-100',
'contrast-more:nx-text-gray-800 contrast-more:dark:nx-text-gray-50'
)

export function TOC({ headings, filePath }: TOCProps): ReactElement {
const activeAnchor = useActiveAnchor()
const config = useConfig()
Expand Down Expand Up @@ -51,11 +56,6 @@ export function TOC({ headings, filePath }: TOCProps): ReactElement {
}
}, [activeSlug])

const linkClassName = cn(
'nx-text-xs nx-font-medium nx-text-gray-500 hover:nx-text-gray-900 dark:nx-text-gray-400 dark:hover:nx-text-gray-100',
'contrast-more:nx-text-gray-800 contrast-more:dark:nx-text-gray-50'
)

return (
<div
ref={tocRef}
Expand Down