Skip to content
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

Add a block based theme option #238

Draft
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions themes/10up-block-theme/.eslintrc
Copy link
Member

Choose a reason for hiding this comment

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

thought: we should add this to the .editorconfig file and make sure it's formatted like the other rc files.

https://github.com/10up/wp-scaffold/blob/trunk/.editorconfig#L10

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"extends": [
"@10up/eslint-config/wordpress"
]
}
14 changes: 14 additions & 0 deletions themes/10up-block-theme/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"*.css": [
"10up-toolkit lint-style"
],
"*.js": [
"10up-toolkit lint-js"
],
"*.jsx": [
"10up-toolkit lint-js"
],
Comment on lines +5 to +10
Copy link
Member

Choose a reason for hiding this comment

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

question: should we add ts and tsx here?

"*.php": [
"./vendor/bin/phpcs --extensions=php --warning-severity=8 -s"
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: these arguments should in the config itself to prevent inconsistencies with IDE integration and lintstagedrc

    <fileextensions>
        <extension>php</extension>
    </fileextensions>

    <!-- Set the severity level for warnings -->
    <arg name="warning-severity" value="8"/>

    <!-- Show sniff codes in output (-s option) -->
    <arg name="s"/>

]
}
1 change: 1 addition & 0 deletions themes/10up-block-theme/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
engine-strict=true
1 change: 1 addition & 0 deletions themes/10up-block-theme/.nvmrc
Copy link
Member

Choose a reason for hiding this comment

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

question: can we bump this to the latest LTS?

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
4 changes: 4 additions & 0 deletions themes/10up-block-theme/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
local-packages/
node_modules/
dist/
vendor/
339 changes: 339 additions & 0 deletions themes/10up-block-theme/LICENSE.md

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions themes/10up-block-theme/assets/css/base/align.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
body .is-layout-constrained > :where(:not(.alignfull, .wp-block-image)) {

&.alignright {
margin-right: var(--wp--custom--main-content-width-side-spacing);
max-width: calc(var(--wp--style--global--content-size) / 2);
}

&.alignleft {
margin-left: var(--wp--custom--main-content-width-side-spacing);
max-width: calc(var(--wp--style--global--content-size) / 2);
}
}

body .is-layout-constrained.has-global-padding > :where(:not(.alignfull, .wp-block-image)) {

&.alignleft {
margin-left: calc(var(--wp--custom--main-content-width-side-spacing) - var(--wp--style--root--padding-left));
}

&.alignright {
margin-right: calc(var(--wp--custom--main-content-width-side-spacing) - var(--wp--style--root--padding-right));
}
}

body .is-layout-constrained > .is-layout-flow.alignwide {

& .alignleft {
margin-left: 0;
}

& .alignright {
margin-right: 0;
}
}

body .has-global-padding > .alignfull {
margin-left: calc(var(--wp--style--root--padding-left) * -1);
margin-right: calc(var(--wp--style--root--padding-right) * -1);
}
4 changes: 4 additions & 0 deletions themes/10up-block-theme/assets/css/base/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url("reset.css");
@import url("link.css");
@import url("layout.css");
@import url("align.css");
73 changes: 73 additions & 0 deletions themes/10up-block-theme/assets/css/base/layout.css
Copy link
Member

Choose a reason for hiding this comment

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

question: why do we need the backwards compatibility? if a new project is started they won't be referencing the old variables and existing projects are not backwards porting future wp-scaffold updates

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* These are deprecated fallbacks for the variables that now live in the
* theme.json file. They are here to ensure backwards compatibility with
* older themes that do used these variables in their styles.
*/
:root {
--full-viewport-width: var(--wp--custom--full-viewport-width);
--site-outer-padding: var(--wp--custom--site-outer-padding);
--site-content-width: var(--wp--custom--site-content-width);
--main-content-width-side-spacing: var(--wp--custom--main-content-width-side-spacing);
--main-wide-width-side-spacing: var(--wp--custom--main-wide-width-side-spacing);
/* stylelint-disable-next-line length-zero-no-unit */
--site-header-top-offset: var(--wp-admin--admin-bar--height, 0px);

&.has-pinned-header {

Choose a reason for hiding this comment

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

Is has-pinned-header a class generated by WP in any way? This seems a bit unnecessary unless there is some mechanism by which that would be commonly added in addition to the --header-height var.

Copy link
Member Author

Choose a reason for hiding this comment

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

Whoops, yeah these should be removed. They are project specific

--site-header-top-offset: calc(var(--header-height) + var(--wp-admin--admin-bar--height, 0px));
}
}

