Make it easy to pass className props down
Open
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
Instead of writing:
export const MyComponent = (props: { className: string }) => {
return (
<div className={props.className}>
<div className="pt-10 pb-14 px-8" />
</div>
);
};
I could write:
export const MyComponent = classy.div(() => {
return <div className="pt-10 pb-14 px-8">;
});
Or:
const MyDiv = classy.div();
export const MyComponent = MyDiv.extend(() => {
return <div className="pt-10 pb-14 px-8">;
});
This would introduce two API changes:
- If the argument type is a function, classy creates a wrapped component.
- Classy components can be extended by calling an
extendmethod. If a classnames object is the argument, it is merged with the original classnames object. If a function is the argument, the original component is wrapped, as per 1.
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 reading the existing classy component API and how classnames are currently supplied. Define the behavior for function arguments and the extend method, including merging classnames objects and wrapping components. Done means both proposed usage forms pass the project's available checks and preserve className behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100