Skip to content

Conversation

@xecdev
Copy link
Collaborator

@xecdev xecdev commented Nov 26, 2025

This PR implements #94 and #80 by adding SVG icons for the Profile and Logout buttons, introducing a proper “logging out” visual state with an animated spinner, and adding a smooth slide-hover animation to both buttons.

Test Plan

  • Install the updated plugin
  • Login via Cashtab
  • Check the new icons for the Profile and Logout buttons.
  • You can check it live on the test website: https://wp.ecashstakingcalc.com

Summary by CodeRabbit

  • New Features

    • Profile and Logout buttons now include inline icons and animated styling.
    • Added animated hover overlay with per-button visual variants and layering to keep icons/text visible.
    • Logout shows a loading state with spinner and swaps button label during sign-out.
    • SVG allowance added to support richer inline icons; responsive header centering/wrapping improved.
  • Bug Fixes

    • Logout flow improved with client-side error handling to re-enable the button and notify on failure.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 26, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds animated paybutton markup and CSS (overlay hover, logging-out spinner, label swap), updates logout JS to accept the clicked button element and use promise-style success/fail handling that toggles the logging state, and inlines sanitized SVG icons for the buttons.

Changes

Cohort / File(s) Summary
CSS: animated buttons & states
assets/css/sticky-header.css
Adds .paybutton-animated overlay animation and reusable ::before overlay, per-button variants (.profile-button.paybutton-animated, .logout-button.paybutton-animated), .logout-button.is-logging-out state, spinner via ::after + cashtab-spin, label-swap spans (.btn-text-default / .btn-text-logging-out), z-index layering, removal of previous hover background rules, and responsive adjustments.
Logout flow JS
assets/js/paybutton-paywall-cashtab-login.js
Changes handleLogout signature to handleLogout(logoutButton), disables the button and adds .is-logging-out during the POST, uses .done() to clear login state and reload on success, and .fail() to restore button state and alert on error.
Templates & SVG helper
templates/public/sticky-header.php, paybutton.php
Replaces simple buttons with animated button markup containing inline SVGs and explicit span structure; logout now calls handleLogout(this). Adds use of an SVG-inlining/sanitization helper (whitelist) to render icons. paybutton.php only had newline/formatting adjustments.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Button as Logout Button
    participant Handler as handleLogout(logoutButton)
    participant Server
    participant Browser as DOM

    User->>Button: Click
    Button->>Handler: handleLogout(this)
    Handler->>Browser: disable button, add .is-logging-out, show spinner
    Handler->>Server: POST /logout
    alt Success
        Server-->>Handler: 200 OK
        Handler->>Browser: set isLoggedIn = false
        Handler->>Browser: reload page
    else Failure
        Server-->>Handler: Error
        Handler->>Browser: enable button, remove .is-logging-out
        Handler->>User: alert error
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Check restoration of button state and edge cases in assets/js/paybutton-paywall-cashtab-login.js (abort, network errors).
  • Verify spinner CSS (::after, cashtab-spin), overlay z-index, and text/icon stacking in assets/css/sticky-header.css.
  • Validate SVG sanitization whitelist and file path handling used by the template SVG inlining.

Poem

🐰 I nibble code and stitch a spin,
A label swaps, the colors grin.
Button hums, a tiny light,
I watch the spinner through the night,
Hop—reload—the page begins.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'improve sticky header button UI/UX' directly aligns with the PR's main objectives of enhancing button styling, adding icons, animations, and visual states to the sticky header buttons.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 feat/improve-header-buttons-ui

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
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

3 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Copy link

@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: 5

♻️ Duplicate comments (1)
templates/public/sticky-header.php (1)

28-34: Add file existence checks and consider sanitizing SVG output.

Same security and error handling concerns apply here as with the Profile button. The logout SVG should also be validated before use.

🧹 Nitpick comments (1)
assets/js/paybutton-paywall-cashtab-login.js (1)

55-55: Consider providing more specific error information.

The generic alert message doesn't help users understand what went wrong. If possible, include error details from the server response to aid troubleshooting.

