Extend `theme*` props to accept functions that receive the default class list
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 90
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
Having experimented with a few different options, here's the outline of a styling pattern that I think could fit our purposes:
- Opinionated defaults.
- Standard variants are easy to implement, with either boolean or keyword props. The current MbxButton component illustrates this approach with the
variant,size, andwidthprops. - Non-standard variants are possible to implement, with
theme*props. This is the pattern established by the bulk of existing components and has proven useful. The main problem with it is that it requires a lot of the user — so it makes sense for advanced users, but not for the average user. We should continue to use these but indicate in the docs that they are advanced props and most people should not need to use them.
One major annoyance with the theme* props is that you need to replace every class that you don't want to override. A common use case is to just append a class to the end of the list, but to do this you actually need to copy-paste the default class list and add your own to the end — and that's not very robust or cheery. So I'm thinking that instead of theme* props accepting only strings, they'll also accept functions that receive the default class list and return a modified one. Appending would be very easy, then.
cc @danswick
Contributor guide
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 with src/components/mbx-button/mbx-button.js and its existing variant, size, and width props to understand the component pattern. Trace how theme* props are handled in the surrounding components, then verify that they can accept functions receiving the default class list and that the returned classes are used.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100