Skip to content

Commit f238d69

Browse files
authored
Refactor/base and elements sass (#220)
* Text-selection has been moved, and the heading margins don't seem to be doing much of anything. * No need to have a file just for z-index. * No more z-index file to import. * Removing headings, utility, and all elements styles in favor of a single elements.scss file. * Moving some of the base layout styles out of site-header and removing some fluff from layout.scss. * Removing imports for all the elements styles, headings, and utility files. * Tidying up the elements and normalize files.
1 parent c63edea commit f238d69

14 files changed

+106
-194
lines changed

source/wp-content/themes/wporg-news-2021/sass/elements/_forms.scss source/wp-content/themes/wporg-news-2021/sass/base/_elements.scss

+38
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
// Links
2+
a {
3+
cursor: pointer;
4+
text-decoration: none;
5+
text-decoration-thickness: 1px;
6+
text-underline-offset: 0.15em;
7+
8+
&:hover,
9+
&:focus {
10+
text-decoration-line: underline;
11+
}
12+
}
13+
14+
// Links that appear in the main content area
15+
.block-editor-block-list__layout a, // Needed for the post area
16+
.wp-block-post-content a {
17+
text-decoration-line: underline;
18+
19+
&:hover,
20+
&:focus {
21+
text-decoration: none;
22+
}
23+
}
24+
25+
26+
// Captions
27+
.wp-block-gallery.wp-block-gallery, // Double class for increased specificity.
28+
[class*="wp-block-"] {
29+
figcaption {
30+
font-size: var(--wp--custom--gallery--caption--font-size);
31+
text-align: right;
32+
padding-left: var(--wp--style--block-gap);
33+
padding-right: var(--wp--style--block-gap);
34+
}
35+
}
36+
37+
38+
// Forms
139
input.wp-block-search__input,
240
input[type="text"],
341
input[type="email"],

source/wp-content/themes/wporg-news-2021/sass/base/_headings.scss

-11
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/base/_layout.scss

+20-36
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
// Setup the main container to use a flex box-model
2+
// allowing us to simplify the layout and "sticky" bar.
3+
.wp-site-blocks {
4+
min-height: 100vh;
5+
display: flex;
6+
flex-direction: column;
7+
margin-top: -(var(--wp-admin--admin-bar--height, 0));
8+
9+
// Make sure the footer is always at the bottom of the viewport, even on pages with little content.
10+
// Otherwise there'd be empty space below the footer
11+
justify-content: space-between;
12+
}
13+
14+
// The following "placeholder selectors" define many of the layout-related
15+
// styles for various sections of the site.
16+
// Read more here: https://sass-lang.com/documentation/style-rules/placeholder-selectors
117
%two-column-grid-container {
218

319
@include break-wide() {
@@ -6,10 +22,8 @@
622
calc(var(--wp--custom--layout--content-meta-size) - 32px)
723
auto;
824

9-
/*
10-
* This defines the minimum horizontal gap. An additional implicit gap is created because the right column
11-
* contents have a `max-width` and are justified in the center.
12-
*/
25+
// This defines the minimum horizontal gap. An additional implicit gap is created because the right column
26+
// contents have a `max-width` and are justified in the center.
1327
grid-gap: 0 var(--wp--style--block-gap);
1428
}
1529
}
@@ -70,38 +84,8 @@
7084
display: grid;
7185
grid-template-columns: repeat(4, 1fr);
7286

73-
/*
74-
* This defines the minimum horizontal gap. An additional implicit gap is created because the right column
75-
* contents have a `max-width` and are justified in the center.
76-
*/
87+
// This defines the minimum horizontal gap. An additional implicit gap is created because the right column
88+
// contents have a `max-width` and are justified in the center.
7789
grid-gap: 0 var(--wp--style--block-gap);
7890
}
7991
}
80-
81-
82-
:root {
83-
--wpadmin-bar--height: 46px;
84-
}
85-
86-
.wp-site-blocks {
87-
min-height: 100vh;
88-
display: flex;
89-
flex-direction: column;
90-
91-
/*
92-
* Make sure the footer is always at the bottom of the viewport, even on pages with little content.
93-
* Otherwise there'd be empty space below the footer
94-
*/
95-
justify-content: space-between;
96-
}
97-
98-
body.admin-bar {
99-
100-
@include break-small() {
101-
--wpadmin-bar--height: 32px;
102-
}
103-
104-
.wp-site-blocks {
105-
min-height: calc(100vh - var(--wpadmin-bar--height));
106-
}
107-
}

source/wp-content/themes/wporg-news-2021/sass/base/_normalize.scss

+27-5
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,36 @@ body {
77
// Smooth out the fonts
88
-webkit-font-smoothing: antialiased;
99
-moz-osx-font-smoothing: grayscale;
10-
}
1110

