Comments (4)
hm, interesting. Can you post what this becomes past transpilation for you? :)
from babel-plugin-styled-components.
Sorry for the delay. It also happens on regular sub selectors.
I tested with
const RadioWrap = styled.div`
display: flex-inline;
height: ${p => p.theme.inputHeight}px;
align-items: center;
position: relative; // Our real input likes to run away
input:focus + div {
// Add focus shadow to our checkbox
${p => p.theme.focusShadow};
}
&:hover {
svg {
fill: ${p => p.theme.color.hint};
}
}
`
This is what it looks like without preprocessing:
var RadioWrap = __WEBPACK_IMPORTED_MODULE_3_styled_components__["default"].div.withConfig({
displayName: 'RadioInput__RadioWrap'
})(['\n\tdisplay: flex-inline;\n\theight: ', 'px;\n\talign-items: center;\n\tposition: relative; // Our real input likes to run away\n\tinput:focus + div {\n\t\t// Add focus shadow to our checkbox \n\t\t', ';\n\t}\n\t&:hover {\n\t\tsvg {\n\t\t\tfill: ', ';\n\t\t}\n\t}\n'], function (p) {
return p.theme.inputHeight;
}, function (p) {
return p.theme.focusShadow;
}, function (p) {
return p.theme.color.hint;
});
theme.focusShadow:
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_styled_components__["css"])(['box-shadow: 0 0 5px 0 ', ';'], function (p) {
return p.theme.color.accent.bg;
}),
This is the resulting css:
/* sc-component-id: RadioInput__RadioWrap-gJaBgx */
.RadioInput__RadioWrap-gJaBgx {}
.cDwhCN {display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;height: 25px;-webkit-align-items: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;}.cDwhCN input:focus + div {box-shadow: 0 0 5px 0 rgba(67, 84, 33, 1);;}.cDwhCN:hover svg {fill: rgba(0,0,0,.22);}
and with preprocessing:
var RadioWrap = __WEBPACK_IMPORTED_MODULE_3_styled_components_no_parser___default.a.div.withConfig({
displayName: 'RadioInput__RadioWrap'
})([[' {display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;height: ', function (p) {
return p.theme.inputHeight;
}, 'px;-webkit-align-items: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;}'], [' input:focus + div {', function (p) {
return p.theme.focusShadow;
}, ';}'], [':hover svg {fill: ', function (p) {
return p.theme.color.hint;
}, ';}']]);
theme.focusShadow:
__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_1_styled_components_no_parser__["css"])([[' {box-shadow: 0 0 5px 0 ', function (p) {
return p.theme.color.accent.bg;
}, ';}']]),
css:
/* sc-component-id: RadioInput__RadioWrap-gJaBgx */
.RadioInput__RadioWrap-gJaBgx {}
.cgFzra {display: -webkit-box;display: -webkit-flex;display: -ms-flexbox;display: flex;height: 25px;-webkit-align-items: center;-webkit-box-align: center;-ms-flex-align: center;align-items: center;position: relative;}.cgFzra input:focus + div {;}.cgFzra {box-shadow: 0 0 5px 0 rgba(67, 84, 33, 1);}.cgFzra:hover svg {fill: rgba(0,0,0,.22);}
As you can see, the box-shadow moves out of the input:focus
selector, but I don't understand how, because it does seem to be placed in the correct location in the preprocessed js output.
It also converts flex-inline
to flex
🤔
from babel-plugin-styled-components.
bumping this... main reason we had to disable this awesome plugin :)
from babel-plugin-styled-components.
@jasongornall preprocess
is an experimental option and will soon be removed in favour of a future new idea (more info can be found here: https://github.com/kitten/sweetsour). This means that we currently don't have a replacement for this option, but on the other hand we have something better planned 🙌
from babel-plugin-styled-components.
Related Issues (20)
- Incorrect styles applied bug after v1.10.5 HOT 3
- Css prop no more working with Babel macro HOT 1
- displayName not working with styled-components/macro HOT 3
- babel plugin which will change order of styled components HOT 1
- bumping the babel-plugin-styled-components to 2.0.5 make a regression in performance inside our tests HOT 6
- Performance regression in 1.12.1 HOT 4
- Better naming for styled components nested in objects.
- Doesn't identify styled components in pre-transpiled code HOT 2
- Support for styled-component v6-beta HOT 1
- Babel and corresponding core packages versions 6.25.0 and prior have already reached their end of life. HOT 2
- redundant imports cause default-export version to not be transformed HOT 1
- Npm error while installing latest version (v6.0.0-rc.6) HOT 1
- Vite + babel-plugin-styled-components throws HOT 3
- Compatibility with Million.js HOT 1
- NEED HELP: CSS Styles Not Applied with styled-components v6.0.7 and webpack v5.88.2
- Missing peerDependencies on babel-plugin-styled-components
- Support auto import
- Transform displayName in config
- replace lodash with lodash.difference
- [Bug]: babel-plugin-styled-components is ignored/not working starting Jest 27
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 babel-plugin-styled-components.