Skip to content

Avoid CSS element selection in table styles #3707

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

Merged
merged 2 commits into from
Apr 19, 2023

Conversation

julieg18
Copy link
Contributor

@julieg18 julieg18 commented Apr 18, 2023

4/4 main <= #3667 <= #3674 <= #3681 <= this

Doing this fixes issues we have with storybook making component styles global (see slack thread) and is a good practice in general (avoids accidental element selection and keeps specificity more equal across selectors).

Part of #3597

@@ -197,10 +197,6 @@ table.withExpColumnShadow tr > *:first-child {
@extend %cellContentsBase;
}

ul {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we are actually using this anywhere.

background-color: $row-border-selected-color;
}
}
}

.nestedRow {
.experimentCell .innerCell {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved these lines to fix a specificity issue but I also think it looks more readable :)

@julieg18 julieg18 marked this pull request as ready for review April 18, 2023 16:46
@@ -113,18 +113,18 @@ $badge-size: 0.85rem;
flex-flow: column nowrap;
}

table {
.table {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Q] Do we want to prefix these with "experiments" to make it more obvious what they are for?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the idea for these classes is that they apply to all table elements, just like they would if I was using element selectors like we were originally. But no huge preference, I can update them with a prefix!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little late to the discussion (we can keep the prefixes), but it's forgetting we are inside of a CSS module. The fact that it gives local names to classes and let us use small meaningful names without prefixing them is the main purpose of using CSS Modules. This cleanup is to move closer to best practices using CSS Modules.

Copy link
Contributor Author

@julieg18 julieg18 Apr 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed that we can simplify names when inside CSS modules but shouldn't that apply to cases when SCSS files are more broken up? Like one file is used for one or a group of similar components? With our current situation, one scss file being used for all experiments components, lengthy names can help to make more sense of things.

Though (I think you mentioned this already in one of these prs if I'm remembering correctly), if we go on to break up this file into more files, simplified names would easily make sense without any risk of confusion.

Again though, no huge preference, just my thoughts!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file is indeed huge, but we are still inside experiments. It's normal to distinguish between something like .headerRow and bodyRow as they would both be found inside of the file, but there is one table and this particular module is inside Experiments.

Like I said, no need to rechange them, but in the future, let's keep short names. If we end up having to use prefixes or suffixes for class names, it's a great sign that our components and style modules are modular enough. (It really is the case here, but we cannot solve it that easily).

@julieg18 julieg18 merged commit 2a9895d into group-table-body-styles Apr 19, 2023
@julieg18 julieg18 deleted the avoid-css-element-selection branch April 19, 2023 12:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants