-
Notifications
You must be signed in to change notification settings - Fork 1
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
Add specificity to css selectors #3
base: master
Are you sure you want to change the base?
Conversation
src/utils/getComponentCssSelector.js
Outdated
*/ | ||
export default function getComponentCssSelector(componentName: string, options: Object) { | ||
if (options && options.specificityClass) { | ||
return `.${options.specificityClass} .${componentName}` |
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'd like to see us support more than one specificityClass... can we support an array here? While we think one level of increased specificity is enough for our purposes now, we don't know for certain and other consumers of the framework may need it as well.
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.
As mentioned in the related PR, these are usually called "namespace classes". Perhaps that terminology would be more clear.
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.
lgtm
The linter...maybe they updated the linting rule at some point but it only runs against staged files.
Also I'm disappointed in git for these poor diffs, it looks like a bigger change than it actually is.
Yeah, when we open a PR on the real repository, we need to make certain we aren't pushing lint-induced changes. |
unsubscribeFromContext() { | ||
if (this.unsubscribeId !== -1) { | ||
this.context[CHANNEL_NEXT].unsubscribe(this.unsubscribeId) | ||
const createBaseStyledComponent = (options: Object) => { |
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.
This diff is still really bad. I tried a second time.
let namespaceClass = options.namespaceClasses | ||
if (Array.isArray(options.namespaceClasses)) { | ||
namespaceClass = options.namespaceClasses.join(' .') | ||
} |
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.
👍
4fdffa6
to
6c21bb9
Compare
Allows the specificity of the css selector for a styled component to be modified through the options.
It passes through the options to the BaseStyledComponent so that it can call the css
generateAndInjectStyles
with the options. The specificityClass is set in options and used to increase the specificity of all classes.This works with QuickBase/babel-plugin-styled-components#1 to apply the options through babel.