Skip to content

Use more css vars in single theme css#2646

Merged
Crabcyborg merged 5 commits into
masterfrom
use_more_css_vars_in_single_theme_css
Dec 11, 2025
Merged

Use more css vars in single theme css#2646
Crabcyborg merged 5 commits into
masterfrom
use_more_css_vars_in_single_theme_css

Conversation

@Crabcyborg
Copy link
Copy Markdown
Contributor

In addtion

  • I added some plugin checks to avoid a couple unnecessary styles specific to plugins (signatures and math captcha).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 11, 2025

Walkthrough

Replaces many PHP-injected CSS values in css/_single_theme.css.php with CSS custom properties, preserves PHP conditionals and !important usage, and adds plugin-gated style sections for CPT and signature fields. No runtime behavior changes.

Changes

Cohort / File(s) Summary
CSS theme refactor
css/_single_theme.css.php
Replaced direct PHP-inserted CSS values with CSS custom properties (e.g., --form-width, --field-margin, --submit-bg-color, --text-color-disabled, --label-color, --submit-height, etc.) across form/container, field spacing, typography, placeholders, focus/hover, submit/button, error, and plugin-specific (math captcha, signature) styles. Preserved existing PHP conditional blocks and !important suffixes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Single file with systematic, repetitive substitutions.
  • Review focus:
    • Ensure required CSS custom properties are defined/available at runtime.
    • Confirm !important handling preserved where intended.
    • Verify plugin-conditional blocks (math captcha, signature) remain correct.

Possibly related PRs

Suggested labels

action: needs qa

Suggested reviewers

  • lauramekaj1
  • Liviu-p

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: introducing more CSS variables into the single theme CSS file, which aligns with the extensive refactoring summarized in the changeset.
Description check ✅ Passed The description relates to the changeset by mentioning CSS variable usage updates and the addition of plugin checks (signatures and math captcha), which matches the summary of changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch use_more_css_vars_in_single_theme_css

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6616d90 and 8bbb7b3.

📒 Files selected for processing (1)
  • css/_single_theme.css.php (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
css/_single_theme.css.php (1)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-5084)
  • kses_echo (1075-1077)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
  • GitHub Check: PHP 8 tests in WP trunk
🔇 Additional comments (11)
css/_single_theme.css.php (11)

23-24: Form container width & direction now driven by CSS vars

Using var(--form-width) and var(--direction) while preserving the $important suffix keeps behavior while making the layout themable via variables. Looks good.


40-42: Field margin switched to CSS variable correctly

margin-bottom:var(--field-margin) with the $important toggle matches the intent of the style builder and aligns with the rest of the field spacing rules.


120-123: Right-positioned element width now uses --width

Updating .frm_pos_right to use width:var(--width) with $important is consistent with the new variable-driven approach and keeps the specificity behavior intact.


147-149: Placeholder color unified on --text-color-disabled

Both native placeholders and .placeholder now use var(--text-color-disabled) with $important, which centralizes disabled/placeholder text styling in a single token. No issues here.

Also applies to: 160-162


180-182: Focus/active field state uses CSS vars for background/border/text

The focus/active block now reads from --bg-color-active, --border-color-active, and --text-color while preserving $important on background and border. This keeps behavior and makes the active state themeable.


251-254: Submit hover/active/loading states wired to submit CSS variables

Hooking hover/active/button-loading states into --submit-hover-*, --submit-active-*, --submit-bg-color, --submit-text-color, --submit-height, and --submit-width with $important maintains current behavior and exposes the full button lifecycle to theming. Looks consistent with the rest of the submit styles.

Also applies to: 267-269, 281-295


302-313: Inline submit pseudo-label picks up label typography variables

Using --font-size, --label-color, --weight, and --label-padding (with $important) for .frm_inline_top .frm_submit::before aligns this pseudo-label with the main label typography system. Implementation is consistent and safe.


325-340: Math captcha styles correctly gated by plugin check and vars

