Skip to content

Fix centered submit button bottom margin value with modern dark theme#2195

Merged
Crabcyborg merged 4 commits into
masterfrom
issue-5557-fix_centered_submit_margin_with_modern_dark_theme
Jan 9, 2025
Merged

Fix centered submit button bottom margin value with modern dark theme#2195
Crabcyborg merged 4 commits into
masterfrom
issue-5557-fix_centered_submit_margin_with_modern_dark_theme

Conversation

@AbdiTolesa
Copy link
Copy Markdown
Contributor

@AbdiTolesa AbdiTolesa commented Jan 2, 2025

Fix https://github.com/Strategy11/formidable-pro/issues/5557
Quoting Mike's workaround the issue implemented in this PR:

We should check for this, and use the bottom value.

So if the submit_margin has 2 units (vertical, horizontal), we want to use the first value (10px in this case). If there are 4 (top, right, bottom, left), we'll want to use the bottom value (the 3rd one).

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 2, 2025

Walkthrough

The pull request introduces a new method get_bottom_value() in the FrmStylesHelper class, designed to extract the bottom value from margin or padding strings. This method is then utilized in the CSS generation process, specifically modifying how the margin-bottom is calculated for the .frm_center_submit .frm_submit class. Additionally, a new test method is added to validate the functionality of get_bottom_value(), enhancing test coverage for the FrmStylesHelper class.

Changes

File Change Summary
classes/helpers/FrmStylesHelper.php Added get_bottom_value() static method to extract bottom value from margin/padding strings
css/_single_theme.css.php Updated margin-bottom calculation to use FrmStylesHelper::get_bottom_value() method
tests/phpunit/styles/test_FrmStylesHelper.php Added test_get_bottom_value() method to validate get_bottom_value() functionality

Sequence Diagram

sequenceDiagram
    participant CSS Generator
    participant FrmStylesHelper
    participant $submit_margin

    CSS Generator->>FrmStylesHelper: get_bottom_value($submit_margin)
    FrmStylesHelper-->>CSS Generator: Return bottom margin value
    CSS Generator->>CSS Generator: Apply bottom margin value
Loading

The sequence diagram illustrates how the get_bottom_value() method is called during CSS generation, extracting the bottom margin value from the input string and returning it for application in the stylesheet.

Finishing Touches

  • 📝 Generate Docstrings

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread css/_single_theme.css.php Outdated
@AbdiTolesa AbdiTolesa requested a review from Crabcyborg January 8, 2025 06:38
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

🧹 Nitpick comments (1)
classes/helpers/FrmStylesHelper.php (1)

951-951: Update the @SInCE version tag

The @SInCE tag contains a placeholder 'x.x' version number.

-	 * @since x.x
+	 * @since 6.0
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0a702b3 and e287fea.

📒 Files selected for processing (2)
  • classes/helpers/FrmStylesHelper.php (1 hunks)
  • css/_single_theme.css.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Run PHP Syntax inspection (8.3)
  • GitHub Check: Cypress
🔇 Additional comments (2)
css/_single_theme.css.php (1)

257-257: LGTM! The margin-bottom fix is properly implemented.

The change correctly implements the margin extraction logic by using FrmStylesHelper::get_bottom_value() to get the bottom margin value, which addresses the issue with centered submit buttons in the modern dark theme.

classes/helpers/FrmStylesHelper.php (1)

956-965: LGTM! The margin value extraction is well implemented.

The implementation correctly handles:

  • Empty value validation
  • Different margin value formats (1-2 parts vs 3-4 parts)
  • Proper string splitting and array access

Comment thread classes/helpers/FrmStylesHelper.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

🧹 Nitpick comments (1)
tests/phpunit/styles/test_FrmStylesHelper.php (1)

250-252: Consider adding error case test scenarios.

While the happy path cases are well covered, consider adding test cases for potential error scenarios:

  • Invalid CSS values (e.g., "invalid")
  • Malformed spacing (e.g., "5px 10px")
  • Mixed units (e.g., "5px 10em 15% 20vh")
// Additional test cases to consider
$expected = array(
    'invalid'           => '',  // Invalid value should return empty
    '5px  10px'        => '5px',  // Extra spaces
    '5px 10em 15% 20vh' => '15%',  // Mixed units
);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e287fea and a983430.

📒 Files selected for processing (1)
  • tests/phpunit/styles/test_FrmStylesHelper.php (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: PHP 8 tests in WP trunk
  • GitHub Check: Cypress
  • GitHub Check: PHP 7.4 tests in WP trunk
🔇 Additional comments (3)
tests/phpunit/styles/test_FrmStylesHelper.php (3)

238-241: LGTM! Well-documented test method.

The test method is properly documented with the @covers annotation, clearly indicating which method it's testing.


242-248: Comprehensive test cases covering all margin value formats.

The test cases effectively cover:

  • Empty string: Edge case
  • Single value: Direct value
  • Two values: Vertical/horizontal format
  • Three values: Top/horizontal/bottom format
  • Four values: Top/right/bottom/left format

This aligns well with the PR objective of handling both 2-value and 4-value margin formats.


237-253: Verify test coverage against implementation.

Let's verify if all edge cases from the implementation are covered in the test cases.

✅ Verification successful

Test coverage is complete and matches implementation logic

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Find the implementation file and check for edge cases
echo "Searching for FrmStylesHelper implementation..."
rg -l "class FrmStylesHelper"

echo "Checking get_bottom_value implementation..."
rg -A 10 "function get_bottom_value" 

echo "Checking for any TODO/FIXME comments related to margin handling..."
rg -i "todo|fixme|hack|xxx" -g "**/*Style*"

Length of output: 1373

@AbdiTolesa AbdiTolesa requested a review from Crabcyborg January 9, 2025 07:49
Copy link
Copy Markdown
Contributor

@Crabcyborg Crabcyborg left a comment

Choose a reason for hiding this comment

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

Thanks @AbdiTolesa!

🚀

@Crabcyborg Crabcyborg added this to the 6.17 milestone Jan 9, 2025
@Crabcyborg Crabcyborg merged commit e69aea4 into master Jan 9, 2025
@Crabcyborg Crabcyborg deleted the issue-5557-fix_centered_submit_margin_with_modern_dark_theme branch January 9, 2025 13:54
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.

2 participants