-
Notifications
You must be signed in to change notification settings - Fork 182
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 theme that uses the latest block style system + block templates #39
Closed
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
159c9e3
Initial commit.
jffng b9672ff
Clean up What's Here
jffng 7806fdb
Switch to a colorful theme.
jffng 7cf810d
Merge branch 'try/theme-json' of github.com:jffng/theme-experiments i…
jffng 7f4f5e9
Replace local font for simplicity.
jffng 909b9c3
Rename to colorful.
jffng 986283a
Remove reference to local font.
jffng 30a4b6e
Rename textdomain.
jffng c9455ec
Change color preset slugs.
jffng File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Colorful | ||
|
||
Colorful is an experimental WordPress theme that uses the [Block Style System](https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/themes/theme-json.md) and [Block Templates](https://github.com/WordPress/gutenberg/blob/master/docs/designers-developers/developers/themes/block-based-themes.md) to create a minimal theme demo. | ||
|
||
## What's here | ||
|
||
``` | ||
colorful | ||
|__ block-templates | ||
|__ index.html | ||
|__ experimental-theme.json | ||
|__ functions.php | ||
|__ style.css | ||
``` | ||
|
||
## Requirements | ||
|
||
- Gutenberg plugin as of [a271af4872](https://github.com/WordPress/gutenberg/tree/a271af487eb8e04945048cca856c211454b6e56c) | ||
- FSE experiment enabled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<!-- wp:post-content /--> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
{ | ||
"global": { | ||
"presets": { | ||
"color": [ | ||
{ | ||
"slug": "foreground", | ||
"value": "#313131" | ||
}, | ||
{ | ||
"slug": "background", | ||
"value": "#FFDE69" | ||
}, | ||
{ | ||
"slug": "primary", | ||
"value": "#022384" | ||
}, | ||
{ | ||
"slug": "secondary", | ||
"value": "#DB403B" | ||
} | ||
], | ||
"font-size": [ | ||
{ | ||
"slug": "small", | ||
"value": "12px" | ||
}, | ||
{ | ||
"slug": "medium", | ||
"value": "16px" | ||
}, | ||
{ | ||
"slug": "large", | ||
"value": "50px" | ||
} | ||
], | ||
"line-height": [ | ||
{ | ||
"slug": "small", | ||
"value": "1.3" | ||
}, | ||
{ | ||
"slug": "medium", | ||
"value": "1.3" | ||
}, | ||
{ | ||
"slug": "large", | ||
"value": "1.4" | ||
} | ||
], | ||
"font-family": [ | ||
{ | ||
"slug": "primary", | ||
"value": "'Jost', sans-serif" | ||
}, | ||
{ | ||
"slug": "secondary", | ||
"value": "'Lora', serif" | ||
} | ||
], | ||
"gradient": [ | ||
] | ||
}, | ||
"features": { | ||
"typography": { | ||
"dropCap": false | ||
} | ||
} | ||
}, | ||
"core/paragraph": { | ||
"styles": { | ||
"color": { | ||
"text": "var(--wp--preset--color--foreground )" | ||
}, | ||
"typography": { | ||
"fontSize": "var( --wp--preset--font-size--medium )" | ||
} | ||
} | ||
}, | ||
"core/heading/h1": { | ||
"styles": { | ||
"color": { | ||
"text": "var( --wp--preset--color--primary )" | ||
}, | ||
"typography": { | ||
"fontSize": "var( --wp--preset--font-size--large )" | ||
} | ||
} | ||
}, | ||
"core/heading/h2": { | ||
"styles": { | ||
"color": { | ||
"text": "var( --wp--preset--color--primary )" | ||
}, | ||
"typography": { | ||
"fontSize": "28px" | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
<?php | ||
|
||
if ( ! function_exists( 'colorful_theme_setup' ) ) : | ||
/** | ||
* Initialize the theme supports. | ||
*/ | ||
function colorful_theme_setup() { | ||
// Let WordPress manage the document title. | ||
add_theme_support( 'title-tag' ); | ||
|
||
// Alignwide and alignfull classes in the block editor. | ||
add_theme_support( 'align-wide' ); | ||
|
||
// Adding support for core block visual styles. | ||
add_theme_support( 'wp-block-styles' ); | ||
|
||
// Adding support for responsive embedded content. | ||
add_theme_support( 'responsive-embeds' ); | ||
|
||
// Adding support for editor styles. | ||
add_theme_support( 'editor-styles' ); | ||
|
||
// Enqueue stylesheet for the editor. | ||
add_editor_style( get_stylesheet_uri() ); | ||
|
||
// Editor color palette. | ||
// All of these values will be overridden by the theme.json's global => preset => colors array. | ||
add_theme_support( | ||
'editor-color-palette', | ||
array( | ||
array( | ||
'name' => __( 'Foreground', 'colorful' ), | ||
'slug' => 'foreground', | ||
'color' => '#313131', | ||
), | ||
array( | ||
'name' => __( 'Background', 'colorful' ), | ||
'slug' => 'background', | ||
'color' => '#FFDE69', | ||
), | ||
array( | ||
'name' => __( 'Primary', 'colorful' ), | ||
'slug' => 'primary', | ||
'color' => '#022384', | ||
), | ||
array( | ||
'name' => __( 'Secondary', 'colorful' ), | ||
'slug' => 'secondary', | ||
'color' => '#DB403B', | ||
) | ||
) | ||
); | ||
|
||
// Editor font sizes. | ||
add_theme_support( | ||
'editor-font-sizes', | ||
array( | ||
array( | ||
'name' => __( 'Small', 'colorful' ), | ||
'shortName' => __( 'S', 'colorful' ), | ||
'size' => 12, | ||
'slug' => 'small', | ||
), | ||
array( | ||
'name' => __( 'Normal', 'colorful' ), | ||
'shortName' => __( 'M', 'colorful' ), | ||
'size' => 16, | ||
'slug' => 'normal', | ||
), | ||
array( | ||
'name' => __( 'Large', 'colorful' ), | ||
'shortName' => __( 'L', 'colorful' ), | ||
'size' => 50, | ||
'slug' => 'large', | ||
), | ||
) | ||
); | ||
} | ||
endif; | ||
add_action( 'after_setup_theme', 'colorful_theme_setup' ); | ||
|
||
/** | ||
* Enqueue scripts and styles. | ||
*/ | ||
function colorful_theme_blocks_scripts() { | ||
$theme_version = wp_get_theme()->get( 'Version' ); | ||
wp_enqueue_style( 'colorful-theme-blocks-styles', get_stylesheet_uri(), array(), $theme_version ); | ||
} | ||
add_action( 'wp_enqueue_scripts', 'colorful_theme_blocks_scripts' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// this can be empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
/* | ||
Theme Name: Colorful | ||
Text Domain: colorful | ||
Version: 0.1 | ||
Requires at least: 5.3 | ||
Description: A test theme using the experimental WordPress global styles system. | ||
Author: Jeff Ong | ||
Author URI: https://jffng.com/ | ||
License: GNU General Public License v2 or later | ||
License URI: http://www.gnu.org/licenses/gpl-2.0.html | ||
|
||
All files, unless otherwise stated, are released under the GNU General Public | ||
License version 2.0 (http://www.gnu.org/licenses/gpl-2.0.html) | ||
|
||
This theme, like WordPress, is licensed under the GPL. | ||
Use it to make something cool, have fun, and share what you've learned | ||
with others. | ||
*/ | ||
|
||
@import url('https://fonts.googleapis.com/css2?family=Jost:wght@500&display=swap'); | ||
@import url('https://fonts.googleapis.com/css2?family=Lora:wght@500&display=swap'); | ||
|
||
html { | ||
font-size: 16px; | ||
} | ||
|
||
body { | ||
background-color: var( --wp--preset--color--background ); | ||
font-family: var(--wp--preset--font-family--primary); | ||
margin: 0; | ||
overflow-x: hidden; | ||
padding: 0; | ||
} | ||
|
||
p { | ||
font-family: var(--wp--preset--font-family--primary); | ||
line-height: var(--wp--preset--line-height--medium); | ||
} | ||
|
||
p.has-small-font-size { | ||
font-size: var(--wp--preset--font-size--small); | ||
line-height: var(--wp--preset--line-height--small); | ||
} | ||
|
||
p.has-medium-font-size { | ||
font-size: var(--wp--preset--font-size--medium); | ||
line-height: var(--wp--preset--line-height--medium); | ||
} | ||
|
||
p.has-large-font-size { | ||
font-size: var(--wp--preset--font-size--large); | ||
line-height: var(--wp--preset--line-height--large); | ||
} | ||
|
||
/* Support editor custom colors */ | ||
.has-primary-background-color { | ||
background-color: var( --wp--preset--color--primary ); | ||
} | ||
|
||
.has-secondary-background-color { | ||
background-color: var( --wp--preset--color--secondary ); | ||
} | ||
|
||
.has-foreground-background-color { | ||
background-color: var(--wp--preset--color--foreground); | ||
} | ||
|
||
.has-background-background-color { | ||
background-color: var( --wp--preset--color--background ); | ||
} | ||
|
||
.has-background-color { | ||
color: var( --wp--preset--color--primary ); | ||
} | ||
|
||
.has-secondary-color { | ||
color: var( --wp--preset--color--secondary ); | ||
} | ||
|
||
.has-foreground-color { | ||
color: var(--wp--preset--color--foreground); | ||
} | ||
|
||
.has-background-color { | ||
color: var( --wp--preset--color--background ); | ||
} | ||
|
||
.entry-content > * { | ||
margin: 0 auto; | ||
max-width: 580px; /* Match the block editor styles */ | ||
} | ||
|
||
.alignwide { | ||
margin: 0 auto; | ||
max-width: 1070px; | ||
} | ||
|
||
.alignfull { | ||
margin: 0; | ||
max-width: 100%; | ||
} | ||
|
||
.alignwide, .alignfull { | ||
padding: 0 12px; | ||
} | ||
|
||
.wp-block-navigation.is-style-light:not(.has-background) .wp-block-navigation__container, .wp-block-navigation:not(.has-background) .wp-block-navigation__container { | ||
background-color: var( --wp--preset--color--background ); | ||
} | ||
|
||
.wp-block-navigation-link__label { | ||
color: var( --wp--preset--color--secondary ); | ||
font-family: var(--wp--preset--font-family--primary); | ||
font-size: var(--wp--preset--font-size--medium); | ||
line-height: var(--wp--preset--line-height--medium); | ||
text-transform: uppercase; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I see how this does anything. Removing it does not change anything relating to the output or color of an H1 tag. @jffng Would you be able to help me understand what this is doing? 🙏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I haven't been able to get this part to work either (both here and in another theme I tried this with).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the API changed since I first opened this PR. Just pushed some changes that should address it, tested on GB 8.3.