Wrapping the #frm_field_cptch_number_container styles in class_exists( 'FrmCptController' ) avoids emitting captcha-specific CSS when the plugin is inactive. The font, size, color, and weight all use the expected font variable and --font-size / --label-color / --weight tokens with $important. This block looks solid.


342-366: Error/invalid field state now fully tokenized

The .frm_blank_field / :invalid error block reads from --text-color-error, --bg-color-error, --border-color-error, --border-width-error, and --border-style-error, all with $important. This cleanly centralizes error styling in variables without changing specificity.


380-384: Error text now bound to shared weight and error color vars

.frm_error / .frm_limit_error using var(--weight) and var(--border-color-error) with $important ties error text styling into the same token system as other labels and borders. This is a straightforward and correct change.


401-402: Progress bar background now uses --bg-color

Changing the loading progress bar’s background to var(--bg-color) with $important keeps it in sync with the primary background color token. This is a safe, consistent update.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
css/_single_theme.css.php (1)

247-255: Unclosed if ( empty( $submit_bg_img ) ) will cause a PHP parse error

if ( empty( $submit_bg_img ) ) { on Line 247 opens a PHP block that is never closed in PHP—the } on Line 255 is CSS, and there is only a single closing } on Line 299, which is already needed for if ( ! $submit_style ). This leaves one if without a matching } and will result in a parse error when this file is loaded.

You can fix this by explicitly closing the inner if right after the hover rule block:

