Comments (31)
@whmountains @mxstbr @kachkaev Can you try language-babel 2.52.0 with auto-complete support. Let me know if you have any comments or issues with it.
from styled-components.
language-babel 2.45.0 now has it's own css grammar styled CSS
that supports both styled CSS out of the box, and normal CSS files, provided the grammar selected is styled CSS
. I think I've added all CSS features, @rules etc that appeared missing from language-css. It now supports autocomplete.
from styled-components.
@whmountains Sorry, just saw your comment. I've just taken a copy of autocomplete-css and begun modifying it. It seems to be working ok but needs a bit more tweaking. I'll probably incorporate it into language-babel rather than have yet another package. Got to do something else first but hopefully I'll roll it out soon.
from styled-components.
Fyi. The latest release now positions the cursor after the semi-colon. If you add a value with parens the cursor is positioned inside the parens and pressing tab moves it to after the value/semi.
from styled-components.
@shanecav The autocomplete bit is provided by Atom's autocomplete-css which assumes that the css is in a proper CSS file. e.g. properties appear inside braces, media statements appear at a top level, etc. That's why you are seeing this issue. If I change the scopes to fix this to allow property autocomplete at the top level then the autocomplete for media, keyframes,... stop working, as these shouldn't appear inside a property block! I may have to provide my own autocomplete to fix this. Bit of a chore but I'll take a look.
from styled-components.
@zaynv @whmountains Actually, it appears there maybe a way for me to do this but I need to get some time to look at it. Emmet seems to have a call that may allow this emmetio/emmet-atom#508 (comment)
from styled-components.
@zaynv @whmountains I've just pushed 2.80.0 that supports emmet in css for styled-components. It's under a flag in the package settings. It uses autocomplete plus to provide a emmet snippet (hopefully) at the top of the pick list. Let me know if you have any issues.
from styled-components.
I asked gandm and the new css grammar parsing is currently being worked on. When complete, other css features in Atom should work in styled-components template strings!
from styled-components.
This is awesome, thanks for the great work @gandm!
One thing I noticed is that autocomplete for CSS rules only seems to work within curly brackets, but isn't working for styled-components where I'm just listing rules within tagged template literals.
e.g. this doesn't enable auto-complete:
const Wrapper = styled.div`
display: flex;
`
but this does:
const Wrapper = styled.div`
& {
display: flex;
}
`
Is there a way around that?
from styled-components.
I hacked together a basic version here: https://github.com/whmountains/autocomplete-css.git. Only thing missing is the psuedo-classes don't auto-complete.
I don't understand the specifics of scopes and I'm having a hard time distinguishing between a psuedo-selector and a property value. @gandm would you mind taking a look? I expect someone who's a seasoned plugin developer would be able to spot the problem right away.
from styled-components.
Thanks for your work @gandm. It will be great to have this come standard!
from styled-components.
Thank you for the amazing work on this. I just have a question about using Emmet
with styled-components
. In normal CSS files, I can write something like:
ta-c
And then if I press tab
, it would autocomplete to text-align: center;
Or doing something like
m0-a
would autocomplete to something like margin: 0 auto
;
Is there some way to replicate this Emmet support within styled-components
in Atom or is it not possible?
from styled-components.
Not yet! I'd love if somebody could hack around on that!
from styled-components.
Amazing!
from styled-components.
(I'll close this for now, but feel free to continue discussing)
from styled-components.
Totally makes sense. Thanks for the explanation!
from styled-components.
@gandm @shanecav have you worked out the solution by a chance? I also wondered if it is possible to enjoy autocomplete in Atom :)
from styled-components.
I really want this! Hope you find the time to do it.
from styled-components.
That's amazing @whmountains! Let's hope @gandm knows the way 😊 Would love to have this!
from styled-components.
@mxstbr Thanks to you for making styled-components. It's awesome!!!
In case anyone wants to try out the version that I just made:
git clone "https://github.com/whmountains/autocomplete-css.git"
cd autocomplete-css
apm link
Now start up Atom, and go to Settings->packages. Disable the autocomplete-css that's listed under "core packages". You should be left with the modified version under "community packages"
from styled-components.
Works great! Thanks @gandm.
Only thing I noticed is that there isn't any autocomplete for media queries. @me
doesn't start auto-completing to @media
. Really that's nitpicking though. I wouldn't care much if it never got fixed. Thanks again for your work!
from styled-components.
@whmountains yes, the completes.json file provided by atom doesn't have any @
completions. I could easily add these.
One thing I don't much like is it adding the semi-colons after a property. I feel inclined to remove that behaviour, but it is how autocomplete-css does it so i left it in here Any views?
from styled-components.
People are loving it! 🎉 Good job @gandm and @whmountains https://twitter.com/mxstbr/status/826840687127752705
from styled-components.
One thing I don't much like is it adding the semi-colons after a property.
I feel like the annoying part is how the semi-colon is after the cursor. Instead of that, it should just be at the end of the line, I think that'd make it better?
from styled-components.
Awesome @gandm, this feels amazing! Well done 👏
from styled-components.
@zaynv , @whmountains No it doesn't look possible. You'd have to change emmet to support this. Firstly you'd have to change the tab key binding to some other key for emmet e.g.
'atom-text-editor[data-grammar="source js jsx"]:not([mini])':
'ctrl-shift-l': 'emmet:expand-abbreviation-with-tab'
but even then emmet checks the scope name of the editor panel here and if it sees JS or JSX in the scope list it returns that as the syntax. This check takes precedence over the following checks for CSS. The scope that is checked in by the above line when inside a styled-componenets string is source.js.jsx source.inside-js.css.styled
so JSX is found in preference to CSS, as it appears earlier in the scope list.
Just using the above keymap means that ta-c
Ctrl-Shift-l would generate some open/close tags as it assumes JSX.
from styled-components.
Nice sleuthing @gandm. You really seem to know your way around the Atom API! 🤓
from styled-components.
@zaynv @whmountains Looking at the code for the atom emmet integration there are two repos - the existing code and a newer one that may be released at some point. In either case there isn't any way of doing this unless emmetio would accept a PR to specifically support this use case. I guess this is a non-starter!
from styled-components.
Hmm, that's unfortunate. Thanks for taking the time to check it out, it is much appreciated!
from styled-components.
Late on this, but thanks so much @gandm you are doing amaznig work
from styled-components.
Probaby worth noting - styled-components autocomplete should be enabled first in Atom's laguage-babel plugin settings like so:
from styled-components.
Related Issues (20)
- Add Support for Easily Configuring a Nonce. HOT 2
- Use the `node:` protocol in ServerStyleSheet.tsx
- Provide setup guide for React Native + Typescript HOT 1
- Update options css for text-wrap HOT 4
- Examples React Native HOT 1
- Having to explicitly set the 'children' prop for EVERY component? HOT 3
- Will styled-components ever support latest react features (server components, streaming, concurrent redering) ? HOT 2
- 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
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.