-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createGlobalStyle not being auto formatted #175
Comments
Same issue, not sure of any side-effects yet but as a workaround, I'm just wrapping the whole thing in the import { createGlobalStyle, css } from 'styled-components';
export default createGlobalStyle`${css`
html,
body,
#root {
padding: 0px;
margin: 0px;
width: 100vw;
height: 100vh;
}
`}`; |
it works |
it not works currently 🙁 |
flowing code works 💪 import * as styled from 'styled-components';
export default styled.createGlobalStyle`
body {
margin: 0;
}
code {
font-family: source-code-pro;
}
`; |
@alikadir That's the best solution thus far. It looks like Prettier is looking for the |
With typescript, if I try to pass the props type definition, createGlobalStyle loses the formatting const GlobalStyles = createGlobalStyle<{prop: any}>`
body {
...
}
` without the props type the formatting works normally |
fixed in 1.0.0 |
Doesn't work for me in VS-Code (1.50.1) on macOS (10.15.7) and with vscode-styled-components (1.2). Actually I'm using the |
@webdevelukas could you paste a snippet of code you would expect to work? (Without the workaround) This will make it easier for me to see the issue |
This won't get formatted: import { createGlobalStyle } from "styled-components"
const GlobalStyles = createGlobalStyle`
* {box-sizing: border-box;
margin: 0; padding: 0;
}
`
export default GlobalStyles |
I'm late to the party but this will also work fine import * as styled from 'styled-components';
const GlobalStyles = styled.createGlobalStyle`
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
`;
export default GlobalStyles; |
This bug ist still not addressed, why is issue marked as resolved? The following block ist not formatted in vscode: import { createGlobalStyle } from 'styled-components'
const GlobalStyle = createGlobalStyle`
html,
body {
padding: 0px;
margin: 0px;
width: 100vw;
height: 100vh;
}
`
export default GlobalStyle |
It bugs my Next.js when using that solution, because babel-plugin-styled-components doesn't quite understand that. |
@luizwhite in nextjs one can write something like this as a workaround import { createGlobalStyle } from 'styled-components'
const styled = { createGlobalStyle }
const GlobalStyle = styled.createGlobalStyle`
body {
margin: 0;
padding: 0;
box-sizing: border-box;
}
...
`
export default GlobalStyle but well I mean... |
This is definitely working for me (as of v1.5.2), we even have it passing in our fixtures https://github.com/styled-components/vscode-styled-components/blob/27a0ab882628646d775989075cfb270085e011f2/src/tests/suite/colorize-fixtures/createGlobalStyle.js Could someone confirm this is still broken and show their extension version? @ibqn I see this when using your example. |
@jasonwilliams no, it's still no working, i.e. code is colorized colorized, but styles are not formatted.
Feel free to let me know, if I somehow can assist here. |
I did some digging into this. You can see its reproduced the same issue. Looks like its been addressed (and not merged) here: |
still no auto formatting here The workaround I am using in my projects is this, as suggested by @ibqn: |
@luizwhite this extension does not do formatting, its a prettier (or whatever formatter you use) issue |
Issue for me was that multiple formatters were active and I just had to pick a default. You can do so by hitting Shift + Option + F and you'll get a window asking to select a default. Simply selecting Prettier here solved the non-formatting issue for me. |
Why does this work? And then is there a way to access the factories? |
renvis's answer fixed it for me. Apparently vscode needs you to choose a default formatter for it, then it knows what to do. Shift + Alt + F on Windows. |
스타일가이드에 추가된 임명장 폰트 작업 px -> pt 수정 GlobalStyle 코드 포메팅이 되지 않는 문제 -> css 서식 불러와서 해결 styled-components/vscode-styled-components#175 (comment)
Anything inside another styled tag will be properly formatted, for example a
styled.div
. But acreateGlobaStyle
function will not have it's contents formatted. Color is still being applied, but formatting won't happen.The text was updated successfully, but these errors were encountered: