[RFC] Pigment CSS v1: Package Structure and API Design #362
Labels
RFC
Request For Comments
status: waiting for maintainer
These issues haven't been looked at yet by a maintainer
What's the problem?
The current Pigment CSS implementation is tightly coupled with Material-UI specific paradigms:
styleOverrides
andcomponents
handling for Material UI's themeslot
functionality that's not core to CSS-in-JSThe current architecture makes it difficult to:
What are the requirements?
Core Functionality:
Developer Experience:
Performance:
What are our options?
Option 1: Enhance Current Architecture
Option 2: Complete Rewrite
Option 3: Modular Refactor (Proposed)
Proposed solution
1. Package Structure
2. Core APIs
Theme Management
Styling
Digressing for the currently released version
theme
-> In current version or the one supporting Material UI, the theme object, besides the tokens itself contains a lot of configuration, likesxConfig
, utils liketheme.breakpoints.up/down
, component styling liketheme.components
, component's default props throughtheme.props
.In v1, theme will purely be a nested collection of tokens and will mostly involve primitive values like
string
ornumber
. You can still add methods to the theme but they won't be part of the final runtime. You can only use those methods in your css definition (same as theme.breakpoints.up). They won't carry any extra meaning for any of the components.css
orstyled
calls will be part of css layers that'll decide the precedence so that it is easier to override base styles of derived styled components. This does not happen in the current release.Stitches
like API instead of just allowing variants array (similar to compound variants).3. Bundler Integration
Mostly same as the current configuration with more options to customize the output css or class names, like
This will also be through typescript to get suggestions in the code.
4. CSS Output Structure
The layers will help users to easily override the base or variant styles of derived styled components like -
This can be easily achieved with layers in context of build time css extraction.
Output CSS
Migration Strategy
Resources and benchmarks
https://github.com/mui/pigment-css/tree/master/packages/pigment-css-theme
#345
Core Package
React package
The text was updated successfully, but these errors were encountered: