Comments (5)
Yeah I get where you're head's at, but I'm reluctant to move in that direction at this moment. The way we use tagged template literals and interpolations makes it difficult to integrate any pure-CSS tool like PostCSS. Which is why we've had to break compatibility already (just minor stuff so far) to get it running where we want.
The other thing is that the two use-cases you mention (object fit polyfill & responsive text) seem far better suited to a component-driven solution (e.g. react-object-fit-cover). Styled Components presupposes both a component system & a runtime JS environment which I feel like can cover most of the things people have needed PostCSS transforms for in the past.
But depending on what #59 ends up with, it might be possible. I'm going to close this in favour of that one, but I'll keep the idea in the back of my head as I work on it.
from styled-components.
csjs has it – maybe you can fork theirs.
But since this library is using postcss internally already there might be a better way, for example here is how we do this in suitcss-preprocessor
from styled-components.
Which plugins would you like to see? We're looking towards linting mostly, which others are interesting to you?
from styled-components.
We're using a modified version of PostCSS internally but we may change that up in future. We're not trying to build a flexible CSS processor we're just providing a minimum of functionality (i.e. nesting). If there are particular transforms people want to use then let us know.
The good news is that a lot of the use cases for postcss transforms can be replaced with pure-JS approaches. I've just updated the docs with an example: https://github.com/styled-components/styled-components/blob/master/docs/tips-and-tricks.md
from styled-components.
The idea is not that we need a specific list of transforms for use with this library, more so that leveraging the previous work and extensive ecosystem of postcss would a great benefit to this project.
A recent, concrete example was that we were wanting to use the object-fit polyfill for certain browsers. There is already a postcss transform designed exactly for our use case. Other things might be responsive text, like we've got in rucksack. It's not really about exactly which ones I want to use, but opening up the tool to leverage an ecosystem that already exists.
One of the things I like about the babel-transform option is that it remove the need for styled-components to have any kind of preprocessing included. You could just set a few sane default postcss plugins and allow the option for addition/overwriting of postcss plugins. csjs has the right idea here in my opinion. They've made a csjs specific babel plugin for postcss transformations at build time. (That is another good reason to use a babel transform, the pure js solutions to postcss (jss has many of these types of things) tend to be designed to run at runtime on the string literal or object. A babel plugin would reduce runtime cost as well as runtime dependency weight.
I can carve out some time to look into this if it's something the styled-components team would consider integrating.
Thanks.
from styled-components.
Related Issues (20)
- Override a styled component that use $ for variables does not pass props correctly HOT 2
- Antd dark theme does not work HOT 1
- Fix plain NodeJS usage
- RNW styles applied twice when using nextjs app directory with react-native-web with SSR HOT 1
- styled-components injects styles for non loaded components on react-native-web
- Simple Styled Component giving error about extending not existing component in Next 14
- Jest test fail on upgrading the styled-components lib version from 5.3.1 to 6.1.8
- correct work in nextjs app route with plugins
- TypeError: __vite_ssr_import_5__.default.div is not a function [fixed]
- `css` props are not applied within the server component.
- Failed to parse `&` multiple times in `:is() :where() :has()` pseudo-class selector
- Theme prop (not styled) is not being passed through HOT 1
- Feature request for v5 to ease migration to v6 of large ecosystems
- Interplay of `shouldForwardProp` clarifying question
- Export the `toStyleSheet` function HOT 3
- createGlobalStyle not working version >= 5.3.1 HOT 1
- [Docs] Lint for pseudo selectors - Styled Components update from v5 to v6 HOT 1
- Tailwind selectors do not work the expected (from me) way
- React SSR Streaming Bug
- Error while building project after upgrading from 5.3.11 to 6.0.0 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styled-components.