-	<?php if ( empty( $submit_bg_img ) ) { ?>
-.<?php echo esc_html( $style_class ); ?> .frm-edit-page-btn:hover,
+	<?php if ( empty( $submit_bg_img ) ) { ?>
+.<?php echo esc_html( $style_class ); ?> .frm-edit-page-btn:hover,
 .<?php echo esc_html( $style_class ); ?> input[type=submit]:hover,
 .<?php echo esc_html( $style_class ); ?> .frm_submit input[type=button]:hover,
 .<?php echo esc_html( $style_class ); ?> .frm_submit button:hover{
 	background: var(--submit-hover-bg-color)<?php echo esc_html( $important ); ?>;
 	border-color: var(--submit-hover-border-color)<?php echo esc_html( $important ); ?>;
 	color: var(--submit-hover-color)<?php echo esc_html( $important ); ?>;
 }
-
-.<?php echo esc_html( $style_class ); ?>.frm_center_submit .frm_submit .frm_ajax_loading{
+	<?php } ?>
+
+.<?php echo esc_html( $style_class ); ?>.frm_center_submit .frm_submit .frm_ajax_loading{

Also applies to: 297-300

🧹 Nitpick comments (1)
css/_single_theme.css.php (1)

325-337: Plugin-conditional CSS is good; minor consistency/typo nits

Conditionally outputting the Math Captcha and Signatures-specific rules only when FrmCptController / FrmSigField exist is a nice optimization to avoid unnecessary selectors when those add-ons are absent.

Two small nits you may want to address:

  1. Line 325 comment has a typo: inclideinclude.

  2. Line 368 hard-codes !important on the signatures error border:
    border-color:var(--border-color-error) !important;
    If you want this to behave like the other error-related declarations, consider using $important instead for consistency:

  • border-color:var(--border-color-error) !important;
  • border-color:var(--border-color-error);





Also applies to: 365-370

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used**: CodeRabbit UI

**Review profile**: CHILL

**Plan**: Pro

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 70eddfce98ff97fd80b40c5385c46f4aa02cc196 and e643a5b2f3c2fc2ef0cb531c2a582f2f3d65ac6b.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `css/_single_theme.css.php` (12 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code graph analysis (1)</summary>

<details>
<summary>css/_single_theme.css.php (1)</summary><blockquote>

<details>
<summary>classes/helpers/FrmAppHelper.php (2)</summary>

* `FrmAppHelper` (6-5084)
* `kses_echo` (1075-1077)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)</summary>

* GitHub Check: Cypress
* GitHub Check: Cypress

</details>

<details>
<summary>🔇 Additional comments (1)</summary><blockquote>

<details>
<summary>css/_single_theme.css.php (1)</summary><blockquote>

`22-24`: **CSS custom property refactor looks consistent and preserves existing semantics**

The switch from hard-coded values to CSS vars for form width/direction, field margins, label/placeholder/disabled colors, active/hover/loading states, error/invalid styling, and inline submit labels all looks consistent. `$important` is correctly appended everywhere in these hunks, so the existing “Important” style toggle behavior should be preserved while gaining more flexible theming via the new `--*` variables.



Also applies to: 39-42, 120-123, 147-162, 164-182, 251-254, 267-270, 281-285, 288-296, 308-313, 331-333, 358-363, 372-383, 392-394

</blockquote></details>

</blockquote></details>

</details>

<!-- This is an auto-generated comment by CodeRabbit for review status -->

Comment thread css/_single_theme.css.php
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
css/_single_theme.css.php (1)

386-394: Missing $important flag on margin-bottom (previously flagged).

Lines 387-391 correctly migrate to CSS variables with proper $important flag handling. However, Line 393's margin-bottom:var(--field-margin); is missing the $important flag, making it inconsistent with all other properties in the .frm_error_style block.

This issue was flagged in a previous review and has not been addressed yet. When the "Important" style toggle is enabled, all error box properties except margin-bottom will have !important, which could lead to unexpected spacing behavior.

Apply this diff to add the missing $important flag:

 .<?php echo esc_html( $style_class ); ?> .frm_error_style{
 	background-color:var(--error-bg)<?php echo esc_html( $important ); ?>;
 	border:1px solid var(--error-border)<?php echo esc_html( $important ); ?>;
 	border-radius:var(--border-radius)<?php echo esc_html( $important ); ?>;
 	color: var(--error-text)<?php echo esc_html( $important ); ?>;
 	font-size:var(--error-font-size)<?php echo esc_html( $important ); ?>;
 	margin:0;
-	margin-bottom:var(--field-margin);
+	margin-bottom:var(--field-margin)<?php echo esc_html( $important ); ?>;
 }
🧹 Nitpick comments (1)
css/_single_theme.css.php (1)

369-378: Signature field error styling correctly gated, but consider $important consistency.

The conditional block appropriately uses class_exists('FrmSigField') to gate signature-specific styling. The migration to --border-color-error is correct.

However, Line 374 uses a hardcoded !important instead of the $important variable used throughout the rest of the file. Consider whether this should be:

-	border-color:var(--border-color-error) !important;
+	border-color:var(--border-color-error)<?php echo esc_html( $important ); ?>;

This would maintain consistency with the pattern used elsewhere, unless the hardcoded !important is intentionally required for signature fields.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e643a5b and 7466c2a.

📒 Files selected for processing (1)
  • css/_single_theme.css.php (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
css/_single_theme.css.php (1)
classes/helpers/FrmAppHelper.php (1)
  • FrmAppHelper (6-5084)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Cypress
🔇 Additional comments (13)
css/_single_theme.css.php (13)

23-24: LGTM! Form-level properties migrated to CSS variables.

The conversion to --form-width and --direction CSS variables is correct, and the $important flag is properly preserved.


41-41: LGTM! Field spacing and width migrated to CSS variables.

The conversion to --field-margin and --width is correct and maintains the $important flag handling.

Also applies to: 122-122


149-149: LGTM! Placeholder styling migrated to CSS variables.

The use of --text-color-disabled for placeholder text is semantically appropriate and correctly preserves the $important flag.

Also applies to: 161-161


180-181: LGTM! Active field state styling migrated to CSS variables.

The conversion to --bg-color-active and --border-color-active is correct with proper $important flag handling.


251-253: LGTM! Submit button hover state migrated to CSS variables.

The conversion to --submit-hover-* variables is consistent and correctly maintains the $important flag for all three properties.


267-269: LGTM! Submit button active/focus state migrated to CSS variables.

The conversion to --submit-active-* variables is correct and properly preserves the $important flag.


281-283: LGTM! Loading state styling migrated to CSS variables.

The use of --submit-bg-color for both background and border during loading creates the intended uniform appearance. The $important flag is correctly preserved.


288-295: LGTM! Loading spinner styling migrated to CSS variables.

The conversion to --submit-text-color, --submit-height, and --submit-width is correct, and the conditional checks for 'auto' values are properly preserved.


308-312: LGTM! Inline submit alignment styling migrated to CSS variables.

The conversion to --font-size, --label-color, --weight, and --label-padding correctly ensures the invisible pseudo-element matches label dimensions for proper inline form alignment.


325-340: LGTM! Math captcha styling correctly gated by plugin check.

The conditional block appropriately uses class_exists('FrmCptController') to prevent generating unnecessary CSS when the plugin is inactive. The migration to --font-size, --label-color, and --weight variables is consistent with the rest of the file.


362-366: LGTM! Error field styling migrated to CSS variables.

The conversion to --text-color-error, --bg-color-error, --border-color-error, --border-width-error, and --border-style-error is comprehensive and consistent, with proper $important flag handling.


382-383: LGTM! Error message text styling migrated to CSS variables.

The conversion to --weight and --border-color-error is correct, ensuring error messages match the error border color for visual consistency.


401-401: LGTM! Progress bar styling migrated to CSS variables.

The conversion to --bg-color is correct and properly preserves the $important flag.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
css/_single_theme.css.php (1)

386-394: Apply $important to .frm_error_style margin-bottom for consistency

margin-bottom on .frm_error_style is still the only property in this rule not respecting the $important toggle, so enabling “Important” won’t affect the error block’s bottom spacing. This is inconsistent with nearby declarations and the rest of the theme controls.

Recommend aligning it with the other properties:

 .<?php echo esc_html( $style_class ); ?> .frm_error_style{
 	background-color:var(--error-bg)<?php echo esc_html( $important ); ?>;
 	border:1px solid var(--error-border)<?php echo esc_html( $important ); ?>;
 	border-radius:var(--border-radius)<?php echo esc_html( $important ); ?>;
 	color: var(--error-text)<?php echo esc_html( $important ); ?>;
 	font-size:var(--error-font-size)<?php echo esc_html( $important ); ?>;
 	margin:0;
-	margin-bottom:var(--field-margin);
+	margin-bottom:var(--field-margin)<?php echo esc_html( $important ); ?>;
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7466c2a and 6616d90.

⛔ Files ignored due to path filters (1)
  • .github/workflows/syntax.yml is excluded by !**/*.yml
📒 Files selected for processing (1)
  • css/_single_theme.css.php (12 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
css/_single_theme.css.php (1)
classes/helpers/FrmAppHelper.php (2)
  • FrmAppHelper (6-5084)
  • kses_echo (1075-1077)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Cypress
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (2)
css/_single_theme.css.php (2)

23-24: CSS variable substitutions look consistent and preserve $important behavior

The conversions to var(--…)<?php echo esc_html( $important ); ?> across these rules (form width/direction, field margins, right position width, placeholders, focus/active states, submit hover/active/loading, inline labels, error colors, and progress bar) look coherent and match the previous semantics while centralizing styling in CSS variables. No functional concerns from these changes.

Also applies to: 41-41, 122-122, 149-149, 161-161, 180-181, 251-253, 267-269, 281-283, 288-295, 308-310, 312-312, 362-366, 382-383, 387-391, 401-401


325-340: Math captcha CSS gating behind FrmCptController looks good

The new guard around #frm_field_cptch_number_container ensures this block only outputs when the related plugin class exists, and the switch to var(--font-size), var(--label-color), and var(--weight) with $important matches the pattern used elsewhere. This aligns with the PR goal of avoiding unnecessary styles for inactive add-ons.

Comment thread css/_single_theme.css.php
@Crabcyborg Crabcyborg merged commit 50c1777 into master Dec 11, 2025
16 checks passed
@Crabcyborg Crabcyborg deleted the use_more_css_vars_in_single_theme_css branch December 11, 2025 16:30
@Crabcyborg Crabcyborg modified the milestones: 6.27, 6.26.1 Dec 15, 2025
stephywells pushed a commit that referenced this pull request Apr 4, 2026
…theme_css

Use more css vars in single theme css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant