Skip to content

Commit 908b583

Browse files
authored
fix: Windows High Contrast Mode colors (#769)
1 parent 88889ba commit 908b583

File tree

20 files changed

+60
-36
lines changed

20 files changed

+60
-36
lines changed

.changeset/modern-rocks-switch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"namesake": patch
3+
---
4+
5+
Fix color issues in Windows High Contrast (Forced Colors) mode

src/components/app/Logo/Logo.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@ export interface LogoProps {
77
export const Logo = ({ className }: LogoProps) => (
88
<svg
99
aria-label="Namesake"
10-
className={twMerge("w-auto text-normal shrink-0", className)}
10+
className={twMerge(
11+
"w-auto text-normal shrink-0 forced-colors:text-[CanvasText]",
12+
className,
13+
)}
1114
fill="currentColor"
1215
height="30"
1316
role="img"

src/components/common/Badge/Badge.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export interface BadgeProps extends React.HTMLAttributes<HTMLDivElement> {
3030
}
3131

3232
const badge = tv({
33-
base: "px-1 font-medium w-max tabular-nums text-center inline-flex justify-center gap-1 items-center shrink-0 bg-theme-a3 text-dim",
33+
base: "px-1 font-medium w-max tabular-nums text-center inline-flex justify-center gap-1 items-center shrink-0 bg-theme-a3 text-dim forced-colors:border forced-colors:bg-transparent forced-colors:border-[ButtonBorder] forced-colors:text-[CanvasText]",
3434
variants: {
3535
size: {
3636
xs: "text-[10px] rounded-sm h-4 px-1 min-w-4 leading-none",
@@ -50,7 +50,7 @@ const badge = tv({
5050
});
5151

5252
const icon = tv({
53-
base: "shrink-0 size-4",
53+
base: "shrink-0 size-4 forced-colors:text-[CanvasText]",
5454
variants: {
5555
size: {
5656
xs: "size-3",

src/components/common/Banner/Banner.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export interface BannerProps {
1616
}
1717

1818
const bannerStyles = tv({
19-
base: "flex items-start w-full rounded-lg bg-primary-3 text-primary-12 [&_a]:text-primary-12 prose",
19+
base: "flex items-start w-full rounded-lg bg-primary-3 text-primary-12 [&_a]:text-primary-12 prose forced-colors:border forced-colors:border-[ButtonBorder]",
2020
variants: {
2121
variant: {
2222
success: "bg-green-3 text-green-12 [&_a]:text-green-12",
@@ -35,7 +35,7 @@ const bannerStyles = tv({
3535
});
3636

3737
const iconStyles = tv({
38-
base: "text-primary-11 shrink-0",
38+
base: "text-primary-11 shrink-0 forced-colors:text-[ButtonText]",
3939
variants: {
4040
variant: {
4141
success: "text-green-11",

src/components/common/Breadcrumbs/Breadcrumbs.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ export function Breadcrumb(
3131
)}
3232
>
3333
<Link variant="secondary" {...props} />
34-
{props.href && <ChevronRight className="w-4 h-4 text-subtle" />}
34+
{props.href && (
35+
<ChevronRight className="w-4 h-4 text-subtle forced-colors:text-[CanvasText]" />
36+
)}
3537
</AriaBreadcrumb>
3638
);
3739
}

src/components/common/Button/Button.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,19 @@ export interface ButtonProps extends AriaButtonProps {
3131

3232
export const buttonStyles = tv({
3333
extend: focusRing,
34-
base: "py-2 text-sm shadow-sm font-medium relative whitespace-nowrap rounded-lg border-0 transition-all duration-200 ease-in-out flex items-center justify-center tabular-nums",
34+
base: "py-2 text-sm shadow-sm font-medium relative whitespace-nowrap rounded-lg border transition-all duration-200 ease-in-out flex items-center justify-center tabular-nums",
3535
variants: {
3636
variant: {
37-
primary: "bg-primary-9 hover:bg-primary-10 text-primary-contrast",
37+
primary:
38+
"bg-primary-9 border-primary-9 hover:bg-primary-10 text-primary-contrast",
3839
secondary:
39-
"bg-white dark:bg-theme-4 dark:hover:bg-theme-5 text-normal hover:text-theme-11 dark:hover:text-white",
40+
"bg-white border-dim dark:bg-theme-4 dark:hover:bg-theme-5 text-normal hover:text-theme-11 dark:hover:text-white",
4041
destructive:
41-
"bg-red-9 text-white hover:bg-red-10 outline-0 !outline-red-a8",
42-
success: "bg-green-9 text-white hover:bg-green-10",
43-
icon: "bg-transparent hover:bg-theme-a3 text-dim shadow-none hover:text-normal flex shrink-0 items-center justify-center rounded-full",
42+
"bg-red-9 border-red-9 text-white hover:bg-red-10 !outline-red-a8",
43+
success: "bg-green-9 border-green-9 text-white hover:bg-green-10",
44+
icon: "bg-transparent border-transparent hover:bg-theme-a3 text-dim shadow-none hover:text-normal flex shrink-0 items-center justify-center rounded-full",
4445
ghost:
45-
"bg-transparent hover:bg-theme-a3 text-dim shadow-none hover:text-normal",
46+
"bg-transparent border-transparent hover:bg-theme-a3 text-dim shadow-none hover:text-normal",
4647
},
4748
size: {
4849
small: "h-8 px-2 gap-1.5",
@@ -51,7 +52,7 @@ export const buttonStyles = tv({
5152
},
5253
isDisabled: {
5354
false: "cursor-pointer",
54-
true: "cursor-default opacity-40",
55+
true: "cursor-default opacity-40 forced-colors:text-[GrayText]",
5556
},
5657
},
5758
compoundVariants: [

src/components/common/Calendar/Calendar.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,11 @@ import { focusRing } from "@/components/utils";
1818

1919
const cellStyles = tv({
2020
extend: focusRing,
21-
base: "w-9 h-9 text-sm cursor-default rounded-full flex items-center justify-center forced-color-adjust-none",
21+
base: "size-9 text-sm cursor-default rounded-full flex items-center justify-center forced-color-adjust-none",
2222
variants: {
2323
isSelected: {
24-
false: "text-normal hover:bg-primary-3 pressed:bg-primary-3",
24+
false:
25+
"text-normal hover:bg-primary-3 pressed:bg-primary-3 forced-colors:text-[ButtonText] hover:forced-colors:bg-[Highlight] pressed:forced-colors:text-[HighlightText]",
2526
true: "bg-primary-9 invalid:bg-red-9 text-white forced-colors:bg-[Highlight] forced-colors:invalid:bg-[Mark] forced-colors:text-[HighlightText]",
2627
},
2728
isDisabled: {

src/components/common/Checkbox/Checkbox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const boxStyles = tv({
7272
variants: {
7373
isSelected: {
7474
false: "bg-element border-normal",
75-
true: "bg-primary-9 border-transparent",
75+
true: "bg-primary-9 border-transparent forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
7676
},
7777
isInvalid: {
7878
true: "text-red-9",

src/components/common/HiddenText/HiddenText.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ const contentStyles = tv({
2323
variants: {
2424
isRevealed: {
2525
true: "bg-transparent",
26-
false: "text-transparent bg-theme-4",
26+
false:
27+
"text-transparent bg-theme-4 forced-colors:bg-[CanvasText] forced-colors:text-[CanvasText]",
2728
},
2829
},
2930
});

src/components/common/ListBox/ListBox.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export const itemStyles = tv({
3737
base: "group relative flex items-center gap-8 cursor-pointer select-none py-1.5 px-2.5 rounded-md will-change-transform forced-color-adjust-none",
3838
variants: {
3939
isSelected: {
40-
false: "text-normal -outline-offset-2",
40+
false: "text-normal -outline-offset-2 forced-colors:text-[ButtonText]",
4141
true: "bg-primary-9 text-white forced-colors:bg-[Highlight] forced-colors:text-[HighlightText] [&:has(+[data-selected])]:rounded-b-none [&+[data-selected]]:rounded-t-none -outline-offset-4 outline-white forced-colors:outline-[HighlightText]",
4242
},
4343
isDisabled: {
@@ -56,7 +56,7 @@ export function ListBoxItem(props: ListBoxItemProps) {
5656
{composeRenderProps(props.children, (children) => (
5757
<>
5858
{children}
59-
<div className="absolute left-4 right-4 bottom-0 h-px bg-white/20 forced-colors:bg-[HighlightText] hidden [.group[data-selected]:has(+[data-selected])_&]:block" />
59+
<div className="absolute left-4 right-4 bottom-0 h-px bg-white/20 hidden [.group[data-selected]:has(+[data-selected])_&]:block forced-colors:hidden" />
6060
</>
6161
))}
6262
</AriaListBoxItem>
@@ -67,7 +67,7 @@ export const dropdownItemStyles = tv({
6767
base: "group flex items-center gap-3 cursor-pointer select-none py-2 px-2.5 pr-3 rounded-lg outline-none text-sm forced-color-adjust-none",
6868
variants: {
6969
isDisabled: {
70-
false: "text-normal",
70+
false: "text-normal forced-colors:text-[ButtonText]",
7171
true: "text-dim opacity-50 forced-colors:text-[GrayText] cursor-default",
7272
},
7373
isFocused: {

0 commit comments

Comments
 (0)