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 ::selection styles, use hsla instead of hsl because it can overlap text with ::selection background when background-clip: text is set #4011

Merged
merged 1 commit into from
Jan 23, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix
  • Loading branch information
dimaMachina committed Jan 23, 2025
commit 151a40819316b5ddcef69cc57510bf65bdd223d2
5 changes: 5 additions & 0 deletions .changeset/honest-parrots-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"nextra": patch
---

fix `::selection` styles, use `hsla` instead of `hsl` because it can overlap text with `::selection` background when `background-clip: text` is set
12 changes: 1 addition & 11 deletions packages/nextra/src/client/components/head.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ export const Head: FC<HeadProps> = ({ children, ...props }) => {
--nextra-bg: ${backgroundColor.dark};
}
::selection {
background: ${makePrimaryColor('+ 41%')};
}
.dark ::selection {
background: ${makePrimaryColor('- 11%')};
background: hsla(var(--nextra-primary-hue),var(--nextra-primary-saturation),var(--nextra-primary-lightness),.3);
}
html {
background: rgb(var(--nextra-bg));
Expand Down Expand Up @@ -130,10 +127,3 @@ html {
</head>
)
}

function makePrimaryColor(val: string): string {
const h = 'var(--nextra-primary-hue)'
const s = 'var(--nextra-primary-saturation)'
const l = `calc(var(--nextra-primary-lightness) ${val})`
return `hsl(${h + s + l})`
}
Loading