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

Syntax weirdness? #20

Open
bclinkinbeard opened this issue Dec 17, 2015 · 6 comments
Open

Syntax weirdness? #20

bclinkinbeard opened this issue Dec 17, 2015 · 6 comments
Labels

Comments

@bclinkinbeard
Copy link

This could be my fault, but if it's not then it's probably worth addressing.

/* variables.css */
@value borderRadius: 3px;
@value thing: pink;
/* styles.css */
@value vars: styles/variables.css;

@value borderRadius as br from vars;
@value thing from "styles/variables.css";
import styles from './styles.css'
console.log(styles);

Use case 1: If the first line of styles.css is written with quotes around the file name, like @value vars: "styles/variables.css;", then the value of styles.vars in JS is ""styles/variables.css""; a string that includes the quote marks. I'm not sure if the README just needs to be updated to remove the quotes or if this is a bug.

Use case 2: If quotes are omitted when getting a value directly (@value thing from "styles/variables.css";) the rest of the line is interpreted literally, resulting in the value of styles.thing being "from styles/variables.css". Maybe this is related to the colon being optional?

Basically, it seems odd to require the omission of quotes in Use Case 1 and require the inclusion of quotes in Use Case 2. They're doing nearly the same thing, so I'd expect a consistent syntax.

Is this intended, a bug, or something I'm doing wrong?

@bclinkinbeard
Copy link
Author

I'm also getting build errors when trying this:

@value vars: styles/variables.css;

.myList {
  composes: abs-pos from vars;
}

Instead, it only works with this syntax.

.myList {
  composes: abs-pos from "styles/variables.css";
}

@geelen
Copy link
Member

geelen commented Dec 30, 2015

Yeah that final example I think would have to be:

@value vars: styles/variables.css;

.myList {
  composes: abs-post from "vars";
}

Which makes me sad. I'm thinking that a rule of no quotes in values definitions (see #23) makes sense, but with special handling for replacements within composes statements?

@dspnorman
Copy link

@bclinkinbeard I am also seeing the issue you describe with this syntax:

@value vars: styles/variables.css;

.myList {
  composes: abs-pos from vars;
}

This produces a build error of referenced class name "abs-pos" in composes not found.

It's a shame, because this is the syntax presented as an example on the postcss-modules-values project README, and I imagine quite a few folks being mystified when it doesn't work.

@damassi
Copy link

damassi commented Jul 12, 2016

Any update on this? Running into the same issue as @dspnorman. Is the README incorrect, or our implementation?

@kumarharsh
Copy link

I think the README is wrong. I was also trying for 2-3 hours trying to get this "composes: xxx from yyy" to work, but gave up. Now I see that I was doing it wrong 😄

@OliverJAsh
Copy link

I also ran into this. The README is misleading. My error:

Module build failed: referenced class name "from" in composes not found (6:3)

  4 | .notification {
  5 |   color: primary;
> 6 |   composes: notification from notificationListItem;

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

No branches or pull requests

7 participants