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

fix(a11y): fixed color contrast and heading issues #7424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Layout/Sidebar/SidebarLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function SidebarLink({
'text-primary dark:text-primary-dark': level === 0 && !selected,
'text-base text-secondary dark:text-secondary-dark':
level > 0 && !selected,
'text-base text-link dark:text-link-dark bg-highlight dark:bg-highlight-dark border-blue-40 hover:bg-highlight hover:text-link dark:hover:bg-highlight-dark dark:hover:text-link-dark':
'text-base text-primary dark:text-link-dark bg-highlight dark:bg-highlight-dark border-blue-40 hover:bg-highlight hover:text-link dark:hover:bg-highlight-dark dark:hover:text-link-dark':
Copy link
Member

Choose a reason for hiding this comment

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

Instead of using text-primary can we add test-link-secondary with value #045975 (blue-60). This will keep the vibe, while maintaining a good contrast ratio.

selected,
'dark:bg-gray-70 bg-gray-3 dark:hover:bg-gray-70 hover:bg-gray-3':
isPending,
Expand Down
4 changes: 2 additions & 2 deletions src/components/Layout/TopNav/TopNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ function NavItem({url, isActive, children}: any) {
'active:scale-95 transition-transform w-full text-center outline-link py-1.5 px-1.5 xs:px-3 sm:px-4 rounded-full capitalize whitespace-nowrap',
!isActive && 'hover:bg-primary/5 hover:dark:bg-primary-dark/5',
isActive &&
'bg-highlight dark:bg-highlight-dark text-link dark:text-link-dark'
'bg-highlight dark:bg-highlight-dark text-link-10 dark:text-link-dark'
Copy link
Member

Choose a reason for hiding this comment

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

I don't think text-link-10 is set to anything? Can we use test-link-secondary from above?

)}>
{children}
</Link>
Expand Down Expand Up @@ -304,7 +304,7 @@ export default function TopNav({
<button
type="button"
className={cn(
'flex 3xl:w-[56rem] 3xl:mx-0 relative ps-4 pe-1 py-1 h-10 bg-gray-30/20 dark:bg-gray-40/20 outline-none focus:outline-link betterhover:hover:bg-opacity-80 pointer items-center text-start w-full text-gray-30 rounded-full align-middle text-base'
'flex 3xl:w-[56rem] 3xl:mx-0 relative ps-4 pe-1 py-1 h-10 bg-gray-30/20 dark:bg-gray-40/20 outline-none focus:outline-link betterhover:hover:bg-opacity-80 pointer items-center text-start w-full rounded-full align-middle text-base'
Copy link
Member

Choose a reason for hiding this comment

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

I believe test-gray-50 will give enough contrast.

)}
onClick={onOpenSearch}>
<IconSearch className="align-middle me-3 text-gray-30 shrink-0 group-betterhover:hover:text-gray-70" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/Diagram.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface DiagramProps {
function Caption({text}: {text: string}) {
return (
<div className="w-full flex justify-center">
<figcaption className="p-1 sm:p-2 mt-0 sm:mt-0 text-gray-40 text-base lg:text-lg text-center leading-tight table-caption max-w-lg">
<figcaption className="p-1 sm:p-2 mt-0 sm:mt-0 text-base lg:text-lg text-center leading-tight table-caption max-w-lg">
{text}
</figcaption>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/MDX/InlineCode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ function InlineCode({
className={cn(
'inline text-code text-secondary dark:text-secondary-dark px-1 rounded-md no-underline',
{
'bg-gray-30 bg-opacity-10 py-px': !isLink,
'bg-opacity-10 py-px': !isLink,
Copy link
Member

Choose a reason for hiding this comment

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

Instead of removing the background, can you update the a > code color to be #045975 (blue-60) here instead:

a > code {
color: #087ea4 !important; /* blue-50 */
text-decoration: none !important;
}

'bg-highlight dark:bg-highlight-dark py-0': isLink,
}
)}
Expand Down
6 changes: 3 additions & 3 deletions src/components/MDX/SimpleCallout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import * as React from 'react';
import cn from 'classnames';
import {H3} from './Heading';
import {H2} from './Heading';

interface SimpleCalloutProps {
title: string;
Expand All @@ -18,11 +18,11 @@ function SimpleCallout({title, children, className}: SimpleCalloutProps) {
'p-6 xl:p-8 pb-4 xl:pb-6 bg-card dark:bg-card-dark rounded-2xl shadow-inner-border dark:shadow-inner-border-dark text-base text-secondary dark:text-secondary-dark my-8',
className
)}>
<H3
<H2
className="text-primary dark:text-primary-dark mt-0 mb-3 leading-tight"
isPageAnchor={false}>
{title}
</H3>
</H2>
{children}
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion src/content/learn/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ export default function ShoppingList() {
<li
key={product.id}
style={{
color: product.isFruit ? 'magenta' : 'darkgreen'
color: product.isFruit ? 'darkblue' : 'darkgreen'
Copy link
Member

Choose a reason for hiding this comment

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

Can we use a different color or change the magenta color? The tool doesn't know that these items need to have good contrast relative to each other, otherwise it's hard to see the point it's making:

Screenshot 2025-02-18 at 12 32 32 AM

}}
>
{product.title}
Expand Down
4 changes: 2 additions & 2 deletions src/styles/sandpack.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ html .sandpack {

--sp-syntax-color-plain: #24292e;
--sp-syntax-color-comment: #6a737d;
--sp-syntax-color-keyword: #d73a49;
--sp-syntax-color-tag: #22863a;
--sp-syntax-color-keyword: #d21a2d;
--sp-syntax-color-tag: #077e23;
--sp-syntax-color-punctuation: #24292e;
--sp-syntax-color-definition: #6f42c1;
--sp-syntax-color-property: #005cc5;
Expand Down
Loading