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

feat(module): implement --ui-radius CSS variable #2341

Merged
merged 11 commits into from
Oct 9, 2024
Merged

feat(module): implement --ui-radius CSS variable #2341

merged 11 commits into from
Oct 9, 2024

Conversation

sandros94
Copy link
Collaborator

@sandros94 sandros94 commented Oct 8, 2024

πŸ”— Linked issue

Resolves #2314

❓ Type of change

  • πŸ“– Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

As a follow-up for #2298 this PR adds an intermediate --ui-radius css variable that uses Tailwind's defaults --radius ones but enables to edit rounded corners project-wide all at once.

These are the defaults:

:root {
  --ui-radius: var(--radius);
}

For a sharp corners layout, it is sufficient to add the following in your app.vue:

<style>
@import 'tailwindcss';
@import '@nuxt/ui';

:root {
  --ui-radius: 0px;
}
</style>

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@sandros94
Copy link
Collaborator Author

@benjamincanac

The xl, 2xl, 3xl and 4xl aren't actually used, should I remove them?

Copy link
Member

benjamincanac commented Oct 8, 2024

This is not how I want to implement it, the goal here is to only have one --radius: var(--radius); variable in the :root.

And in the theme use calc to reproduce the sm, md, lg, etc.

Copy link
Member

This way we can only change the base radius and all variants will be calculated accordingly 😊

@sandros94
Copy link
Collaborator Author

sandros94 commented Oct 8, 2024

This is not how I want to implement it, the goal here is to only have one --radius: var(--radius); variable in the :root.

And in the theme use calc to reproduce the sm, md, lg, etc.

That was actually my first goto. But then I realized how are we able override the calc? For example when creating a non-rounded layout?

EDIT: might be a dumb question tho...

Copy link
Member

Something like:

  • rounded-sm => rounded-[calc(var(--ui-radius)/2)]
  • rounded => rounded-[--ui-radius]
  • rounded-md => rounded-[calc(var(--ui-radius)*1.5)]
  • rounded-lg => rounded-[calc(var(--ui-radius)*2)]

Copy link
Member

CleanShot 2024-10-08 at 15.13.57@2x.png

Copy link
Member

For non-rounded layouts, 0 / 2 equals 0.

@sandros94
Copy link
Collaborator Author

I've made the change and now it's only one --ui-radius var.

I'm only concerned about full: for now I've set it to be rounded-[calc(var(--ui-radius)*625)] but in reality we just need it to be either 0px or 9999px

Copy link
Member

You can leave rounded-full as-is I guess.

@benjamincanac benjamincanac linked an issue Oct 8, 2024 that may be closed by this pull request
@benjamincanac benjamincanac changed the title feat(module): implement CSS variables to control rounded radius feat(module): implement --ui-radius CSS variable Oct 8, 2024
Copy link

pkg-pr-new bot commented Oct 8, 2024

Open in Stackblitz

pnpm add https://pkg.pr.new/nuxt/ui/@nuxt/ui@2341

commit: 9cf5cd6

@benjamincanac benjamincanac merged commit 057e86c into nuxt:v3 Oct 9, 2024
2 checks passed
@benjamincanac benjamincanac added the v3 #1289 label Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3 #1289
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Handle dynamic --radius token
2 participants