Open superstructor opened 3 years ago
This sounds super promising. Is there any progress or opened pull request for this work?
@sunng87 Thanks. @MawiraIke has done some initial proof of concept branches for a couple of components but we're still finalising the design prior to starting actual impl. @MawiraIke is funded to work on this after he has finished with some higher priority re-frame-10x issues.
Hi. I'm interested in using re-com with tailwind. It looks like you've all been busy with other things, so I've taken a peek at the code and I have a proposal:
Move all of the inline class and style data from the components to a central map structure stored in css.cljs file. Keys will be the name of the component. Values will mirror the structure of the 'parts' parameter.
Create a utility to merge the stored css settings with the user supplied :class, :style and :parts parameters.
Obviously the css has to, on occasion, respond to the state of the component. So the css structure will be able to contain functions as well as strings. The css merging utility will take a map of options to pass in when it finds a function in the structure. The function can then return the appropriate classes or styles based on the options.
Someone who wants to adapt re-com to tailwind or something similar should only need to swap out the central css storage structure.
Foreseen difficulties:
Doesn't involve garden/spade. I haven't had time to investigate these tools and I don't understand them, but imagine they can still be integrated.
CSS won't be near the components that use it.
Shaking out the unused stuff might not work too well.
As a potential solution to #2 and #3 above, instead of a single central data structure, each component could declare its own default class/style structure much like is already done with
To repurpose re-com for other css frameworks, you'll have to hunt down and override all of these *-css-desc
declarations.
So before I start coding, am I missing anything obvious? I've only read through a few of the re-com source files. Are there any tricky corner cases that I might have missed and should know about before I jump in with both feet?
Overview
Resolve all re-com styling issues.
Problems
The styling of re-com is currently a complex layer of:
bootstrap.css
)re-com.css
:class
,:style
,:parts
etc.my-app.css
or my own application's Garden/Spade injections).This leads to issues including:
bootstrap.css
andre-com.css
files to their own projects and include the appropriate links in theirindex.html
fileGoals
bootstrap.css
,re-com.css
and inline styles layers.v-table
row renderers) we want classes, not inline styles. Some benchmarks indicate this should be fasterdatepicker
)disabled?
)datepicker
is not used the code for generating the CSS should not be included in the.js
file and the<style>
tag should not be registered at runtime.Analysis
Proposal
Replace all existing styling with Garden and Spade.
Order of Components
First we will do
dropdown
(i.e. medium complexity) then we will dodatepicker
(i.e. most complex) to immediately verify our working model is good.Process For Each Component
1. State Chart Model
First, we need to understand the abstract model of all the possible states of a component in order to be able to implement a way to style those states.
Write a state chart in PlantUML and embed it in a GitHub Markdown file named after the component (e.g.
src/re_com/datepicker.cljs
would bedocs/datepicker.md
).E.g. for the
dropdown
component it might have adisabled?
and anenabled?
state, and in theenabled?
state it might have states likeopen?
,focused?
etc which fundamentally impact the appearance of the component. Or in other words, what states exist that might need to have different styles or different classes associated with those states ?Make a PR.
2. Parts Model
Second, we need to document all the possible parts (see 'Parts' at bottom of page) of a component.
Although the PlantUML component diagram is talking about a different type of component we could possibly use the 'Grouping Components' syntax as a rendering of part hierarchies. Otherwise, we could just represent it in pure Markdown. Either way, add to the Markdown file created in Step 1.
Make a PR.
3. Restyle Component
re-com.css
andbootstrap.css
(e.g. by commenting out<link..
tags inindex.html
)defclass
.:compose
common styles (e.g.flex-child-style
.unstyled?
parameter to the component that removes all classes and styling that defaults tofalse
.When the component is the same with
unstyled? false
as the existing styling, make a PR.4. Expose Parts and State for Styling
:parts
API:class
or:style
value in:parts
isfn?
then call it with a map of the current component state (e.g.{:disabled? true :open? false :today date}
) and use the return value of the fn<div class="..." data-state="disabled">
)Make a PR.