html {
scroll-behavior: smooth;
}

/*
* Remove the default margin caused by global block-gap
* from the header and footer template parts
*/
.wp-site-blocks {
display: grid;
grid-template-areas:
"header"
"main"
"footer";
grid-template-columns: 1fr;
grid-template-rows: auto 1fr auto;
min-height: 100vh;
min-height: 100dvh;

& > header:where(.wp-block-template-part) {
grid-area: header;
margin-block-end: 0;
}

& > main {
grid-area: main;
height: 100%;
}

& > footer:where(.wp-block-template-part) {
align-self: flex-end;
grid-area: footer;
margin-block-start: 0;
}
}

.wp-block-group:where(:not(:has(> :first-child[style*="margin"], > :last-child[style*="margin"]))) {

@mixin margin-collapse;
}


.has-global-padding :where(.has-global-padding.is-layout-constrained) {
padding-left: var(--wp--style--root--padding-left);
padding-right: var(--wp--style--root--padding-right);
}

.is-layout-constrained .wp-block-image.alignwide {
max-width: min(100%, var(--wp--style--global--wide-size)) !important;
}

.wp-block-post-template.is-layout-flex {
align-items: stretch;
}
11 changes: 11 additions & 0 deletions themes/10up-block-theme/assets/css/base/link.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Ensure that we are not overriding the editor styles of the
* WordPress Components.
*
* This is a workaround for: https://github.com/WordPress/gutenberg/issues/10178
*
* using :where to prevent the specificity increase of using :not
*/
a:where(:not(.components-external-link, :has(> img:only-child), .wp-element-button)) {

Choose a reason for hiding this comment

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

I would like to see a similar file for form elements. I've seen a few projects that don't scope their input/select etc selectors and it affects the editor placeholder components. I've used the following with success to prevent bleeding into those.

// base/forms.css
&:where(:not(.components-placeholder)) {

    input {...}
}


}
85 changes: 85 additions & 0 deletions themes/10up-block-theme/assets/css/base/reset.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*

Choose a reason for hiding this comment

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

I've been adding this to my resets as well to ensure alt tags remain readable if the image doesn't load. Sometimes you see folks put font-size: 0; or line-height: 0 on figure/div tags to avoid that small bit of white space that can occur, this protects against that situation.

img {
  font-size: 1rem;
  font-style: italic;
  line-height: 1.5;
}

* Use a more-intuitive box-sizing model.
*/
*,
*::before,
*::after {
box-sizing: border-box;
}

/*
* Allow percentage-based heights in the application
*/
html,
body,
.wp-site-blocks {
min-height: 100%;
}

/*
* Remove height from the admin bar of the overall height
*/
html {
height: calc(100% - var(--wp-admin--admin-bar--height, 0px));
}


/*
* Improve text rendering
*/
body {
-webkit-font-smoothing: antialiased;
}

/*
* Improve media defaults
*/
img,
picture,
video,
canvas,
svg {
display: block;
height: auto;
max-width: 100%;
}

/*
* Remove built-in form typography styles
*/
input,
button,
textarea,
select {
font: inherit;
}

/*
* Avoid text overflows
*/
p,
h1,
h2,
h3,
h4,
h5,
h6 {
overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
text-wrap: balance;
text-wrap: pretty; /* pretty is the nicer result but it isn't supported as well. So balance is here as a fallback */
}

/*
* Create a root stacking context
*/
.wp-site-blocks {
isolation: isolate;
}
Empty file.
Empty file.
72 changes: 72 additions & 0 deletions themes/10up-block-theme/assets/css/editor-style-overrides.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Override the styling of the post title in the post editor
* to make it look as though it's part of the editor frame instead
* of the post content.
*/
.edit-post-visual-editor__post-title-wrapper {
background-color: #fff; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
border-bottom: 1px solid #e0e0e0;
margin-bottom: 0;
margin-top: 0 !important;
max-width: none;
overflow: hidden;
width: 100%;

& .wp-block-post-title {
color: #000; /* stylelint-disable-line scale-unlimited/declaration-strict-value */
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
font-size: 16px;
height: auto;
line-height: 1;
padding: 4px 0;
}
}

/*
* Define the various widths of editor interface elements.
* Sadly these are not exposed as CSS variables, so we have to
* manually define them here and update them if they ever change.
*/
:root {
--wp--interface--sidebar--width: 280px;
--wp--interface--secondary--sidebar--width: 350px;
}

/*
* Substract Inspector Controls Width from full viewport width if open
*/
.interface-interface-skeleton.is-sidebar-opened .editor-styles-wrapper {
--wp--custom--full-viewport-width: calc(100vw - var(--wp--interface--sidebar--width));
}

