This repository has been archived by the owner on Jan 20, 2022. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goals
Component's anatomy
Each component (except from primitive ones) should advertise its anatomy - which parts this component consist of. This is a key prerequisite that, apart from other things, will allow us to target specific subcomponents of the component.
As an example, lets consider an anatomy that could be provided by
<Search />
component:Applying styles
The following ways currently proposed for component's styles customization.
Rules
Rules are functions that map component's props and variables to style objects - the objects that represents mapping from css property names to their corresponding values.
rules
objectroot
property that would return rule function for the component itselfrules
property - this one will have cascading effect on top of default ones (will be merged into them)Variables
Represent parameters of
rules
functions. These parameters should always have names that reflect clear relationship with component's semantics (so that their effect will be intuitive to the client).The following principles are driving 'variables' part:
variables
is a flat object - there shouldn't be any nested objects provided therevariables
object contains all the variables of component, as well as prefixed variables for all its anatomy subcomponents - as propertiesinput
part)padding
variable of the subcomponent)inputPadding
variable should be provided to main componentvariables
property. All the variables that are passed there will override the ones that are introduced by default or by themeCSS properties
styles
attribute of the rendered HTML elementhowever, if we will find ourselves always relying on CSS properties tweaking during components development, it would mean that provided styling system is not flexible enough to meet our needs, so we will need to reconsider our approach
Example
Concerns
While there are clearly some concerns that could be raised by this solution (for example, the one that is highlighted as bold italic - this fact could cause bloat in number of variables required, because each component of higher order will sum up all the variables of its subcomponents, as well as add few of individual ones).
Still, currently it is about the following points being met:
in case if there would be any problems with the implementation approach tat is currently taken - it would be relatively easy to address them. The most critical problems for us will be the ones that are about flaws in the taken approach (its semantics) - all others are solvable. At this point the most simplest approach to implementation is intentionally taken - to prove the concept.