-.fail(function () {
+.fail(function (jqXHR, textStatus, errorThrown) {
     if (logoutButton) {
         logoutButton.disabled = false;
         logoutButton.classList.remove('is-logging-out');
     }
-    alert('Logout failed. Please try again.');
+    const errorMsg = jqXHR.responseJSON?.data?.message || errorThrown || 'Unknown error';
+    alert('Logout failed: ' + errorMsg + '. Please try again.');
 });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f706e90 and 6aca61b.

⛔ Files ignored due to path filters (2)
  • assets/icons/logout.svg is excluded by !**/*.svg
  • assets/icons/profile.svg is excluded by !**/*.svg
📒 Files selected for processing (3)
  • assets/css/sticky-header.css (2 hunks)
  • assets/js/paybutton-paywall-cashtab-login.js (1 hunks)
  • templates/public/sticky-header.php (1 hunks)
🔇 Additional comments (3)
templates/public/sticky-header.php (1)

27-39: Good implementation of logout state management.

The button structure with separate text spans for default and "logging out" states is well-designed. Passing this to handleLogout() enables proper state management.

assets/css/sticky-header.css (2)

76-117: Well-implemented logout loading state.

The spinner animation and text swapping logic are cleanly implemented. The use of CSS-only state management (hiding/showing text spans) keeps the solution simple and performant.


139-171: Clean animated overlay implementation.

The slide-in animation effect is well-structured with proper z-index layering to keep text above the animated overlay. Good use of CSS custom properties for theming.

Copy link

@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

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 29095db and df10d92.

📒 Files selected for processing (2)
  • paybutton.php (1 hunks)
  • templates/public/sticky-header.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • templates/public/sticky-header.php

Copy link

@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 (2)
templates/public/sticky-header.php (2)

12-38: Reuse existing paybutton_inline_svg() helper instead of redefining SVG allowlist.

This block safely sanitizes SVGs, but it reintroduces a local $paybutton_svg_allowed plus file handling that are already encapsulated by paybutton_inline_svg( $filename ) in paybutton.php. That duplication risks the two allowlists drifting over time.

Consider simplifying to something like:

-<?php
-    $paybutton_svg_allowed = array(
-        // ...
-    );
-?>
+<?php
+    // SVG sanitization and file existence checks are handled centrally
+    // by paybutton_inline_svg( $filename ) in paybutton.php.
+?>

and for the icons:

-            <span class="btn-icon">
-                <?php
-                    $paybutton_svg_path = PAYBUTTON_PLUGIN_DIR . 'assets/icons/profile.svg';
-                    if ( file_exists( $paybutton_svg_path ) ) {
-                        echo wp_kses( file_get_contents( $paybutton_svg_path ), $paybutton_svg_allowed );
-                    }
-                ?>
-            </span>
+            <span class="btn-icon">
+                <?php echo paybutton_inline_svg( 'profile' ); ?>
+            </span>

-            <span class="btn-icon">
-                <?php
-                    $paybutton_svg_path = PAYBUTTON_PLUGIN_DIR . 'assets/icons/logout.svg';
-                    if ( file_exists( $paybutton_svg_path ) ) {
-                        echo wp_kses( file_get_contents( $paybutton_svg_path ), $paybutton_svg_allowed );
-                    }
-                ?>
-            </span>
+            <span class="btn-icon">
+                <?php echo paybutton_inline_svg( 'logout' ); ?>
+            </span>

If the new icons require additional SVG elements/attributes, you can extend the central allowlist in paybutton_inline_svg() instead of maintaining a second one here.

Also applies to: 47-63


66-68: Improve accessibility of the “Logging out…” state.

aria-hidden="true" on the .btn-text-logging-out span means assistive technologies will never announce that state, even when it becomes visible.

Consider either:

  • Removing aria-hidden and relying on CSS display: none/block to hide/show the label, or
  • Using an aria-live="polite" region for the logging-out text so screen readers announce the status change when logout starts.

This keeps the new logging-out UI helpful for keyboard/screen-reader users as well.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between df10d92 and 13d77f9.

📒 Files selected for processing (2)
  • paybutton.php (1 hunks)
  • templates/public/sticky-header.php (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • paybutton.php

@xecdev
Copy link
Collaborator Author

xecdev commented Nov 27, 2025

Bot's feedback applied and ready for review.

@xecdev xecdev requested a review from Klakurka November 27, 2025 13:54
@xecdev xecdev self-assigned this Nov 27, 2025
@xecdev xecdev added the enhancement (UI/UX/feature) New feature or request label Nov 27, 2025
@Klakurka Klakurka merged commit 5d1b3fb into master Nov 29, 2025
1 check passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement (UI/UX/feature) New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add icons to sticky header buttons Add a spinner or text indicating logout to improve UX.

3 participants