/*
* Substract List View Width from full viewport width if open
*/
.interface-interface-skeleton__secondary-sidebar ~ .interface-interface-skeleton__content .editor-styles-wrapper {
--wp--custom--full-viewport-width: calc(100vw - var(--wp--interface--secondary--sidebar--width));
}

/*
* Substract both List View and Inspector Controls
* Width from full viewport width if open
*/
.interface-interface-skeleton.is-sidebar-opened .interface-interface-skeleton__secondary-sidebar ~ .interface-interface-skeleton__content .editor-styles-wrapper {
--wp--custom--full-viewport-width: calc(100vw - var(--wp--interface--secondary--sidebar--width) - var(--wp--interface--sidebar--width));
}

.wp-block-image img[src$=".svg"] {
height: auto;
}

.is-root-container {
min-height: 90dvh;
}

/*
* Small editor blocks like the footer social nav are hard to click
* Setting a min-height so that elements can be selected to edit
* Prior to this scrollbars overlap small elements
*/
.block-editor-iframe__container {
min-height: 70px;
}
4 changes: 4 additions & 0 deletions themes/10up-block-theme/assets/css/frontend.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
@import url("base/index.css");
@import url("templates/index.css");
@import url("components/index.css");
@import url("utilities/index.css");
Empty file.
25 changes: 25 additions & 0 deletions themes/10up-block-theme/assets/css/globals/media-queries.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* Media Queries
*/

/* tiny */
@custom-media --bp-tiny ( min-width: 24.375rem ); /* 390px */
@custom-media --bp-tiny-max ( max-width: 24.3125rem ); /* 389px */

/* small */
@custom-media --bp-small ( min-width: 37.5rem ); /* 600px */
@custom-media --bp-small-max ( max-width: 37.4375rem ); /* 599px */

/* medium */
@custom-media --bp-medium ( min-width: 60rem ); /* 960px */
@custom-media --bp-medium-max ( max-width: 59.9375rem ); /* 959px */

/* large */
@custom-media --bp-large ( min-width: 80rem ); /* 1280px */
@custom-media --bp-large-max ( max-width: 79.9375rem ); /* 1279px */

/* WP Core Breakpoints (used for the admin bar for example) */
@custom-media --wp-small ( min-width: 600px );
@custom-media --wp-small-max ( max-width: 599px );
@custom-media --wp-medium (min-width: 783px);
@custom-media --wp-medium-max (max-width: 782px);
10 changes: 10 additions & 0 deletions themes/10up-block-theme/assets/css/globals/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# PostCSS Globals

Any individual `.css` files placed in this folder or any nested folder will automatically get loaded by the [@csstools/postcss-global-data](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-global-data) plugin.

This ensures that the definitions defined in these files become available to all CSS entrypoints. So individual block styles, the main stylesheet, etc. all have access to these definitions.

> [!WARNING]
> These CSS files should not produce any output. They are only meant to define global postcss features to become available to all entrypoints
> Also the loading order of these files should not matter at all. They get auto included via a glob expression.
Mixins also get their special treatment. They have a special [`mixins`](../mixins/) folder located next to this `globals` folder
14 changes: 14 additions & 0 deletions themes/10up-block-theme/assets/css/mixins/margin-collapse.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
@define-mixin margin-collapse {

Choose a reason for hiding this comment

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

I would recommend calling this margin-trim to better reflect what its doing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Agreed! :)

margin-trim: block;

@supports not (margin-trim: block) {

& > *:first-child {
margin-top: 0;
}

& > *:last-child {
margin-bottom: 0;
}
}
}
10 changes: 10 additions & 0 deletions themes/10up-block-theme/assets/css/mixins/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# PostCSS Global Mixins

Any individual `.css` files placed in this folder or any nested folder will automatically get loaded by the [postcss-mixins](https://github.com/postcss/postcss-mixins) plugin.

This ensures that the mixins defined in these files become available to all CSS entrypoints. So individual block styles, the main stylesheet, etc. all have access to these mixins.

> [!WARNING]
> These CSS files should not produce any output. They are only meant to define global postcss features to become available to all entrypoints
> Also the loading order of these files should not matter at all. They get auto included via a glob expression.
Other global definitions such as `@custom-media`, `@custom-selector`, etc. also get their special treatment. They have a special [`globals`](../globals/) folder located next to this `mixins` folder
Empty file.
1 change: 1 addition & 0 deletions themes/10up-block-theme/assets/css/utilities/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url("visually-hidden.css");
Loading
Loading