Skip to content

Commit 44e30ef

Browse files
author
JoelCDL
committed
Refactor headernav CSS
1 parent af0bff7 commit 44e30ef

1 file changed

Lines changed: 112 additions & 97 deletions

File tree

src/css/components/headernav.css

Lines changed: 112 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,124 @@
11
/***** Header Nav Component *****/
22

33
.c-headernav {
4-
--headernav-section-padding: var(--space3);
5-
--headernav-item-margin: var(--space3);
6-
74
.no-popover & {
85
ul ul {
96
display: none;
107
}
118
}
129

13-
ul {
10+
/* ul {
1411
margin: unset;
1512
padding: unset;
1613
list-style-type: none;
14+
} */
1715

18-
li {
19-
margin: unset;
20-
padding: unset;
21-
}
16+
/* li {
17+
margin: unset;
18+
padding: unset;
19+
} */
20+
21+
/* Panel columns (no columns, by default). These are set via 'columns-[#]' classes defined in the top-level menu items within WP Menus: */
22+
.columns-2 > ul {
23+
column-count: 2;
2224
}
2325

24-
@media (--min-width2) {
25-
a {
26-
display: block;
27-
}
28-
29-
/* Nav bar and top sections: */
30-
> ul {
31-
display: flex;
32-
}
33-
34-
> ul > li {
35-
flex: 1 1 auto;
36-
anchor-scope: all;
37-
38-
&:not(:last-child) {
39-
border-inline-end: 1px solid oklch(55% 0 0deg);
40-
}
41-
}
42-
43-
/* Nav bar links are anchors for popover panels: */
44-
> ul > li > a {
45-
anchor-name: --headernav-anchor;
46-
padding: var(--space1);
47-
background: linear-gradient(oklch(95% 0 0deg), oklch(88% 0 0deg));
48-
color: oklch(36% 0 0deg);
49-
text-align: center;
50-
text-decoration: none;
51-
52-
&:focus,
53-
&:hover {
54-
color: var(--color-blue);
55-
text-decoration: underline;
56-
}
57-
}
26+
.columns-3 > ul {
27+
column-count: 3;
5828
}
29+
}
30+
31+
.c-headernav__section {
32+
flex: 1 1 auto;
33+
anchor-scope: all;
34+
35+
&:not(:last-child) {
36+
border-inline-end: 1px solid oklch(55% 0 0deg);
37+
}
38+
}
39+
40+
/* Nav bar links are anchors for popover panels: */
5941

60-
/* Popover panels: */
61-
[popover] {
62-
position-anchor: --headernav-anchor;
63-
top: anchor(bottom);
64-
left: anchor(left);
65-
margin: 0;
66-
transition: opacity, display, overlay;
67-
transition-duration: 0.3s;
68-
transition-behavior: allow-discrete;
69-
border: unset;
70-
opacity: 0;
71-
72-
&:popover-open {
73-
opacity: 1;
74-
75-
@starting-style {
76-
opacity: 0;
77-
}
42+
.c-headernav__link {
43+
anchor-name: --headernav-anchor;
44+
padding: var(--space1);
45+
background: linear-gradient(oklch(95% 0 0deg), oklch(88% 0 0deg));
46+
color: oklch(36% 0 0deg);
47+
text-align: center;
48+
text-decoration: none;
49+
50+
&:focus,
51+
&:hover {
52+
color: var(--color-blue);
53+
text-decoration: underline;
54+
}
55+
}
56+
57+
.c-headernav__popover {
58+
position-anchor: --headernav-anchor;
59+
top: anchor(bottom);
60+
left: anchor(left);
61+
margin: 0;
62+
transition: opacity, display, overlay;
63+
transition-duration: 0.3s;
64+
transition-behavior: allow-discrete;
65+
border: unset;
66+
opacity: 0;
67+
68+
&:popover-open {
69+
opacity: 1;
70+
71+
@starting-style {
72+
opacity: 0;
7873
}
7974
}
8075

81-
> ul > li > ul {
82-
padding: var(--headernav-section-padding);
83-
column-gap: calc(var(--headernav-section-padding) * 2);
84-
column-rule: 1px solid oklch(88% 0 0deg);
85-
column-width: 9.5em;
86-
border-inline: 1px solid oklch(88% 0 0deg);
87-
border-block-end: 1px solid oklch(88% 0 0deg);
88-
background-color: oklch(95% 0 0deg);
89-
box-shadow: 3px 3px 3px oklch(88% 0 0deg / 70%);
76+
/* ul {
77+
margin: unset;
78+
padding: unset;
79+
list-style-type: none;
80+
} */
81+
82+
/* li {
83+
margin: unset;
84+
padding: unset;
85+
} */
86+
87+
/* Sections: */
88+
89+
> li {
90+
border: solid red;
9091
}
9192

92-
/* Panel columns (no columns, by default). These are set via 'columns-[#]' classes defined in the top-level menu items within WP Menus: */
93-
> ul > .columns-2 > ul {
94-
column-count: 2;
93+
/* Section lists after the section heading link: */
94+
95+
> li > ul {
96+
break-inside: avoid;
97+
border: solid orange;
9598
}
9699

97-
> ul > .columns-3 > ul {
98-
column-count: 3;
100+
/* Keep section links together with section heading link: */
101+
102+
li {
103+
break-inside: avoid;
99104
}
100105

101-
/* Panel lists: */
102-
> ul > li > ul > li {
103-
break-inside: avoid; /* Firefox */
106+
/* Section lists: */
107+
108+
li li {
109+
margin-block-end: 1rem;
104110
}
105111

106-
/* Panel list links: */
107-
> ul > li > ul > li > a {
112+
/* Section heading links: */
113+
114+
> li > a {
108115
margin-block-end: var(--headernav-item-margin);
109116
color: var(--color-dark-red);
117+
}
118+
119+
/* All section links: */
120+
121+
a {
110122
text-decoration: none;
111123

112124
&:focus,
@@ -115,29 +127,32 @@
115127
}
116128
}
117129

118-
/* Panel sub-list 'heading' links: */
119-
> ul > li > ul > li > a:only-child {
120-
color: var(--color-blue);
121-
}
130+
/* Section heading links without a following list: */
122131

123-
/* Panel sub-lists: */
124-
> ul > li > ul > li > ul {
125-
padding-inline: var(--space1);
126-
break-inside: avoid; /* Firefox */
132+
> li > a:only-child {
133+
color: var(--color-blue);
127134
}
135+
}
128136

129-
/* Panel sub-list links: */
130-
> ul > li > ul > li > ul > li > a {
131-
text-decoration: none;
137+
.c-headernav__popover {
138+
padding: var(--space3);
139+
column-gap: calc(var(--space3) * 2);
140+
column-rule: 1px solid oklch(88% 0 0deg);
141+
column-width: 9.5em;
142+
border-inline: 1px solid oklch(88% 0 0deg);
143+
border-block-end: 1px solid oklch(88% 0 0deg);
144+
background-color: oklch(95% 0 0deg);
145+
box-shadow: 3px 3px 3px oklch(88% 0 0deg / 70%);
146+
}
132147

133-
&:focus,
134-
&:hover {
135-
text-decoration: underline;
148+
@media (--min-width2) {
149+
.c-headernav {
150+
a {
151+
display: block;
136152
}
137-
}
138153

139-
/* All panel list items: */
140-
> ul > li li {
141-
margin-block-end: var(--headernav-item-margin);
154+
> ul {
155+
display: flex;
156+
}
142157
}
143158
}

0 commit comments

Comments
 (0)