Skip to content
This repository was archived by the owner on May 14, 2021. It is now read-only.

Intelligent guesses for interpolations #110

Closed
mxstbr opened this issue Aug 28, 2017 · 4 comments
Closed

Intelligent guesses for interpolations #110

mxstbr opened this issue Aug 28, 2017 · 4 comments

Comments

@mxstbr
Copy link
Member

mxstbr commented Aug 28, 2017

While the interpolation tagging will already fix most (all?) the edge cases people had with interpolations, there's still a couple of low-hanging fruits where we should have heuristics around what an interpolation likely is.

I think we should be able to do those guesses before we parse for interpolation tags (?), which means we could replace them with the relevant tags and then let the tagging system do it's thing ™️ avoiding a bunch of duplicate logic.

I'm thinking cases like this:

const Bla = styled.div`
  // Heuristic: Interpolation starts with an uppercase letter? (maybe additionally check for block afterwards)
  // Guess: Probably a sc-selector
  ${Button} {
      // Heuristic: First letter after interpolation is a colon?
      // Guess: Probably a sc-property
      ${something}: blue;
  }

  // Heuristic: Interpolation after a colon?
  // Guess: Probably a sc-value
  background: ${bla};

  // Heuristic: Anything not covered by above heuristics?
  // Guess: Probably a rule, replace with current dummy value
  ${someValue}
`
@emilgoldsmith
Copy link
Member

Yep sounds valid. And I also feel that before it could've been argued that guessing was bad as there are always edge cases, but now that we give the user the interpolation tags I think guessing is good as if we guess incorrectly the user can simply use the tags and all is good :).

I'm about to go back to uni and have other things as well, so I think for the near future at least I wouldn't personally take this one on though, just an FYI.

@mxstbr are you thinking of this as something to include in 1.0 or make it a 2.0? Since this would be a breaking change as it would change the way we guess.

@mxstbr
Copy link
Member Author

mxstbr commented Aug 28, 2017

I'm about to go back to uni and have other things as well, so I think for the near future at least I wouldn't personally take this one on though, just an FYI.

No worries 😉 Whenever you find a minute, you know where to find us!

Definitely post-v1, I want to get that out. This isn't like urgent, happy to make it a SemVer-major change.

@mstarkman
Copy link

I just submitted issue #115 that may be related to this.

@chinesedfan
Copy link
Member

Implemented above heuristic guessing by #219. Not 100% accurate, but should be better than doing nothing.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants