Closed milesj closed 7 years ago
I'm leaning towards switching to extending so you can do things like:
import BaseButton from 'toolkit/components/Button';
export const Button = BaseButton.extendStyles({
button: { ... },
});
export const PrimaryButton = Button.extendStyles({
button: { ... },
});
export const SecondaryButton = Button.extendStyles({
button: { ... },
});
Went with the extending styles approach.
Aesthetic aims to solve the following two ownership scenarios:
The first scenario is rather easily solved without much hassle. The second scenario is what Aesthetic tries to solve via the static
setStyles
method on a wrapped component (provided by a styler function).Now for the comparison. I will use Toolkit components as an example, even though they don't use Aesthetic. Just assume it does use Aesthetic, and defines external classes as its style, like so:
Both approaches need to satisfy the following criteria:
Overwriting
Overwriting allows us to change the styles without having to create a new local component. The original styles can be referenced by using style functions.
Pros
Cons
Extending
Extending allows us to change the styles but creates a new local component in the process (another layer of composition).
Pros
extendStyles
.Cons