Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
129 changes: 124 additions & 5 deletions assets/css/sticky-header.css
Original file line number Diff line number Diff line change
Expand Up @@ -57,24 +57,63 @@
display: flex; /* added for vertical centering */
align-items: center; /* centers content vertically */
justify-content: center; /* centers content horizontally */
opacity: 1 !important;
}

/* Profile button colors */
.profile-button {
background-color: var(--profile-button-bg-color, #ffc107);
color: var(--profile-button-text-color, #000);
}
.profile-button:hover {
background-color: #e0a800;
}

/* Logout button colors */
.logout-button {
background-color: var(--logout-button-bg-color, #d9534f);
color: var(--logout-button-text-color, #fff);
}
.logout-button:hover {
background-color: #c9302c;

/* Logout button "logging out" state */
.logout-button.is-logging-out {
position: relative;
opacity: 0.8;
cursor: wait;
padding-right: 26px; /* space for spinner */
}

/* Default: show "Logout", hide "Logging out..." */
.logout-button .btn-text-logging-out {
display: none;
}

/* When logging out: swap labels */
.logout-button.is-logging-out .btn-text-default {
display: none;
}

.logout-button.is-logging-out .btn-text-logging-out {
display: inline;
}

/* Simple spinner on the right side of the logout button */
.logout-button.is-logging-out::after {
content: "";
position: absolute;
right: 8px;
top: 50%;
width: 14px;
height: 14px;
margin-top: -7px;
border-radius: 50%;
border: 2px solid currentColor;
border-top-color: transparent;
animation: cashtab-spin 0.8s linear infinite;
}

/* Spinner animation */
@keyframes cashtab-spin {
to {
transform: rotate(360deg);
}
}

/* Prevent header from overlapping content */
Expand All @@ -95,4 +134,84 @@ body {
.profile-button, .logout-button {
margin: 4px 0;
}
}

/* --- Animated Slide Effect for Profile + Logout Buttons --- */

/* Base animation wrapper */
.paybutton-animated {
position: relative;
overflow: hidden;
z-index: 0;
transition: color 0.25s ease;
font-weight: bold; /*make text bold for better visibility*/
}

/* Text wrapper stays above the animated layer */
.paybutton-animated span {
position: relative;
z-index: 1;
}

/* Animated overlay grows left to right */
.paybutton-animated::before {
content: "";
position: absolute;
top: 0;
left: 0;
width: 0;
height: 100%;
z-index: 0;
transition: width 0.25s ease-out;
}

/* On hover, fill the whole button */
.paybutton-animated:hover::before {
width: 100%;
}

/* --- Profile button animated variant --- */
.profile-button.paybutton-animated {
border: 2px solid var(--profile-button-bg-color);
color: var(--profile-button-text-color);
}

.profile-button.paybutton-animated::before {
background-color: #808080;
opacity: 0.3;
}

/* --- Logout button animated variant --- */
.logout-button.paybutton-animated {
border: 2px solid var(--logout-button-bg-color);
color: var(--logout-button-text-color, #fff);
}

.logout-button.paybutton-animated::before {
background-color: #808080;
opacity: 0.3;
}

/* --- Profile and Logout Button SVG Icon Style --- */
.paybutton-animated .btn-icon {
display: inline-flex;
align-items: center;
justify-content: center;
margin-right: 6px;
width: 16px;
height: 16px;
position: relative;
z-index: 1;
}

.paybutton-animated .btn-icon svg {
width: 100%;
height: 100%;
fill: currentColor; /* inherits text color */
}

/* Ensure text stays above animation layer */
.paybutton-animated .btn-text {
position: relative;
z-index: 1;
}
2 changes: 2 additions & 0 deletions assets/icons/logout.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions assets/icons/profile.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 19 additions & 6 deletions assets/js/paybutton-paywall-cashtab-login.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,31 @@ function handleLogin(address, txHash, loginToken) {
/**
* Handle user logout.
*/
function handleLogout() {
function handleLogout(logoutButton) {
if (logoutButton) {
// Disable the button and mark as logging out
logoutButton.disabled = true;
logoutButton.classList.add('is-logging-out');
}

jQuery.post(
PaywallAjax.ajaxUrl,
{
action: 'paybutton_logout',
security: PaywallAjax.nonce
},
function() {
isLoggedIn = false;
location.reload();
}
);
)
.done(function () {
isLoggedIn = false;
location.reload();
})
.fail(function () {
if (logoutButton) {
logoutButton.disabled = false;
logoutButton.classList.remove('is-logging-out');
}
alert('Logout failed. Please try again.');
});
}

/**
Expand Down
2 changes: 1 addition & 1 deletion paybutton.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@
exit;
}
}
});
});
54 changes: 52 additions & 2 deletions templates/public/sticky-header.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,65 @@
// If no valid address is set, do not display the sticky header.
return;
}

$paybutton_svg_allowed = array(
'svg' => array(
'xmlns' => true,
'viewbox' => true,
'viewBox' => true,
'width' => true,
'height' => true,
'fill' => true,
),
'path' => array(
'd' => true,
'fill' => true,
),
'circle' => array(
'cx' => true,
'cy' => true,
'r' => true,
'fill' => true,
),
'rect' => array(
'x' => true,
'y' => true,
'width' => true,
'height' => true,
'fill' => true,
),
);
?>

<div id="cashtab-sticky-header">
<?php if ( ! $user_wallet_address ): ?>
<div id="loginPaybutton"></div>
<?php else: ?>
<div class="logged-in-actions">
<button class="profile-button" onclick="window.location.href='<?php echo esc_url( get_permalink( get_option( 'paybutton_profile_page_id', 0 ) ) ); ?>'">Profile</button>
<button class="logout-button" onclick="handleLogout()">Logout</button>
<button class="profile-button paybutton-animated" onclick="window.location.href='<?php echo esc_url( get_permalink( get_option( 'paybutton_profile_page_id', 0 ) ) ); ?>'">
<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-text">Profile</span></button>
<button class="logout-button paybutton-animated" onclick="handleLogout(this)">
<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>
<!-- Default text -->
<span class="btn-text btn-text-default">Logout</span>
<!-- "Logging out..." text (hidden until .is-logging-out is added) -->
<span class="btn-text btn-text-logging-out" aria-hidden="true">Logging out...</span>
</button>
</div>
<?php endif; ?>
</div>