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

Toggle word wrap and Copy buttons in code examples almost invisible #10821

Open
2 of 7 tasks
rakleed opened this issue Jan 6, 2025 · 2 comments
Open
2 of 7 tasks

Toggle word wrap and Copy buttons in code examples almost invisible #10821

rakleed opened this issue Jan 6, 2025 · 2 comments
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers

Comments

@rakleed
Copy link

rakleed commented Jan 6, 2025

Have you read the Contributing Guidelines on issues?

Prerequisites

  • I'm using the latest version of Docusaurus.
  • I have tried the npm run clear or yarn clear command.
  • I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
  • I have tried creating a repro with https://new.docusaurus.io.
  • I have read the console error message carefully (if applicable).

Description

Toggle word wrap and Copy buttons in code examples are almost invisible.

CleanShot 2025-01-06 at 20 24 45

Reproducible demo

https://github.com/facebook/docusaurus/tree/main/website

Steps to reproduce

  1. Open https://docusaurus.io/docs/typescript-support#setup
  2. Change window size, so the code example doesn't fit on one line
  3. Hover on code example

Expected behavior

Toggle word wrap and Copy buttons in code examples should have an opaque background.

Actual behavior

Toggle word wrap and Copy buttons in code examples have a semi-transparent background and merge with the text.

Your environment

Self-service

  • I'd be willing to fix this bug myself.
@rakleed rakleed added bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers labels Jan 6, 2025
@slorber
Copy link
Collaborator

slorber commented Jan 7, 2025

Thanks

Agree it's not great but I wonder if it would be better with a fully opaque background. I'd say it's a bit better yes.

Do you have examples of other docs doing this properly?


Looks like other docs sites like Starlight are also affected, although their background is a bit more opaque than ours:

https://starlight.astro.build/guides/css-and-tailwind/

CleanShot 2025-01-07 at 12 36 52


VitePress is using an opaque background:
https://vitepress.dev/guide/routing#linking-to-non-vitepress-pages

CleanShot 2025-01-07 at 12 42 23

(can't screenshot while hovering 😅 it's already fading out)


Nextra has the same problem:
https://nextra.site/docs/docs-theme/start

CleanShot 2025-01-07 at 12 39 32


Material for MkDocs has the same problem:

https://squidfunk.github.io/mkdocs-material/getting-started/

CleanShot 2025-01-07 at 12 40 24


There's also this related @Roiocam PR (waiting for my review 😅) suggesting moving buttons to the title when possible: #10461

@rakleed
Copy link
Author

rakleed commented Jan 7, 2025

If such an edge case is not considered in other tools, it shouldn't be ignored in Docusaurus.

Well, PR #10461 does not solve the problem if there is nowhere to move the buttons (as in my screenshot).

It seems to me that the correct solution would be to always use opacity: 1 for buttons. And at the same time, you can add an additional indent to the right of the text equal to the width of the buttons, so that even when the buttons are displayed, it is possible to read the text in full.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An error in the Docusaurus core causing instability or issues with its execution status: needs triage This issue has not been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants