Skip to content

Commit

Permalink
Add active class for selected plan ✨
Browse files Browse the repository at this point in the history
  • Loading branch information
Khadreal committed Dec 24, 2024
1 parent 62f3b8f commit 20d6658
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 15 deletions.
7 changes: 4 additions & 3 deletions assets/css/wpr-admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ a:focus, button:focus {
color: #121116;
padding: 8px 0;
padding-left: 4px;
border-bottom: 1px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
border-bottom: 1px solid #c2cad4;
}
.wpr-Popin .wp-rocket-data-table td:not(.column-primary) {
font-family: "Monaco";
Expand Down Expand Up @@ -2862,7 +2862,7 @@ div.wpr-tutorial-item {
font-family: Monaco;
color: #121116;
background: #fff;
border: 2px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
border: 2px solid #c2cad4;
border-radius: 3px;
font-size: 0.8125rem;
line-height: 1.2307692308;
Expand Down Expand Up @@ -2894,7 +2894,7 @@ div.wpr-tutorial-item {
height: 32px;
color: #121116;
background: #fff;
border: 2px solid rgb(194.1698113208, 202.0188679245, 211.8301886792);
border: 2px solid #c2cad4;
border-radius: 3px;
font-family: Monaco;
font-size: 0.75rem;
Expand Down Expand Up @@ -3248,6 +3248,7 @@ div.wpr-tutorial-item {
}

.select-dropdown li:hover,
.select-dropdown li.active,
.select-dropdown input:checked ~ label {
background-color: #f2f2f2;
}
Expand Down
2 changes: 1 addition & 1 deletion assets/css/wpr-admin.min.css

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions assets/js/wpr-admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/wpr-admin.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/js/wpr-admin.min.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions inc/Engine/License/Upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function get_promo_message( $promo_name = '', $promo_discount = 0 ) {
$license_types = $this->get_upgrade_types();

return sprintf(
// translators: %1$s = promotion name, %2$s = <br>, %3$s = <strong>, %4$s = promotion discount percentage, %5$s = </strong>, %6$s = Growth/Multi.
// translators: %1$s = promotion name, %2$s = <br>, %3$s = <strong>, %4$s = promotion discount percentage, %5$s = </strong>, %6$s = Growth or Multi.
esc_html__(
'Take advantage of %1$s to speed up more websites:%2$s get a %3$s%4$s off%5$s for %3$supgrading your license to %6$s!%5$s',
'rocket'
Expand All @@ -255,7 +255,7 @@ private function get_promo_message( $promo_name = '', $promo_discount = 0 ) {
'<strong>',
$promo_discount . '%',
'</strong>',
implode( ', ', $license_types ),
implode( ' or ', $license_types ),
);
}

Expand Down
10 changes: 9 additions & 1 deletion src/js/custom/custom-select.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ document.querySelectorAll(".custom-select").forEach(customSelect => {

customSelect.addEventListener('click', function(e) {
if (e.target.matches('label')) {
handler(e.target.closest('li'));

const allItems = customSelect.querySelectorAll('li');
allItems.forEach(item => item.classList.remove('active'));
const clickedPlan = e.target.closest('li');

if (clickedPlan) {
clickedPlan.classList.add('active');
handler(clickedPlan);
}
}
});
document.addEventListener("click", (e) => {
Expand Down
4 changes: 2 additions & 2 deletions src/js/global/fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,11 @@ $(document).ready(function(){
let stacked_select = document.getElementById( 'rocket_stacked_select' );
if ( stacked_select ) {
stacked_select.addEventListener('custom-select-change',function(event){
console.log(event.detail.selectedOption);

let selected_option = $( event.detail.selectedOption );

let name = selected_option.data('name');
console.log(name);

let saving = selected_option.data('saving');
let regular_price = selected_option.data('regular-price');
let price = selected_option.data('price');
Expand Down
1 change: 1 addition & 0 deletions src/scss/components/fields/_customselect.scss
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
}

.select-dropdown li:hover,
.select-dropdown li.active,
.select-dropdown input:checked ~ label {
background-color: #f2f2f2;
}
Expand Down

0 comments on commit 20d6658

Please sign in to comment.