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

[v3] reduce global style conflicts with external components #3154

Conversation

87xie
Copy link
Contributor

@87xie 87xie commented Aug 29, 2024

Description

Hi teams,

I've referenced the following issues: #2613, #2764, and #3099. This change aims to reduce conflicts with outer-land styles and components.

I introduce cascade layers that unlayered styles can take precedence over Nextra's predefined styles. This approach seems to resolve issues like #747 (comment). At the same time, it prevents Nextra's unlayered styles from inadvertently overriding user-defined CSS layers.

The current priority order is as follows:

  • nextra-utilities (highest)
  • nextra-components
  • nextra-base (lowest)

To avoid conflicts with the focus-visible style in external components, I added a nextra-focus-ring class to replace the original element selector. Users can choose in the theme config's focusRing option whether to apply it to all elements or selectively opt out using the not-nextra-focus-ring class name.

As shown in the image below, when the focusRing option is false, the focus-visible style comes from the user agent settings.

I believe this modification is more aligned with the design system docs. As seen with kuma-ui, some components are currently affected by Nextra's focus ring, which might confuse some users.

Feel free to close this if the approach is not suitable.

image

Copy link

changeset-bot bot commented Aug 29, 2024

🦋 Changeset detected

Latest commit: 46a4aa1

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented Aug 29, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
nextra-v2 ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 30, 2024 1:46pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nextra ⬜️ Ignored (Inspect) Visit Preview Aug 30, 2024 1:46pm

Copy link

vercel bot commented Aug 29, 2024

@87xie is attempting to deploy a commit to the Vercel Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Collaborator

@dimaMachina dimaMachina left a comment

Choose a reason for hiding this comment

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

@87xie thank you for your amazing PRs, I will review/merge them when will have some free time 🚀

@87xie 87xie marked this pull request as draft August 30, 2024 01:58
@87xie
Copy link
Contributor Author

87xie commented Aug 30, 2024

I will make some modifications for fewer changes and better consistency, so I have turned it back to a draft. 🙏

@87xie 87xie marked this pull request as ready for review August 30, 2024 13:26
@87xie 87xie changed the title [v3] reduce focus-visible style conflicts with external components [v3] reduce global style conflicts with external components Aug 30, 2024
@dimaMachina
Copy link
Collaborator

@87xie I am OOO currently and will go to the graphql conf next week, will review once will have some free time

@87xie
Copy link
Contributor Author

87xie commented Sep 7, 2024

Thanks for letting me know! No rush. I’ll go ahead and close this PR for now and split the content into separate PRs. This should make it easier to review and help avoid conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants