Feature: clsx.arr() to return class names in array format
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 9.8k
- Forks
- 185
- PR merge metrics
- No merged PRs in 30d
Description
## Motivation
When using it in Svelte attachments that apply classes imperatively using `element.classList.add|remove`, we need the list of classes in array format. Surely one can do `clsx(...).split(' ').filter(x => x.trim().length > 0)`, but this adds an extra loop that can potentially be avoided.
## Proposal
A new function, `clsx.arr()` or whatever people like best that returns the calculations in array format, with one CSS class per array slot.
I can PR this if approved.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the clsx public API and the behavior described for Svelte attachments. Define the array-returning API and verify that it produces one non-empty CSS class per array slot while preserving existing clsx behavior; the issue does not name specific files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100