Changeset 3794418 for tokenforge/trunk/includes/class-ai.php
- Timestamp:
- 11/10/2026 12:51:32 PM (6 days ago)
- File:
-
- 1 edited
-
tokenforge/trunk/includes/class-ai.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tokenforge/trunk/includes/class-ai.php
r3784841 r3794418 24 24 */ 25 25 class Ai { 26 27 /** Largest css or html input check-css takes, in bytes. */ 28 const MAX_INPUT = 204800; 29 30 /** Deepest at-rule nesting check-css follows. */ 31 const MAX_DEPTH = 20; 26 32 27 33 /** … … 583 589 '- **Cards:** `card` = padded flex column with background, radius, border and shadow. Inside it, elements whose class contains `__media` (images) and `__avatar` are styled; headings use `var(--card-heading-size)`. Example: `<article class="card"><img class="card__media" …><h3>…</h3><p>…</p></article>`.', 584 590 '- **Icons:** add `data-icon` to an svg or i element; size with `data-icon-size="l"` or `icon--l`; `icon--boxed` for a box.', 585 '- **Grids:** `grid-2` … `grid-12` (equal columns), `grid-1-2`, `grid-2-1` (ratios), or `grid--auto-3` (same as `grid-template-columns: var(--grid-auto-3)`) for columns that wrap on their own.', 591 '- **Grids:** `grid-2` … `grid-12` (equal columns), `grid-1-2`, `grid-2-1` (ratios), or `grid--auto-3` (same as `grid-template-columns: var(--grid-auto-3)`) for columns that wrap on their own. `flex-grid-1` … `flex-grid-12`: equal-width items in a wrapping flex row whose short last row is centred (add `flex-grid--start`, `flex-grid--end` or `flex-grid--stretch` to change that; `flex-grid-2-at-m` sets 2 per row at the m breakpoint and below, also -at-xs, -at-s, -at-l, -at-xl, -at-xxl, when breakpoint variants are on); use it for logo walls and card lists whose count does not fill the last row.', 592 '- **Grid children:** `col-span-2`, `col-span-all`, `col-start-2`, `col-end-last`, `row-span-2`; `grid-alternate` for rows that alternate 1:2 and 2:1; `grid--auto-1-2` for a 1:2 pair that stacks when space runs out; `masonry-3`; `order-first`, `order-last`.', 593 '- **Flex and layout:** `flex-col-reverse`, `items-baseline`, `self-center`, `justify-self-end`, `content-between`, `center-all`, `center-x`, `center-y`, `height-full`, `height-screen`, `aspect-16-9`, `object-top`, `line-clamp-3`, `opacity-50`, `z-10`, `z-top`, `flip-x`, `sticky-top--m`, `columns-2` … `columns-6` with `col-rule`.', 594 '- **Text:** `font-100` … `font-900`, `bold`, `italic`, `uppercase`, `underline--wavy`, `text-balance`, `text-justify`, `list-none` (add role="list"), `focus-parent`, `fade-bottom` (`--fade-amount`), `divider--all`, `border-left`; per colour `link-{color}`, `link-hover-{color}`, `focus-{color}`, `marker-{color}`.', 595 '- **Breakpoints:** when breakpoint variants are on, add `-at-xs`, `-at-s`, `-at-m`, `-at-l`, `-at-xl` or `-at-xxl` to a layout or text class for that value at that width and below: `grid-3 grid-1-at-s`, `flex-row flex-col-at-m`, `hidden-at-s`, `grid-stack-at-m`, `text-center-at-s`.', 596 '- **Header:** `--header-height` follows the real header when Extras, Header height, Measure is on; `--admin-bar-height` is 0px without the admin bar. Mark a custom header with `data-tf-header`.', 597 '- **Builder input helper:** when it is on, typing `space-m` or `--space-m` in a style field becomes `var(--space-m)` on blur or Enter, and `var(--space-m) * 2` becomes `calc(var(--space-m) * 2)`.', 586 598 '- **Effects:** `on-enter--fade`, `on-enter--float`, `on-enter-all--fade` (children one after another), `on-hover--grow`, `on-hover--shadow`.', 587 599 '- **Backgrounds with images:** put the image first inside the section with class `is-bg`; add `overlay` to the section for a tint.', … … 601 613 * 602 614 * @param array $input Input. 603 * @return array 615 * @return array|\WP_Error 604 616 */ 605 617 public function check_css( $input = array() ) { 606 618 $css = isset( $input['css'] ) ? (string) $input['css'] : ''; 607 619 $html = isset( $input['html'] ) ? (string) $input['html'] : ''; 620 if ( strlen( $css ) > self::MAX_INPUT || strlen( $html ) > self::MAX_INPUT ) { 621 return new \WP_Error( 'tokenforge_too_large', 'Send at most 200 KB of CSS and 200 KB of HTML per check.' ); 622 } 608 623 $vars = array(); 609 624 foreach ( Token_Catalog::every_variable() as $t ) { … … 723 738 * @param string $ctx At-rule context. 724 739 * @param array $rules Out: [ ctx, selector, body ]. 740 * @param int $level At-rule nesting so far. 725 741 * @return void 726 742 */ 727 private static function rules( $css, $ctx, &$rules ) {743 private static function rules( $css, $ctx, &$rules, $level = 0 ) { 728 744 $len = strlen( $css ); 729 745 $i = 0; … … 747 763 $i = $j; 748 764 if ( '' !== $sel && '@' === $sel[0] ) { 749 self::rules( $body, $sel, $rules ); 765 if ( $level < self::MAX_DEPTH ) { 766 self::rules( $body, $sel, $rules, $level + 1 ); 767 } 750 768 } elseif ( '' !== $sel ) { 751 769 // Nested CSS: only the declarations of this level.
Note:
See TracChangeset
for help on using the changeset viewer.