Skip to content

Commit 5f07fad

Browse files
authored
release: new version
- Adds experimental atomic-wind blocks - Improves handling of boxed values, allowing string values for four-directional properties
2 parents e766574 + 8e6829f commit 5f07fad

51 files changed

Lines changed: 5081 additions & 9 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,6 @@ license.json
1717
tests/assets/*_tmp
1818
.phpunit.result.cache
1919
languages
20+
21+
# Lucide source SVGs — generated by npm run icons:update, not committed
22+
assets/atomic-wind/icons/

assets/atomic-wind/icons.json

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

bin/generate-icons-json.mjs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Generates assets/atomic-wind/icons.json from the individual SVG files in
4+
* assets/atomic-wind/icons/.
5+
*
6+
* Each key is the icon name (filename without .svg).
7+
* Each value is the minified inner SVG markup — the content between <svg> and </svg>.
8+
*
9+
* Usage:
10+
* node bin/generate-icons-json.mjs
11+
* node bin/generate-icons-json.mjs --icons-dir path/to/icons --out path/to/output.json
12+
*/
13+
14+
import { readFileSync, writeFileSync, readdirSync } from 'fs';
15+
import { join, basename, dirname } from 'path';
16+
import { fileURLToPath } from 'url';
17+
18+
const ROOT = join( dirname( fileURLToPath( import.meta.url ) ), '..' );
19+
20+
function parseArgs() {
21+
const args = process.argv.slice( 2 );
22+
const opts = {
23+
iconsDir: join( ROOT, 'assets/atomic-wind/icons' ),
24+
out: join( ROOT, 'assets/atomic-wind/icons.json' ),
25+
};
26+
for ( let i = 0; i < args.length; i++ ) {
27+
if ( args[ i ] === '--icons-dir' ) { opts.iconsDir = args[ ++i ]; }
28+
if ( args[ i ] === '--out' ) { opts.out = args[ ++i ]; }
29+
}
30+
return opts;
31+
}
32+
33+
function extractInner( svgText ) {
34+
const match = svgText.match( /<svg[^>]*>([\s\S]*?)<\/svg>/i );
35+
if ( ! match ) { return null; }
36+
// Collapse all runs of whitespace (newlines, tabs, multiple spaces) to a single space,
37+
// then trim and remove spaces around > and <.
38+
return match[ 1 ]
39+
.replace( /\s+/g, ' ' )
40+
.replace( />\s+</g, '><' )
41+
.trim();
42+
}
43+
44+
function main() {
45+
const { iconsDir, out } = parseArgs();
46+
47+
const files = readdirSync( iconsDir )
48+
.filter( ( f ) => f.endsWith( '.svg' ) )
49+
.sort();
50+
51+
if ( files.length === 0 ) {
52+
console.error( `No SVG files found in ${ iconsDir }` );
53+
process.exit( 1 );
54+
}
55+
56+
const icons = {};
57+
let skipped = 0;
58+
59+
for ( const file of files ) {
60+
const name = basename( file, '.svg' );
61+
const svg = readFileSync( join( iconsDir, file ), 'utf8' );
62+
const inner = extractInner( svg );
63+
if ( inner === null ) {
64+
console.warn( ` skipped (no <svg> found): ${ file }` );
65+
skipped++;
66+
continue;
67+
}
68+
icons[ name ] = inner;
69+
}
70+
71+
writeFileSync( out, JSON.stringify( icons ), 'utf8' );
72+
73+
const sizeKB = ( Buffer.byteLength( JSON.stringify( icons ), 'utf8' ) / 1024 ).toFixed( 1 );
74+
console.log( `icons.json written: ${ Object.keys( icons ).length } icons, ${ sizeKB } KB${ skipped ? ` (${ skipped } skipped)` : '' }` );
75+
console.log( ` -> ${ out }` );
76+
}
77+
78+
main();

bin/update-atomic-wind-icons.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
5+
ICONS_DIR="$ROOT_DIR/assets/atomic-wind/icons"
6+
WORK_DIR="$(mktemp -d)"
7+
trap 'rm -rf "$WORK_DIR"' EXIT
8+
9+
git clone --no-checkout --depth=1 --filter=blob:none \
10+
https://github.com/lucide-icons/lucide.git "$WORK_DIR/lucide"
11+
12+
cd "$WORK_DIR/lucide"
13+
git sparse-checkout set icons
14+
git checkout
15+
16+
rm -rf "$ICONS_DIR"
17+
mkdir -p "$ICONS_DIR"
18+
find "$WORK_DIR/lucide/icons" -name "*.svg" -exec cp {} "$ICONS_DIR/" \;
19+
20+
node "$ROOT_DIR/bin/generate-icons-json.mjs" \
21+
--icons-dir "$ICONS_DIR" \
22+
--out "$ROOT_DIR/assets/atomic-wind/icons.json"

inc/class-main.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ public function autoload_classes() {
8787
'\ThemeIsle\GutenbergBlocks\Server\Prompt_Server',
8888
'\ThemeIsle\GutenbergBlocks\Plugins\Template_Cloud',
8989
'\ThemeIsle\GutenbergBlocks\Server\Template_Cloud_Server',
90+
'\ThemeIsle\GutenbergBlocks\Plugins\Atomic_Wind_Blocks',
9091
);
9192

9293
$classnames = apply_filters( 'otter_blocks_autoloader', $classnames );

inc/css/class-css-utility.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -322,11 +322,15 @@ public function generate() {
322322
/**
323323
* Get the CSS string for padding, margin that comes from BoxControl.
324324
*
325-
* @param array $box The box.
326-
* @param array $box_default The default box.
325+
* @param array|string $box The box.
326+
* @param array $box_default The default box.
327327
* @return string
328328
*/
329329
public static function box_values( $box, $box_default = array() ) {
330+
if ( ! is_array( $box ) ) {
331+
return $box;
332+
}
333+
330334
$box = array_map(
331335
function ( $value ) {
332336
return is_numeric( $value ) ? $value . 'px' : $value;

0 commit comments

Comments
 (0)