quarks-css / quarks

A CSS-in-JS library for applying styles to React components via props
MIT License
3 stars 1 forks source link

Allow users to create custom overwrites #9

Open dslovinsky opened 1 year ago

dslovinsky commented 1 year ago

Is your feature request related to a problem? Please describe. Currently custom overwrites are hard-coded for testing purposes, but these should be something the user can control. For example, some users may not want to use them at all. Simple applications may not even have a theme. Other users may come up with more creative implementations of these than we could anticipate.

Describe the solution you'd like Custom overwrites can be captured in an object with each key as a prop name and the value as a method which takes the passed value as an argument and returns the style value. Ex:

const customOverwrites = {
  $backgroundColor: (value: keyof typeof flattenedColors) => flattenedColors[value],
  $color: (value: keyof typeof flattenedColors) => flattenedColors[value],
};

This object could be passed into Quarks as an argument in setup, or maybe added to a config file. Implementation should be same/similar to how theme is added.

Describe alternatives you've considered None

Additional context There's broad leeway on how to implement these. For example, should we have defaults overwrites? Should they be called something else?

jpwallace22 commented 1 year ago

I think cssPropOverwrite, quarkPropOverwrite, or customQuarkOverwrite are all good options for this. I also feel like we should provide some default functions or utilities that can be used to assist in setting up strongly typed shorthands.

dslovinsky commented 1 year ago

I think cssPropOverwrite, quarkPropOverwrite, or customQuarkOverwrite are all good options for this

Hmm, can we get it down to two words? styleOverwrites? cssOverwrites? propOverwrites?