nuxt / nuxt/ui

UTheme: name/scope - or a way to prevent it from applying to overlays

Open
#6,486 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

triage
Dominant language
TypeScript
Stars
6.9k
Forks
1.1k
Avg merge
1d 7h
Merged PRs (30d)
57

Description

Package

v4.x

Description

First of all: I'm super happy about the UTheme component, and hope it keeps evolving! It's a lifesaver for complex apps with discretely themed modules as well as enabling a lot of user prefs when it comes to layout.


Not quite sure how to best explain this possibly-edge case, but I've made a "FormCard" wrapper component similar to the settings page in the Dashboard template.

In this components I apply some defaults and adjustments to UFormField.

However, if this FormCard includes a button triggering a modal, popover etc, FormFields inside those overlays also inherit the theme settings.


I've included a few suggested ways of doing this (prop names for illustration purposes only):

Specify that a UTheme should not apply inside overlays
  • <UTheme :overlay-nesting="false">...</UTheme>
  • Should apply to the "current" overlay (if any), but not overlays called from within this declaration
Specify that a UTheme should not apply inside portals
  • <UTheme :portal-nesting="false">...</UTheme>
  • As for overlays, but specifically for portals. This may or may not be easier to implement and/or have less potential for side effects than the overlay scope
Named/resettable UTheme stack/scopes:
  • <UTheme name="formcard">...</UTheme> | <UTheme :omit="['formcard']">...</UTheme>
  • Needs to store a theme nesting stack to be able to generate component ui without the named theme(s)
  • omit could take a string or an array of strings
  • Optionally log a warning if no theme with the specified names were found in the stack, and/or add a silent prop to disable such warnings
Additional context

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the UTheme component entry point and tracing how its settings reach fields rendered in overlays and portals. Compare the proposed overlay, portal, and named-scope approaches with the existing component behavior; done requires an agreed API and documented behavior for preventing selected nested overlays or portals from inheriting a theme.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.