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

Support splat + concat of slots in SVA recipes #3040

Open
dcousineau opened this issue Dec 12, 2024 · 1 comment
Open

Support splat + concat of slots in SVA recipes #3040

dcousineau opened this issue Dec 12, 2024 · 1 comment

Comments

@dcousineau
Copy link

Description

When building SVA recipes using ArkUI's @ark-ui/anatomy sometimes I need to add additional slots as I compose complex components. Unfortunately, Panda's build-time compiler does not support the [...anatomy.keys(), "more", "slots"] pattern.

Problem Statement/Justification

I am intentionally classifying this as a Feature Request and not a Bug given that the documentation does not explicitly call this out as a valid use case and I cannot reasonably expect static analysis to cover every valid run-time case.

I am using ArkUI's primitives to build my more complex components around but manually building style recipes using @ark-ui/anatomy to provide some helpful type checking.

Given the following example:

const styles = sva({
  className: "foo",
  slots: [...componentAnatomy.keys(), "additional", "slots", "here"],
  // ...snip...
});

Panda currently enters into what feels like undefined behavior where styles for slot names found in componentAnatomy.keys() are not generated into the output CSS during build, but class names are correctly generated at run time.

Proposed Solution or API

Ideally Panda would support the use case provided in the Problem Statement/Justification at build time.

However if not (or between now and when a solution can be shipped) a compile-time or eslint warning/error indicating that the splat + concat pattern ([...someArr, "more", "strings"]) will produce unexpected results would be super helpful.

Alternatives

Currently I manually and statically copy out the possible keys from the anatomy package. This is less than ideal but perfectly viable. My only issue with this is... I eventually forget that [...splat, "concat"] isn't supported and spent hours banging my forehead before checking my codebase and realizing I've already discovered and worked around this limitation.

Additional Information

This is mildly related to #2671

@dcousineau
Copy link
Author

Apologies if this should be a discussion, feel free to shove it in a dark corner. Just wanted to note before I forget. again.

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

No branches or pull requests

1 participant