This repository has been archived by the owner on Sep 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
RFC: Version 1 #149
Open
joe-bell
wants to merge
46
commits into
main
Choose a base branch
from
rfc/v1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
RFC: Version 1 #149
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/joebell/raam/Eqv4zRwRt1eCR4mqX3eSPQNzh9MY |
This was referenced Feb 18, 2021
Merged
To avoid conflicts with different versions of csstype being used in styling libraries, the csstype values that are essential have been hard- coded. Interfaces are used where possible Co-authored-by: joe-bell <joe@joebell.co.uk> Co-authored-by: Piotr Monwid-Olechnowicz <hasparus@gmail.com>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
RFC: Version 1
TL;DR
See the updated docs for further usage guidelines
Problem
Tied to Theme UI (and React.js)
Initially, raam was built to meet my own use-case for needing layout primitives across multiple Theme UI projects. Given that there are many options to choose from in the CSS-in-JS world, it would be foolish not to support others.
Large bundle size
Relying heavily on third-party libraries makes for a rather large bundle size:
22.3kB
7.4kB
Lack of extensibility
raam's layout components make the assumption that you want each item to be wrapped with styles, rather than combined with the item's styles.
Although this approach works well to separate concerns, it makes use-case changes to individual items (such as
flex
, orflexGrow
) difficult/near impossible.Implementation isn't clear
flex
-based layoutsSolution
A complete refactor and separation of concerns
raam
(mixins)Introduces a new 'Mixins' API to support (and encourage) rolling-your-own layout primitives, starting with
flexbox()
Previous layouts such as 'inline' and 'wrap' are accessible via the
variant
option:flexbox({ variant: "wrap" })
.See the updated docs for usage guidelines.
Under-the-hood, raam replaces
gap
with a set of custom properties to control parent and child margins. These are toggled off (back toinitial
) depending on the requirements of specific flex properties; a technique heavily inspired by David Khourshid's "prop-and-lock" technique.@raam/stitches
-util
along withvariants
to spin up your own Flex primitives@raam/tailwind
- plugin to replace existingflex
styles and supportflex-gap
Benefits
Removing components and self-composing the core functionality drastically improves
raam
's bundle size:More importantly, this new architecture makes it a lot easier to maintain; especially around inheriting responsive styles a ton easier.
Caveats
"Why not just use
:first-child
?"Some CSS-in-JS SSR techniques rely on injecting inline
<style>
components which alter the DOM order. Using:first-child
would cause these to gain a margin. Manually definingindex
is a bit of a pain, but it makes it ensures stability.Combining
child
andparent
causes conflicting stylesCSS Custom Properties need thorough testing with various libraries before release.
Future
I'm still keen to implement
rowGap
andcolumnGap
options, and I hope this PR makes it a little easier to add in later.Another idea is to distribute plain CSS versions of raam's primitives, along with a PostCSS plugin
Todo
gap
prop (should support number)flexGap
propraam
fromsrc
. Maybe babel?@raam/stitches
@raam/tailwind
@raam/core