feat: add CHRNX theme preference and marks
This commit is contained in:
11 files changed
+469
-3
No files matched your search
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"$schema": "https://schemas.wp.org/trunk/block.json",
|
||||
"apiVersion": 3,
|
||||
"name": "chrnx/theme-toggle",
|
||||
"version": "0.1.0",
|
||||
"title": "Theme Toggle",
|
||||
"category": "theme",
|
||||
"description": "Choose a light, dark, or system color theme.",
|
||||
"textdomain": "chrnx",
|
||||
"supports": { "html": false },
|
||||
"viewScript": "file:../../assets/js/theme-toggle.js",
|
||||
"render": "file:./render.php"
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
/**
|
||||
* Render the theme preference controls.
|
||||
*
|
||||
* @package CHRNX
|
||||
*/
|
||||
|
||||
$chrnx_control_name = wp_unique_id( 'chrnx-theme-' );
|
||||
?>
|
||||
<fieldset
|
||||
<?php
|
||||
// WordPress escapes each generated wrapper attribute.
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo get_block_wrapper_attributes(
|
||||
array(
|
||||
'class' => 'chrnx-theme-toggle',
|
||||
'data-chrnx-theme-toggle' => '',
|
||||
)
|
||||
);
|
||||
?>
|
||||
data-status-light="<?php esc_attr_e( 'Light theme active', 'chrnx' ); ?>"
|
||||
data-status-dark="<?php esc_attr_e( 'Dark theme active', 'chrnx' ); ?>"
|
||||
data-status-system="<?php esc_attr_e( 'following system', 'chrnx' ); ?>"
|
||||
>
|
||||
<legend><?php esc_html_e( 'Color theme', 'chrnx' ); ?></legend>
|
||||
<label><input type="radio" name="<?php echo esc_attr( $chrnx_control_name ); ?>" value="light"> <?php esc_html_e( 'Light', 'chrnx' ); ?></label>
|
||||
<label><input type="radio" name="<?php echo esc_attr( $chrnx_control_name ); ?>" value="dark"> <?php esc_html_e( 'Dark', 'chrnx' ); ?></label>
|
||||
<label><input type="radio" name="<?php echo esc_attr( $chrnx_control_name ); ?>" value="system" checked> <?php esc_html_e( 'System', 'chrnx' ); ?></label>
|
||||
<output data-chrnx-theme-status aria-live="polite"><?php esc_html_e( 'Following system theme', 'chrnx' ); ?></output>
|
||||
</fieldset>
|
||||
Reference in new issue
Block a user