-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
More specific CSS selector for SVG icons. #5352
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,13 @@ import { selectBlock } from '../../store/actions'; | |
* Module constants | ||
*/ | ||
const upArrow = ( | ||
<svg tabIndex="-1" width="18" height="18" xmlns="http://www.w3.org/2000/svg" aria-hidden role="img" focusable="false"> | ||
<svg className="dashicon" width="18" height="18" xmlns="http://www.w3.org/2000/svg" aria-hidden role="img" focusable="false"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Asked about the intent of these icons at #5263 (comment), but I generally would discourage pretending to inherit styles from a separate component. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd agree best would be to have them integrated into Dashicon |
||
<path d="M12.293 12.207L9 8.914l-3.293 3.293-1.414-1.414L9 6.086l4.707 4.707z" /> | ||
</svg> | ||
); | ||
|
||
const downArrow = ( | ||
<svg tabIndex="-1" width="18" height="18" xmlns="http://www.w3.org/2000/svg" aria-hidden role="img" focusable="false"> | ||
<svg className="dashicon" width="18" height="18" xmlns="http://www.w3.org/2000/svg" aria-hidden role="img" focusable="false"> | ||
<path d="M12.293 6.086L9 9.379 5.707 6.086 4.293 7.5 9 12.207 13.707 7.5z" /> | ||
</svg> | ||
); | ||
|
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.
If these styles are targeted at Dashicon, seems sensible that they be added to a
components/dashicon/style.scss
, also because they don't seem specific to Gutenberg.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 far as I know,
components/dashicon/index.js
is a copy from the Dashicons repo, how to import a newcomponents/dashicon/style.scss
in this file if then it gets overridden with any update from the Dashicons repo?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.
It's a tough one. I think long-term this approach of copy-paste from the Dashicons repository is not very sustainable. Ideally we'd just
import
from a Dashicons module. Where that repository lives, I'm not sure (it could even stay where it's at, or be merged to here). Then, we'd changecomponents/dashicon/index.js
to...It's an open question though whether those styles should be bundled with the shared component itself. Alternatively, we could assign the styles as an inline
style
attribute, though of course these are much harder to override in their high specificity.It's possible (though not implemented in Gutenberg anywhere) to implement the styles as a stylesheet from the Dashicon module and import into the project 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.
I understand all the concerns 🙁 However, this issue is specifically about changing the CSS selector used for this rule. The placement of the rule is unrelated. Can we split the two issues and move on?
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 resolving one issue, you've introduced two others which did not exist previously (styles applied to a component outside its stylesheet, ad hoc inheriting styles from a component elsewhere in the codebase). Arguably the style placement code conventions are less important than the user-impacting ones fixed here, but all the same I'm not inclined to give blessing to the accumulation of technical debt.
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.
@aduth: the styles were already in this file. I've just added
.dashicon
🙂 I haven't moved anything nor introduce a new issue. The issue you're pointing out is a pre-existing issue and unrelated.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 is the issue.
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.
It really doesn't change the original issue. The previous CSS selector was already styling the dashicon SVGs.