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

Fix: Remove Styleguide from scaffold #265

Merged
merged 1 commit into from
Dec 12, 2024
Merged
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
195 changes: 0 additions & 195 deletions themes/10up-theme/assets/css/styleguide/styleguide.css

This file was deleted.

6 changes: 0 additions & 6 deletions themes/10up-theme/assets/js/styleguide/styleguide.js

This file was deleted.

101 changes: 0 additions & 101 deletions themes/10up-theme/assets/js/styleguide/uikitsection.js

This file was deleted.

63 changes: 0 additions & 63 deletions themes/10up-theme/includes/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,66 +38,3 @@ function get_asset_info( $slug, $attribute = null ) {

return $asset;
}

/**
* Extract colors from a CSS or Sass file
*
* @param string $path the path to your CSS variables file
*
* @throws \RuntimeException If the file is not found or could not be read
*
* @return array<string>
*/
function get_colors( $path ) {

$dir = get_stylesheet_directory();

if ( file_exists( $dir . $path ) ) {
$css_vars = file_get_contents( $dir . $path ); // phpcs:ignore WordPress.WP.AlternativeFunctions

if ( false === $css_vars ) {
throw new \RuntimeException( 'Could not read CSS variables file.' );
}

// HEX(A) | RGB(A) | HSL(A) - rgba & hsla alpha as decimal or percentage
// https://regex101.com/r/l7AZ8R/
// this is a loose match and will accept almost anything within () for rgb(a) & hsl(a)
// a more optinionated solution is WIP here if you can improve on it https://regex101.com/r/FEtzDu/
preg_match_all( '(#(?:[\da-f]{3}){1}\b|#(?:[\da-f]{2}){3,4}\b|(rgb|hsl)a?\((\s|\d|[a-zA-Z]+|,|-|%|\.|\/)+\))', $css_vars, $matches );

return $matches[0];
}

throw new \RuntimeException( 'CSS variables file not found.' );
}

/**
* Adjust the brightness of a color (HEX)
*
* @param string $hex The hex code for the color
* @param number $steps amount you want to change the brightness
* @return string new color with brightness adjusted
*/
function adjust_brightness( $hex, $steps ) {

// Steps should be between -255 and 255. Negative = darker, positive = lighter
$steps = max( -255, min( 255, $steps ) );

// Normalize into a six character long hex string
$hex = str_replace( '#', '', $hex );
if ( 3 === strlen( $hex ) ) {
$hex = str_repeat( substr( $hex, 0, 1 ), 2 ) . str_repeat( substr( $hex, 1, 1 ), 2 ) . str_repeat( substr( $hex, 2, 1 ), 2 );
}

// Split into three parts: R, G and B
$color_parts = str_split( $hex, 2 );
$return = '#';

foreach ( $color_parts as $color ) {
$color = hexdec( $color ); // Convert to decimal
$color = max( 0, min( 255, $color + $steps ) ); // Adjust color
$return .= str_pad( dechex( intval( $color ) ), 2, '0', STR_PAD_LEFT ); // Make two char hex code
}

return $return;
}
1 change: 0 additions & 1 deletion themes/10up-theme/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
"editor-style-overrides": "./assets/js/admin/editor-style-overrides.js",
"frontend": "./assets/js/frontend/frontend.js",
"shared": "./assets/js/shared/shared.js",
"styleguide": "./assets/js/styleguide/styleguide.js",
"block-editor-script": "./includes/block-editor-script.js"
}
}
Expand Down
Loading
Loading