-
Notifications
You must be signed in to change notification settings - Fork 187
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
Allow disabling of !important appending via aphrodite/no-important #104
Conversation
I made it Please refrain in this PR from discussing whether or not you think |
You need a file in the root of the built package, which with the current setup probably means the root of the repo. It can be as simple as
|
|
||
const css = (...styleDefinitions) => { | ||
// Do not append !important to style definitions | ||
return injectAndGetClassName(false, styleDefinitions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make it so you don't need the comment above, I would recommend giving that boolean a name:
const useImportant = false;
return injectAndGetClassName(useImportant, styleDefinitions);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see your intent, but I think the comment is more descriptive than that variable name, and it ends up being the same # of lines. If this thing had many arguments of ambiguous meaning, I'd be more inclined to the go the variable naming route (possibly still keeping the comments above the variable declarations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just prefer to avoid comments where I can because they can go out of date. Also, unless you know the function signature, you don't know that this comment is referring to the false
argument... It almost looks like a todo
comment that's missing the TODO
pragma.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In personal experience, comments only tend to get out of date when they're far removed from the thing they apply to spacially (e.g. a comment discussion caveats of function use). I've rarely seen comments a single line above what they apply to get out of date when you have a sane code reviewing process in place.
I do see your point about the non-obvious connection between the comment and the false
here, so I'm happy to take the hybrid approach and include the variable too.
This looks great to me |
* Inject styles associated with the passed style definition objects, and return | ||
* an associated CSS class name. | ||
* | ||
* @param {boolean} useImportant If true, will |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, forgot the rest of this sentence. Will fix.
nit: a vote from me for |
validDefinitions.map(d => d._definition)); | ||
|
||
return className; | ||
const useImportant = true; // Append !important to all style definitions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, this is much more clear 👍
+1 from me too. I've never heard Out of interest, I looked it up
|
Switched to |
LGTM! |
This is a non-breaking change to make it possible to use Aphrodite without it automatically appending
!important
to your styles, but does not make it the default.Fixes #25.
Also see discussion in #102, #41.