Skip to content

Commit d2f4dab

Browse files
OpenStaxClaudeclaude
authored andcommitted
Fix CSS selectors to correctly target nested styled-components
Address Copilot review comments by fixing CSS selectors that were incorrectly using direct child combinator (>) from .study-guides-wrapper. Since .study-guides-wrapper has display:contents, the styled-components (HighlightsChapterWrapper, HighlightWrapper) are nested inside HighlightsWrapper, not direct children. Changes: - Remove > from .study-guides-wrapper > div selectors - Use div:has(> h2[...]) to precisely target HighlightsChapterWrapper - Use div:has(> h3[...]) to precisely target HighlightWrapper - Update comments to clarify the DOM structure and targeting approach Fixes all four issues identified in the review: 1. Mobile styles for HighlightsChapterWrapper (line 21) 2. Print padding for HighlightsChapterWrapper (line 45) 3. Print margin-left for HighlightWrapper (line 54) 4. Print margin-top for adjacent siblings (line 63) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent d209bd8 commit d2f4dab

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

src/app/content/studyGuides/components/StudyGuides.css

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313

1414
/*
1515
* Mobile styles for HighlightsChapterWrapper
16-
* Target: div containing h2[data-testid="chapter-title"]
16+
* Target: div containing h2[data-testid="chapter-title"] as direct child
17+
* Note: .study-guides-wrapper has display:contents, so HighlightsChapterWrapper
18+
* is inside HighlightsWrapper, which is the direct child
1719
*/
1820
@media screen and (max-width: 75em) {
19-
.study-guides-wrapper > div:has(h2[data-testid="chapter-title"]) {
21+
.study-guides-wrapper div:has(> h2[data-testid="chapter-title"]) {
2022
max-width: 90%;
2123
white-space: nowrap;
2224
overflow: hidden;
@@ -38,25 +40,27 @@
3840
@media print {
3941
/*
4042
* HighlightsChapterWrapper padding
41-
* Target: div containing h2[data-testid="chapter-title"]
43+
* Target: div containing h2[data-testid="chapter-title"] as direct child
4244
*/
43-
.study-guides-wrapper > div:has(h2[data-testid="chapter-title"]) {
45+
.study-guides-wrapper div:has(> h2[data-testid="chapter-title"]) {
4446
padding-left: 0;
4547
}
4648

4749
/*
4850
* HighlightWrapper margin
49-
* Target: divs that don't contain chapter titles (i.e., highlight wrappers)
51+
* Target: divs that contain h3[data-testid="section-title"] (HighlightWrapper)
52+
* These are descendants of HighlightsWrapper, not direct children of .study-guides-wrapper
5053
*/
51-
.study-guides-wrapper > div:not(:has(h2[data-testid="chapter-title"])) {
54+
.study-guides-wrapper div:has(> h3[data-testid="section-title"]) {
5255
margin-left: 0;
5356
}
5457

5558
/*
5659
* HighlightsChapterWrapper + HighlightWrapper margin
57-
* Target: div following chapter wrapper
60+
* Target: Any div immediately following a div that contains h2[data-testid="chapter-title"]
61+
* These are siblings inside HighlightsWrapper
5862
*/
59-
.study-guides-wrapper > div:has(h2[data-testid="chapter-title"]) + div {
63+
.study-guides-wrapper div:has(> h2[data-testid="chapter-title"]) + div {
6064
margin-top: 0;
6165
}
6266

0 commit comments

Comments
 (0)