Changeset 3826085
- Timestamp:
- 11/26/2026 09:03:17 AM (less than one hour ago)
- Location:
- tokenforge/trunk
- Files:
-
- 7 added
- 24 edited
-
CHANGELOG.md (modified) (1 diff)
-
assets/admin/admin.js (modified) (8 diffs)
-
assets/admin/tips.js (modified) (2 diffs)
-
assets/builder/scheme-preview.js (added)
-
assets/manual (added)
-
assets/manual/manual.css (added)
-
assets/manual/manual.html (added)
-
changelog.txt (added)
-
composer.json (added)
-
includes/class-acss-import.php (modified) (7 diffs)
-
includes/class-admin.php (modified) (4 diffs)
-
includes/class-cheatsheet.php (modified) (1 diff)
-
includes/class-class-usage.php (modified) (4 diffs)
-
includes/class-contrast.php (modified) (4 diffs)
-
includes/class-css-generator.php (modified) (3 diffs)
-
includes/class-framework.php (modified) (6 diffs)
-
includes/class-frontend.php (modified) (1 diff)
-
includes/class-motion.php (modified) (16 diffs)
-
includes/class-plugin.php (modified) (1 diff)
-
includes/class-recipes.php (modified) (1 diff)
-
includes/class-rest.php (modified) (5 diffs)
-
includes/class-settings.php (modified) (2 diffs)
-
includes/features/class-block-editor.php (modified) (1 diff)
-
includes/features/class-builder-enhancements.php (modified) (1 diff)
-
includes/features/class-builders.php (modified) (1 diff)
-
includes/platforms/class-bricks-style-manager.php (modified) (9 diffs)
-
includes/platforms/class-bricks.php (modified) (1 diff)
-
readme.txt (modified) (4 diffs)
-
tokenforge.php (modified) (2 diffs)
-
vendor/scssphp/NOTICE.md (modified) (1 diff)
-
vendor/scssphp/composer.json (added)
Legend:
- Unmodified
- Added
- Removed
-
tokenforge/trunk/CHANGELOG.md
r3823805 r3826085 2 2 3 3 All the changes to TokenForge, newest first. 4 5 ## 0.58.2 6 7 - New: TokenForge, Manual. An English user manual in the admin, with a contents list, from setup to the developer hooks. 8 - Class names from another utility framework now work too: `grid--3`, `grid--m-2`, `flex-grid--3`, `text--center` and others that do exactly the same as a TokenForge class. Colour names such as `bg--primary` have their own switch (Options, Utility framework), off by default. 9 - The other framework's class names show in TokenForge's class menu in the builder, the block editor's class field and the Cheatsheet ("Same as .grid-3"). They are not added to the builder's own class list, so it does not fill up with second names; picking one adds just that class. 10 - New: default button effects. Pick one hover, one entrance and one hover border effect for every TokenForge button (`.btn`, `btn--*`, and every button when Buttons, Restyle every button is on) on the Effects screen (Button effects). All are off by default. They animate with your own button transition too: the effect is added to it, and "none" stays off. 11 - New recipes: eight gradients (linear, radial, conic, sharp, fade, vignette, gradient text and gradient border), `?before`, `?after`, `?before-after`, `?hover`, `?focus-visible`, `?hover-focus`, `?hover-exclude-touch`, `?color-mix`, `?transparency`, `?tooltip`, `?footer-reveal`, `?fade-all`, `?concentric-radius-reverse`, `?is-bg`, `?skip-link`, `?border-check` and `?center-all`, `-top`, `-bottom`, `-left` and `-right`. 12 - Builder: a small moon button beside the TokenForge button previews the canvas in dark mode while you build. Only you see it, nothing is saved into the page and visitors are not affected. It shows while dark mode is on; Builder, Dark mode preview switches it off. 13 - Fixed: a TokenForge window opened before a newer save (another builder tab, the dashboard, or a change in the builder's Style Manager) no longer puts the older settings back. TokenForge keeps the newer ones, says so, and shows the current settings. Two builder tabs editing the Style Manager scales each keep only their own changes. 14 - The builder canvas copy of the stylesheet keeps the Global SCSS marker, so an add-on's SCSS preview replaces the saved SCSS instead of sitting on top of it. 15 - Settings import: says plainly when it switches the front-end launcher on (the other framework shows its dashboard icon by default). 16 - Settings import: brings over the button effects, the switches for hiding deactivated classes, the class field on top in the block editor and the front-end launcher, and the older letter values of the full-width button breakpoint. 17 - Contrast checker: text written as a see-through mix (how a settings import writes muted text) is now measured, so Page Text and Muted text no longer show as skipped on imported sites. 18 - Effects: an entrance element already on screen at load now stays at its start frame until the page is ready, so it no longer shows for a moment and then jumps back to play. 19 - Settings import: a 3.x card radius value "on" is now skipped like "standard" and named in the report. 20 - Readme: shorter, with an External services section; the full version history moved to changelog.txt. The bundled SCSS library now ships its composer.json. 21 - Leave out unused utility classes: switching on a setting that adds classes (breakpoint variants such as `flex-grid-2-at-m`, or a utility family) now checks the site again, so classes your pages already use are kept. Before, they stayed left out until you ran the scan by hand. 4 22 5 23 ## 0.58.1 -
tokenforge/trunk/assets/admin/admin.js
r3800339 r3826085 145 145 function A( k, l, x ) { return F( 'a', k, l, x ); } // textarea 146 146 function S( k, l, o, x ) { var f = F( 's', k, l, x ); f.o = o; return f; } // select 147 function FX( l ) { return [ [ '', __( 'None', 'tokenforge' ) ] ].concat( l.map( function ( f ) { return [ f, f ]; } ) ); } // effect select options 147 148 function K( k, l, x ) { return F( 'k', k, l, x ); } // keyboard shortcut recorder 148 149 var WOO_FAMS = [ 'primary', 'secondary', 'tertiary', 'accent', 'base', 'neutral', 'action', 'success', 'danger', 'warning', 'info' ].map( function ( f ) { return [ f, f.charAt( 0 ).toUpperCase() + f.slice( 1 ) ]; } ); … … 266 267 P( __( 'Hover', 'tokenforge' ), 'motion', [ T( 'hover_duration', __( 'Duration', 'tokenforge' ) ), T( 'hover_timing', __( 'Timing', 'tokenforge' ) ), T( 'hover_grow', __( 'Grow scale', 'tokenforge' ) ), T( 'hover_shrink', __( 'Shrink scale', 'tokenforge' ) ), T( 'hover_float', __( 'Float distance', 'tokenforge' ) ), T( 'hover_sink', __( 'Sink distance', 'tokenforge' ) ), T( 'hover_slide_right', __( 'Slide right', 'tokenforge' ) ), T( 'hover_slide_left', __( 'Slide left', 'tokenforge' ) ), T( 'hover_shadow', __( 'Shadow', 'tokenforge' ) ), C( 'hover_glow_color', __( 'Glow colour', 'tokenforge' ) ), T( 'hover_glow_spread', __( 'Glow spread', 'tokenforge' ) ), T( 'hover_glow_opacity', __( 'Glow opacity', 'tokenforge' ) ), T( 'hover_fade', __( 'Fade opacity', 'tokenforge' ) ), T( 'hover_brighten', __( 'Brighten', 'tokenforge' ) ) ], { on: 'hover', d: __( '<code>.on-hover--grow / shrink / float / sink / slide-right / slide-left / shadow / glow / fade / brighten</code>.', 'tokenforge' ) } ), 267 268 P( __( 'Hover borders', 'tokenforge' ), 'motion', [ C( 'ripple_color', __( 'Ripple colour', 'tokenforge' ) ), T( 'ripple_width', __( 'Ripple width', 'tokenforge' ) ), T( 'ripple_duration', __( 'Ripple duration', 'tokenforge' ) ), T( 'ripple_distance', __( 'Ripple distance', 'tokenforge' ) ), C( 'outline_color', __( 'Outline colour', 'tokenforge' ) ), T( 'outline_width', __( 'Outline width', 'tokenforge' ) ), T( 'outline_duration', __( 'Outline duration', 'tokenforge' ) ), C( 'underline_color', __( 'Underline colour', 'tokenforge' ) ), T( 'underline_width', __( 'Underline width', 'tokenforge' ) ), T( 'underline_duration', __( 'Underline duration', 'tokenforge' ) ) ], { on: 'border_fx', d: __( '<code>.on-hover--ripple-out/-in</code>, <code>--outline-out/-in</code>, <code>--underline-left/-center/-right</code>.', 'tokenforge' ) } ), 269 P( __( 'Button effects', 'tokenforge' ), 'motion', [ S( 'btn_hover_fx', __( 'Hover', 'tokenforge' ), FX( [ 'grow', 'shrink', 'float', 'sink', 'slide-right', 'slide-left', 'shadow', 'glow', 'fade', 'brighten' ] ) ), S( 'btn_enter_fx', __( 'Entrance (scroll)', 'tokenforge' ), FX( [ 'fade', 'float', 'sink', 'slide-left', 'slide-right', 'grow', 'shrink', 'blur' ] ) ), S( 'btn_border_fx', __( 'Hover border', 'tokenforge' ), FX( [ 'ripple-out', 'ripple-in', 'outline-out', 'outline-in', 'underline-left', 'underline-center', 'underline-right' ] ) ) ], { d: __( 'One effect for every TokenForge button (.btn, btn--*; every button with Buttons, Restyle every button on). Each needs its effect group above switched on.', 'tokenforge' ) } ), 268 270 P( __( 'Builders & accessibility', 'tokenforge' ), 'motion', [ B( 'disable_in_builder', __( 'Keep scroll & visible effects still in the builder canvas / block editor', 'tokenforge' ) ) ], { d: __( 'Visitors who prefer reduced motion get no scroll or visible animations and no hover movement.', 'tokenforge' ) } ) 269 271 ] }, … … 300 302 P( __( 'Canvas', 'tokenforge' ), 'enhancements', [ B( 'grid_overlay', __( 'The builder’s grid overlay on the selected grid', 'tokenforge' ) ), B( 'element_outlines', __( 'Outline containers', 'tokenforge' ) ), B( 'grid_visualizer', __( 'Outline every grid / flex container (debug)', 'tokenforge' ) ), B( 'overflow_detection', __( 'Outline elements that overflow the viewport', 'tokenforge' ) ) ], { needs: 'canvas_tools' } ), 301 303 P( __( 'Canvas badges', 'tokenforge' ), 'enhancements', [ B( 'canvas_headings', __( 'Heading levels', 'tokenforge' ) ), B( 'canvas_focus', __( 'Focus order', 'tokenforge' ) ) ], { needs: 'canvas_tools', d: __( 'Small badges in the builder canvas that only you see: the level of every heading, and the order the Tab key visits links, buttons and fields.', 'tokenforge' ) } ), 304 P( __( 'Dark mode preview', 'tokenforge' ), 'settings', [ B( 'scheme_preview', __( 'Light/dark preview button for the canvas', 'tokenforge' ) ) ], { d: __( 'A small button beside the TokenForge button in the builder switches the canvas between light and dark while you build. Only you see it; nothing is saved into the page and visitors are not affected. It shows only while Dark mode is on under Color Scheme.', 'tokenforge' ) } ), 302 305 P( __( 'Style tab & code', 'tokenforge' ), 'enhancements', [ B( 'css_group_top', __( 'CSS group first', 'tokenforge' ), { needs: 'editor_tweaks' } ), B( 'bigger_code_editor', __( 'Taller code editor', 'tokenforge' ), { needs: 'editor_tweaks' } ), B( 'css_autocomplete', __( 'Autocomplete TokenForge variables and classes', 'tokenforge' ) ) ], { needs: 'css_complete' } ), 303 306 P( __( 'Contextual menus', 'tokenforge' ), 'enhancements', [ B( 'ctx_vars_menu', __( 'Right-click an input to insert a variable', 'tokenforge' ), { needs: 'vars_menu' } ), B( 'ctx_class_menu', __( 'Right-click the class field to add utility classes', 'tokenforge' ), { needs: 'class_menu' } ) ], { needs: 'context_menus', d: __( 'Shift + right-click opens the browser menu.', 'tokenforge' ) } ), … … 323 326 P( __( 'Breakpoints', 'tokenforge' ), 'scss', [ N( 'bp_xs', __( 'xs (px)', 'tokenforge' ) ), N( 'bp_s', __( 's (px)', 'tokenforge' ) ), N( 'bp_m', __( 'm (px)', 'tokenforge' ) ), N( 'bp_l', __( 'l (px)', 'tokenforge' ) ), N( 'bp_xl', __( 'xl (px)', 'tokenforge' ) ), N( 'bp_xxl', __( 'xxl (px)', 'tokenforge' ) ) ], { d: __( 'Widths in px for the breakpoint names (xs to xxl) used by the <code>?breakpoint-*</code> recipes and the responsive data attributes.', 'tokenforge' ) } ), 324 327 P( __( 'Cascade layers', 'tokenforge' ), 'settings', [ B( 'layer_defaults', __( 'Defaults & utilities', 'tokenforge' ) ), B( 'layer_base', __( 'Base typography & sections', 'tokenforge' ) ), B( 'layer_buttons', __( 'Buttons & external links', 'tokenforge' ) ), B( 'layer_cards', __( 'Cards', 'tokenforge' ) ), B( 'layer_icons', __( 'Icons', 'tokenforge' ) ), B( 'layer_content', __( 'Content / prose', 'tokenforge' ) ) ], { d: __( 'A layered part loses to <em>any</em> unlayered CSS (theme, builder, custom). Variables and utility classes are never layered.', 'tokenforge' ) } ), 325 P( __( 'Utility framework', 'tokenforge' ), 'framework', [ B( 'utilities_color', __( 'Colour utilities', 'tokenforge' ) ), B( 'utilities_spacing', __( 'Spacing utilities', 'tokenforge' ) ), B( 'utilities_typography', __( 'Typography utilities', 'tokenforge' ) ), B( 'utilities_layout', __( 'Layout utilities', 'tokenforge' ) ), B( 'utilities_color_more', __( 'Link, focus, bullet and column rule colour classes', 'tokenforge' ) ), B( 'utilities_ responsive', __( 'Breakpoint variants (-at-xs to -at-xxl)', 'tokenforge' ) ), B( 'register_with_bricks', __( 'Register classes with the builder', 'tokenforge' ), { needs: 'class_complete' } ), B( 'prune_unused', __( 'Leave out unused utility classes', 'tokenforge' ), { w: 1 } ), A( 'prune_keep', __( 'Always keep these classes', 'tokenforge' ), { rows: 2, h: __( 'Class names added by theme or plugin code, one per line or separated by spaces. End a name with * to keep every class that starts with it (bg-primary*).', 'tokenforge' ) } ) ], { custom: 'utilCount' } )328 P( __( 'Utility framework', 'tokenforge' ), 'framework', [ B( 'utilities_color', __( 'Colour utilities', 'tokenforge' ) ), B( 'utilities_spacing', __( 'Spacing utilities', 'tokenforge' ) ), B( 'utilities_typography', __( 'Typography utilities', 'tokenforge' ) ), B( 'utilities_layout', __( 'Layout utilities', 'tokenforge' ) ), B( 'utilities_color_more', __( 'Link, focus, bullet and column rule colour classes', 'tokenforge' ) ), B( 'utilities_color_aliases', __( 'Colour classes with double dashes too (bg--primary)', 'tokenforge' ) ), B( 'utilities_responsive', __( 'Breakpoint variants (-at-xs to -at-xxl)', 'tokenforge' ) ), B( 'register_with_bricks', __( 'Register classes with the builder', 'tokenforge' ), { needs: 'class_complete' } ), B( 'prune_unused', __( 'Leave out unused utility classes', 'tokenforge' ), { w: 1 } ), A( 'prune_keep', __( 'Always keep these classes', 'tokenforge' ), { rows: 2, h: __( 'Class names added by theme or plugin code, one per line or separated by spaces. End a name with * to keep every class that starts with it (bg-primary*).', 'tokenforge' ) } ) ], { custom: 'utilCount' } ) 326 329 ] } 327 330 ]; … … 2646 2649 setStatus( __( 'Saving…', 'tokenforge' ) ); 2647 2650 var pruneNew = !! ( state.framework || {} ).prune_unused && ! state.pruneWas; 2648 return api( '/save', 'POST', { tokens: state.tokens, tokens_rev: state.tokensRev, settings: state.settings, framework: state.framework, scales: state.scales, components: state.components, scheme: state.scheme, extras: state.extras, defaults: state.defaults, content: state.content, width: state.width, motion: state.motion, overlays: state.overlays, enhancements: state.enhancements, bricks_native: state.bricksNative, scss: state.scss, recipes: state.recipes, palette: state.palette, palette_rev: state.paletteRev, fonts: state.fonts, woo: state.woo, modules: state.modules } )2651 return api( '/save', 'POST', { tokens: state.tokens, tokens_rev: state.tokensRev, settings: state.settings, framework: state.framework, scales: state.scales, components: state.components, scheme: state.scheme, extras: state.extras, defaults: state.defaults, content: state.content, width: state.width, motion: state.motion, overlays: state.overlays, enhancements: state.enhancements, bricks_native: state.bricksNative, scss: state.scss, recipes: state.recipes, palette: state.palette, palette_rev: state.paletteRev, revs: state.revs, fonts: state.fonts, woo: state.woo, modules: state.modules } ) 2649 2652 .then( function ( res ) { 2650 2653 state.dirty = false; state.cheat = null; announce( res.css_ver, res.css_url ); … … 2652 2655 try { window.dispatchEvent( new CustomEvent( 'tokenforge:settings', { detail: { shortcut: state.settings.panel_shortcut || '', badges: { headings: !! ( state.enhancements || {} ).canvas_headings, focus: !! ( state.enhancements || {} ).canvas_focus } } } ) ); } catch ( e ) {} 2653 2656 return load().then( function () { 2654 if ( res.tokens_conflict && res.palette_conflict ) { return saveSay( __( 'Saved, but the tokens and the colour families had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited them here, make the edit again.', 'tokenforge' ), 'tf-err' ); } 2655 if ( res.tokens_conflict ) { return saveSay( __( 'Saved, but the tokens had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited tokens here, make the edit again.', 'tokenforge' ), 'tf-err' ); } 2656 if ( res.palette_conflict ) { return saveSay( __( 'Saved, but the colour families had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited colours here, make the edit again.', 'tokenforge' ), 'tf-err' ); } 2657 var alsoSet = ( res.settings_conflict || [] ).length ? ' ' + __( 'Some settings had changed meanwhile too and now show their current values.', 'tokenforge' ) : ''; 2658 if ( res.tokens_conflict && res.palette_conflict ) { return saveSay( __( 'Saved, but the tokens and the colour families had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited them here, make the edit again.', 'tokenforge' ) + alsoSet, 'tf-err' ); } 2659 if ( res.tokens_conflict ) { return saveSay( __( 'Saved, but the tokens had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited tokens here, make the edit again.', 'tokenforge' ) + alsoSet, 'tf-err' ); } 2660 if ( res.palette_conflict ) { return saveSay( __( 'Saved, but the colour families had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you edited colours here, make the edit again.', 'tokenforge' ) + alsoSet, 'tf-err' ); } 2661 if ( res.settings_conflict && res.settings_conflict.length ) { return saveSay( __( 'Saved, but some settings had changed meanwhile (in the builder or another window), so the dashboard now shows the current ones. If you changed them here, make the change again.', 'tokenforge' ), 'tf-err' ); } 2657 2662 if ( false === res.css_ok ) { return saveSay( __( 'Saved, but the stylesheet could not be written (the uploads folder is not writable), so the site keeps its old styles.', 'tokenforge' ), 'tf-err' ); } 2658 2663 if ( res.palette && res.palette.length ) { return saveSay( __( 'Saved · colour families updated: %s.', 'tokenforge' ).replace( '%s', res.palette.join( ', ' ) ), 'tf-ok' ); } … … 2661 2666 // "Leave out unused classes" is on with no scan yet, or was just switched on (the save no longer scans): do it now, unless a warning is showing. 2662 2667 // It runs inside the save (saveBusy), so two quick saves never scan at once; its result carries the Save message. 2663 if ( ( state.framework || {} ).prune_unused && ( pruneNew || ! ( state.classUsage || {} ).time ) && ! res.tokens_conflict && ! res.palette_conflict&& false !== res.css_ok ) { return classScan( saved ).then( function () { return saved; } ); }2668 if ( ( state.framework || {} ).prune_unused && ( pruneNew || res.rescan || ! ( state.classUsage || {} ).time ) && ! res.tokens_conflict && ! res.palette_conflict && ! ( res.settings_conflict || [] ).length && false !== res.css_ok ) { return classScan( saved ).then( function () { return saved; } ); } 2664 2669 return saved; 2665 2670 } ); … … 2700 2705 state.tokensRev = s.tokens_rev || ''; 2701 2706 state.paletteRev = s.palette_rev || ''; 2707 state.revs = s.revs || {}; // one per setting group: Save sends them back (settings_conflict) 2702 2708 [ 'settings', 'framework', 'scales', 'components', 'scheme', 'extras', 'defaults', 'content', 'width', 'motion', 'enhancements' ].forEach( function ( m ) { state[ m ] = s[ m ] || {}; } ); 2703 2709 state.pruneWas = !! state.framework.prune_unused; // a save that switches it on again rescans, since saves skip the scan while it is off -
tokenforge/trunk/assets/admin/tips.js
r3800339 r3826085 414 414 'motion.underline_width': __( 'Thickness of the animated underline.', 'tokenforge' ), 415 415 'motion.underline_duration': __( 'Length of the underline animation.', 'tokenforge' ), 416 'motion.btn_hover_fx': __( 'A hover effect every TokenForge button gets, as if it had that .on-hover-- class. Needs Hover switched on.', 'tokenforge' ), 417 'motion.btn_enter_fx': __( 'An entrance effect every TokenForge button plays as it scrolls into view, in browsers with scroll-driven animations. Needs Entrance switched on.', 'tokenforge' ), 418 'motion.btn_border_fx': __( 'A hover border effect every TokenForge button gets. Needs Hover borders switched on.', 'tokenforge' ), 416 419 'motion.disable_in_builder': __( 'Keeps scroll and visible effects still while you edit in the builder canvas or the block editor, so content is not hidden.', 'tokenforge' ), 417 420 … … 475 478 // ---- Settings ---- 476 479 'settings.sync_bricks_vars': __( 'Copies every token into the builder’s global variables, so they appear in its variable picker. The text, heading and space sizes also show as typography and spacing scales in its style manager, with the HTML font size, screen widths and default mode in its settings. A scale or setting you change there comes back into TokenForge.', 'tokenforge' ), 480 'settings.scheme_preview': __( 'Shows a small moon button beside the TokenForge button in the builder. It switches only the canvas between light and dark, for you. Nothing is saved into the page.', 'tokenforge' ), 481 'framework.utilities_color_aliases': __( 'Also writes the colour classes with a double dash (bg--primary, link-hover--primary), the names another utility framework uses, so pages moved from it keep their colours. Adds about 10 KB unless unused classes are left out.', 'tokenforge' ), 477 482 'settings.vars_trans': __( 'Sends the transparent steps of every colour (primary-trans-10 … 90, white-trans-50 …) to the builder\x27s variable list. About 400 variables.', 'tokenforge' ), 478 483 'settings.vars_channels': __( 'Sends the parts colours are built from (primary-hex, primary-rgb, primary-h, primary-s …) to the builder\x27s variable list. You rarely pick these by hand. About 400 variables.', 'tokenforge' ), -
tokenforge/trunk/includes/class-acss-import.php
r3823805 r3826085 550 550 } 551 551 } 552 $bp = $this->num( 'option-btn-full-width-mobile-breakpoint' ); 552 $bp = $this->num( 'option-btn-full-width-mobile-breakpoint' ); 553 $letter = strtolower( $this->raw( 'option-btn-full-width-mobile-breakpoint' ) ); 554 $named = array( 555 'xs' => 360, 556 's' => 480, 557 'm' => 768, 558 'l' => 992, 559 'xl' => 1280, 560 ); 561 if ( null === $bp && isset( $named[ $letter ] ) ) { 562 // Before 4.0.2 a breakpoint letter: resolve it the way the framework's own migration does. 563 $bp = null !== $this->num( "breakpoint-$letter" ) ? $this->num( "breakpoint-$letter" ) : $named[ $letter ]; 564 } 553 565 $this->apply( 554 566 'Buttons', … … 588 600 return true; 589 601 } 590 if ( 'standard' === $v ) { 591 $this->report['Cards'][] = 'option-card-concentric-radius = standard: no TokenForge equivalent, skipped'; 602 // Older files store "on", which the framework's own 4.x migration turns into "standard". 603 if ( 'standard' === $v || 'on' === $v ) { 604 $this->report['Cards'][] = 'option-card-concentric-radius = ' . $v . ': no TokenForge equivalent (the outer radius grows by the padding), skipped'; 592 605 return null; 593 606 } … … 906 919 } 907 920 } 921 // Default button effects: comma lists there, one effect each here (the first known one; the rest are reported). 922 // The names its help text uses for effects that are called differently here. 923 $alias = array( 924 'scale' => 'grow', 925 'lift' => 'float', 926 'slide-up' => 'float', 927 'slide-down' => 'sink', 928 ); 929 $btn = function ( $key, $fx ) use ( $alias ) { 930 $pick = null; 931 $rest = array(); 932 foreach ( preg_split( '/[\s,]+/', strtolower( $this->raw( $key ) ), -1, PREG_SPLIT_NO_EMPTY ) as $given ) { 933 $given = preg_replace( '/[^a-z0-9-]/', '', $given ); 934 $name = isset( $alias[ $given ] ) ? $alias[ $given ] : $given; 935 if ( null === $pick && in_array( $name, $fx, true ) ) { 936 $pick = $name; 937 } elseif ( '' !== $given ) { 938 $rest[] = $given; 939 } 940 } 941 if ( $rest ) { 942 $this->report['Motion'][] = $key . ': one effect per button, skipped ' . implode( ', ', $rest ); 943 } 944 return $pick; 945 }; 946 $map['btn_hover_fx'] = array( 'btn-hover-effects', $btn( 'btn-hover-effects', Motion::HOVER_FX ) ); 947 $map['btn_enter_fx'] = array( 'btn-enter-effects', $btn( 'btn-enter-effects', Motion::SCROLL_FX ) ); 948 $map['btn_border_fx'] = array( 'btn-border-effects', $btn( 'btn-border-effects', Motion::BORDER_FX ) ); 908 949 $this->apply( 'Motion', $s, $map ); 909 950 Motion::save_settings( $s ); … … 1003 1044 } 1004 1045 1005 /** Cascade layers, inline CSS, admin bar, Gutenberg palette . */1046 /** Cascade layers, inline CSS, admin bar, Gutenberg palette, block class field, front-end launcher. */ 1006 1047 private function plugin_settings() { 1007 1048 $settings = Settings::get_instance(); … … 1010 1051 $gen = $this->on( 'option-gutenberg-color-palette-generate' ); 1011 1052 $rep = $this->on( 'option-gutenberg-color-palette-replace' ); 1053 $launcher = ! empty( $s['frontend_launcher'] ); 1012 1054 $this->apply( 1013 1055 'Settings', … … 1024 1066 'admin_bar_link' => array( 'admin-bar-enabled', $this->on( 'admin-bar-enabled' ) ), 1025 1067 'gutenberg_palette' => array( 'option-gutenberg-color-palette-generate/replace', null === $gen ? null : ( $gen ? ( $rep ? 'replace' : 'add' ) : 'off' ) ), 1068 'block_class_field' => array( 'option-move-gutenberg-css-input', $this->on( 'option-move-gutenberg-css-input' ) ), 1069 'frontend_launcher' => array( 'option-acss-dashboard-icon-display', $this->on( 'option-acss-dashboard-icon-display' ) ), 1026 1070 ) 1027 1071 ); 1072 // That icon shows by default there, so switching the launcher on is said in plain words (same row, same count). 1073 if ( ! $launcher && ! empty( $s['frontend_launcher'] ) ) { 1074 $this->report['Settings'] = preg_replace( '/^frontend_launcher ← .*/u', 'Front-end launcher switched on (the other framework showed its dashboard icon)', $this->report['Settings'] ); 1075 } 1028 1076 $settings->save_settings( $s ); 1029 1077 } … … 1050 1098 'ctx_vars_menu' => array( 'option-contextual-menus-enable', $ctx ), 1051 1099 'ctx_class_menu' => array( 'option-contextual-menus-enable', $ctx ), 1100 'hide_stale_classes' => array( 'option-hide-deactivated-classes', $this->on( 'option-hide-deactivated-classes' ) ), 1052 1101 ) 1053 1102 ); -
tokenforge/trunk/includes/class-admin.php
r3784841 r3826085 16 16 17 17 const SLUG = 'tokenforge'; 18 19 /** 20 * Hook suffix of the Manual page. 21 * 22 * @var string 23 */ 24 private $manual_hook = ''; 18 25 19 26 /** … … 40 47 59 41 48 ); 49 $this->manual_hook = (string) add_submenu_page( 50 self::SLUG, 51 __( 'TokenForge manual', 'tokenforge' ), 52 __( 'Manual', 'tokenforge' ), 53 'manage_options', 54 self::SLUG . '-manual', 55 array( $this, 'render_manual' ) 56 ); 42 57 } 43 58 … … 49 64 */ 50 65 public function assets( $hook ) { 66 if ( $this->manual_hook && $this->manual_hook === $hook ) { 67 wp_enqueue_style( 'tokenforge-manual', TOKENFORGE_URL . 'assets/manual/manual.css', array(), TOKENFORGE_VERSION ); 68 return; 69 } 51 70 if ( 'toplevel_page_' . self::SLUG !== $hook ) { 52 71 return; … … 91 110 echo '<div id="tokenforge-app"></div></div>'; 92 111 } 112 113 /** 114 * Render the Manual page (English, from a plugin file). 115 * 116 * @return void 117 */ 118 public function render_manual() { 119 $file = TOKENFORGE_DIR . 'assets/manual/manual.html'; 120 $html = is_readable( $file ) ? (string) file_get_contents( $file ) : ''; // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- local file 121 echo '<div class="wrap tf-manual"><h1>' . esc_html__( 'TokenForge manual', 'tokenforge' ) . '</h1><div class="tf-manual-body">' . wp_kses_post( $html ) . '</div></div>'; 122 } 93 123 } -
tokenforge/trunk/includes/class-cheatsheet.php
r3798750 r3826085 69 69 70 70 // ---- Classes ---- 71 $css = self::class_css(); 71 $css = self::class_css(); 72 $same = array_flip( Framework::build( true )['aliases'] ); // the other framework's name => TokenForge's. 72 73 foreach ( Features\Builder_Enhancements::menu_classes() as $name ) { 73 list( $group, $desc ) = self::describe_class( $name );74 list( $group, $desc ) = self::describe_class( isset( $same[ $name ] ) ? $same[ $name ] : $name ); 74 75 $applied = isset( $css[ $name ] ) ? self::short( $css[ $name ] ) : ''; 75 76 if ( '' === $desc ) { 76 77 $desc = '' !== $applied ? 'Applies ' . rtrim( self::short( $applied, 110 ), ';' ) . '.' : 'Utility class ' . $name . '.'; 78 } 79 if ( isset( $same[ $name ] ) ) { 80 $desc = 'Same as .' . $same[ $name ] . '. ' . $desc; 77 81 } 78 82 $items[ $group ][] = array( -
tokenforge/trunk/includes/class-class-usage.php
r3784841 r3826085 47 47 48 48 /** 49 * A settings save asked for recheck() at shutdown. 50 * 51 * @var bool 52 */ 53 private static $recheck = false; 54 55 /** 49 56 * Hooks: new classes in saved content are added to the list. 50 57 * … … 55 62 add_action( 'updated_post_meta', array( __CLASS__, 'on_meta' ), 10, 4 ); 56 63 add_action( 'save_post', array( __CLASS__, 'on_post' ), 10, 2 ); 64 // Settings that change which utility classes exist: classes already on the site but not made 65 // at the last scan (breakpoint variants switched on, say) were never counted, so check again. 66 // Breakpoints name the aliases; tokens and colour families add classes. 67 foreach ( array( Framework::OPTION, Scale_Engine::OPTION, Modules::OPTION, Scss::OPTION, Settings::OPTION_TOKENS, Palette::OPTION ) as $option ) { 68 add_action( 'update_option_' . $option, array( __CLASS__, 'on_settings' ) ); 69 add_action( 'add_option_' . $option, array( __CLASS__, 'on_settings' ) ); 70 } 57 71 foreach ( self::OPTIONS as $option ) { 58 72 add_action( 'update_option_' . $option, array( __CLASS__, 'on_option' ), 10, 2 ); … … 245 259 'classes' => $classes, 246 260 'total' => count( $names ), 261 'names' => self::signature( $names ), 247 262 ); 248 263 update_option( self::OPTION, $out, false ); … … 266 281 $last['kept_kb'] = round( strlen( $kept['css'] ) / 1024, 1 ); 267 282 update_option( self::OPTION, $last, false ); 283 } 284 285 /** 286 * A short fingerprint of the class names the framework can make. 287 * 288 * @param array $names name => true (lookup() names). 289 * @return string 290 */ 291 private static function signature( $names ) { 292 return md5( implode( ',', array_keys( $names ) ) ); 293 } 294 295 /** 296 * Framework, scale or module settings were saved: check at the end of the request. 297 * 298 * @return void 299 */ 300 public static function on_settings() { 301 if ( ! self::$recheck && self::active() ) { 302 self::$recheck = true; 303 add_action( 'shutdown', array( __CLASS__, 'recheck' ) ); 304 } 305 } 306 307 /** 308 * A dashboard save: the queued check goes to the dashboard instead (it scans through 309 * /class-uses), so the save request itself never scans up to 5000 posts. 310 * 311 * @return bool Whether a scan is needed (the classes the framework can make changed). 312 */ 313 public static function take_recheck() { 314 if ( ! self::$recheck ) { 315 return false; 316 } 317 self::$recheck = false; 318 remove_action( 'shutdown', array( __CLASS__, 'recheck' ) ); 319 $last = self::last(); 320 list( $names ) = self::lookup(); 321 return ! isset( $last['names'] ) || self::signature( $names ) !== $last['names']; 322 } 323 324 /** 325 * When the classes the framework can make changed since the last scan, scan again and 326 * rebuild the stylesheet, so classes the site already uses are not left out. 327 * 328 * @return bool Whether it scanned. 329 */ 330 public static function recheck() { 331 self::$recheck = false; 332 if ( ! self::active() ) { 333 return false; 334 } 335 $last = self::last(); 336 list( $names ) = self::lookup(); 337 if ( isset( $last['names'] ) && self::signature( $names ) === $last['names'] ) { 338 return false; 339 } 340 self::scan(); 341 Css_Generator::get_instance()->generate(); 342 return true; 268 343 } 269 344 -
tokenforge/trunk/includes/class-contrast.php
r3794418 r3826085 46 46 * @param bool $dark Take the dark side of light-dark(). 47 47 * @param int $depth Recursion guard. 48 * @param bool $mix Also read color-mix(in srgb, X N%, transparent), for measuring only: the 49 * token files keep it out, so an import never flattens such a reference. 48 50 * @return array|null 49 51 */ 50 public static function parse( $v, $vars, $dark = false, $depth = 0 ) {52 public static function parse( $v, $vars, $dark = false, $depth = 0, $mix = false ) { 51 53 $v = trim( (string) $v ); 52 54 if ( '' === $v || $depth > 12 ) { … … 55 57 $ld = Ai::light_dark( $v ); 56 58 if ( $ld ) { 57 return self::parse( $ld[ $dark ? 1 : 0 ], $vars, $dark, $depth + 1 );59 return self::parse( $ld[ $dark ? 1 : 0 ], $vars, $dark, $depth + 1, $mix ); 58 60 } 59 61 if ( preg_match( '/^var\(\s*--([a-z0-9-]+)\s*(?:,(.*))?\)$/is', $v, $m ) ) { 60 62 $n = strtolower( $m[1] ); 61 63 if ( isset( $vars[ $n ] ) && '' !== trim( (string) $vars[ $n ] ) ) { 62 return self::parse( $vars[ $n ], $vars, $dark, $depth + 1 );63 } 64 return isset( $m[2] ) ? self::parse( $m[2], $vars, $dark, $depth + 1 ) : null;64 return self::parse( $vars[ $n ], $vars, $dark, $depth + 1, $mix ); 65 } 66 return isset( $m[2] ) ? self::parse( $m[2], $vars, $dark, $depth + 1, $mix ) : null; 65 67 } 66 68 if ( preg_match( '/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i', $v, $m ) ) { … … 76 78 if ( isset( $named[ strtolower( $v ) ] ) ) { 77 79 return $named[ strtolower( $v ) ]; 80 } 81 // color-mix(in srgb|oklch|oklab, X N%, transparent) is X at N% of its alpha (how imported muted text and ?transparency are written). 82 if ( $mix && preg_match( '/^color-mix\(\s*in\s+(?:srgb|oklch|oklab)\s*,\s*(.+?)\s+(\d*\.?\d+)%\s*,\s*transparent\s*\)$/i', $v, $m ) ) { 83 $c = self::parse( $m[1], $vars, $dark, $depth + 1, $mix ); 84 if ( null !== $c ) { 85 $c[3] *= min( 100, (float) $m[2] ) / 100; 86 } 87 return $c; 78 88 } 79 89 if ( ! preg_match( '/^(rgba?|hsla?|oklch)\(\s*([^()]*)\)$/i', $v, $m ) ) { … … 328 338 $out = array(); 329 339 foreach ( $modes as $dark ) { 330 $f = self::parse( $fg, $vars, $dark );331 $b = self::parse( $bg, $vars, $dark );340 $f = self::parse( $fg, $vars, $dark, 0, true ); 341 $b = self::parse( $bg, $vars, $dark, 0, true ); 332 342 if ( null === $f || null === $b ) { 333 343 return null; 334 344 } 335 345 $white = array( 1.0, 1.0, 1.0, 1.0 ); 336 $page = self::parse( self::PAGE, $vars, $dark ); 337 $b = self::over( $b, null === $page ? $white : self::over( $page, $white ) ); 346 $page = self::parse( self::PAGE, $vars, $dark, 0, true ); 347 // The page sits on the white canvas, anything else on the page (a translucent page is not drawn twice). 348 $b = self::over( $b, null === $page || self::PAGE === $bg ? $white : self::over( $page, $white ) ); 338 349 $f = self::over( $f, $b ); 339 350 $out[] = array( -
tokenforge/trunk/includes/class-css-generator.php
r3784841 r3826085 152 152 */ 153 153 public function editor_css() { 154 // The shop pages part too: Cart, Checkout and product blocks can be edited there. 155 return $this->build_css( false, true ) . Woo::build_shop();154 // The shop pages part too: Cart, Checkout and product blocks can be edited there. Before the SCSS, which stays last. 155 return $this->build_css( false, true, false, Woo::build_shop() ); 156 156 } 157 157 … … 177 177 * Build the CSS text from enabled tokens. 178 178 * 179 * @param bool $allow_layers Wrap the opted-in low-priority parts in @layer 180 * (false for the block editor, whose style 181 * scoping doesn't reliably handle @layer). 182 * @param bool $for_editor For the block editor (every utility class, no root font size). 183 * @param bool $full Every utility class, even ones the site does not use. 184 * @return string 185 */ 186 public function build_css( $allow_layers = true, $for_editor = false, $full = false ) { 179 * @param bool $allow_layers Wrap the opted-in low-priority parts in @layer 180 * (false for the block editor, whose style 181 * scoping doesn't reliably handle @layer). 182 * @param bool $for_editor For the block editor (every utility class, no root font size). 183 * @param bool $full Every utility class, even ones the site does not use. 184 * @param string $before_scss CSS that goes right before the developer SCSS (the block editor's shop part). 185 * @return string 186 */ 187 public function build_css( $allow_layers = true, $for_editor = false, $full = false, $before_scss = '' ) { 187 188 $tokens = Settings::get_instance()->all_variables(); 188 189 $lines = array(); … … 246 247 247 248 // Developer SCSS (tokenforge_global_scss filter) last and unlayered, so it wins over everything generated. 249 // The add-on's live SCSS preview finds this exact marker in the canvas copy and swaps what follows it. 248 250 $scss = Scss::css(); 249 $scss = '' !== $scss ? ' 250 /* --- Developer SCSS --- */ 251 ' . $scss . ' 252 ' : ''; 253 254 return $header . $order . Fonts::css() . ( isset( $defaults['reset'] ) ? $defaults['reset'] : '' ) . $parts['defaults'] . $body . $root . $parts['base'] . $parts['buttons'] . $parts['cards'] . $woo . $scheme['css'] . $extras['css'] . $parts['icons'] . Attributes::build( ! $full && ! $for_editor ) . $overlays['css'] . $motion['css'] . $width['css'] . $parts['content'] . $fw['css'] . $scss; 251 $scss = '' !== $scss ? "\n/* --- Global SCSS --- */\n" . $scss . "\n" : ''; 252 253 return $header . $order . Fonts::css() . ( isset( $defaults['reset'] ) ? $defaults['reset'] : '' ) . $parts['defaults'] . $body . $root . $parts['base'] . $parts['buttons'] . $parts['cards'] . $woo . $scheme['css'] . $extras['css'] . $parts['icons'] . Attributes::build( ! $full && ! $for_editor ) . $overlays['css'] . $motion['css'] . $width['css'] . $parts['content'] . $fw['css'] . $before_scss . $scss; 255 254 } 256 255 -
tokenforge/trunk/includes/class-framework.php
r3794418 r3826085 30 30 31 31 /** 32 * Other spellings of utility classes, kept by sites that move from another framework: 33 * a TokenForge class pattern => the other name. "{bp-}" or "{-bp}" marks where that 34 * framework puts a breakpoint ("m-" before the value, "-m" after); a pattern without 35 * one gets no alias on the -at-{bp} variants. Only classes whose CSS gives the same 36 * result as the other framework's own rule (its 3.3 output; tf-class-aliases.php). 37 * Left out because the CSS differs: grid--1 and ratio grids, col-span--all, span 38 * breakpoints, height, masonry, column counts, centring, flip, aspect, flex--col/row, 39 * flex--grow, text decorations and wrapping, text-, link- and focus- colours. 40 */ 41 const ALIASES = array( 42 '/^grid-([2-9]|1[0-2])$/' => 'grid--{bp-}$1', 43 '/^grid-stack$/' => 'grid--{bp-}1', 44 '/^flex-grid-([1-6])$/' => 'flex-grid--{bp-}$1', 45 '/^(col-start|row-start|row-end)-([1-9]|1[0-2])$/' => '$1--{bp-}$2', 46 '/^col-end-([1-9]|1[0-2]|last)$/' => 'col-end--{bp-}$1', 47 '/^(col-span|row-span)-([1-9]|1[0-2])$/' => '$1--$2', 48 '/^justify-(start|end|center|between|around)$/' => 'justify-content--$1{-bp}', 49 '/^items-(start|end|center|baseline|stretch)$/' => 'align-items--$1{-bp}', 50 '/^content-(center|stretch)$/' => 'align-content--$1{-bp}', 51 '/^self-(center|stretch)$/' => 'self--$1{-bp}', 52 '/^justify-items-(start|end|center|stretch)$/' => 'justify-items--$1{-bp}', 53 '/^order-(first|last)$/' => 'order--$1{-bp}', 54 '/^hidden$/' => 'display--{bp-}none', 55 '/^block$/' => 'display--{bp-}block', 56 '/^(inline-block|inline-flex)$/' => 'display--$1', 57 '/^display-(contents|inline|list-item)$/' => 'display--$1', 58 '/^flex-wrap$/' => 'flex--wrap', 59 '/^text-(center|left|right|justify)$/' => 'text--$1', 60 '/^font-([1-9]00)$/' => 'text--$1', 61 '/^(bold|italic|uppercase|lowercase|capitalize)$/' => 'text--$1', 62 '/^normal-case$/' => 'text--transform-none', 63 '/^(z|opacity)-(\d+|top|bottom)$/' => '$1--$2', 64 '/^fade-(top|bottom|left|right|block|inline)$/' => 'fade--$1', 65 '/^line-clamp-([1-5])$/' => 'line-clamp--$1', 66 '/^isolate$/' => 'isolation--isolate', 67 '/^invisible$/' => 'visibility--hidden', 68 '/^visible$/' => 'visibility--visible', 69 ); 70 71 /** 72 * Colour aliases, one per colour token and shade: only with "utilities_color_aliases" 73 * (about 10 KB unpruned for the default palette, the rest of ALIASES about 2.5 KB). 74 */ 75 const ALIAS_COLORS = array( 76 '/^(bg|link-hover|marker|col-rule)-([a-z][a-z0-9-]*)$/' => '$1--$2', 77 ); 78 79 /** 80 * The other framework's default breakpoints (px, at and below) that had class variants. 81 * A TokenForge breakpoint within 2px of one gets its aliases (defaults: xs, s, m, l). 82 */ 83 const ALIAS_BREAKPOINTS = array( 84 's' => 480, 85 'm' => 768, 86 'l' => 992, 87 'xl' => 1280, 88 ); 89 90 /** 91 * Class names other modules make that an alias could spell (a colour token named "dark"). 92 */ 93 const ALIAS_RESERVED = array( 'bg--light', 'bg--dark', 'bg--ultra-light', 'bg--ultra-dark' ); 94 95 /** 32 96 * Default framework toggles. 33 97 * … … 45 109 public static function builtin_defaults() { 46 110 return array( 47 'utilities_color' => true, 48 'utilities_spacing' => true, 49 'utilities_typography' => true, 50 'utilities_layout' => true, 51 'utilities_color_more' => false, // link-, link-hover-, focus-, marker- and col-rule- per colour (about 30 KB unpruned). 52 'utilities_responsive' => false, // breakpoint variants {class}-at-{bp}; off: they add a lot of CSS when unused classes are kept. 53 'register_with_bricks' => true, 54 'prune_unused' => false, // leave out utility classes the site does not use (after a scan). 55 'prune_keep' => '', // class names (or prefixes ending in *) always kept. 111 'utilities_color' => true, 112 'utilities_spacing' => true, 113 'utilities_typography' => true, 114 'utilities_layout' => true, 115 'utilities_color_more' => false, // link-, link-hover-, focus-, marker- and col-rule- per colour (about 30 KB unpruned). 116 'utilities_responsive' => false, // breakpoint variants {class}-at-{bp}; off: they add a lot of CSS when unused classes are kept. 117 'utilities_color_aliases' => false, // bg--{colour} names (ALIAS_COLORS) for sites moving from another framework. 118 'register_with_bricks' => true, 119 'prune_unused' => false, // leave out utility classes the site does not use (after a scan). 120 'prune_keep' => '', // class names (or prefixes ending in *) always kept. 56 121 ); 57 122 } … … 178 243 * utility classes" on, the CSS has only the classes the site uses; the 179 244 * names list is always complete (the builder's class list shows them all). 245 * The other spellings (ALIASES) ride on the rule of their TokenForge class 246 * and are listed only with $full: the class scan and the class menus read that 247 * list, while the Bricks sync does not register them (its picker shows them all). 180 248 * 181 249 * @param bool $full Every class, whatever the site uses (builder canvas, block editor). 182 * @return array [ 'css' => string, 'classes' => string[] ]250 * @return array [ 'css' => string, 'classes' => string[], 'aliases' => TokenForge name => alias ] 183 251 */ 184 252 public static function build( $full = false ) { … … 188 256 $classes = array(); 189 257 $keep = $full ? null : Class_Usage::keep_set(); 190 $emit = function ( $selector, $body ) use ( &$css, &$classes, $keep ) { 191 $name = ltrim( $selector, '.' ); 192 $classes[] = $name; 193 if ( null === $keep || Class_Usage::kept( $name, $keep ) ) { 194 $css[] = $selector . '{' . $body . '}'; 195 } 258 $emit = function ( $selector, $body ) use ( &$css, &$classes ) { 259 $classes[] = ltrim( $selector, '.' ); 260 $css[] = $selector . '{' . $body . '}'; 196 261 }; 197 262 … … 307 372 $grid = Scale_Engine::grid_css(); 308 373 if ( $grid['css'] ) { 309 $css[] = null === $keep ? $grid['css'] : self::kept_rules( $grid['css'], $keep );374 $css[] = $grid['css']; 310 375 $classes = array_merge( $classes, $grid['classes'] ); 311 376 } … … 319 384 $u = call_user_func( array( $family, 'build' ), $s ); 320 385 if ( $u['css'] ) { 321 $css[] = null === $keep ? $u['css'] : self::kept_rules( $u['css'], $keep );386 $css[] = $u['css']; 322 387 $classes = array_merge( $classes, $u['classes'] ); 323 388 } 324 389 } 325 390 326 $header = "\n/* --- TokenForge utility framework --- */\n"; 391 // Aliases first, then the unused rules out: a rule stays when its alias alone is used. 392 $aliases = self::aliases( $classes ); 393 $text = self::add_aliases( implode( "\n", $css ), $aliases ); 394 $header = "\n/* --- TokenForge utility framework --- */\n"; 327 395 return array( 328 'css' => $header . implode( "\n", $css ) . "\n", 329 'classes' => array_values( array_unique( $classes ) ), 396 'css' => $header . ( null === $keep ? $text : self::kept_rules( $text, $keep ) ) . "\n", 397 'classes' => array_values( array_unique( $full ? array_merge( $classes, array_values( $aliases ) ) : $classes ) ), 398 'aliases' => $aliases, 330 399 ); 400 } 401 402 /** 403 * The other spelling of each class that has one (ALIASES), never a name TokenForge makes. 404 * 405 * @param string[] $classes Class names the framework makes. 406 * @return array TokenForge name => alias. 407 */ 408 private static function aliases( $classes ) { 409 $bps = array(); // TokenForge breakpoint => the other framework's one at the same width. 410 foreach ( Scss::breakpoints() as $bp => $px ) { 411 foreach ( self::ALIAS_BREAKPOINTS as $theirs => $at ) { 412 if ( abs( $px - $at ) <= 2 ) { 413 $bps[ $bp ] = $theirs; 414 } 415 } 416 } 417 $table = self::ALIASES + ( empty( self::settings()['utilities_color_aliases'] ) ? array() : self::ALIAS_COLORS ); 418 $taken = array_fill_keys( array_merge( $classes, self::ALIAS_RESERVED ), true ); 419 $out = array(); 420 foreach ( $classes as $name ) { 421 $base = $name; 422 $bp = ''; 423 if ( preg_match( '/^(.+)-at-([a-z]+)$/', $name, $m ) ) { 424 if ( ! isset( $bps[ $m[2] ] ) ) { 425 continue; 426 } 427 $base = $m[1]; 428 $bp = $bps[ $m[2] ]; 429 } 430 foreach ( $table as $re => $to ) { 431 if ( ! preg_match( $re, $base ) ) { 432 continue; 433 } 434 if ( '' === $bp || false !== strpos( $to, '{' ) ) { 435 $alias = str_replace( array( '{bp-}', '{-bp}' ), '' === $bp ? '' : array( "$bp-", "-$bp" ), preg_replace( $re, $to, $base ) ); 436 if ( ! isset( $taken[ $alias ] ) ) { 437 $out[ $name ] = $alias; 438 $taken[ $alias ] = true; 439 } 440 } 441 break; 442 } 443 } 444 return $out; 445 } 446 447 /** 448 * Add each alias to the rules of its class, in the same line: every selector that starts 449 * with the class gets a copy that starts with the alias (same specificity and order). 450 * 451 * @param string $text One-rule-per-line CSS. 452 * @param array $aliases aliases(). 453 * @return string 454 */ 455 private static function add_aliases( $text, $aliases ) { 456 if ( ! $aliases ) { 457 return $text; 458 } 459 $out = array(); 460 foreach ( explode( "\n", $text ) as $line ) { 461 if ( preg_match( '/^(@media[^{]*\{)?([^{@]+)(\{.*)$/', $line, $m ) ) { 462 $sels = preg_split( '/,(?![^()]*\))/', $m[2] ); // not the commas inside :where(a,b). 463 foreach ( $sels as $sel ) { 464 if ( preg_match( '/^\.([A-Za-z0-9_-]+)(.*)$/', $sel, $c ) && isset( $aliases[ $c[1] ] ) ) { 465 $sels[] = '.' . $aliases[ $c[1] ] . $c[2]; 466 } 467 } 468 $line = $m[1] . implode( ',', $sels ) . $m[3]; 469 } 470 $out[] = $line; 471 } 472 return implode( "\n", $out ); 331 473 } 332 474 -
tokenforge/trunk/includes/class-frontend.php
r3800339 r3826085 36 36 // reveal/stagger them from the footer. 37 37 add_action( 'wp_head', array( $this, 'motion_head' ), 2 ); 38 add_action( 'wp_footer', array( $this, 'motion_footer' ), 20 ); 38 // Before the footer scripts (priority 20): held entrance elements must not wait for them. 39 add_action( 'wp_footer', array( $this, 'motion_footer' ), 5 ); 39 40 add_shortcode( 'tokenforge_scheme_toggle', array( $this, 'scheme_shortcode' ) ); 40 41 -
tokenforge/trunk/includes/class-motion.php
r3823805 r3826085 13 13 * - Hover effects (.on-hover--*) and hover border effects (ripple, outline, 14 14 * underline). 15 * - Default button effects: one hover, entrance and border effect for every 16 * button, by adding the buttons to that effect's own rules. 15 17 * 16 18 * Effects compose (".on-enter--fade on-enter--float"), respect … … 140 142 'underline_width' => '3px', 141 143 'underline_duration' => '.3s', 144 // ---- Default button effects: one effect name from the lists above, '' = none ---- 145 'btn_hover_fx' => '', 146 'btn_enter_fx' => '', 147 'btn_border_fx' => '', 142 148 // ---- Builders ---- 143 149 'disable_in_builder' => true, // no scroll/visible effects in the Bricks canvas or block editor. … … 344 350 } 345 351 return implode( ',', array_merge( $single, $all ) ); 352 } 353 354 /** 355 * The buttons the default button effects apply to: the set Components::build() styles, at zero 356 * specificity, so an effect class on the element (or the site's own CSS) still wins. 357 * 358 * @return string 359 */ 360 private static function btn_sel() { 361 $c = Components::settings(); 362 $sel = '.btn,[class*="btn--"]:not(.btn--none,.wp-block-button),[class*="btn--"].wp-block-button>.wp-block-button__link'; 363 if ( ! empty( $c['control_bricks_buttons'] ) ) { 364 $sel .= ',.brxe-button.bricks-button,.wp-block-button__link,button:not([class]),input[type="submit"]'; 365 } 366 return ':where(' . $sel . ')'; 367 } 368 369 /** 370 * The default button effect a setting names, or '' (none or not one of the effects). 371 * 372 * @param array $s Settings. 373 * @param string $key btn_hover_fx|btn_enter_fx|btn_border_fx. 374 * @param array $fx The effects it may name. 375 * @return string 376 */ 377 private static function btn_fx( $s, $key, $fx ) { 378 return isset( $s[ $key ] ) && in_array( $s[ $key ], $fx, true ) ? $s[ $key ] : ''; 346 379 } 347 380 … … 493 526 $x_range = 'var(--exit-range-start, cover 50%) var(--exit-range-end, cover 100%)'; 494 527 if ( $s['enter'] ) { 528 // Default button entrance: buttons join the scroll rules only (no timed play on load, no 529 // fallback), so a button never waits on the script and simply shows where scroll timelines are missing. 530 $b_fx = self::btn_fx( $s, 'btn_enter_fx', self::SCROLL_FX ); 531 $b_sel = $b_fx ? ',' . self::btn_sel() : ''; 495 532 $scroll[] = '@keyframes tf-enter{from{' . $frame( '--tf-e' ) . '}}'; 496 $scroll[] = $enter . '{' . $ident( '--tf-e' ) . ';animation-name:tf-enter;animation-duration:auto;animation-timing-function:linear;animation-fill-mode:both;animation-timeline:view();animation-range:' . $e_range . '}';533 $scroll[] = $enter . $b_sel . '{' . $ident( '--tf-e' ) . ';animation-name:tf-enter;animation-duration:auto;animation-timing-function:linear;animation-fill-mode:both;animation-timeline:view();animation-range:' . $e_range . '}'; 497 534 foreach ( self::fx_props( 'enter', '--tf-e' ) as $f => $d ) { 498 $scroll[] = ".on-enter--$f,.on-enter-all--$f>* {". $d . '}';535 $scroll[] = ".on-enter--$f,.on-enter-all--$f>*" . ( $f === $b_fx ? $b_sel : '' ) . '{' . $d . '}'; 499 536 } 500 537 // Stagger: each child's range starts a little later. … … 544 581 $scroll[] = '@keyframes tf-enter-now{from{' . $frame( '--tf-e' ) . '}}'; 545 582 $scroll[] = $now . "{animation-name:tf-enter-now;animation-fill-mode:both;animation-timeline:auto;animation-range:normal;animation-duration:$timed;animation-timing-function:$ease;animation-delay:$wait}"; 583 // Until the footer script has marked them (.tf-enter-wait from the head script), every entrance 584 // element holds its start frame, so a hero painted early does not show and then jump back. 585 $scroll[] = ':is(.tf-enter-wait ' . str_replace( ',', ',.tf-enter-wait ', $enter ) . "){animation-name:tf-enter-now;animation-fill-mode:both;animation-timeline:auto;animation-range:normal;animation-duration:$timed;animation-play-state:paused}"; 546 586 if ( $s['exit'] ) { 547 587 $scroll[] = $now . ':is(' . $exit . "){animation-name:tf-enter-now,tf-exit;animation-fill-mode:both,forwards;animation-timeline:auto,view();animation-range:normal,$x_range;animation-duration:$timed,auto;animation-timing-function:$ease,linear;animation-delay:$wait,0s}"; … … 628 668 } 629 669 670 $btn_tr = array(); // Transitions the default button effects need on buttons. 671 630 672 // ---- Hover ---- 631 673 if ( $s['hover'] ) { … … 649 691 $css[] = '.on-hover--fade:hover{opacity:var(--hover-fade-opacity, .8)}'; 650 692 $css[] = '.on-hover--brighten:hover{filter:brightness(var(--hover-brighten-amount, 1.1))}'; 693 // Default button hover: buttons join that effect's :hover rule (they keep their own transition). 694 $f = self::btn_fx( $s, 'btn_hover_fx', self::HOVER_FX ); 695 if ( $f ) { 696 $css = str_replace( ".on-hover--$f:hover{", ".on-hover--$f:hover," . self::btn_sel() . ':hover{', $css ); 697 $t = ' var(--hover-duration, .3s) var(--hover-timing, ease-in-out)'; 698 foreach ( array( 'scale', 'translate', 'box-shadow', 'opacity', 'filter' ) as $p ) { 699 $btn_tr[] = $p . $t; 700 } 701 } 651 702 } 652 703 … … 663 714 $ow = 'var(--border-outline-width, 4px)'; 664 715 $ot = 'var(--border-outline-duration, .3s) var(--hover-timing, ease-in-out)'; 665 $css[] = '.on-hover--outline-out,.on-hover--outline-in{outline:' . $ow . ' solid transparent;transition:outline-color ' . $ot . ',outline-offset ' . $ot . '}'; 716 $css[] = '.on-hover--outline-out,.on-hover--outline-in{outline:' . $ow . ' solid transparent}'; 717 // Written as attribute selectors so a default button effect never joins it (buttons get it through --btn-transition). 718 $css[] = '[class~="on-hover--outline-out"],[class~="on-hover--outline-in"]{transition:outline-color ' . $ot . ',outline-offset ' . $ot . '}'; 666 719 $css[] = '.on-hover--outline-out{outline-offset:0}.on-hover--outline-in{outline-offset:calc(' . $ow . ' * 2)}'; 667 720 $css[] = '.on-hover--outline-out:hover{outline-color:var(--border-outline-color, currentColor);outline-offset:' . $ow . '}'; … … 669 722 // Underline drawn by a pseudo-element, growing from the chosen side. 670 723 $u = '.on-hover--underline-left,.on-hover--underline-center,.on-hover--underline-right'; 671 $css[] = ':where( ' . $u . '){position:relative}';724 $css[] = ':where([class~="on-hover--underline-left"],[class~="on-hover--underline-center"],[class~="on-hover--underline-right"]){position:relative}'; // Buttons: below, without the focus exception. 672 725 $css[] = ':is(' . $u . ')::after{content:"";position:absolute;inset-inline:0;inset-block-end:0;block-size:var(--border-underline-width, 3px);background:var(--border-underline-color, currentColor);scale:0 1;pointer-events:none;transition:scale var(--border-underline-duration, .3s) var(--hover-timing, ease-in-out)}'; 673 726 $css[] = '.on-hover--underline-left::after{transform-origin:left}.on-hover--underline-center::after{transform-origin:center}.on-hover--underline-right::after{transform-origin:right}'; … … 676 729 $classes[] = "on-hover--$f"; 677 730 } 731 // Default button border effect: buttons join every selector list of that effect's class. 732 $f = self::btn_fx( $s, 'btn_border_fx', self::BORDER_FX ); 733 if ( $f ) { 734 // The pseudo part (:hover, ::after) is repeated for the button; a keyboard focus ring wins over the effect. 735 $btn = ':where(' . self::btn_sel() . ':not(:focus-visible))'; 736 $css = preg_replace( '/\.on-hover--' . $f . '((?:::?[a-z-]+)*)(?=[,{)])/', '$0,' . $btn . '$1', $css ); 737 if ( 0 === strpos( $f, 'underline-' ) ) { 738 $css[] = self::btn_sel() . '{position:relative}'; 739 } elseif ( 0 === strpos( $f, 'outline-' ) ) { 740 $btn_tr[] = 'outline-color ' . $ot; 741 $btn_tr[] = 'outline-offset ' . $ot; 742 } 743 } 744 } 745 // Buttons animate the default effects: their transition comes from --btn-transition (Components), extended here. 746 // A custom one (Buttons screen) is kept; "none" or a CSS-wide keyword stays as set (a list after it is invalid), "all" already covers the effect. 747 $bt = self::clean( Components::settings()['btn_transition'] ?? '' ); 748 if ( $btn_tr && ! preg_match( '/^(none|inherit|initial|unset|revert(-layer)?)$/i', $bt ) && ! preg_match( '/(?:^|,)\s*all(?![\w-])/i', $bt ) ) { 749 $css[] = self::btn_sel() . '{--btn-transition:' . ( '' === $bt ? 'var(--transition, background-color .15s, color .15s, border-color .15s)' : $bt ) . ',' . implode( ',', $btn_tr ) . '}'; 678 750 } 679 751 … … 702 774 $sel = array(); 703 775 if ( $s['enter'] ) { 704 $sel[] = self::sel( 'enter', self::SCROLL_FX ) . ',.on-enter--parallax' ;776 $sel[] = self::sel( 'enter', self::SCROLL_FX ) . ',.on-enter--parallax' . ( self::btn_fx( $s, 'btn_enter_fx', self::SCROLL_FX ) ? ',' . self::btn_sel() : '' ); 705 777 } 706 778 if ( $s['exit'] ) { … … 736 808 } 737 809 if ( $s['enter'] ) { 738 $add[] = 'if( !(W.CSS&&CSS.supports&&CSS.supports("animation-timeline: view()"))){R.classList.add("tf-motion-fallback")}';810 $add[] = 'if(W.CSS&&CSS.supports&&CSS.supports("animation-timeline: view()")){R.classList.add("tf-enter-wait")}else{R.classList.add("tf-motion-fallback")}'; 739 811 } 740 812 if ( ! $add ) { … … 744 816 (function(){var R=document.documentElement,W=window;if(!("IntersectionObserver" in W)||(W.matchMedia&&W.matchMedia("(prefers-reduced-motion: reduce)").matches)){return} 745 817 %ADD% 746 setTimeout(function(){if(!W.tfMotionReady){R.classList.remove("tf-motion","tf-motion-fallback" )}},4000)})();818 setTimeout(function(){if(!W.tfMotionReady){R.classList.remove("tf-motion","tf-motion-fallback","tf-enter-wait")}},4000)})(); 747 819 JS; 748 820 return str_replace( '%ADD%', implode( '', $add ), $js ); … … 756 828 */ 757 829 public static function script() { 758 // shortcut: a hero painted before this footer script runs shows once, then plays from the start (.tf-now); hide entrance elements from the head script if that flash shows on real sites.759 830 $s = self::settings(); 760 831 $t = (float) $s['visible_threshold']; … … 762 833 $js = <<<'JS' 763 834 (function(){var d=document,R=d.documentElement,W=window;W.tfMotionReady=1; 764 d.querySelectorAll(".on-enter--stagger,.on-exit--stagger,.on-visible--stagger").forEach(function(p){for(var i=0;i<p.children.length;i++){p.children[i].style.setProperty("--tf-i",i)}}); 765 if(W.CSS&&CSS.supports&&CSS.supports("animation-timeline: view()")){var tn=[];d.querySelectorAll('[class*="on-enter"]').forEach(function(e){var c=e.getAttribute("class")||"";if(!has(c,"enter","stagger|parallax")||/(^|\s)on-enter--parallax(\s|$)/.test(c)){return}[].forEach.call(/(^|\s)on-enter-all--/.test(c)?e.children:[e],function(x){var r=x.getBoundingClientRect();if(r.top<W.innerHeight&&r.bottom>0&&r.left<W.innerWidth&&r.right>0){tn.push(x)}})});tn.forEach(function(x){x.classList.add("tf-now")})} 835 if(W.CSS&&CSS.supports&&CSS.supports("animation-timeline: view()")){var tn=[];d.querySelectorAll('[class*="on-enter"]').forEach(function(e){var c=e.getAttribute("class")||"";if(!has(c,"enter","stagger|parallax")||/(^|\s)on-enter--parallax(\s|$)/.test(c)){return}[].forEach.call(/(^|\s)on-enter-all--/.test(c)?e.children:[e],function(x){var r=x.getBoundingClientRect();if(r.top<W.innerHeight&&r.bottom>0&&r.left<W.innerWidth&&r.right>0){tn.push(x)}})});tn.forEach(function(x){x.classList.add("tf-now")});R.classList.remove("tf-enter-wait")} 766 836 var RV='[data-tf-reveal="fade"],[data-tf-reveal="up"]',V=R.classList.contains("tf-motion"),F=R.classList.contains("tf-motion-fallback"),io; 767 837 var T=%T%,th=[0];for(var x=.05;x<T;x+=.05){th.push(x)}th.push(T); … … 770 840 function has(c,fam,skip){return new RegExp("(^|\\s)on-"+fam+"(-all)?--(?!("+skip+")(\\s|$))").test(c)} 771 841 function obs(e){io=io||new IntersectionObserver(function(es){es.forEach(function(e){if(e.isIntersecting&&(e.intersectionRatio>=T||e.intersectionRect.height>=W.innerHeight*T)){e.target.classList.add("tf-in");if(e.target.tfV){done(e.target)}io.unobserve(e.target)}})},{threshold:th});io.observe(e)} 772 function scan(r){var l=[].slice.call(r.querySelectorAll('[class*="on-visible"],[class*="on-enter"],[ data-tf-reveal]')),a=0,b=0;if(r.nodeType===1){l.unshift(r)}l.forEach(function(e){var c=e.getAttribute("class")||"";if(V&&!e.tfV&&(e.matches(RV)||has(c,"visible","stagger"))){e.tfV=1;a++;obs(e)}if(F&&!e.tfE&&has(c,"enter","stagger|parallax")){e.tfE=1;b++;obs(e)}});return[a,b]}773 var n=scan(d) ;774 if(!n[0]){V=0;R.classList.remove("tf-motion")}if(!n[1]){F=0;R.classList.remove("tf-motion-fallback")}842 function scan(r){var l=[].slice.call(r.querySelectorAll('[class*="on-visible"],[class*="on-enter"],[class*="on-exit"],[data-tf-reveal]')),a=0,b=0;if(r.nodeType===1){l.unshift(r)}l.forEach(function(e){var c=e.getAttribute("class")||"";if(/(^|\s)on-(enter|exit|visible)--stagger(\s|$)/.test(c)){for(var i=0;i<e.children.length;i++){e.children[i].style.setProperty("--tf-i",i)}}if(V&&!e.tfV&&(e.matches(RV)||has(c,"visible","stagger"))){e.tfV=1;a++;obs(e)}if(F&&!e.tfE&&has(c,"enter","stagger|parallax")){e.tfE=1;b++;obs(e)}});return[a,b]} 843 var n=scan(d),mo; 844 function cut(){if(!n[0]){V=0;R.classList.remove("tf-motion")}if(!n[1]){F=0;R.classList.remove("tf-motion-fallback")}if(!(V||F)&&mo){mo.disconnect()}} 775 845 if(!(V||F)){return} 776 new MutationObserver(function(ms){ms.forEach(function(m){[].forEach.call(m.addedNodes,function(x){if(1===x.nodeType){scan(x)}})})}).observe(d.body,{childList:true,subtree:true})})(); 846 mo=new MutationObserver(function(ms){ms.forEach(function(m){[].forEach.call(m.addedNodes,function(x){if(1===x.nodeType){var k=scan(x);n[0]+=k[0];n[1]+=k[1]}})})});mo.observe(d.body,{childList:true,subtree:true}); 847 if(d.readyState==="loading"){d.addEventListener("DOMContentLoaded",cut)}else{cut()}})(); 777 848 JS; 778 849 return str_replace( '%T%', (string) $t, $js ); -
tokenforge/trunk/includes/class-plugin.php
r3800339 r3826085 200 200 } 201 201 } 202 // 0.58.2 adds class-name aliases: a scan from before never counted them, so check again once. 203 if ( $previous && version_compare( (string) $previous, '0.58.2', '<' ) ) { 204 Class_Usage::on_settings(); 205 } 202 206 Css_Generator::get_instance()->rebuild(); 203 207 update_option( 'tokenforge_version', TOKENFORGE_VERSION ); -
tokenforge/trunk/includes/class-recipes.php
r3800339 r3826085 173 173 $r['query-children'] = array( 'Code', "return [\n\t'post_type' => 'page', /* the post type */\n\t'post_parent__not_in' => [ 0 ], /* only child posts */\n\t'posts_per_page' => -1,\n\t'post_status' => 'publish',\n];{{cursor}}", null, false ); 174 174 $r['property'] = array( 'Code', "@property --{{cursor}}name {\n\tsyntax: \"<length>\";\n\tinherits: false;\n\tinitial-value: 0px;\n}", null, false ); 175 176 // ---- Gradients: values for a background (or any image) property; text and border are declarations. 177 $r['linear-gradient'] = array( 'Gradients', 'linear-gradient(180deg, var(--primary), var(--primary-dark))', null, true ); 178 $r['gradient-radial'] = array( 'Gradients', 'radial-gradient(circle, var(--primary-light), var(--primary-dark))', null, true ); 179 $r['gradient-conic'] = array( 'Gradients', 'conic-gradient(from 0deg, var(--primary), var(--primary-dark), var(--primary))', null, true ); 180 $r['gradient-sharp'] = array( 'Gradients', 'linear-gradient(180deg, var(--primary) 50%, var(--primary-dark) 50%)', null, true ); 181 $r['gradient-fade'] = array( 'Gradients', 'linear-gradient(180deg, var(--primary), transparent)', null, true ); 182 $r['gradient-vignette'] = array( 'Gradients', 'radial-gradient(circle, transparent 50%, var(--black-trans-60))', null, true ); 183 $r['gradient-text'] = array( 'Gradients', "/* Gradient text: the letters show the gradient */\nbackground-image: linear-gradient(90deg, var(--primary), var(--primary-dark));\n-webkit-background-clip: text;\nbackground-clip: text;\ncolor: transparent;{{cursor}}", null, false ); 184 $r['gradient-border'] = array( 'Gradients', "/* Gradient border: the inside keeps the surface colour, the border shows the gradient */\nborder: 2px solid transparent;\nbackground: linear-gradient(var(--bg), var(--bg)) padding-box, linear-gradient(90deg, var(--primary), var(--primary-dark)) border-box;{{cursor}}", null, false ); 185 186 // ---- Pseudo-classes and pseudo-elements on the element itself. 187 $r['before'] = array( 'Pseudo', "%root%::before {\n\tcontent: \"\";\n\t{{cursor}}\n}", null, false ); 188 $r['after'] = array( 'Pseudo', "%root%::after {\n\tcontent: \"\";\n\t{{cursor}}\n}", null, false ); 189 $r['before-after'] = array( 'Pseudo', "%root%::before,\n%root%::after {\n\tcontent: \"\";\n\t{{cursor}}\n}", null, false ); 190 $r['hover'] = array( 'Pseudo', "%root%:hover {\n\t{{cursor}}\n}", null, false ); 191 $r['focus-visible'] = array( 'Pseudo', "%root%:focus-visible {\n\t{{cursor}}\n}", null, false ); 192 $r['hover-focus'] = array( 'Pseudo', "%root%:hover,\n%root%:focus-visible {\n\t{{cursor}}\n}", null, false ); 193 $r['hover-exclude-touch'] = array( 'Pseudo', "/* Hover only with a mouse or trackpad: touch screens skip it, so a tap never leaves it stuck on */\n@media (hover: hover) and (pointer: fine) {\n\t%root%:hover {\n\t\t{{cursor}}\n\t}\n}", null, false ); 194 195 // ---- Colour mixing (values). 196 $r['color-mix'] = array( 'Color', 'color-mix(in oklch, var(--primary) 50%, var(--bg))', null, true ); 197 $r['transparency'] = array( 'Color', 'color-mix(in oklch, var(--primary) 10%, transparent)', null, true ); 198 199 // ---- More helpers. 200 $r['tooltip'] = array( 'Interaction', "/* Tooltip: the text of data-tooltip=\"Your text\" shows above on hover and keyboard focus (make the element focusable, e.g. a button) */\n%root% {\n\t--tooltip-background: var(--text-dark);\n\t--tooltip-color: var(--bg-ultra-light);\n\t--tooltip-gap: 0.5em;\n\tposition: relative;\n\ttext-decoration: underline dashed 1px;\n\ttext-underline-offset: 0.25em;\n}\n%root%::after {\n\tcontent: attr(data-tooltip);\n\tposition: absolute;\n\tinset-block-end: calc(100% + var(--tooltip-gap));\n\tinset-inline-start: 50%;\n\ttranslate: -50% 0;\n\tinline-size: max-content;\n\tmax-inline-size: 30ch;\n\tpadding: 0.25em 0.5em;\n\tborder-radius: var(--radius);\n\tbackground: var(--tooltip-background);\n\tcolor: var(--tooltip-color);\n\tfont-size: var(--text-s);\n\tline-height: 1.3;\n\ttext-align: center;\n\tpointer-events: none;\n\topacity: 0;\n\tvisibility: hidden;\n\ttransition: opacity 0.15s, visibility 0.15s;\n\tz-index: 10;\n}\n%root%:is(:hover, :focus-visible)::after {\n\topacity: 1;\n\tvisibility: visible;\n}{{cursor}}", null, false ); 201 $r['skip-link'] = array( 'Interaction', "/* Skip link: waits above the page and slides in on keyboard focus */\n%root% {\n\tposition: absolute !important;\n\tinset-block-start: 1rem;\n\tinset-inline-start: 1rem;\n\tz-index: 100;\n\ttransform: translateY(-250%);\n}\n%root%:focus-visible {\n\ttransform: translateY(0);\n}{{cursor}}", null, false ); 202 $r['footer-reveal'] = array( 'Layout', "/* Footer reveal: the page slides up and uncovers this footer (the footer comes right after main) */\n%root% {\n\tposition: sticky;\n\tinset-block-end: 0;\n\tz-index: 0;\n}\nmain:has(+ %root%) {\n\tposition: relative;\n\tz-index: 1;\n\tbackground: var(--body-bg-color, var(--bg-ultra-light, #fff));\n\tbox-shadow: 0 1em 1em -0.5em var(--black-trans-10);\n}{{cursor}}", null, false ); 203 $r['concentric-radius-reverse'] = array( 'Layout', "/* Concentric corners, the other way round: the inner radius = outer radius minus the padding */\n%root% {\n\t--padding: var(--space-m);\n\tpadding: var(--padding);\n\tborder-radius: var(--radius);\n}\n/* the child that gets the inner radius (never below 4px) */\n%root% > * {\n\tborder-radius: max(4px, var(--radius) - var(--padding));\n\toverflow: hidden;\n}{{cursor}}", null, false ); 204 $r['is-bg'] = array( 'Layout', "/* Background element: fills its parent behind the content (an image, a video, a shape) */\n:has(> %root%) {\n\tposition: relative;\n\tisolation: isolate;\n}\n%root% {\n\tposition: absolute !important;\n\tinset: 0;\n\tinline-size: 100%;\n\tblock-size: 100%;\n\tobject-fit: cover;\n\tz-index: -2; /* overlays sit at -1 */\n\tpointer-events: none;\n}\n%root% > img {\n\tinline-size: 100%;\n\tblock-size: 100%;\n\tobject-fit: cover;\n}{{cursor}}", null, false ); 205 $r['border-check'] = array( 'Layout', "/* Debug: a red outline shows this element's box (remove it when done) */\noutline: 2px solid red !important;\noutline-offset: -2px;{{cursor}}", null, false ); 206 foreach ( array( 207 'all' => array( 'center', 'center' ), 208 'top' => array( 'start', 'center' ), 209 'bottom' => array( 'end', 'center' ), 210 'left' => array( 'center', 'start' ), 211 'right' => array( 'center', 'end' ), 212 ) as $at => $v ) { 213 $r[ "center-$at" ] = array( 'Layout', "display: grid;\nalign-content: {$v[0]};\njustify-items: {$v[1]};{{cursor}}", null, false ); 214 } 215 // Both fades at once: the two masks intersect (added together, each would hide the other's fade). 216 $all = 'linear-gradient(' . $fades['block'] . '), linear-gradient(' . $fades['inline'] . ')'; 217 $r['fade-all'] = array( 'Fades', "/* Fade out: all four edges */\n%root% {\n\t--fade-amount: 15%;\n\t-webkit-mask-image: $all;\n\t-webkit-mask-composite: source-in;\n\tmask-image: $all;\n\tmask-composite: intersect;\n}{{cursor}}", null, false ); 175 218 176 219 return $r; -
tokenforge/trunk/includes/class-rest.php
r3798750 r3826085 16 16 17 17 const NS = 'tokenforge/v1'; 18 19 /** 20 * The setting groups /save writes whole (body key => getter; 'settings' is the Settings instance). 21 * /state sends a rev of each ('revs'), so a window loaded before another save can't undo it. 22 */ 23 const STORED = array( 24 'settings' => null, 25 'framework' => array( Framework::class, 'settings' ), 26 'scales' => array( Scale_Engine::class, 'settings' ), 27 'components' => array( Components::class, 'settings' ), 28 'scheme' => array( Scheme::class, 'settings' ), 29 'extras' => array( Extras::class, 'settings' ), 30 'defaults' => array( Defaults::class, 'settings' ), 31 'width' => array( Width::class, 'settings' ), 32 'content' => array( Content::class, 'settings' ), 33 'motion' => array( Motion::class, 'settings' ), 34 'overlays' => array( Overlays::class, 'settings' ), 35 'woo' => array( Woo::class, 'settings' ), 36 'fonts' => array( Fonts::class, 'settings' ), 37 'modules' => array( Modules::class, 'settings' ), 38 'enhancements' => array( Features\Builder_Enhancements::class, 'settings' ), 39 'scss' => array( Scss::class, 'settings' ), 40 'recipes' => array( Recipes::class, 'settings' ), 41 'bricks_native' => array( Features\Builder_Enhancements::class, 'native_settings' ), 42 ); 18 43 19 44 /** … … 809 834 'tokens' => $tokens, 810 835 'tokens_rev' => self::tokens_rev( $tokens ), // Save sends it back: a window opened before a builder edit can't drop the new tokens. 836 'revs' => array_map( array( __CLASS__, 'settings_rev' ), self::stored_settings() ), // the same for each setting group. 811 837 'settings' => $settings->get_settings(), 812 838 'framework' => Framework::settings(), … … 889 915 890 916 /** 917 * The setting groups as stored (module switches not applied), by /save body key. 918 * 919 * @return array 920 */ 921 private static function stored_settings() { 922 return Modules::raw( 923 function () { 924 $out = array(); 925 foreach ( self::STORED as $key => $get ) { 926 $out[ $key ] = null === $get ? Settings::get_instance()->get_settings() : call_user_func( $get ); 927 } 928 return $out; 929 } 930 ); 931 } 932 933 /** 934 * A fingerprint of a setting group that survives the trip through the browser 935 * (numbers as strings, keys sorted: 16.0, 16 and "16" are the same). 936 * 937 * @param mixed $value Setting group. 938 * @return string 939 */ 940 private static function settings_rev( $value ) { 941 $norm = function ( $v ) use ( &$norm ) { 942 if ( is_array( $v ) ) { 943 ksort( $v ); 944 return array_map( $norm, $v ); 945 } 946 return is_int( $v ) || is_float( $v ) ? (string) ( 0 + $v ) : $v; 947 }; 948 return md5( (string) wp_json_encode( $norm( $value ) ) ); 949 } 950 951 /** 891 952 * The linked Bricks theme style (for the dashboard). 892 953 * … … 936 997 $old_w = Width::settings(); 937 998 $old_m = Motion::settings(); 999 1000 // A setting group changed (builder, another window) since this window loaded it, and this window 1001 // would change it again: keep the stored one, as with tokens_rev. Without 'revs' (older clients) as before. 1002 $settings_conflict = array(); 1003 if ( isset( $body['revs'] ) && is_array( $body['revs'] ) ) { 1004 foreach ( self::stored_settings() as $key => $have ) { 1005 $rev = self::settings_rev( $have ); 1006 $base = isset( $body['revs'][ $key ] ) && is_string( $body['revs'][ $key ] ) ? $body['revs'][ $key ] : ''; 1007 if ( '' !== $base && $rev !== $base && isset( $body[ $key ] ) && is_array( $body[ $key ] ) && self::settings_rev( array_intersect_key( $body[ $key ], $have ) ) !== $rev ) { 1008 $settings_conflict[] = $key; 1009 unset( $body[ $key ] ); // skipped by the saves below. 1010 } 1011 } 1012 } 938 1013 939 1014 if ( isset( $body['settings'] ) && is_array( $body['settings'] ) ) { … … 1038 1113 return rest_ensure_response( 1039 1114 array( 1040 'ok' => true, 1041 'count' => count( $stored ), 1042 'css_url' => Css_Generator::get_instance()->css_url(), 1043 'css_ver' => Css_Generator::get_instance()->version(), 1044 'tokens_conflict' => $tokens_conflict, 1045 'palette_conflict' => $palette_conflict, 1046 'css_ok' => (bool) $css_ok, 1047 'palette' => $palette, 1048 'theme_style' => self::theme_style(), 1115 'ok' => true, 1116 'count' => count( $stored ), 1117 'css_url' => Css_Generator::get_instance()->css_url(), 1118 'css_ver' => Css_Generator::get_instance()->version(), 1119 'tokens_conflict' => $tokens_conflict, 1120 'palette_conflict' => $palette_conflict, 1121 'settings_conflict' => $settings_conflict, // the setting groups kept as stored (body keys). 1122 'css_ok' => (bool) $css_ok, 1123 // The dashboard scans next (/class-uses); it skips the scan after a conflict or a failed write, so the check stays queued then. 1124 'rescan' => ( $tokens_conflict || $palette_conflict || $settings_conflict || ! $css_ok ) ? false : Class_Usage::take_recheck(), 1125 'palette' => $palette, 1126 'theme_style' => self::theme_style(), 1049 1127 ) 1050 1128 ); -
tokenforge/trunk/includes/class-settings.php
r3800339 r3826085 102 102 'frontend_launcher' => false, // a floating TokenForge button on the front end. 103 103 'canvas_panel' => true, // a TokenForge button in the builder canvas while editing (opens the window). 104 'scheme_preview' => true, // a light/dark preview button for the builder canvas (shown only while dark mode is on). 104 105 'ai_abilities' => true, // tokenforge/* abilities (MCP tools) for AI agents. 105 106 'ai_guidance' => true, // tell agents to use TokenForge (MCP instructions, Bricks orientation + design context). … … 154 155 'frontend_launcher' => ! empty( $settings['frontend_launcher'] ), 155 156 'canvas_panel' => ! empty( $settings['canvas_panel'] ), 157 'scheme_preview' => ! empty( $settings['scheme_preview'] ), 156 158 'ai_abilities' => ! empty( $settings['ai_abilities'] ), 157 159 'ai_guidance' => ! empty( $settings['ai_guidance'] ), -
tokenforge/trunk/includes/features/class-block-editor.php
r3800339 r3826085 45 45 return $hit['rows']; 46 46 } 47 if ( ! is_readable( $file ) || ! preg_match_all( '/(?<![\w\-\\\\)\]:.>+~* ]) \.(-?[_a-zA-Z][\w\-]*)\{([^{}]+)\}/', (string) file_get_contents( $file ), $m, PREG_SET_ORDER ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- a local file.47 if ( ! is_readable( $file ) || ! preg_match_all( '/(?<![\w\-\\\\)\]:.>+~* ])((?:\.-?[_a-zA-Z][\w\-]*,)*\.-?[_a-zA-Z][\w\-]*)\{([^{}]+)\}/', (string) file_get_contents( $file ), $m, PREG_SET_ORDER ) ) { // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents -- a local file. 48 48 return $out; 49 49 } 50 50 foreach ( $m as $x ) { 51 if ( ! isset( $out[ $x[1] ] ) ) { 52 $out[ $x[1] ] = strlen( $x[2] ) > 80 ? substr( $x[2], 0, 77 ) . '...' : $x[2]; 51 // A list of plain classes shares one rule (.grid-3,.grid--3): each name gets the preview. 52 foreach ( explode( ',', $x[1] ) as $name ) { 53 $name = substr( $name, 1 ); 54 if ( ! isset( $out[ $name ] ) ) { 55 $out[ $name ] = strlen( $x[2] ) > 80 ? substr( $x[2], 0, 77 ) . '...' : $x[2]; 56 } 53 57 } 54 58 } -
tokenforge/trunk/includes/features/class-builder-enhancements.php
r3800339 r3826085 364 364 365 365 /** 366 * Every utility/component class TokenForge generates (for the class menu). 366 * Every utility/component class TokenForge generates (for the class menu), 367 * with the other framework's spellings (grid--3), so their users find them. 367 368 * 368 369 * @return string[] 369 370 */ 370 371 public static function menu_classes() { 371 $names = array();372 foreach ( array( '\TokenForge\ Framework', '\TokenForge\Components', '\TokenForge\Scheme', '\TokenForge\Extras', '\TokenForge\Defaults', '\TokenForge\Content', '\TokenForge\Width', '\TokenForge\Overlays', '\TokenForge\Motion' ) as $cls ) {372 $names = \TokenForge\Framework::build( true )['classes']; // true: with the aliases. 373 foreach ( array( '\TokenForge\Components', '\TokenForge\Scheme', '\TokenForge\Extras', '\TokenForge\Defaults', '\TokenForge\Content', '\TokenForge\Width', '\TokenForge\Overlays', '\TokenForge\Motion' ) as $cls ) { 373 374 $b = call_user_func( array( $cls, 'build' ) ); 374 375 $names = array_merge( $names, $b['classes'] ); -
tokenforge/trunk/includes/features/class-builders.php
r3800339 r3826085 118 118 } 119 119 } 120 // The canvas light/dark preview button, only while dark mode is on (a preview: nothing is saved). 121 if ( 'auto' === \TokenForge\Scheme::settings()['dark_mode'] && ! empty( \TokenForge\Settings::get_instance()->get_settings()['scheme_preview'] ) ) { 122 wp_enqueue_script( 'tokenforge-scheme-preview', TOKENFORGE_URL . 'assets/builder/scheme-preview.js', array( 'wp-i18n' ), TOKENFORGE_VERSION, true ); 123 wp_set_script_translations( 'tokenforge-scheme-preview', 'tokenforge' ); 124 } 120 125 /** 121 126 * Fires in the editor page of every supported page builder, for users who can edit posts, -
tokenforge/trunk/includes/platforms/class-bricks-style-manager.php
r3797232 r3826085 18 18 * its own stamp held when the builder loaded it: only what differs from that is 19 19 * an edit, so an old builder tab never undoes a newer TokenForge save. 20 * Two tabs can hold the same stamp: each builder load also marks our scales and 21 * settings with its own tab id (tokenforgeTab, never stored), and a tab that saved 22 * before is compared with what it saved last. So a second tab only changes what it 23 * changed itself, and one tab can still set its own change back. 20 24 * 21 25 * Only runs when Bricks is the active theme and variables are synced. … … 48 52 49 53 /** 54 * The builder tab ids each option's latest write sent (option => part => tab id), taken off before it is stored. 55 * 56 * @var array 57 */ 58 private static $sent = array(); 59 60 /** 50 61 * The settings keys TokenForge looks after. 51 62 */ … … 67 78 add_action( 'update_option_' . $opt, array( __CLASS__, 'on_saved' ), 20, 0 ); 68 79 add_action( 'add_option_' . $opt, array( __CLASS__, 'on_saved' ), 20, 0 ); 80 add_filter( 'option_' . $opt, array( __CLASS__, 'tag_tab' ) ); 81 add_filter( 'pre_update_option_' . $opt, array( __CLASS__, 'strip_tab' ), 10, 3 ); 69 82 } 70 83 add_action( 'update_option_' . self::VARS, array( __CLASS__, 'on_vars_saved' ), 20, 2 ); 84 } 85 86 /** 87 * The builder page: our scales and the settings get one id per load (the builder sends it back 88 * on save), so on_saved() tells two tabs on the same stamp apart. push() drops it again. 89 * 90 * @param mixed $value Categories or Style Manager settings, as stored. 91 * @return mixed 92 */ 93 public static function tag_tab( $value ) { 94 static $tab = ''; 95 if ( ! is_array( $value ) || ! function_exists( 'bricks_is_builder_main' ) || ! bricks_is_builder_main() || ! self::enabled() ) { 96 return $value; 97 } 98 $tab = '' !== $tab ? $tab : wp_generate_password( 12, false ); 99 if ( 'option_' . self::OPTION === current_filter() ) { 100 $value['tokenforgeTab'] = $tab; 101 return $value; 102 } 103 $ours = self::scales(); 104 foreach ( $value as $i => $c ) { 105 if ( isset( $c['id'] ) && isset( $ours[ $c['id'] ] ) ) { 106 $value[ $i ]['tokenforgeTab'] = $tab; 107 } 108 } 109 return $value; 110 } 111 112 /** 113 * A builder save sends the tab ids back: keep them for on_saved() and store the value without them 114 * (no second write to take them off). 115 * 116 * @param mixed $value Categories or Style Manager settings, as sent. 117 * @param mixed $old The stored value. 118 * @param string $option The option name. 119 * @return mixed 120 */ 121 public static function strip_tab( $value, $old = null, $option = '' ) { 122 self::$sent[ $option ] = array(); // What this write sends replaces what the last one sent, as the stored copy did. 123 if ( ! is_array( $value ) ) { 124 return $value; 125 } 126 if ( array_key_exists( 'tokenforgeTab', $value ) ) { 127 if ( is_string( $value['tokenforgeTab'] ) ) { 128 self::$sent[ $option ]['sm'] = $value['tokenforgeTab']; 129 } 130 unset( $value['tokenforgeTab'] ); 131 } 132 foreach ( $value as $i => $c ) { 133 if ( is_array( $c ) && array_key_exists( 'tokenforgeTab', $c ) ) { 134 if ( isset( $c['id'] ) && is_string( $c['id'] ) && is_string( $c['tokenforgeTab'] ) ) { 135 self::$sent[ $option ][ $c['id'] ] = $c['tokenforgeTab']; 136 } 137 unset( $value[ $i ]['tokenforgeTab'] ); 138 } 139 } 140 return $value; 71 141 } 72 142 … … 381 451 * Sync state. 382 452 * 383 * @return array [ 'held' => [ part => [ stamp => snapshot part ] ], ' backup' => settings before TokenForge|null ]453 * @return array [ 'held' => [ part => [ stamp => snapshot part ] ], 'tabs' => [ tab id => [ part => snapshot part ] ], 'backup' => settings before TokenForge|null ] 384 454 */ 385 455 public static function state() { … … 388 458 return array( 389 459 'held' => isset( $s['held'] ) && is_array( $s['held'] ) ? $s['held'] : array(), 460 'tabs' => isset( $s['tabs'] ) && is_array( $s['tabs'] ) ? $s['tabs'] : array(), // What each builder tab saved last (KEEP tabs). 390 461 'backup' => isset( $s['backup'] ) && is_array( $s['backup'] ) ? $s['backup'] : null, 391 462 'off' => isset( $s['off'] ) ? (int) $s['off'] : 0, // The stamp of the settings restored when the sync went off. … … 451 522 $new[] = $c; 452 523 } elseif ( isset( $want['cats'][ $id ] ) ) { 524 unset( $c['tokenforgeTab'] ); // A builder tab's id (tag_tab()) is not stored. 453 525 $new[] = array_merge( $c, $want['cats'][ $id ] ); 454 526 unset( $want['cats'][ $id ] ); … … 492 564 $vars = is_array( $all ) && array_values( $all ) !== $vars ? $vars : null; 493 565 } 566 unset( $sm2['tokenforgeTab'] ); 494 567 495 568 // A part gets a new stamp when what it holds is not what its current stamp held … … 600 673 $stamps = self::stamps( $cats, $sm ); 601 674 $edits = array(); 675 $tabs = ( isset( self::$sent[ self::OPTION ] ) ? self::$sent[ self::OPTION ] : array() ) + ( isset( self::$sent[ self::CATS ] ) ? self::$sent[ self::CATS ] : array() ) + array( 'sm' => is_array( $sm ) && isset( $sm['tokenforgeTab'] ) && is_string( $sm['tokenforgeTab'] ) ? $sm['tokenforgeTab'] : '' ); 676 foreach ( (array) $cats as $c ) { 677 if ( isset( $c['id'], $c['tokenforgeTab'] ) && is_string( $c['id'] ) && is_string( $c['tokenforgeTab'] ) && ! isset( $tabs[ $c['id'] ] ) ) { 678 $tabs[ $c['id'] ] = $c['tokenforgeTab']; // Stored with the id (first add_option, no pre_update filter). 679 } 680 } 602 681 foreach ( $state['held'] as $part => $held ) { 603 682 if ( ! isset( $snap[ $part ] ) || ! $held ) { 604 683 continue; // A deleted scale: the push below puts it back. 605 684 } 606 $s = isset( $stamps[ $part ] ) ? $stamps[ $part ] : 0; 607 if ( $s > 0 && ! isset( $held[ $s ] ) ) { 685 $s = isset( $stamps[ $part ] ) ? $stamps[ $part ] : 0; 686 $tab = isset( $tabs[ $part ] ) ? $tabs[ $part ] : ''; 687 $mine = '' !== $tab && isset( $state['tabs'][ $tab ][ $part ] ); // This builder tab saved this part before. 688 if ( ! $mine && $s > 0 && ! isset( $held[ $s ] ) ) { 608 689 continue; // A stamp too old to remember: an old copy, nothing in it counts. 609 690 } 610 // What this copy held when the builder loaded it; without a stamp, the newest version.611 $base = $ s > 0 ? $held[ $s ] : end( $held);691 // What this tab saved last; else what this copy held when the builder loaded it; without a stamp, the newest version. 692 $base = $mine ? $state['tabs'][ $tab ][ $part ] : ( $s > 0 ? $held[ $s ] : end( $held ) ); 612 693 foreach ( $snap[ $part ] as $k => $v ) { 613 694 if ( 'steps' === $k ) { … … 625 706 } 626 707 } 627 if ( $pull ) { 708 if ( $pull && '' !== $tab ) { 709 // This tab now holds this copy. The stamp keeps what it held, for another tab that loaded it. 710 $t = isset( $state['tabs'][ $tab ] ) ? $state['tabs'][ $tab ] : array(); 711 unset( $state['tabs'][ $tab ] ); 712 $t[ $part ] = $snap[ $part ]; 713 $state['tabs'][ $tab ] = $t; 714 $state['tabs'] = array_slice( $state['tabs'], -self::KEEP, null, true ); 715 } elseif ( $pull ) { 628 716 self::hold( $state, $part, $s, $snap[ $part ] ); // The builder now holds this copy under this stamp. 629 717 } -
tokenforge/trunk/includes/platforms/class-bricks.php
r3797232 r3826085 105 105 $names = array(); 106 106 if ( ! empty( $fw['register_with_bricks'] ) ) { 107 // Not build( true ): the builder lists every global class, so the other framework's spellings would double it. 107 108 $built = \TokenForge\Framework::build(); 108 109 $components = \TokenForge\Components::build(); -
tokenforge/trunk/readme.txt
r3823805 r3826085 5 5 Tested up to: 7.1 6 6 Requires PHP: 7.4 7 Stable tag: 0.58. 17 Stable tag: 0.58.2 8 8 License: GPLv2 or later 9 9 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 13 13 == Description == 14 14 15 TokenForge is a design system you set up once and use everywhere. Colours, type and spacing scales, layout, buttons, cards, icons , effects and more are all CSS variables and classes, built into one static stylesheet that loads on your front end, in the block editor and, with Bricks, in the builder.15 TokenForge is a design system you set up once and use everywhere. Colours, type and spacing scales, layout, buttons, cards, icons and effects become CSS variables and classes in one static stylesheet, loaded on the front end, in the block editor and in your page builder. 16 16 17 **Why TokenForge** 18 19 * One place to set your whole design: colours, type, spacing, layout and components. 20 * Works with the block editor, Bricks, Etch, Oxygen, Breakdance, Divi and Elementor. Bricks has the deepest support today. 21 * Etch, Oxygen, Breakdance, Elementor and Divi: the TokenForge window inside the editor, TokenForge variables by right-click in style fields, TokenForge classes by right-click in the class field (Divi: its Attributes list), the input helper (space-m becomes var(--space-m)), variable, class and recipe suggestions in the custom CSS box, placeholder text recipes in text fields and the TokenForge stylesheet in the canvas. The builder's own Save keeps every change. 22 * Block editor: your colours, font sizes, spacing, font families and shadows are the presets the editor offers. It also gets ready patterns, a Button style for each button family, a class field with suggestions on top of the block sidebar, and optional editor tools (a compact, builder-style block sidebar, swapped and resizable sidebars, a dark interface, outlines in the canvas, the TokenForge window). Placeholder text recipes (?ipsum-short, ?ipsum, ?ipsum-long) work in the editor canvas too. All of it is set on the Block editor screen. 23 * Bricks: your tokens stay in step with Bricks variables, colours, global classes and the theme style. The dashboard and a design check also open inside the builder. 24 * Moving from another utility framework? Press Import from Automatic.css under Import, export & reset. You confirm before it runs, and the settings history can undo it. Custom CSS does not come across, so move it into your builder's own CSS box. 25 * One stylesheet, built when you save, not on every page load. Unused classes can be left out after a site scan. 26 * Accessibility checks: contrast in light and dark mode, with a suggested fix you can apply in one click. 27 * Export your tokens as W3C design token files, for Figma, Tokens Studio and Style Dictionary. 28 * Settings history: the last 20 saves are kept, and a restore can be undone. 29 * Free under GPLv2 or later. No account needed. The only outside service is Google Fonts, and only when you ask for it. 30 31 A new site starts ready: a complete starter design system (every token, colour family and setting), so there is nothing to import. Reset to defaults any time, for everything or one section. 17 A new site starts ready with a complete starter design system. Reset to defaults any time, for everything or one section. The built-in Manual (TokenForge, Manual) explains every screen. 32 18 33 19 **Design system** 34 20 35 * Colour families: shades generated from one colour in light and dark mode, with a live preview. Add, remove or edit your own families. 36 * Fluid type and spacing scales from one setting each, plus a width scale, a root font size, grids and automatic gaps. 37 * Layout, gutters, boxed or full width, borders, radius, shadows, icons, header height and prose styles. 38 * Utility classes for spacing, grids and grid placement, flex grids (equal-width items with a centred or stretched last row), flex and alignment, text styles, corners and more, with optional breakpoint variants ({class}-at-{bp}). Unused classes can be left out of the stylesheet after a site scan, to keep it small. 39 * A Tokens screen that lists every variable, the setting that makes it and where it is used. Add your own tokens in a built-in or your own category. 40 * Dark mode: assign it by section and add a light or dark switch anywhere, with a shortcode or a block. 21 * Colour families with light and dark shades from one colour, live preview, and dark mode by section with a light or dark switch (shortcode or block). 22 * Fluid type and spacing scales from one setting each, a width scale, grids and automatic gaps. 23 * Layout, borders, radius, shadows, icons, buttons, cards, overlays and prose styles. 24 * Utility classes for spacing, grids, flex grids, flex and alignment, text and more, with optional breakpoint variants. Unused classes can be left out after a site scan. 25 * Effects: entrance, exit, hover, border and scroll effects, and optional default effects for your buttons. 26 * A Tokens screen that lists every variable, where it comes from and where it is used. 27 28 **Builders and the block editor** 29 30 * Works with the block editor, Bricks, Etch, Oxygen, Breakdance, Divi and Elementor. Bricks has the deepest support. 31 * In every supported builder: the TokenForge window, variables and classes by right-click, the input helper, suggestions and recipes in the custom CSS box, text recipes, a light and dark preview of the canvas, and the TokenForge stylesheet in the canvas. 32 * Block editor: your tokens become the editor presets, plus patterns, button styles, a class field and optional editor tools. 33 * Bricks: two-way sync with Bricks variables, colours, global classes and the theme style, a design check, a BEM class generator, form element extensions and a setup wizard. 41 34 42 35 **Accessibility** 43 36 44 * Contrast check of text, links, focus rings and buttons against their backgrounds, in light and dark mode (WCAG 2 AA, with the APCA value shown). Each problem gets a suggested colour token, applied withone click.45 * Automatic attributes for the front end, every one off by default: hidden decorative icons, alt text from the media library, menu labels, the current page mark, a new tab notice and two labelled guesses. TokenForge adds only what is missing and stores nothing.46 * Data attributes for layout and behaviour without custom code, listed under Data attributes below, with a screen that shows where each one is used.47 * A page check in the builder, based on the open-source axe-core engine. It runs only when an administrator presses Run check, and nothing is saved unless you choose a fix.37 * Contrast check of text, links, focus rings and buttons in light and dark mode (WCAG 2 AA, APCA shown), with a suggested token applied in one click. 38 * Optional automatic attributes: hidden decorative icons, alt text, menu labels, the current page mark and a new tab notice. 39 * A page check in the builder (axe-core), only when an administrator presses Run check. 40 * Data attributes for layout and behaviour without code (data-tf-stack, data-tf-space, data-tf-surface, data-tf-reveal, data-tf-tooltip, data-tf-filter and more). 48 41 49 **Fonts **42 **Fonts, WooCommerce and tools** 50 43 51 * Self-hosted fonts: upload TTF or OTF files and TokenForge turns them into WOFF2 (or WOFF), preloads them and lists them in the builder's font list. 52 * Or download a Google font once to your server. Your visitors never contact Google. 53 54 **WooCommerce** 55 56 * While WooCommerce is active: shop, product, cart, checkout and account pages, product cards and filters, header carts, and the Cart and Checkout blocks, styled with your tokens. 57 * Every part has its own switch. The shop styles load only on pages that show the shop, or on every page if you choose. 58 59 **Data and tools** 60 61 * Export and import your settings, and export your tokens as W3C design token files (light and dark) for Figma, Tokens Studio and Style Dictionary. Each import shows a preview of every change first. 62 * Settings history: before every save, import, reset or setup, TokenForge keeps a copy (the last 20). You can see what changed and put any copy back, and a restore can be undone. 63 * WP-CLI commands: regenerate, export, import (with --dry-run), snapshot, history, restore, status and contrast. 64 * Guidance and abilities for AI agents (MCP and Bricks AI). 65 * The dashboard and its settings are translatable (translate.wordpress.org). 66 67 **With Bricks** 68 69 When Bricks is active, TokenForge also: 70 71 * Syncs your tokens into Bricks global variables, the colour palette and global classes, so they appear in the builder's pickers and autocomplete. The sync runs both ways. 72 * Keeps a Bricks theme style for the whole website in step with your settings, both ways. 73 * Adds the full dashboard inside the builder, right-click menus for variables and classes, a BEM class generator, a design check (typed colours and font sizes that should be tokens, contrast in light and dark mode, sizes off the type scale) and the page check. 74 * Extends the Bricks form element with steps (back, next and a progress bar), conditional fields, required-if rules, calculated fields, sliders, star ratings, ranges, input masks, character counters, date rules, choices filled from your content, live values on the page, send limits, an Update meta action, an Add to cart action, and form presets. Each has its own switch. 75 * Keeps the form submissions in the builder: search, read and unread marks, statuses, notes, editable entries, CSV or JSON export, and optional auto-delete after a set number of days (only after a dry run you confirm). 76 * Has a setup wizard that sets Bricks' own settings for working with TokenForge in one go. You choose which, and Undo puts them back. 77 78 **Data attributes** 79 80 These attributes work on any element in Bricks, the block editor or your own markup. Each one is listed on the Data attributes screen with where it is used. 81 82 * data-tf-stack: switches a row to a column below a breakpoint. 83 * data-tf-space: section spacing or stack gap. 84 * data-tf-surface: a raised panel from your colour tokens. 85 * data-tf-reveal: shows an element on scroll, using the visible effects. 86 * data-tf-clamp and data-tf-ratio: limit lines of text and keep a fixed shape. 87 * data-tf-copy: a copy button for a value on the page. 88 * data-tf-tooltip: a tooltip that stays on screen, also on a phone. 89 * data-tf-filter-group, data-tf-filter and data-tf-term: a list filter with no code. 90 * data-tf-decorative: marks an image as decorative (Mark as decorative in the builder). 91 * data-tf-state: marks an element as open, active or disabled, so your CSS can style that state. Disabled also dims the element and blocks mouse clicks. 92 93 TokenForge is original software released under the GPLv2 or later. 44 * Self-hosted fonts: upload TTF or OTF and get WOFF2, or download a Google font once to your server. 45 * WooCommerce shop, product, cart, checkout and account pages and blocks styled with your tokens, each part with its own switch. 46 * Export and import settings (with a preview), W3C design token files for Figma, Tokens Studio and Style Dictionary, the settings history (last 20 saves, undoable), WP-CLI commands and tools for AI agents. 47 * Moving from another utility framework? The settings import under Import, export & reset brings your settings across, and its class names work too. 94 48 95 49 **Developers** 96 50 97 A developer can add SCSS from code. The filter `tokenforge_global_scss` receives an empty string and returns SCSS. TokenForge compiles it with its own library (mixins and functions) and adds it last to the stylesheet. A compile error never breaks the site.51 The filter `tokenforge_global_scss` returns SCSS that TokenForge compiles and adds last to the stylesheet (put it in a child theme or a mu-plugin). The action `tokenforge_builder_enqueue` loads an add-on's assets in every supported builder, and `tokenforge_block_editor_enqueue` in the block editor. Details and examples are in the Manual. 98 52 99 This is code, not a setting. Put it in a child theme's functions.php or in a mu-plugin, never in TokenForge's own files, so an update does not remove it. 100 101 An add-on can load its scripts and styles in the editor of every supported page builder. The action `tokenforge_builder_enqueue` passes the builder (bricks, etch, oxygen, breakdance, elementor or divi). It fires in the editor page for users who can edit posts, after TokenForge's own assets (the window, handle tokenforge-panel, for administrators; the tools, handle tokenforge-builder, outside Bricks). Call wp_enqueue_script and wp_enqueue_style as usual; where the builder's editor skips the WordPress queue (Oxygen, Breakdance), TokenForge prints them. In Divi it fires in the top window, where the settings panels are; the canvas is the same-origin frame #et-vb-app-frame. The block editor has its own action, `tokenforge_block_editor_enqueue`, which passes the editor switches. 102 103 **Roadmap** 104 105 Planned, with no dates yet: 106 107 * Block editor: panels for block styles and the global styles. 108 * More accessibility checks, with clearer fixes. 109 110 Example: add `add_filter( 'tokenforge_global_scss', 'my_pricing_scss' );` to your functions.php, then define `my_pricing_scss( $scss )` so it appends `.pricing { padding: var(--space-m); }` to `$scss` and returns it. 111 112 TokenForge is developed by Prista Digital. Website: https://pristadigital.com 53 TokenForge is original software released under the GPLv2 or later, developed by Prista Digital (https://pristadigital.com). 113 54 114 55 == Installation == 115 56 116 1. Upload the `tokenforge` folder to `/wp-content/plugins/`, or install the zip from Plugins, Add New, Upload.117 2. Activate. A new site starts with the starter design system. On a Bricks site, TokenForge links or creates a theme style for the whole website on the next page load.118 3. Open **TokenForge** in the admin menu, change what you like and save. 57 1. Install the zip from Plugins, Add New, Upload, or upload the `tokenforge` folder to `/wp-content/plugins/`. 58 2. Activate. A new site starts with the starter design system. 59 3. Open **TokenForge** in the admin menu, change what you like and save. TokenForge, Manual explains each screen. 119 60 120 61 == Frequently Asked Questions == … … 122 63 = Do I need a page builder? = 123 64 124 No. TokenForge works on any WordPress site: the stylesheet loads on the front end and in the block editor. The builder tools switch on only when a supported builder is active: Bricks, Etch, Oxygen, Breakdance, Elementor or Divi 5. 125 126 = What does TokenForge add to the block editor? = 127 128 Your tokens become the editor's presets: colours, font sizes, spacing, font families and shadows. By default they replace the theme's presets, and the theme's old preset names are pointed at the nearest token, so existing posts and the theme's own styles keep their look. On the Block editor screen you can show them beside the theme's presets instead, or switch them off. 129 130 The same screen has the rest, each with its own switch: a class field with suggestions on top of the block sidebar, TokenForge patterns (hero, cards, pricing, questions and answers, contact), a Button style for each button family, a list of blocks to hide from the inserter, a compact editor interface with the block settings laid out like the builder (one setting per row, the Styles tab in the builder order), the sidebars swapped and drag handles to make them wider or narrower, a dark editor interface, a dark canvas, outlines in the canvas, and a TokenForge button in the editor header that opens the dashboard as a window. 131 132 Presets, patterns and button styles work with any theme. The Site Editor parts need a block theme. TokenForge never changes the styles you saved in the Site Editor: a preset list you saved there still shows first in its picker. 65 No. The stylesheet loads on the front end and in the block editor. The builder tools switch on only with Bricks, Etch, Oxygen, Breakdance, Elementor or Divi 5. 133 66 134 67 = Will it slow my site down? = 135 68 136 TokenForge writes one static stylesheet, so no CSS is built while a page loads. You can print it inline (no extra request) under Options, Performance, and switch off any section you do not use. Under Options, Utility framework, you can leave out the utility classes your site does not use. With WooCommerce, the shop styles are in a second file that loads only on pages that show the shop. 137 138 = Does it work with WooCommerce? = 139 140 Yes. While WooCommerce is active, TokenForge styles the shop, product, cart, checkout and account pages, the builder's shop elements and the WooCommerce blocks with your tokens. Every part has its own switch under WooCommerce. With a block theme, the product price, sale badge and rating blocks can take their look from global styles. 141 142 = How do I load the shop styles on every page? = 143 144 Set WooCommerce, Shop pages, Load shop page styles to On every page. Developers can also decide per page with the `tokenforge_woo_shop_styles` filter. 145 146 = Where do the tokens come from? = 147 148 Most come from your settings: Colors makes the colour families, and Typography, Spacing, Layout, Borders, Icons and Effects make their own variables, all when the stylesheet is built. The Tokens screen lists every variable with the part that makes it. Add your own tokens with + Add token, in a built-in category or one you name yourself. A token with the same name as a variable a setting makes replaces it; Use settings removes copies that only repeat a setting. 149 150 = Can I bring in settings from another framework? = 151 152 Yes. See the switching guide below. 69 No CSS is built while a page loads: TokenForge writes one static stylesheet when you save. You can print it inline, switch off sections you do not use and leave out unused utility classes. Shop styles are a second file loaded only where the shop shows. 153 70 154 71 = How do I switch from another utility framework? = 155 72 156 1. Open TokenForge, then Import, export & reset. 157 2. Press Import from Automatic.css and confirm. The import merges into your settings: colours, scales, layout, typography, buttons, cards, components, overlays and fonts come across. If a token has the same name as one you already have, the imported value replaces it. 158 3. Read the message that follows. It gives the number of variables and settings imported. 159 4. Check Colors, Typography and Accessibility, then look at a few pages on the front end and in the builder. 160 5. Move any custom CSS into your builder's own CSS box. Custom CSS is not imported. 161 162 If something is wrong, open Import, export & reset and use the settings history to put back the copy from before the import. 73 Open Import, export & reset, press the settings import button and confirm. Colours, scales, layout, typography, buttons, cards, components, overlays and fonts come across; custom CSS does not. The settings history can undo it. 163 74 164 75 = Can I add my own CSS? = 165 76 166 Yes , in two places. Add CSS to the builder's own custom CSS box (in Bricks, the theme style's Custom CSS), or to your theme's Additional CSS in the Customizer. Developers can also add SCSS from code with the `tokenforge_global_scss` filter, shown under Developers in the description.77 Yes: in your builder's custom CSS box or the Customizer's Additional CSS. Developers can add SCSS with the `tokenforge_global_scss` filter. 167 78 168 79 = What happens when I deactivate or delete TokenForge? = 169 80 170 Deactivating stops the stylesheet from loading; your settings stay. Deleting the plugin removes its settings, the generated stylesheets and the variables, colours and classes it added to Bricks. Font files you uploaded stay in `uploads/tokenforge/fonts/`, because other CSS may still use them. On a multisite network, uninstall cleans every site. 171 172 Two Bricks settings are not put back. A Bricks theme style kept in step with TokenForge keeps its var(--...) values, which no longer resolve once the variables are gone: set those fields again or pick another theme style. Bricks settings the setup wizard changed stay as the wizard left them. 81 Deactivating stops the stylesheet; settings stay. Deleting removes the settings, the generated stylesheets and what TokenForge added to Bricks. Uploaded font files stay in `uploads/tokenforge/fonts/`. 173 82 174 83 = Does TokenForge keep anything about visitors? = 175 84 176 Only what your forms ask for . On your server, a form with a send limit keeps a count of its sends, and a form limited per user keeps the time of each signed-in user's last send in their user data. A form with the Update meta action writes the answers you map to the post or user meta you choose, and the Add to cart action puts the answers you allow on the cart item and the order. Two things stay in the visitor's own browser (local storage): their light or dark choice when you show the dark mode switch, and, only for forms where you turn on Remember answers on this device, what they typed until the form is sent. Passwords, files and hidden fields are never kept, and the saved answers are removed after a successful send. Deleting TokenForge removes its counts and the per-usersend times.85 Only what your forms ask for: send counts for forms with a send limit, and the last send time per signed-in user for per-user limits. In the visitor's browser: their light or dark choice, and, where you turn it on, unsent form answers. Deleting TokenForge removes the counts and send times. 177 86 178 = Does TokenForge contact other servers? =87 = Where is the full documentation? = 179 88 180 Only when an administrator asks it to, and there is one such service: Google Fonts, when you press Download from Google Fonts (Typography, Self-hosted fonts). Your server asks fonts.googleapis.com for the family's CSS, then downloads the font files from fonts.gstatic.com, once. It sends the family name, the weights and styles you picked, and your server's IP address, like any web request. The files are stored in `uploads/tokenforge/fonts/`, so your visitors never contact Google.89 In the plugin: TokenForge, Manual in the admin menu. 181 90 182 Terms: https://developers.google.com/terms 183 Privacy: https://policies.google.com/privacy 91 == External services == 184 92 185 T he accessibility checker (axe-core, MPL 2.0) is bundled with the plugin and runs only in the builder when an administrator presses Run check. Nothing else is contacted.93 TokenForge contacts one outside service, Google Fonts, and only when an administrator presses Download from Google Fonts (Typography, Self-hosted fonts). Your server then asks fonts.googleapis.com for the family's CSS and downloads the font files from fonts.gstatic.com, once. It sends the family name, the weights and styles you picked, and your server's IP address, like any web request. The files are stored in `uploads/tokenforge/fonts/`, so your visitors never contact Google. 186 94 187 = How do I connect an AI agent (Claude, ChatGPT, Cursor) to TokenForge? = 95 Google terms: https://developers.google.com/terms 96 Google privacy policy: https://policies.google.com/privacy 188 97 189 TokenForge's tools for AI agents are on by default (Options, AI agents). They reach your AI client through the WordPress MCP Adapter, the same connection the builder's own AI tools use: 190 191 1. Install and activate the MCP Adapter plugin (https://github.com/WordPress/mcp-adapter). With Bricks 2.4 or later, Bricks > AI installs it for you and walks you through every step. 192 2. Create an application password for your user (Users > Profile > Application Passwords). 193 3. Add the site to your AI client as an MCP server that runs `npx -y @automattic/mcp-wordpress-remote@latest`, with three environment values: WP_API_URL (your site's `/wp-json/mcp/mcp-adapter-default-server`), WP_API_USERNAME (your user name) and WP_API_PASSWORD (the application password). Bricks > AI shows this setup ready to copy for each client. 194 195 The agent then sees `tokenforge-get-framework`, `tokenforge-search`, `tokenforge-check-css` and `tokenforge-get-recipe`. The server instructions and, on Bricks, the builder's own start-here guide tell it to call `tokenforge-get-framework` first. That guide covers the tokens, the classes, BEM naming for its own classes (block__element--modifier, no site prefix) and, on Bricks, how classes are added: as global classes, never typed into an element's CSS classes field. 196 197 = Can I translate TokenForge? = 198 199 Yes. The dashboard and the builder settings use the `tokenforge` text domain, so translations from translate.wordpress.org are loaded automatically. 200 201 = Does "Close after this many sends" stop one visitor from taking every place? = 202 203 No. The limit counts sends, not people, so one visitor or a script can send the form until it closes, and two sends at the same moment can both get the last place. For places that matter, such as event seats, also turn on the form's CAPTCHA (reCAPTCHA, hCaptcha or Turnstile) or "Only signed-in visitors can send" with "Sends per user". 98 The accessibility checker (axe-core, MPL 2.0) is bundled and runs in the builder only. Nothing else is contacted. 204 99 205 100 == Screenshots == … … 213 108 == Changelog == 214 109 215 The full history is in CHANGELOG.md, also shown from the Changelog link next to TokenForge on the Plugins screen. 110 Older versions are in changelog.txt. 111 112 = 0.58.2 = 113 * New: TokenForge, Manual, an English user manual in the admin. 114 * Class names from another utility framework (grid--3, grid--m-2, flex-grid--3, text--center and more) now work too; colour names such as bg--primary have their own switch. 115 * New: default button effects (hover, entrance and hover border) on the Effects screen. 116 * New recipes: gradients, ?before, ?after, ?hover, ?focus-visible, ?color-mix, ?tooltip, ?footer-reveal and more. 117 * Builder: a moon button previews the canvas in dark mode while you build. 118 * Fixed: a window opened before a newer save (another builder tab or the dashboard) no longer puts older settings back. 119 * Fixed: switching on a setting that adds classes rechecks the site, so used classes are not left out. Entrance effects on screen at load no longer flash before they play. 120 * Settings import: more switches, button effects and older breakpoint values come across. 216 121 217 122 = 0.58.1 = 218 123 * Effects: entrance effects on elements already on screen when the page opens (a hero, for example) now play as the page loads. Before, they waited for a scroll that never came. 219 124 * Importing another framework's settings now brings over its site colour scheme and card inner radius from its newer version. 220 221 = 0.58.0 =222 * Page builders: Etch, Oxygen 6, Breakdance, Elementor (classic widgets and containers) and Divi 5 now get the TokenForge window, variables and classes by right-click, the input helper, suggestions and recipes in custom CSS, and the TokenForge stylesheet in the canvas while editing.223 * Recipes: placeholder text recipes (?ipsum-short, ?ipsum, ?ipsum-long and your own Text recipes) work in every supported builder and in the block editor sidebar.224 * Block editor: a new setting picks the default unit for empty size fields (rem by default, px keeps WordPress as it is).225 * Developers: the new action tokenforge_builder_enqueue loads an add-on's scripts and styles in every supported builder.226 * Fixed: dark text on the dark Appearance list in the dark editor interface, and Divi's settings panels getting the front-end styles.227 228 = 0.57.0 =229 * Block editor: a new Block editor screen holds every block editor setting. Your colours, font sizes, spacing, font families and shadows become the editor presets (replace the theme's presets, sit beside them, or off), and the theme's old preset names point at the nearest token so existing posts keep their look.230 * Block editor tools, each with its own switch: a class field with suggestions, TokenForge patterns, a Button style for each button family, blocks hidden from the inserter, a compact sidebar laid out like the builder, swapped sidebars, drag handles to resize the sidebars, a dark interface and canvas, canvas outlines and the TokenForge window.231 * Recipes: ?ipsum (a medium paragraph) and ?ipsum-long join ?ipsum-short, and all three also work in the block editor canvas (type the name, then a space or a semicolon).232 * Fixed: dashboard fields lost their name for screen readers when changed from the default, and two suggestion lists could open on top of each other in the builder's CSS box.233 234 = 0.56.0 =235 * Bricks Style Manager: the text, heading and space sizes show as typography and spacing scales, and the HTML font size, screen widths and default mode fill its Settings. Changes made there come back into TokenForge.236 * AI agents: the guide now covers BEM naming for an agent's own classes and, on Bricks, adding classes as global classes. The FAQ explains how to connect an AI client through the MCP Adapter.237 * Fixed: the BEM class generator gave empty names in a builder shown in another alphabet (such as Bulgarian); labels are transliterated and unnamed elements are named by type.238 * Deleting TokenForge also removes its short upgrade lock. The admin bar menu shows the TokenForge icon.239 240 = 0.55.0 =241 * Flex grids: flex-grid-1 to flex-grid-12 with equal-width items and a centred last row, flex-grid--start, flex-grid--end and flex-grid--stretch, and per-breakpoint counts such as flex-grid-2-at-m.242 * Breakpoint variants (off by default): {class}-at-{bp} copies of the layout and text classes, such as col-span-1-at-m.243 * Grid classes: column and row placement, per-breakpoint and stacking grids, grid-alternate, ratio auto grids, masonry and order.244 * Layout classes: more flex and alignment, centring, height, container queries, opacity, z-index, display, flip, sticky offsets, aspect ratio, object position, line clamp and column classes.245 * Text classes: weights, italics, case, underline styles, balanced text, list reset, edge fades, border sides, dividers, and optional link, focus and bullet colours per colour.246 * Optional live header height: --header-height follows the real header, plus --admin-bar-height.247 * Builder: input helper (variable names to var(), maths to calc()), hide switched-off classes in the class list, checkerboard behind transparent swatches, TokenForge classes reused on template import (all optional except the checkerboard).248 * Fixed: oklch() and light-dark() palette colours get their colour classes again; columns-2 to 4 leave WooCommerce product lists alone; Bricks buttons without a btn class keep their border.249 * Hardening: a value with an unclosed bracket, quote or comment is no longer saved, so it cannot blank the rest of the stylesheet; on multisite, saving, importing and restoring settings needs the Additional CSS right (edit_css); damaged font files and oversized AI checks are refused.250 * Security: stricter checks on form cart prices, products, open meta writes and date rules; presets listed to editors only; safer font and AI CSS checks; on multisite, settings need edit_css.251 * Fixed: flex grids lay out in a row on builder blocks; columns breakpoint variants override columns-N; sticky-top with a 0 offset; focus-parent keeps field focus rings.252 253 = 0.54.2 =254 * Developers can extend Export / Import and the Starter reset: the hooks tokenforge_transfer_parts, tokenforge_transfer_export_data, tokenforge_transfer_imported, tokenforge_starter_parts and tokenforge_starter_reset.255 * Undo now restores add-on parts too, and an import passes only the parts you selected to the import hook.256 * Export leaves out keys that look like secrets (licence, token, password), except the core and registered parts.257 * Nothing changes for sites that do not use these hooks.258 259 = 0.54.1 =260 * Developers can add to the dashboard from a plugin or theme: sections, navigation entries, icons and panels through the wp.hooks filters tokenforge.sections, tokenforge.nav, tokenforge.icons, tokenforge.render and tokenforge.section_html.261 * Developers can add recipes with the tokenforge_recipes filter.262 * Nothing changes for sites that do not use these filters.263 * Developer and website details updated: Prista Digital, https://pristadigital.com.264 265 = 0.54.0 =266 * The Global SCSS editor is removed from the WordPress.org version. Developers can still add SCSS with the tokenforge_global_scss filter.267 * Custom recipes (your own CSS snippets) are removed from the WordPress.org version; built-in recipes stay. Export them first if you need them.268 269 = 0.53.7 =270 * WordPress.org review: the WP-CLI export no longer writes to a chosen file; use the shell redirect instead.271 * WordPress.org review: removed links to outside documentation from the admin screens.272 273 = 0.53.6 =274 * The attribute suggestion menu is easier to read and use with a screen reader or in high contrast; unused builder code removed.275 276 = 0.53.5 =277 * Form entries: the auto-delete confirmation, the delete dry run, titles, notes, search and the menu entry are tidied.278 279 = 0.53.4 =280 * The page check treats an image role written as Presentation or "none " the same way as everywhere else, so it no longer lists that image as having empty alt text.281 282 = 0.53.3 =283 * Saving from the dashboard no longer drops a colour family made with Generate in the builder or another window; the stored ones are kept and you are told.284 * The Saved message stays visible next to the site scan result, and Save no longer says "CSS updated" when the stylesheet could not be written.285 * "Leave out unused utility classes" also leaves out the styles of data attributes the site does not use (after a scan).286 * The tooltip bubble stays on screen inside a scaled or zoomed container.287 * Nested filter groups work: each group changes only its own buttons and items.288 289 = 0.53.2 =290 * A tooltip near the edge of a phone screen stays in view, and a hidden one no longer makes the page scroll sideways.291 * Switching on "Leave out unused utility classes" no longer scans the whole site during Save.292 * Uninstall cleans every site of a multisite network.293 294 = 0.53.0 =295 * New data attributes: data-tf-stack, data-tf-space, data-tf-surface, data-tf-reveal, data-tf-copy, data-tf-tooltip, and a no-code list filter (data-tf-filter-group, data-tf-filter, data-tf-term).296 * Data attributes screen under Foundations: lists every TokenForge data attribute with where it is used, unused ones and misspelt names.297 * Mark as decorative in the builder's page check; the Attributes control suggests data-scheme and the form attributes.298 299 = 0.52.0 =300 * One Accessibility hub in the TokenForge window: the page check, palette contrast, automatic attributes, focus, reduced motion, the external-link indicator and the canvas badge.301 * Fix a failing contrast pair with any token or colour you pick, with the ratio shown as you choose.302 * Design check in the builder: typed colours and font sizes that should be tokens, contrast in light and dark mode, and sizes off the type scale.303 * Global SCSS outline: section comments, a Jump to list with search (Ctrl+Shift+O).304 305 = 0.51.0 =306 * Page check in the builder: lists accessibility problems on the page you are editing, with Show and, where it is safe, Fix. Nothing is saved; Undo works.307 * Automatic accessibility attributes for the front end, every switch off. Needs WordPress 6.2 or newer.308 * Data attributes for clamped text, ratios, states and decorative images, with suggestions in the builder.309 310 = 0.50.0 =311 * Forms: submissions in the builder get search, read and unread marks, statuses and notes, editable entries, column choice, CSV or JSON export, and auto-delete after a set number of days (only after a confirmed dry run).312 * Dashboard: a Light look beside Builder panels and Flat.313 314 = 0.49.0 =315 * Forms: sliders, star ratings, two-handle ranges, input masks, character counters, date rules, choices filled from posts, terms, users or custom field choices.316 * Forms: live answers on the page, send counts and places left, close after a number of sends, signed-in only, and once per user. All checked again on the server.317 * Forms: Update meta and Add to cart actions, and whole-form, field and style presets.318 319 = 0.48.0 =320 * Design token files: export and import W3C design token files (light and dark) with a preview of every change. History keeps a copy, so an import can be undone.321 * WP-CLI commands: regenerate, export, import, snapshot, history, restore, status and contrast.322 323 = 0.47.0 =324 * Contrast check: text, links, focus rings and buttons against their backgrounds, in light and dark mode, with a suggested colour token for each problem.325 326 = 0.46.0 =327 * Settings history: before every save, import, reset and setup, TokenForge keeps a copy of its settings, tokens, colour families, fonts and Global SCSS (the last 20).328 * WooCommerce: product, cart and checkout styles load only where the shop appears.329 330 = 0.45.1 =331 * On a site without a supported page builder, the builder screen lists the builders TokenForge knows instead of switches that do nothing. -
tokenforge/trunk/tokenforge.php
r3823805 r3826085 4 4 * Plugin URI: https://pristadigital.com 5 5 * Description: Design tokens, fluid scales and utility classes for any WordPress site, block editor included. With Bricks active it also syncs variables, colours, classes and a theme style both ways, and adds the dashboard inside the builder. 6 * Version: 0.58. 16 * Version: 0.58.2 7 7 * Requires at least: 5.9 8 8 * Requires PHP: 7.4 … … 19 19 defined( 'ABSPATH' ) || exit; 20 20 21 define( 'TOKENFORGE_VERSION', '0.58. 1' );21 define( 'TOKENFORGE_VERSION', '0.58.2' ); 22 22 define( 'TOKENFORGE_FILE', __FILE__ ); 23 23 define( 'TOKENFORGE_DIR', plugin_dir_path( __FILE__ ) ); -
tokenforge/trunk/vendor/scssphp/NOTICE.md
r3784841 r3826085 14 14 15 15 Removed: `src/Exception/ServerException.php` (deprecated upstream, unused here; it was the only file that ran code when opened on its own). 16 17 `composer.json` is the upstream file of scssphp 1.12.1, unchanged (it still names the original namespace; TokenForge loads the library with its own autoloader, not Composer).
Note:
See TracChangeset
for help on using the changeset viewer.