12-
// Needed until https://github.com/WordPress/gutenberg/pull/27518/ is merged.
13-
img {
14-
height: auto;
15-
max-width: 100%;
11+
// Text selection background color
12+
::selection {
13+
background-color: var(--wp--preset--color--coral-red);
14+
}
15+
16+
::-moz-selection {
17+
background-color: var(--wp--preset--color--coral-red);
18+
}
1619
}
1720

21+
// Use (the much easier to comprehend) border-box sizing, which makes it easier
22+
// to define the sizes without having to do a bunch of math.
1823
* {
1924
box-sizing: border-box;
2025
}
26+
27+
// Note: The selector `[class]` is added to increase specificity, to override the inline styles
28+
// on `body` generated by `theme.json`.
29+
body[class] {
30+
@include break-mobile {
31+
// Changing the values of the CSS variables works better than redeclaring the attributes because
32+
// of some issues with precedence, especially in the block editor.
33+
--wp--custom--h-1--typography--font-size: var(--wp--custom--h-1--breakpoint--mobile--typography--font-size);
34+
--wp--custom--h-1--typography--line-height: var(--wp--custom--h-1--breakpoint--mobile--typography--line-height);
35+
--wp--custom--h-2--typography--font-size: var(--wp--custom--h-2--breakpoint--mobile--typography--font-size);
36+
--wp--custom--h-3--typography--font-size: var(--wp--custom--h-3--breakpoint--mobile--typography--font-size);
37+
--wp--custom--h-3--typography--line-height: var(--wp--custom--h-3--breakpoint--mobile--typography--line-height);
38+
--wp--custom--h-4--typography--font-size: var(--wp--custom--h-4--breakpoint--mobile--typography--font-size);
39+
--wp--custom--h-5--typography--font-size: var(--wp--custom--h-5--breakpoint--mobile--typography--font-size);
40+
--wp--custom--h-5--typography--line-height: var(--wp--custom--h-5--breakpoint--mobile--typography--line-height);
41+
}
42+
}

source/wp-content/themes/wporg-news-2021/sass/base/_text.scss

-19
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/base/_utility.scss

-15
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/base/_z-index.scss

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
// Setup the main container to use a flex box-model
2-
// allowing us to simplify the layout and "sticky" bar.
3-
.wp-site-blocks {
4-
display: flex;
5-
margin-top: -(var(--wp-admin--admin-bar--height, 0));
1+
// The container for the site-specific (/news/) menu bar.
2+
.site-header-container {
63

7-
// The container for the site-specific (/news/) menu bar.
8-
.site-header-container {
9-
10-
@include break-small {
11-
position: sticky;
12-
top: 0;
13-
}
4+
@include break-small {
5+
position: sticky;
6+
top: 0;
7+
z-index: 10;
8+
}
149

15-
body.admin-bar & {
16-
padding-top: var(--wp-admin--admin-bar--height, 0);
17-
}
10+
body.admin-bar & {
11+
padding-top: var(--wp-admin--admin-bar--height, 0);
1812
}
1913
}

source/wp-content/themes/wporg-news-2021/sass/elements/_captions.scss

-9
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/elements/_headings.scss

-28
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/elements/_links.scss

-23
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/elements/_lists.scss

-10
This file was deleted.

source/wp-content/themes/wporg-news-2021/sass/page/_404.scss

+10
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,15 @@ body.error404 {
2121
margin-bottom: min(100px, 15vh);
2222
}
2323

24+
ul.is-inline {
25+
display: inline;
26+
margin: 0;
27+
padding: 0;
28+
29+
li {
30+
display: inline;
31+
}
32+
}
33+
2434
@extend %bottom-banner-dark;
2535
}

source/wp-content/themes/wporg-news-2021/sass/style.scss

+2-14
Original file line numberDiff line numberDiff line change
@@ -24,23 +24,11 @@ GNU General Public License for more details.
2424
// Base
2525
// Foundational styles like browser normalization, mixins, layout, z-index.
2626
@import "base/mixins";
27-
@import "base/normalize";
2827
@import "base/breakpoints";
28+
@import "base/normalize";
2929
@import "base/alignment";
30-
@import "base/headings";
3130
@import "base/layout";
32-
@import "base/text";
33-
@import "base/utility";
34-
@import "base/z-index";
35-
36-
37-
// Elements
38-
// Foundational styles that apply to primitive HTML elements.
39-
@import "elements/forms";
40-
@import "elements/headings";
41-
@import "elements/links";
42-
@import "elements/lists";
43-
@import "elements/captions";
31+
@import "base/elements";
4432

4533

4634
// Blocks

0 commit comments

Comments
 (0)