djgrant / djgrant/classy

Make it easy to pass className props down

Open
#2 0 comments 0 reactions 0 assignees View on GitHub

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:

  1. If the argument type is a function, classy creates a wrapped component.
  2. Classy components can be extended by calling an extend method. 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

  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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.