You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a collection of ideas we could consider implementing in @adeira/sx. It's not certain whether every idea is a good idea though so do not consider this to be a roadmap.
🤔 - needs further investigation
🧑💻 - we should develop this
🚧 - under development
✅ - idea implemented
❌ - idea rejected
🧑💻 Babel transpilation
Motivation: transpile away code to reduce the production bundle size and overall performance. We could print the final atomic CSS classes directly into React markup.
Alternatively, we could have something like Relay Compiler for SX to collect the styles in compile-time (since it's an atomic output that grows logarithmically).
It might be a bit strange that we are manipulating "class names" when actually, we want to apply styles. Moreover it's a bit verbose. Why not to write it just like this:
Obviously, this requires a Babel plugin but we are planning it anyway.
🤔 Automatic PX -> REM conversion of fontSize
Originally, we were converting PX units to REM for font size, however, we removed the feature because it disallows us to use the "62.5 trick". We simply didn't want to be too opinionated about it (automatic conversion expects 16px default but 62.5 trick changes it making the conversion wrong).
We might consider something like "SX plugins" to allow such features optionally. Alternatively, we could accept the default pixel value in a config.
importsx,{typeAllCSSProperties}from'@adeira/sx';typeProps={|+xstyle: {|+marginTop: number,// you can restrict what styles are customizable|},|};conststyles=sx.create({default: {fontSize: 16}});functionMyBaseComponent(props: Props){return<divclassName={sx(styles.default,props.xstyle)}/>;}
It would be awesome if you could restrict the type.
It is like a bit more advanced prefixer (prefixers actually cannot transform this). It's worth investigating if we could get rid of the stylis overhead and implement our own version that supports even these advanced cases. We could actually start prefixing very early, even before we start the styles collector. 🤔
Motivation: it's quite difficult to work with atomic CSS classes when developing. Instead, we could generate developer-friendly output in dev and atomic classes only in production.
🤔 Render only used styles by sx
If I define some style in sx.create and don't use it anywhere, the sx.renderStatic still returns it. Could it be done the way only styles used via style('...') will be rendered?
Rejected: SX should work well with CSS as it is and we should avoid inventing some awkward "SX only" patterns. Instead, we could somehow use or suggest CSS Logical Properties.
This discussion was converted from issue #996 on December 08, 2020 15:21.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This is a collection of ideas we could consider implementing in
@adeira/sx
. It's not certain whether every idea is a good idea though so do not consider this to be a roadmap.Legend:
🤔 - needs further investigation
🧑💻 - we should develop this
🚧 - under development
✅ - idea implemented
❌ - idea rejected
🧑💻 Babel transpilation
Motivation: transpile away code to reduce the production bundle size and overall performance. We could print the final atomic CSS classes directly into React markup.
Alternatively, we could have something like Relay Compiler for SX to collect the styles in compile-time (since it's an atomic output that grows logarithmically).
🧑💻 Jest snapshot serializer
Inspiration: https://github.com/dmiller9911/jest-aphrodite-react
First SX version: #2188
🤔 Additional Eslint rules
🤔 Better usage DX
Currently, we have to write this:
It might be a bit strange that we are manipulating "class names" when actually, we want to apply styles. Moreover it's a bit verbose. Why not to write it just like this:
Or:
It might get a bit weird here:
Obviously, this requires a Babel plugin but we are planning it anyway.
🤔 Automatic PX -> REM conversion of
fontSize
Originally, we were converting PX units to REM for font size, however, we removed the feature because it disallows us to use the "62.5 trick". We simply didn't want to be too opinionated about it (automatic conversion expects 16px default but 62.5 trick changes it making the conversion wrong).
We might consider something like "SX plugins" to allow such features optionally. Alternatively, we could accept the default pixel value in a config.
🤔 Merging of custom styles with limited Flow type
Currently, this is possible:
However, this is NOT possible:
It would be awesome if you could restrict the type.
🤔 Automatic stylesheet transformation
Transform this:
Into this:
It is like a bit more advanced prefixer (prefixers actually cannot transform this). It's worth investigating if we could get rid of the
stylis
overhead and implement our own version that supports even these advanced cases. We could actually start prefixing very early, even before we start the styles collector. 🤔Another useful transformation would be from this:
Into this:
See:
Button
left with hover state on iOS #2935🤔 Improve DX when in
__DEV__
Motivation: it's quite difficult to work with atomic CSS classes when developing. Instead, we could generate developer-friendly output in dev and atomic classes only in production.
🤔 Render only used styles by
sx
Motivation: Tailwind CSS wrapper, see: https://adeira.slack.com/archives/C2J04DL01/p1598647663000500
✅ Finished or rejected improvements (click to expand)
Please note that the current version might include different decisions or implementation. Always consult the latest docs rather than these PRs. ✌️
✅ Support for external styles merging (#1352)
See: https://youtu.be/9JZHodNR184
✅ Eslint rules for
sx()
andsx.create()
Motivation:
className={`${styles('aaa')} ${styles('bbb')}`}
(ef2e493)styles({ blue: isBlue, red: isRed })
) (SX Eslint: improve detection of unused styles for conditional objects #2028)use-logical-properties
#2621)✅
@keyframes
support (cd71541)Motivation: https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes
❌ Include some simple CSS reset (#1196, eventually removed)
Motivation: developer experience so you don't have to include the reset stylesheet manually. This could be an opt-in feature.
✅ Autoprefixer based on Browserlist info (#1480, #1467)
Motivation: automatically prefix some problematic properties for older browsers. Inspiration:
✅ SX function could accept an object with booleans (#1809)
At this moment, we allow the following syntax for conditional styles:
We could also allow this:
See: https://youtu.be/9JZHodNR184
❌ Utility
sx.inline
Motivation: to be able to define a single stylesheet instead of using
sx.create
and defining only one named stylesheet there.Concerns: runtime vs. compile type caching (performance).
❌ Support for
marginEnd
,marginVertical
, ...Motivation: easy support for RTL/LTR layouts, see https://reactnative.dev/docs/layout-props#marginend
Rejected: SX should work well with CSS as it is and we should avoid inventing some awkward "SX only" patterns. Instead, we could somehow use or suggest CSS Logical Properties.
Beta Was this translation helpful? Give feedback.
All reactions