Skip to content
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

Please support other libraries as well #14

Open
kof opened this issue Oct 13, 2017 · 22 comments
Open

Please support other libraries as well #14

kof opened this issue Oct 13, 2017 · 22 comments

Comments

@kof
Copy link

kof commented Oct 13, 2017

For e.g. styled-primitives library based on JSS http://cssinjs.org/styled-jss/ and core JSS and http://cssinjs.org/react-jss

I am happy to help where I can.

@paulmolluzzo
Copy link
Collaborator

Thanks for the suggestion! Any ideas on what we would need to do to support those libraries? Is it just auto completing to the usual CSS string or something more than that?

Ultimately (as least for VS Code) there should be a means on discovering which syntax you want so the autocomplete provides those suggestions. Right now VS Code just provides suggestions in any JS file with no regard for scope. 😕

Of course PRs welcome, but maybe first we can just define the needed features.

@kof
Copy link
Author

kof commented Oct 18, 2017

React-JSS example

import injectSheet from 'react-jss'

const styles = {
  label: {
    fontWeight: 'bold'
  }
}

export default injectSheet(styles)(Component)

What do we need to identify styles in such case?

@kof
Copy link
Author

kof commented Oct 18, 2017

Styled-JSS is similar to styled components at this point

import styled from 'styled-jss'

const Button = styled('button')({
  fontSize: 12,
  color: (props) => props.theme.textColor
})

@ansumanshah
Copy link
Owner

We currently support the styled-jss syntax as any function with name styled/css is supported

but for react-jss I feel as it is a general object syntax we can't do much, maybe at max we can check wherever name of the an object is styles we can show autocomplete in that case (not sure of the performance issue it can/maybe cause)

@kof
Copy link
Author

kof commented Oct 18, 2017

what about following injectSheet(styles) function call?

@kof
Copy link
Author

kof commented Oct 18, 2017

So Styled-JSS is supported, even though it uses objects, not strings?

@kof
Copy link
Author

kof commented Oct 18, 2017

ok tried styled-jss and glamorous, it works, awesome! Lets add examples!

@ansumanshah
Copy link
Owner

actually any function call with a name that follows the regex glamorous|css|style|StyleSheet.create is valid for now, even if it contains string literals, that is a bug I think

@kof
Copy link
Author

kof commented Oct 18, 2017

so you are tracking function calls with a regex, thats why it needs to be an obejct directly like css({...}), not css(objectRef)

@ansumanshah
Copy link
Owner

yes css(objectRef) would not work as we are not parsing the whole file for all calls

@ansumanshah
Copy link
Owner

Would you suggest a way if that could work?

@kof
Copy link
Author

kof commented Oct 18, 2017

Would you suggest a way if that could work?

If we start parsing javascript with a real parser?

@ansumanshah
Copy link
Owner

babel parser fails as the input is not a valid js when user is typing

@kof
Copy link
Author

kof commented Oct 18, 2017

Can we make an assumption what valid js would be in our specific case and give babel parser something that is valid?

@kof
Copy link
Author

kof commented Oct 18, 2017

If it is all too complicated, we can just say that injectSheet({}) needs to be used, no refs. It would be a limitation, but at least something working.

@kof
Copy link
Author

kof commented Oct 18, 2017

functions we have right now is injectSheet() and createStyleSheet() (core JSS)

@kof
Copy link
Author

kof commented Oct 18, 2017

Also I assume @injectSheet() already works, because it looks like a fn call for the regex, right?

@ansumanshah
Copy link
Owner

regex is editable in the settings we can specify more defaults as well, we can try with the
const styles = {}; object as well and check for issues if any.

@kof
Copy link
Author

kof commented Oct 18, 2017

Cool, yeah better defaults is nice, because people will fail to edit those settings 90% of the time and then ask why it doesn't work)

@ansumanshah
Copy link
Owner

True, default are specified here for now and I am not that good with regex so we will have to cross check cases for now

@peteruithoven
Copy link

A totally different approach might be to also look at file extensions. This could be used when using:

  • separate .jss files with just the jss code
  • Webpack (so you could add a .jss loader config)

The list of supported extensions would need to be configurable to support other css-in-js approaches.

Beside supporting a smaller usecase, would there be downsides to this?

@kosaki08
Copy link

kosaki08 commented Feb 21, 2024 via email

Repository owner deleted a comment from BhavyClover Feb 22, 2024
Repository owner deleted a comment from mepcovenkat97 Feb 23, 2024
@github-staff github-staff deleted a comment from flexipgroup May 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@kof @peteruithoven @paulmolluzzo @ansumanshah @kosaki08 and others