feat: establish CHRNX block theme foundation
This commit is contained in:
21 files changed
+2394
-13
No files matched your search
@@ -0,0 +1 @@
|
|||||||
|
assets/fonts/OFL.txt -whitespace
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
.worktrees/
|
.worktrees/
|
||||||
node_modules/
|
node_modules/
|
||||||
vendor/
|
vendor/
|
||||||
|
.phpunit.result.cache
|
||||||
dist/
|
dist/
|
||||||
.wp-env.override.json
|
.wp-env.override.json
|
||||||
test-results/
|
test-results/
|
||||||
|
|||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* Local Zen Maru Gothic sources are registered once in theme.json with
|
||||||
|
* font-display: swap.
|
||||||
|
*/
|
||||||
|
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
html {
|
||||||
|
color-scheme: dark;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
background: var(--wp--preset--color--night);
|
||||||
|
color: var(--wp--preset--color--text);
|
||||||
|
}
|
||||||
|
|
||||||
|
img,
|
||||||
|
svg,
|
||||||
|
video {
|
||||||
|
display: block;
|
||||||
|
max-width: 100%;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
input,
|
||||||
|
select,
|
||||||
|
textarea {
|
||||||
|
font: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
a:hover {
|
||||||
|
color: var(--wp--preset--color--green);
|
||||||
|
}
|
||||||
|
|
||||||
|
:focus-visible {
|
||||||
|
outline: 3px solid var(--wp--preset--color--green);
|
||||||
|
outline-offset: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-reduced-motion: reduce) {
|
||||||
|
|
||||||
|
*,
|
||||||
|
*::before,
|
||||||
|
*::after {
|
||||||
|
scroll-behavior: auto !important;
|
||||||
|
transition-duration: 0.01ms !important;
|
||||||
|
animation-duration: 0.01ms !important;
|
||||||
|
animation-iteration-count: 1 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,93 @@
|
|||||||
|
Copyright 2021 The Zen Maru Gothic Project Authors (https://github.com/googlefonts/zen-marugothic)
|
||||||
|
|
||||||
|
This Font Software is licensed under the SIL Open Font License, Version 1.1.
|
||||||
|
This license is copied below, and is also available with a FAQ at:
|
||||||
|
http://scripts.sil.org/OFL
|
||||||
|
|
||||||
|
|
||||||
|
-----------------------------------------------------------
|
||||||
|
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
|
||||||
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
PREAMBLE
|
||||||
|
The goals of the Open Font License (OFL) are to stimulate worldwide
|
||||||
|
development of collaborative font projects, to support the font creation
|
||||||
|
efforts of academic and linguistic communities, and to provide a free and
|
||||||
|
open framework in which fonts may be shared and improved in partnership
|
||||||
|
with others.
|
||||||
|
|
||||||
|
The OFL allows the licensed fonts to be used, studied, modified and
|
||||||
|
redistributed freely as long as they are not sold by themselves. The
|
||||||
|
fonts, including any derivative works, can be bundled, embedded,
|
||||||
|
redistributed and/or sold with any software provided that any reserved
|
||||||
|
names are not used by derivative works. The fonts and derivatives,
|
||||||
|
however, cannot be released under any other type of license. The
|
||||||
|
requirement for fonts to remain under this license does not apply
|
||||||
|
to any document created using the fonts or their derivatives.
|
||||||
|
|
||||||
|
DEFINITIONS
|
||||||
|
"Font Software" refers to the set of files released by the Copyright
|
||||||
|
Holder(s) under this license and clearly marked as such. This may
|
||||||
|
include source files, build scripts and documentation.
|
||||||
|
|
||||||
|
"Reserved Font Name" refers to any names specified as such after the
|
||||||
|
copyright statement(s).
|
||||||
|
|
||||||
|
"Original Version" refers to the collection of Font Software components as
|
||||||
|
distributed by the Copyright Holder(s).
|
||||||
|
|
||||||
|
"Modified Version" refers to any derivative made by adding to, deleting,
|
||||||
|
or substituting -- in part or in whole -- any of the components of the
|
||||||
|
Original Version, by changing formats or by porting the Font Software to a
|
||||||
|
new environment.
|
||||||
|
|
||||||
|
"Author" refers to any designer, engineer, programmer, technical
|
||||||
|
writer or other person who contributed to the Font Software.
|
||||||
|
|
||||||
|
PERMISSION & CONDITIONS
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of the Font Software, to use, study, copy, merge, embed, modify,
|
||||||
|
redistribute, and sell modified and unmodified copies of the Font
|
||||||
|
Software, subject to the following conditions:
|
||||||
|
|
||||||
|
1) Neither the Font Software nor any of its individual components,
|
||||||
|
in Original or Modified Versions, may be sold by itself.
|
||||||
|
|
||||||
|
2) Original or Modified Versions of the Font Software may be bundled,
|
||||||
|
redistributed and/or sold with any software, provided that each copy
|
||||||
|
contains the above copyright notice and this license. These can be
|
||||||
|
included either as stand-alone text files, human-readable headers or
|
||||||
|
in the appropriate machine-readable metadata fields within text or
|
||||||
|
binary files as long as those fields can be easily viewed by the user.
|
||||||
|
|
||||||
|
3) No Modified Version of the Font Software may use the Reserved Font
|
||||||
|
Name(s) unless explicit written permission is granted by the corresponding
|
||||||
|
Copyright Holder. This restriction only applies to the primary font name as
|
||||||
|
presented to the users.
|
||||||
|
|
||||||
|
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
|
||||||
|
Software shall not be used to promote, endorse or advertise any
|
||||||
|
Modified Version, except to acknowledge the contribution(s) of the
|
||||||
|
Copyright Holder(s) and the Author(s) or with their explicit written
|
||||||
|
permission.
|
||||||
|
|
||||||
|
5) The Font Software, modified or unmodified, in part or in whole,
|
||||||
|
must be distributed entirely under this license, and must not be
|
||||||
|
distributed under any other license. The requirement for fonts to
|
||||||
|
remain under this license does not apply to any document created
|
||||||
|
using the Font Software.
|
||||||
|
|
||||||
|
TERMINATION
|
||||||
|
This license becomes null and void if any of the above conditions are
|
||||||
|
not met.
|
||||||
|
|
||||||
|
DISCLAIMER
|
||||||
|
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
|
||||||
|
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
|
||||||
|
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
|
||||||
|
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
|
||||||
|
OTHER DEALINGS IN THE FONT SOFTWARE.
|
||||||
Binary file not shown.
Binary file not shown.
+3
-1
@@ -5,7 +5,9 @@
|
|||||||
"license": "proprietary",
|
"license": "proprietary",
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
"wp-coding-standards/wpcs": "^3.0",
|
"wp-coding-standards/wpcs": "^3.0",
|
||||||
"dealerdirect/phpcodesniffer-composer-installer": "^1.0"
|
"dealerdirect/phpcodesniffer-composer-installer": "^1.0",
|
||||||
|
"yoast/phpunit-polyfills": "^2.0.5",
|
||||||
|
"phpunit/phpunit": "^9.6"
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"allow-plugins": {
|
"allow-plugins": {
|
||||||
|
|||||||
Generated
+1844
-1
File diff suppressed because it is too large.
Load diff
@@ -206,7 +206,7 @@ git commit -m "chore: scaffold CHRNX theme tooling"
|
|||||||
- Create: `templates/index.html`
|
- Create: `templates/index.html`
|
||||||
- Create: `tests/smoke/theme-contract.test.mjs`
|
- Create: `tests/smoke/theme-contract.test.mjs`
|
||||||
- Create: `tests/php/bootstrap.php`
|
- Create: `tests/php/bootstrap.php`
|
||||||
- Create: `tests/php/test-theme-setup.php`
|
- Create: `tests/php/ThemeSetupTest.php`
|
||||||
|
|
||||||
- [ ] **Step 1: Write failing token and setup tests**
|
- [ ] **Step 1: Write failing token and setup tests**
|
||||||
|
|
||||||
@@ -283,8 +283,8 @@ git commit -m "feat: establish CHRNX block theme foundation"
|
|||||||
- Create: `inc/podcast-meta.php`
|
- Create: `inc/podcast-meta.php`
|
||||||
- Create: `assets/js/editor-taxonomies.js`
|
- Create: `assets/js/editor-taxonomies.js`
|
||||||
- Create: `assets/js/editor-podcast.js`
|
- Create: `assets/js/editor-podcast.js`
|
||||||
- Create: `tests/php/test-taxonomies.php`
|
- Create: `tests/php/TaxonomiesTest.php`
|
||||||
- Create: `tests/php/test-podcast-meta.php`
|
- Create: `tests/php/PodcastMetaTest.php`
|
||||||
- Create: `tests/js/editor-taxonomies.test.js`
|
- Create: `tests/js/editor-taxonomies.test.js`
|
||||||
- Create: `tests/js/editor-podcast.test.js`
|
- Create: `tests/js/editor-podcast.test.js`
|
||||||
|
|
||||||
@@ -363,7 +363,7 @@ array(
|
|||||||
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run test:php -- --filter 'Taxonomies|Podcast_Meta'
|
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run test:php -- --filter 'Taxonomies|Podcast_Meta'
|
||||||
npm run test:js -- --runTestsByPath tests/js/editor-taxonomies.test.js tests/js/editor-podcast.test.js
|
npm run test:js -- --runTestsByPath tests/js/editor-taxonomies.test.js tests/js/editor-podcast.test.js
|
||||||
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run phpcs
|
PATH="/opt/homebrew/opt/docker/bin:$PATH" npm run phpcs
|
||||||
git add inc/taxonomies.php inc/editor.php inc/podcast-meta.php assets/js/editor-taxonomies.js assets/js/editor-podcast.js tests/php/test-taxonomies.php tests/php/test-podcast-meta.php tests/js/editor-taxonomies.test.js tests/js/editor-podcast.test.js
|
git add inc/taxonomies.php inc/editor.php inc/podcast-meta.php assets/js/editor-taxonomies.js assets/js/editor-podcast.js tests/php/TaxonomiesTest.php tests/php/PodcastMetaTest.php tests/js/editor-taxonomies.test.js tests/js/editor-podcast.test.js
|
||||||
git commit -m "feat: add CHRNX editorial metadata"
|
git commit -m "feat: add CHRNX editorial metadata"
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -390,9 +390,9 @@ git commit -m "feat: add CHRNX editorial metadata"
|
|||||||
- Create: `blocks/related-posts/render.php`
|
- Create: `blocks/related-posts/render.php`
|
||||||
- Create: `blocks/subscribe-cta/block.json`
|
- Create: `blocks/subscribe-cta/block.json`
|
||||||
- Create: `blocks/subscribe-cta/render.php`
|
- Create: `blocks/subscribe-cta/render.php`
|
||||||
- Create: `tests/php/test-editorial-queries.php`
|
- Create: `tests/php/EditorialQueriesTest.php`
|
||||||
- Create: `tests/php/test-block-rendering.php`
|
- Create: `tests/php/BlockRenderingTest.php`
|
||||||
- Create: `tests/php/test-settings.php`
|
- Create: `tests/php/SettingsTest.php`
|
||||||
|
|
||||||
- [ ] **Step 1: Write failing feature-selection tests**
|
- [ ] **Step 1: Write failing feature-selection tests**
|
||||||
|
|
||||||
@@ -548,7 +548,7 @@ git commit -m "feat: add CHRNX shell and theme preference"
|
|||||||
- Create: `patterns/podcast-show.php`
|
- Create: `patterns/podcast-show.php`
|
||||||
- Create: `patterns/podcast-episode.php`
|
- Create: `patterns/podcast-episode.php`
|
||||||
- Create: `tests/smoke/templates.test.mjs`
|
- Create: `tests/smoke/templates.test.mjs`
|
||||||
- Create: `tests/php/test-patterns.php`
|
- Create: `tests/php/PatternsTest.php`
|
||||||
|
|
||||||
- [ ] **Step 1: Write failing template/pattern tests**
|
- [ ] **Step 1: Write failing template/pattern tests**
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
define( 'CHRNX_VERSION', '0.1.0' );
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
|
||||||
|
foreach ( array( 'setup', 'assets', 'taxonomies', 'editor', 'podcast-meta', 'settings', 'queries', 'blocks', 'theme-preference' ) as $module ) {
|
||||||
|
// phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
|
||||||
|
$path = get_theme_file_path( "inc/{$module}.php" );
|
||||||
|
if ( file_exists( $path ) ) {
|
||||||
|
require_once $path;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Frontend assets.
|
||||||
|
*
|
||||||
|
* @package CHRNX
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Enqueue the minimal frontend stylesheet.
|
||||||
|
*/
|
||||||
|
function chrnx_enqueue_assets() {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'chrnx-base',
|
||||||
|
get_theme_file_uri( 'assets/css/base.css' ),
|
||||||
|
array(),
|
||||||
|
CHRNX_VERSION
|
||||||
|
);
|
||||||
|
}
|
||||||
|
add_action( 'wp_enqueue_scripts', 'chrnx_enqueue_assets' );
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Theme setup.
|
||||||
|
*
|
||||||
|
* @package CHRNX
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register the theme's core WordPress features.
|
||||||
|
*/
|
||||||
|
function chrnx_setup() {
|
||||||
|
add_theme_support( 'title-tag' );
|
||||||
|
add_theme_support( 'post-thumbnails' );
|
||||||
|
add_theme_support( 'responsive-embeds' );
|
||||||
|
add_theme_support( 'editor-styles' );
|
||||||
|
add_editor_style( 'assets/css/base.css' );
|
||||||
|
|
||||||
|
add_image_size( 'chrnx-card', 720, 480, true );
|
||||||
|
}
|
||||||
|
add_action( 'after_setup_theme', 'chrnx_setup' );
|
||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
"phpcs": "npm run composer -- exec phpcs -- -q",
|
"phpcs": "npm run composer -- exec phpcs -- -q",
|
||||||
"test:smoke": "node --test tests/smoke/*.test.mjs",
|
"test:smoke": "node --test tests/smoke/*.test.mjs",
|
||||||
"test:js": "wp-scripts test-unit-js --runInBand",
|
"test:js": "wp-scripts test-unit-js --runInBand",
|
||||||
"test:php": "wp-env run cli --env-cwd=wp-content/themes/chrnx phpunit -- --configuration=phpunit.xml.dist",
|
"test:php": "wp-env run cli --env-cwd=wp-content/themes/chrnx composer exec phpunit",
|
||||||
"test:e2e": "playwright test",
|
"test:e2e": "playwright test",
|
||||||
"lint:js": "wp-scripts lint-js assets/js tests/js scripts",
|
"lint:js": "wp-scripts lint-js assets/js tests/js scripts",
|
||||||
"lint:css": "wp-scripts lint-style 'assets/css/**/*.css' 'blocks/**/*.css'",
|
"lint:css": "wp-scripts lint-style 'assets/css/**/*.css' 'blocks/**/*.css'",
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@
|
|||||||
>
|
>
|
||||||
<testsuites>
|
<testsuites>
|
||||||
<testsuite name="CHRNX theme tests">
|
<testsuite name="CHRNX theme tests">
|
||||||
<directory suffix=".php">tests/php</directory>
|
<directory suffix="Test.php">tests/php</directory>
|
||||||
</testsuite>
|
</testsuite>
|
||||||
</testsuites>
|
</testsuites>
|
||||||
</phpunit>
|
</phpunit>
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/*
|
||||||
|
Theme Name: CHRNX
|
||||||
|
Description: A native block theme for chrnx.dev.
|
||||||
|
Requires at least: 6.9
|
||||||
|
Requires PHP: 8.1
|
||||||
|
Version: 0.1.0
|
||||||
|
Text Domain: chrnx
|
||||||
|
*/
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<!-- wp:template-part {"slug":"header","tagName":"header"} /-->
|
||||||
|
|
||||||
|
<!-- wp:group {"tagName":"main","layout":{"type":"constrained"}} -->
|
||||||
|
<main class="wp-block-group">
|
||||||
|
<!-- wp:query {"queryId":0,"query":{"inherit":true},"layout":{"type":"default"}} -->
|
||||||
|
<div class="wp-block-query">
|
||||||
|
<!-- wp:post-template -->
|
||||||
|
<!-- wp:group {"tagName":"article","layout":{"type":"constrained"}} -->
|
||||||
|
<article class="wp-block-group">
|
||||||
|
<!-- wp:post-title {"isLink":true} /-->
|
||||||
|
<!-- wp:post-excerpt /-->
|
||||||
|
</article>
|
||||||
|
<!-- /wp:group -->
|
||||||
|
<!-- /wp:post-template -->
|
||||||
|
|
||||||
|
<!-- wp:query-pagination {"layout":{"type":"flex","justifyContent":"space-between"}} -->
|
||||||
|
<!-- wp:query-pagination-previous /-->
|
||||||
|
<!-- wp:query-pagination-numbers /-->
|
||||||
|
<!-- wp:query-pagination-next /-->
|
||||||
|
<!-- /wp:query-pagination -->
|
||||||
|
</div>
|
||||||
|
<!-- /wp:query -->
|
||||||
|
</main>
|
||||||
|
<!-- /wp:group -->
|
||||||
|
|
||||||
|
<!-- wp:template-part {"slug":"footer","tagName":"footer"} /-->
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Tests for theme setup.
|
||||||
|
*
|
||||||
|
* @package CHRNX
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify the theme's WordPress setup contract.
|
||||||
|
*/
|
||||||
|
class ThemeSetupTest extends WP_UnitTestCase {
|
||||||
|
/**
|
||||||
|
* Ensure the required theme supports are registered.
|
||||||
|
*/
|
||||||
|
public function test_required_theme_supports_are_registered() {
|
||||||
|
$this->assertTrue( current_theme_supports( 'title-tag' ) );
|
||||||
|
$this->assertTrue( current_theme_supports( 'post-thumbnails' ) );
|
||||||
|
$this->assertTrue( current_theme_supports( 'responsive-embeds' ) );
|
||||||
|
$this->assertTrue( current_theme_supports( 'editor-styles' ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the card crop is available to future card components.
|
||||||
|
*/
|
||||||
|
public function test_card_image_size_is_registered() {
|
||||||
|
$this->assertTrue( has_image_size( 'chrnx-card' ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* PHPUnit bootstrap for the CHRNX theme.
|
||||||
|
*
|
||||||
|
* @package CHRNX
|
||||||
|
*/
|
||||||
|
|
||||||
|
$chrnx_tests_dir = getenv( 'WP_TESTS_DIR' );
|
||||||
|
|
||||||
|
if ( ! $chrnx_tests_dir ) {
|
||||||
|
$chrnx_tests_dir = '/wordpress-phpunit';
|
||||||
|
}
|
||||||
|
|
||||||
|
// phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedConstantFound
|
||||||
|
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', dirname( __DIR__, 2 ) . '/vendor/yoast/phpunit-polyfills' );
|
||||||
|
|
||||||
|
require_once $chrnx_tests_dir . '/includes/functions.php';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Activate the mapped theme before WordPress finishes bootstrapping.
|
||||||
|
*/
|
||||||
|
function chrnx_tests_load_theme() {
|
||||||
|
switch_theme( 'chrnx' );
|
||||||
|
}
|
||||||
|
|
||||||
|
tests_add_filter( 'muplugins_loaded', 'chrnx_tests_load_theme' );
|
||||||
|
|
||||||
|
require $chrnx_tests_dir . '/includes/bootstrap.php';
|
||||||
@@ -41,5 +41,5 @@ test('PHP quality tools enforce the CHRNX conventions and cannot pass an empty s
|
|||||||
assert.match(phpcs, /name="prefixes"[^>]+value="chrnx_"/);
|
assert.match(phpcs, /name="prefixes"[^>]+value="chrnx_"/);
|
||||||
assert.match(phpunit, /bootstrap="tests\/php\/bootstrap\.php"/);
|
assert.match(phpunit, /bootstrap="tests\/php\/bootstrap\.php"/);
|
||||||
assert.match(phpunit, /failOnEmptyTestSuite="true"/);
|
assert.match(phpunit, /failOnEmptyTestSuite="true"/);
|
||||||
assert.match(phpunit, /<directory suffix="\.php">tests\/php<\/directory>/);
|
assert.match(phpunit, /<directory suffix="Test\.php">tests\/php<\/directory>/);
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
import assert from 'node:assert/strict';
|
||||||
|
import { access, readFile } from 'node:fs/promises';
|
||||||
|
import test from 'node:test';
|
||||||
|
|
||||||
|
const readProjectFile = (path) => readFile(new URL(`../../${path}`, import.meta.url), 'utf8');
|
||||||
|
|
||||||
|
test('Composer provides the PHPUnit Polyfills version required by WordPress tests', async () => {
|
||||||
|
const composer = JSON.parse(await readProjectFile('composer.json'));
|
||||||
|
const packageConfig = JSON.parse(await readProjectFile('package.json'));
|
||||||
|
|
||||||
|
assert.equal(composer['require-dev']['yoast/phpunit-polyfills'], '^2.0.5');
|
||||||
|
assert.equal(composer['require-dev']['phpunit/phpunit'], '^9.6');
|
||||||
|
assert.equal(
|
||||||
|
packageConfig.scripts['test:php'],
|
||||||
|
'wp-env run cli --env-cwd=wp-content/themes/chrnx composer exec phpunit',
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('PHPUnit discovers native test filenames without treating bootstrap as a test', async () => {
|
||||||
|
const config = await readProjectFile('phpunit.xml.dist');
|
||||||
|
|
||||||
|
assert.match(config, /<directory suffix="Test\.php">tests\/php<\/directory>/);
|
||||||
|
await access(new URL('../../tests/php/ThemeSetupTest.php', import.meta.url));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('style.css declares the supported WordPress theme contract', async () => {
|
||||||
|
const stylesheet = await readProjectFile('style.css');
|
||||||
|
|
||||||
|
assert.match(stylesheet, /^Theme Name:\s*CHRNX$/m);
|
||||||
|
assert.match(stylesheet, /^Text Domain:\s*chrnx$/m);
|
||||||
|
assert.match(stylesheet, /^Requires at least:\s*6\.9$/m);
|
||||||
|
assert.match(stylesheet, /^Requires PHP:\s*8\.1$/m);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('theme.json declares the v3 schema and layout widths', async () => {
|
||||||
|
const theme = JSON.parse(await readProjectFile('theme.json'));
|
||||||
|
|
||||||
|
assert.equal(theme.$schema, 'https://schemas.wp.org/trunk/theme.json');
|
||||||
|
assert.equal(theme.version, 3);
|
||||||
|
assert.equal(theme.settings.layout.contentSize, '720px');
|
||||||
|
assert.equal(theme.settings.layout.wideSize, '1120px');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('theme.json exposes the complete dark and warm-light palette with stable semantic slugs', async () => {
|
||||||
|
const theme = JSON.parse(await readProjectFile('theme.json'));
|
||||||
|
const palette = Object.fromEntries(
|
||||||
|
theme.settings.color.palette.map(({ slug, color }) => [slug, color.toUpperCase()]),
|
||||||
|
);
|
||||||
|
const expectedTokens = {
|
||||||
|
night: '#0D1117',
|
||||||
|
panel: '#161B22',
|
||||||
|
violet: '#7C6CF0',
|
||||||
|
green: '#5FB88A',
|
||||||
|
text: '#E6EDF3',
|
||||||
|
muted: '#8B949E',
|
||||||
|
paper: '#F6F2E9',
|
||||||
|
surface: '#FFFDF7',
|
||||||
|
ink: '#25221F',
|
||||||
|
'light-muted': '#625C54',
|
||||||
|
'light-violet': '#674CA4',
|
||||||
|
'light-green': '#327854',
|
||||||
|
border: '#DED6C7',
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.deepEqual(palette, expectedTokens);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the local Zen Maru Gothic files and license are present', async () => {
|
||||||
|
await Promise.all([
|
||||||
|
'assets/fonts/zen-maru-gothic-latin-500.woff2',
|
||||||
|
'assets/fonts/zen-maru-gothic-latin-700.woff2',
|
||||||
|
'assets/fonts/OFL.txt',
|
||||||
|
].map((path) => access(new URL(`../../${path}`, import.meta.url))));
|
||||||
|
});
|
||||||
|
|
||||||
|
test('the index template has header, semantic query content, and footer regions', async () => {
|
||||||
|
const template = await readProjectFile('templates/index.html');
|
||||||
|
|
||||||
|
assert.match(template, /<!-- wp:template-part \{"slug":"header","tagName":"header"\} \/-->/);
|
||||||
|
assert.match(template, /<!-- wp:group \{"tagName":"main"[^>]*-->/);
|
||||||
|
assert.match(template, /<!-- wp:query\b/);
|
||||||
|
assert.match(template, /<!-- wp:post-template -->/);
|
||||||
|
assert.match(template, /<!-- wp:post-(?:content|excerpt)\b/);
|
||||||
|
assert.match(template, /<!-- wp:template-part \{"slug":"footer","tagName":"footer"\} \/-->/);
|
||||||
|
});
|
||||||
+160
@@ -0,0 +1,160 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://schemas.wp.org/trunk/theme.json",
|
||||||
|
"version": 3,
|
||||||
|
"settings": {
|
||||||
|
"appearanceTools": true,
|
||||||
|
"color": {
|
||||||
|
"defaultPalette": false,
|
||||||
|
"palette": [
|
||||||
|
{ "slug": "night", "color": "#0D1117", "name": "Night" },
|
||||||
|
{ "slug": "panel", "color": "#161B22", "name": "Panel" },
|
||||||
|
{ "slug": "violet", "color": "#7C6CF0", "name": "Violet" },
|
||||||
|
{ "slug": "green", "color": "#5FB88A", "name": "Green" },
|
||||||
|
{ "slug": "text", "color": "#E6EDF3", "name": "Text" },
|
||||||
|
{ "slug": "muted", "color": "#8B949E", "name": "Muted" },
|
||||||
|
{ "slug": "paper", "color": "#F6F2E9", "name": "Paper" },
|
||||||
|
{ "slug": "surface", "color": "#FFFDF7", "name": "Surface" },
|
||||||
|
{ "slug": "ink", "color": "#25221F", "name": "Ink" },
|
||||||
|
{ "slug": "light-muted", "color": "#625C54", "name": "Light Muted" },
|
||||||
|
{ "slug": "light-violet", "color": "#674CA4", "name": "Light Violet" },
|
||||||
|
{ "slug": "light-green", "color": "#327854", "name": "Light Green" },
|
||||||
|
{ "slug": "border", "color": "#DED6C7", "name": "Border" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"layout": {
|
||||||
|
"contentSize": "720px",
|
||||||
|
"wideSize": "1120px"
|
||||||
|
},
|
||||||
|
"spacing": {
|
||||||
|
"defaultSpacingSizes": false,
|
||||||
|
"spacingSizes": [
|
||||||
|
{ "slug": "20", "size": "clamp(0.5rem, 0.4rem + 0.4vw, 0.75rem)", "name": "2XS" },
|
||||||
|
{ "slug": "30", "size": "clamp(0.75rem, 0.6rem + 0.6vw, 1rem)", "name": "XS" },
|
||||||
|
{ "slug": "40", "size": "clamp(1rem, 0.8rem + 0.8vw, 1.5rem)", "name": "Small" },
|
||||||
|
{ "slug": "50", "size": "clamp(1.5rem, 1.1rem + 1.2vw, 2.25rem)", "name": "Medium" },
|
||||||
|
{ "slug": "60", "size": "clamp(2.25rem, 1.6rem + 2vw, 3.5rem)", "name": "Large" },
|
||||||
|
{ "slug": "70", "size": "clamp(3rem, 2rem + 3vw, 5rem)", "name": "XL" }
|
||||||
|
],
|
||||||
|
"units": [ "px", "rem", "em", "%", "vw", "vh" ]
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"defaultFontSizes": false,
|
||||||
|
"fluid": true,
|
||||||
|
"fontFamilies": [
|
||||||
|
{
|
||||||
|
"slug": "body",
|
||||||
|
"name": "System UI",
|
||||||
|
"fontFamily": "-apple-system, BlinkMacSystemFont, \"Segoe UI\", sans-serif"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "heading",
|
||||||
|
"name": "Zen Maru Gothic",
|
||||||
|
"fontFamily": "\"Zen Maru Gothic\", sans-serif",
|
||||||
|
"fontFace": [
|
||||||
|
{
|
||||||
|
"fontFamily": "Zen Maru Gothic",
|
||||||
|
"fontStyle": "normal",
|
||||||
|
"fontWeight": "500",
|
||||||
|
"fontDisplay": "swap",
|
||||||
|
"src": [ "file:./assets/fonts/zen-maru-gothic-latin-500.woff2" ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fontFamily": "Zen Maru Gothic",
|
||||||
|
"fontStyle": "normal",
|
||||||
|
"fontWeight": "700",
|
||||||
|
"fontDisplay": "swap",
|
||||||
|
"src": [ "file:./assets/fonts/zen-maru-gothic-latin-700.woff2" ]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"slug": "metadata",
|
||||||
|
"name": "System Monospace",
|
||||||
|
"fontFamily": "ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fontSizes": [
|
||||||
|
{ "slug": "small", "size": "clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem)", "name": "Small" },
|
||||||
|
{ "slug": "medium", "size": "clamp(1rem, 0.95rem + 0.2vw, 1.125rem)", "name": "Medium" },
|
||||||
|
{ "slug": "large", "size": "clamp(1.35rem, 1.15rem + 0.8vw, 1.75rem)", "name": "Large" },
|
||||||
|
{ "slug": "x-large", "size": "clamp(1.75rem, 1.35rem + 1.6vw, 2.75rem)", "name": "Extra Large" },
|
||||||
|
{ "slug": "display", "size": "clamp(2.5rem, 1.7rem + 3.2vw, 4.75rem)", "name": "Display" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"styles": {
|
||||||
|
"color": {
|
||||||
|
"background": "var:preset|color|night",
|
||||||
|
"text": "var:preset|color|text"
|
||||||
|
},
|
||||||
|
"spacing": {
|
||||||
|
"blockGap": "var:preset|spacing|50"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"fontFamily": "var:preset|font-family|body",
|
||||||
|
"fontSize": "var:preset|font-size|medium",
|
||||||
|
"lineHeight": "1.65"
|
||||||
|
},
|
||||||
|
"elements": {
|
||||||
|
"button": {
|
||||||
|
"color": {
|
||||||
|
"background": "var:preset|color|green",
|
||||||
|
"text": "var:preset|color|night"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"fontWeight": "700"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"heading": {
|
||||||
|
"color": {
|
||||||
|
"text": "var:preset|color|text"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"fontFamily": "var:preset|font-family|heading",
|
||||||
|
"fontWeight": "700",
|
||||||
|
"lineHeight": "1.2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"link": {
|
||||||
|
"color": {
|
||||||
|
"text": "var:preset|color|violet"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"textDecoration": "underline"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"blocks": {
|
||||||
|
"core/button": {
|
||||||
|
"border": {
|
||||||
|
"radius": "0.35rem"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"core/post-date": {
|
||||||
|
"color": {
|
||||||
|
"text": "var:preset|color|muted"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"fontFamily": "var:preset|font-family|metadata",
|
||||||
|
"fontSize": "var:preset|font-size|small"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"core/post-terms": {
|
||||||
|
"color": {
|
||||||
|
"text": "var:preset|color|muted"
|
||||||
|
},
|
||||||
|
"typography": {
|
||||||
|
"fontFamily": "var:preset|font-family|metadata",
|
||||||
|
"fontSize": "var:preset|font-size|small"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"core/quote": {
|
||||||
|
"border": {
|
||||||
|
"color": "var:preset|color|violet",
|
||||||
|
"style": "solid",
|
||||||
|
"width": "0 0 0 3px"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in new issue
Block a user