Add support for selectors/pseudo classes #119
Merged
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.
This PR implements the ability to pass a map of selectors to a
<Box />
with theselectors
prop. This will allow consumers to define more advanced hover/state classes without relying on another css-in-js solution like we do in Evergreen (glamor). This work is based off a branch that @mshwery had started at the start of 2021 but was never finished/merged in.I think this cover the basic use-case but I'd love to have some feedback on whether the design can be improved - or if there are edge cases that I might not be thinking of. This should not introduce a large performance hit from my benchmarking:
Results from
master
branch3,225 ops/sec ±5.74% (52 runs sampled)
3,619 ops/sec ±4.38% (55 runs sampled)
3,595 ops/sec ±3.86% (56 runs sampled)
3,584 ops/sec ±4.03% (54 runs sampled)
3,637 ops/sec ±4.29% (52 runs sampled)
3,563 ops/sec ±4.46% (52 runs sampled)
3,557 ops/sec ±4.48% (55 runs sampled)
3,581 ops/sec ±3.98% (55 runs sampled)
3,536 ops/sec ±4.43% (54 runs sampled)
3,547 ops/sec ±4.32% (54 runs sampled)
3544.4 ops/sec avg
Results from
pseudo-selectors-again
branch3,487 ops/sec ±4.08% (53 runs sampled)
3,485 ops/sec ±4.24% (53 runs sampled)
3,457 ops/sec ±4.36% (53 runs sampled)
3,569 ops/sec ±3.82% (55 runs sampled)
3,529 ops/sec ±4.14% (55 runs sampled)
3,547 ops/sec ±4.32% (52 runs sampled)
3,612 ops/sec ±3.92% (54 runs sampled)
3,156 ops/sec ±6.26% (49 runs sampled)
3,675 ops/sec ±4.17% (54 runs sampled)
3,637 ops/sec ±4.23% (55 runs sampled)
3515.4 ops/sec avg
Demo of the new functionality in Storybook:
