From 7dc6c77a35b058474c1577bfd0375605d14c5b69 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Tue, 23 Jan 2024 13:44:09 -0500 Subject: [PATCH 01/13] feat(modal-checkout): add ui to thankyou --- includes/class-modal-checkout.php | 2 +- src/modal-checkout/checkout.scss | 3 + src/modal-checkout/templates/thankyou.php | 80 ++++++++--------------- src/shared/sass/_boxes.scss | 44 +++++++++++++ src/shared/sass/_buttons.scss | 61 +++++++++++++++++ src/shared/sass/variables/_colors.scss | 34 ++++++++++ src/shared/sass/variables/_fonts.scss | 18 +++++ src/shared/sass/variables/_index.scss | 4 ++ src/shared/sass/variables/_misc.scss | 38 +++++++++++ src/shared/sass/variables/_spacing.scss | 13 ++++ 10 files changed, 242 insertions(+), 55 deletions(-) create mode 100644 src/shared/sass/_boxes.scss create mode 100644 src/shared/sass/_buttons.scss create mode 100644 src/shared/sass/variables/_colors.scss create mode 100644 src/shared/sass/variables/_fonts.scss create mode 100644 src/shared/sass/variables/_index.scss create mode 100644 src/shared/sass/variables/_misc.scss create mode 100644 src/shared/sass/variables/_spacing.scss diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 178c258d9..56e762c00 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -834,7 +834,7 @@ private static function render_after_success_button() { href="" target="_top" - class="button newspack-modal-newsletters__button" + class="newspack-blocks-ui__button newspack-ui__button--primary newspack-ui__button--wide" > diff --git a/src/modal-checkout/checkout.scss b/src/modal-checkout/checkout.scss index d6bfff2d3..355d39b0a 100644 --- a/src/modal-checkout/checkout.scss +++ b/src/modal-checkout/checkout.scss @@ -1,3 +1,6 @@ +@use '../shared/sass/boxes'; +@use '../shared/sass/buttons'; + /* stylelint-disable-next-line */ #newspack_modal_checkout { padding: 24px; diff --git a/src/modal-checkout/templates/thankyou.php b/src/modal-checkout/templates/thankyou.php index 305b9c520..ccba484e4 100644 --- a/src/modal-checkout/templates/thankyou.php +++ b/src/modal-checkout/templates/thankyou.php @@ -47,67 +47,39 @@ function newspack_blocks_replace_login_with_order_summary() { return; } - $is_success = ! $order->has_status( 'failed' ); - $order_item_name = array_values( $order->get_items() )[0]->get_name(); - + $is_success = ! $order->has_status( 'failed' ); ?>
-

- +
+

+ + + +

+
+ -

- -

- -

- - - - -

+
+

+ +

+ +

+ + + + +

+
- - - - - *:first-child { + margin-top: 0; + } + + > *:last-child { + margin-bottom: 0; + } + } +} + diff --git a/src/shared/sass/_buttons.scss b/src/shared/sass/_buttons.scss new file mode 100644 index 000000000..940d62ce3 --- /dev/null +++ b/src/shared/sass/_buttons.scss @@ -0,0 +1,61 @@ +@use './variables'; + +.newspack-blocks-ui { + &__button { + align-items: center; + border: 0; + border-radius: var( --newspack-ui-border-radius-small ); + display: inline-flex; + font-family: var( --newspack-ui-font-family ); + font-size: var( --newspack-ui-font-size-small ); + font-weight: 600; + gap: var( --newspack-ui-spacer-2 ); + justify-content: center; + line-height: var( --newspack-ui-line-height-large ); + margin-bottom: var( --newspack-ui-spacer-base ); + padding: var( --newspack-ui-spacer-2 ) var( --newspack-ui-spacer-3 ); // TODO: correct this + transition: background-color 150ms ease-in-out; + + &:disabled { + background: var( --newspack-ui-color-gray-100 ) !important; + color: var( --newspack-ui-color-text-med-contrast ) !important; + cursor: default; + } + + &--wide { + display: flex; + width: 100%; + } + + &--primary { + background: var( --newspack-ui-color-button-bg ); + color: var( --newspack-ui-color-button-text ); + + &:hover { + background: var( --newspack-ui-color-button-bg-hover ); + } + } + + &--secondary { + background: transparent; + border: 1px solid var( --newspack-ui-color-border ); + color: var( --newspack-ui-color-text-high-contrast ); + padding: calc( var( --newspack-ui-spacer-2 ) - 1px ) + calc( var( --newspack-ui-spacer-3 ) - 1px ); + + &:hover { + background: var( --newspack-ui-color-gray-100 ); + } + } + + &--tertiary { + background: transparent; + color: var( --newspack-ui-color-text-high-contrast ); + + &:hover { + background: var( --newspack-ui-color-gray-100 ); + } + } + } +} + diff --git a/src/shared/sass/variables/_colors.scss b/src/shared/sass/variables/_colors.scss new file mode 100644 index 000000000..f9588a4cb --- /dev/null +++ b/src/shared/sass/variables/_colors.scss @@ -0,0 +1,34 @@ +:root { + // Grays - notes from the Gutenberg styles. + // TODO: Import from 'wordpress/base-styles/colors' ? + --newspack-ui-color-black: #000; // Use only when you truly need pure black. For UI, use $gray-900. + --newspack-ui-color-gray-900: #1e1e1e; + --newspack-ui-color-gray-800: #2f2f2f; + --newspack-ui-color-gray-700: #757575; // Meets 4.6:1 text contrast against white. + --newspack-ui-color-gray-600: #949494; // Meets 3:1 UI or large text contrast against white. + --newspack-ui-color-gray-400: #ccc; + --newspack-ui-color-gray-300: #ddd; // Used for most borders. + --newspack-ui-color-gray-200: #e0e0e0; // Used sparingly for light borders. + --newspack-ui-color-gray-100: #f0f0f0; // Used for light gray backgrounds. + --newspack-ui-color-white: #fff; + + // Alert colors + --newpsack-ui-color-alert-yellow: #f0b849; + --newspack-ui-color-alert-green: #4ab866; + --newspack-ui-color-alert-red: #cc1818; + // --newpsack-ui-color-alert-yellow-bg: TBD + --newspack-ui-color-alert-green-bg: #edfaef; + --newpsack-ui-color-alert-red-bg: #fcf0f1; + + // Specific assignments - general: + --newspack-ui-color-text-high-contrast: var( --newspack-ui-color-gray-900 ); + --newspack-ui-color-text-med-contrast: var( --newspack-ui-color-gray-700 ); + --newspack-ui-color-border: var( --newspack-ui-color-gray-300 ); + --newspack-ui-color-body-bg: var( --newspack-ui-color-white ); + + // Specific assignments - form elements + --newspack-ui-color-button-bg: var( --newspack-ui-color-gray-900 ); + --newspack-ui-color-button-bg-hover: var( --newspack-ui-color-gray-800 ); // TODO: Replace w/correct value. + --newspack-ui-color-button-text: var( --newspack-ui-color-white ); + --newspack-ui-color-radio-bg: var( --newspack-ui-color-gray-900 ); +} diff --git a/src/shared/sass/variables/_fonts.scss b/src/shared/sass/variables/_fonts.scss new file mode 100644 index 000000000..910d29de3 --- /dev/null +++ b/src/shared/sass/variables/_fonts.scss @@ -0,0 +1,18 @@ +:root { + // Fonts + --newspack-ui-font-family: system-ui, sans-serif; + + // TODO: the base size for the modals is 16px, with small text/labels at 14px; + // The My Account designs appear to use 16px for most labels + // Should we have a in-modal vs. non-modal set of font sizes? + --newspack-ui-font-size-large: 20px; + --newspack-ui-font-size-medium: 16px; // modal baseline + --newspack-ui-font-size-small: 14px; // modal small + --newspack-ui-font-weight-strong: 600; + + // Line heights - TODO: sort this out: + --newspack-ui-line-height-large: 1.7143; // inputs, buttons + --newspack-ui-line-height-medium: 1.5; // 16px font size + --newspack-ui-line-height-small: 1.4286; // 14px font sizes +} + diff --git a/src/shared/sass/variables/_index.scss b/src/shared/sass/variables/_index.scss new file mode 100644 index 000000000..1b7a8f26c --- /dev/null +++ b/src/shared/sass/variables/_index.scss @@ -0,0 +1,4 @@ +@use './colors'; +@use './fonts'; +@use './spacing'; +@use './misc'; diff --git a/src/shared/sass/variables/_misc.scss b/src/shared/sass/variables/_misc.scss new file mode 100644 index 000000000..d4e63b4e8 --- /dev/null +++ b/src/shared/sass/variables/_misc.scss @@ -0,0 +1,38 @@ +$mobile_width: 600px; +$tablet_width: 782px; +$desktop_width: 1168px; +$wide_width: 1379px; + +$font__size_base: 20px; +$font__size-ratio: 1.125; + +$font__size-xxxs: 1em * 0.5; // 10px +$font__size-xxs: 1em * 0.6; // 12px +$font__size-xs: 1em * 0.7; // 14px +$font__size-sm: 1em * 0.8; // 16px +// $font__size_base: 1em * 1; // 20px +$font__size-md: 1em * 1.2; // 24px +$font__size-lg: 1em * 1.4; // 28px +$font__size-xl: 1em * 1.8; // 36px +$font__size-xxl: 1em * 2.2; // 44px +$font__size-xxxl: 1em * 2.8; // 56px +$font__size-xxxxl: 1em * 3.2; // 64px + +$font__line-height-body: 1.6; +$font__line-height-pre: 1.6; +$font__line-height-heading: 1.2; +$font__line-height-double: 2 * $font__line-height-heading; + +$color__border: #ccc; + +// TODO: Some misc styles that need a home! +:root { + // Modal widths + --newspack-ui-modal-width-large: 964px; + --newspack-ui-modal-width-medium: 600px; + --newspack-ui-modal-width-small: 368px; + + // Border radius - not ems because the font size of the element itself caused a cascade. + --newspack-ui-border-radius: 6px; + --newspack-ui-border-radius-small: 5px; +} diff --git a/src/shared/sass/variables/_spacing.scss b/src/shared/sass/variables/_spacing.scss new file mode 100644 index 000000000..530dffeca --- /dev/null +++ b/src/shared/sass/variables/_spacing.scss @@ -0,0 +1,13 @@ +:root { + // Spacing - not ems because the font size of the element itself caused a cascade + --newspack-ui-spacer-base: 8px; + --newspack-ui-spacer-2: calc( var( --newspack-ui-spacer-base ) * 1.5 ); // 12px + --newspack-ui-spacer-3: calc( var( --newspack-ui-spacer-base ) * 2 ); // 16px + --newspack-ui-spacer-4: calc( var( --newspack-ui-spacer-base ) * 2.5 ); // 20px + --newspack-ui-spacer-5: calc( var( --newspack-ui-spacer-base ) * 3 ); // 24px + --newspack-ui-spacer-6: calc( var( --newspack-ui-spacer-base ) * 4 ); // 32px - TODO: clamp? + --newspack-ui-spacer-7: calc( var( --newspack-ui-spacer-base ) * 5 ); // 40px - TODO: clamp? + --newspack-ui-spacer-8: calc( var( --newspack-ui-spacer-base ) * 6 ); // 48px - TODO: clamp? + --newspack-ui-spacer-9: calc( var( --newspack-ui-spacer-base ) * 8 ); // 64px - TODO: clamp? +} + From fc01e3cd288a4dafda5501a4c17270d06457d198 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Tue, 23 Jan 2024 18:22:48 -0500 Subject: [PATCH 02/13] feat(modal-checkout): remove redundant styles --- includes/class-modal-checkout.php | 8 +- src/blocks/checkout-button/block.json | 2 +- src/blocks/donate/block.json | 2 +- src/modal-checkout/index.js | 4 - src/modal-checkout/modal.js | 5 -- src/modal-checkout/templates/thankyou-v2.php | 84 ++++++++++++++++++++ src/modal-checkout/templates/thankyou.php | 80 +++++++++++++------ src/shared/sass/_boxes.scss | 44 ---------- src/shared/sass/_buttons.scss | 61 -------------- src/shared/sass/variables/_colors.scss | 34 -------- src/shared/sass/variables/_fonts.scss | 18 ----- src/shared/sass/variables/_index.scss | 4 - src/shared/sass/variables/_misc.scss | 38 --------- src/shared/sass/variables/_spacing.scss | 13 --- 14 files changed, 145 insertions(+), 252 deletions(-) create mode 100644 src/modal-checkout/templates/thankyou-v2.php delete mode 100644 src/shared/sass/_boxes.scss delete mode 100644 src/shared/sass/_buttons.scss delete mode 100644 src/shared/sass/variables/_colors.scss delete mode 100644 src/shared/sass/variables/_fonts.scss delete mode 100644 src/shared/sass/variables/_index.scss delete mode 100644 src/shared/sass/variables/_misc.scss delete mode 100644 src/shared/sass/variables/_spacing.scss diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 56e762c00..d2f92ab18 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -54,6 +54,7 @@ public static function init() { add_action( 'woocommerce_checkout_before_customer_details', [ __CLASS__, 'render_before_customer_details' ] ); add_filter( 'woocommerce_enable_order_notes_field', [ __CLASS__, 'enable_order_notes_field' ] ); add_action( 'woocommerce_checkout_process', [ __CLASS__, 'wcsg_apply_gift_subscription' ] ); + add_filter( 'woocommerce_order_received_verify_known_shoppers', '__return_false' ); /** Custom handling for registered users. */ add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_user' ] ); @@ -572,14 +573,15 @@ public static function wc_get_template( $located, $template_name ) { return $located; } - $custom_templates = [ + $is_newspack_plugin_active = class_exists( '\Newspack\Newspack_UI' ); + $custom_templates = [ 'checkout/form-checkout.php' => 'src/modal-checkout/templates/form-checkout.php', - 'checkout/thankyou.php' => 'src/modal-checkout/templates/thankyou.php', 'checkout/form-coupon.php' => 'src/modal-checkout/templates/form-coupon.php', 'checkout/form-gift-subscription.php' => 'src/modal-checkout/templates/form-gift-subscription.php', + 'checkout/thankyou.php' => 'src/modal-checkout/templates/' . ( $is_newspack_plugin_active ? 'thankyou-v2' : 'thankyou' ) . '.php', // Replace the login form with the order summary if using the modal checkout. This is // for the case where the reader used an existing email address. - 'global/form-login.php' => 'src/modal-checkout/templates/thankyou.php', + 'global/form-login.php' => 'src/modal-checkout/templates/' . ( $is_newspack_plugin_active ? 'thankyou-v2' : 'thankyou' ) . '.php', ]; // Only show the woocommerce-subscriptions-gifting fields when we want to. diff --git a/src/blocks/checkout-button/block.json b/src/blocks/checkout-button/block.json index dee914c43..be761653d 100644 --- a/src/blocks/checkout-button/block.json +++ b/src/blocks/checkout-button/block.json @@ -41,7 +41,7 @@ }, "afterSuccessButtonLabel": { "type": "string", - "default": "Continue browsing" + "default": "Continue" }, "afterSuccessURL": { "type": "string" diff --git a/src/blocks/donate/block.json b/src/blocks/donate/block.json index a4778eef3..d5656ba16 100644 --- a/src/blocks/donate/block.json +++ b/src/blocks/donate/block.json @@ -84,7 +84,7 @@ }, "afterSuccessButtonLabel": { "type": "string", - "default": "Continue browsing" + "default": "Continue" }, "afterSuccessURL": { "type": "string" diff --git a/src/modal-checkout/index.js b/src/modal-checkout/index.js index 8215ce142..7b267d1ba 100644 --- a/src/modal-checkout/index.js +++ b/src/modal-checkout/index.js @@ -1,8 +1,4 @@ /* globals newspackBlocksModalCheckout, jQuery, wc_checkout_params */ -/** - * Style dependencies - */ -import './checkout.scss'; ( function ( $ ) { if ( ! $ ) { diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 45525cb98..85852a611 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -1,8 +1,3 @@ -/** - * Internal dependencies - */ -import './modal.scss'; - /** * Specify a function to execute when the DOM is fully loaded. * diff --git a/src/modal-checkout/templates/thankyou-v2.php b/src/modal-checkout/templates/thankyou-v2.php new file mode 100644 index 000000000..224cee749 --- /dev/null +++ b/src/modal-checkout/templates/thankyou-v2.php @@ -0,0 +1,84 @@ +get_order_key(), $key ); // Validate order key to prevent CSRF. + + // Handle the newsletter signup form. + $newsletter_confirmation = \Newspack_Blocks\Modal_Checkout::confirm_newsletter_signup(); + $is_error = \is_wp_error( $newsletter_confirmation ); + $no_selected_lists = $is_error && 'newspack_no_lists_selected' === $newsletter_confirmation->get_error_code(); + if ( true === $newsletter_confirmation || $no_selected_lists ) { + echo \Newspack_Blocks\Modal_Checkout::render_newsletter_confirmation( $no_selected_lists ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + return; + } elseif ( $is_error ) { + echo esc_html( $newsletter_confirmation->get_error_message() ); + return; + } + + if ( ! $is_valid ) { + return; + } + + $is_success = ! $order->has_status( 'failed' ); + ?> + +
+ +
+

+ + + +

+ +
+ +
+

+ +

+ + + + + +
+ +
+ has_status( 'failed' ); + $is_success = ! $order->has_status( 'failed' ); + $order_item_name = array_values( $order->get_items() )[0]->get_name(); + ?>
-
-

- - - -

-
- +

+
    +
  • + + get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> +
  • + + get_billing_email() ) : ?> + + + +
  • + + get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> +
  • + + get_payment_method_title() ) : ?> +
  • + + get_payment_method_title() ); ?> +
  • + + +
  • + + +
  • + +
  • + + get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> +
  • +
-
-

- -

- -

- - - - -

-
+

+ +

+ +

+ + + + +

+ + + + + *:first-child { - margin-top: 0; - } - - > *:last-child { - margin-bottom: 0; - } - } -} - diff --git a/src/shared/sass/_buttons.scss b/src/shared/sass/_buttons.scss deleted file mode 100644 index 940d62ce3..000000000 --- a/src/shared/sass/_buttons.scss +++ /dev/null @@ -1,61 +0,0 @@ -@use './variables'; - -.newspack-blocks-ui { - &__button { - align-items: center; - border: 0; - border-radius: var( --newspack-ui-border-radius-small ); - display: inline-flex; - font-family: var( --newspack-ui-font-family ); - font-size: var( --newspack-ui-font-size-small ); - font-weight: 600; - gap: var( --newspack-ui-spacer-2 ); - justify-content: center; - line-height: var( --newspack-ui-line-height-large ); - margin-bottom: var( --newspack-ui-spacer-base ); - padding: var( --newspack-ui-spacer-2 ) var( --newspack-ui-spacer-3 ); // TODO: correct this - transition: background-color 150ms ease-in-out; - - &:disabled { - background: var( --newspack-ui-color-gray-100 ) !important; - color: var( --newspack-ui-color-text-med-contrast ) !important; - cursor: default; - } - - &--wide { - display: flex; - width: 100%; - } - - &--primary { - background: var( --newspack-ui-color-button-bg ); - color: var( --newspack-ui-color-button-text ); - - &:hover { - background: var( --newspack-ui-color-button-bg-hover ); - } - } - - &--secondary { - background: transparent; - border: 1px solid var( --newspack-ui-color-border ); - color: var( --newspack-ui-color-text-high-contrast ); - padding: calc( var( --newspack-ui-spacer-2 ) - 1px ) - calc( var( --newspack-ui-spacer-3 ) - 1px ); - - &:hover { - background: var( --newspack-ui-color-gray-100 ); - } - } - - &--tertiary { - background: transparent; - color: var( --newspack-ui-color-text-high-contrast ); - - &:hover { - background: var( --newspack-ui-color-gray-100 ); - } - } - } -} - diff --git a/src/shared/sass/variables/_colors.scss b/src/shared/sass/variables/_colors.scss deleted file mode 100644 index f9588a4cb..000000000 --- a/src/shared/sass/variables/_colors.scss +++ /dev/null @@ -1,34 +0,0 @@ -:root { - // Grays - notes from the Gutenberg styles. - // TODO: Import from 'wordpress/base-styles/colors' ? - --newspack-ui-color-black: #000; // Use only when you truly need pure black. For UI, use $gray-900. - --newspack-ui-color-gray-900: #1e1e1e; - --newspack-ui-color-gray-800: #2f2f2f; - --newspack-ui-color-gray-700: #757575; // Meets 4.6:1 text contrast against white. - --newspack-ui-color-gray-600: #949494; // Meets 3:1 UI or large text contrast against white. - --newspack-ui-color-gray-400: #ccc; - --newspack-ui-color-gray-300: #ddd; // Used for most borders. - --newspack-ui-color-gray-200: #e0e0e0; // Used sparingly for light borders. - --newspack-ui-color-gray-100: #f0f0f0; // Used for light gray backgrounds. - --newspack-ui-color-white: #fff; - - // Alert colors - --newpsack-ui-color-alert-yellow: #f0b849; - --newspack-ui-color-alert-green: #4ab866; - --newspack-ui-color-alert-red: #cc1818; - // --newpsack-ui-color-alert-yellow-bg: TBD - --newspack-ui-color-alert-green-bg: #edfaef; - --newpsack-ui-color-alert-red-bg: #fcf0f1; - - // Specific assignments - general: - --newspack-ui-color-text-high-contrast: var( --newspack-ui-color-gray-900 ); - --newspack-ui-color-text-med-contrast: var( --newspack-ui-color-gray-700 ); - --newspack-ui-color-border: var( --newspack-ui-color-gray-300 ); - --newspack-ui-color-body-bg: var( --newspack-ui-color-white ); - - // Specific assignments - form elements - --newspack-ui-color-button-bg: var( --newspack-ui-color-gray-900 ); - --newspack-ui-color-button-bg-hover: var( --newspack-ui-color-gray-800 ); // TODO: Replace w/correct value. - --newspack-ui-color-button-text: var( --newspack-ui-color-white ); - --newspack-ui-color-radio-bg: var( --newspack-ui-color-gray-900 ); -} diff --git a/src/shared/sass/variables/_fonts.scss b/src/shared/sass/variables/_fonts.scss deleted file mode 100644 index 910d29de3..000000000 --- a/src/shared/sass/variables/_fonts.scss +++ /dev/null @@ -1,18 +0,0 @@ -:root { - // Fonts - --newspack-ui-font-family: system-ui, sans-serif; - - // TODO: the base size for the modals is 16px, with small text/labels at 14px; - // The My Account designs appear to use 16px for most labels - // Should we have a in-modal vs. non-modal set of font sizes? - --newspack-ui-font-size-large: 20px; - --newspack-ui-font-size-medium: 16px; // modal baseline - --newspack-ui-font-size-small: 14px; // modal small - --newspack-ui-font-weight-strong: 600; - - // Line heights - TODO: sort this out: - --newspack-ui-line-height-large: 1.7143; // inputs, buttons - --newspack-ui-line-height-medium: 1.5; // 16px font size - --newspack-ui-line-height-small: 1.4286; // 14px font sizes -} - diff --git a/src/shared/sass/variables/_index.scss b/src/shared/sass/variables/_index.scss deleted file mode 100644 index 1b7a8f26c..000000000 --- a/src/shared/sass/variables/_index.scss +++ /dev/null @@ -1,4 +0,0 @@ -@use './colors'; -@use './fonts'; -@use './spacing'; -@use './misc'; diff --git a/src/shared/sass/variables/_misc.scss b/src/shared/sass/variables/_misc.scss deleted file mode 100644 index d4e63b4e8..000000000 --- a/src/shared/sass/variables/_misc.scss +++ /dev/null @@ -1,38 +0,0 @@ -$mobile_width: 600px; -$tablet_width: 782px; -$desktop_width: 1168px; -$wide_width: 1379px; - -$font__size_base: 20px; -$font__size-ratio: 1.125; - -$font__size-xxxs: 1em * 0.5; // 10px -$font__size-xxs: 1em * 0.6; // 12px -$font__size-xs: 1em * 0.7; // 14px -$font__size-sm: 1em * 0.8; // 16px -// $font__size_base: 1em * 1; // 20px -$font__size-md: 1em * 1.2; // 24px -$font__size-lg: 1em * 1.4; // 28px -$font__size-xl: 1em * 1.8; // 36px -$font__size-xxl: 1em * 2.2; // 44px -$font__size-xxxl: 1em * 2.8; // 56px -$font__size-xxxxl: 1em * 3.2; // 64px - -$font__line-height-body: 1.6; -$font__line-height-pre: 1.6; -$font__line-height-heading: 1.2; -$font__line-height-double: 2 * $font__line-height-heading; - -$color__border: #ccc; - -// TODO: Some misc styles that need a home! -:root { - // Modal widths - --newspack-ui-modal-width-large: 964px; - --newspack-ui-modal-width-medium: 600px; - --newspack-ui-modal-width-small: 368px; - - // Border radius - not ems because the font size of the element itself caused a cascade. - --newspack-ui-border-radius: 6px; - --newspack-ui-border-radius-small: 5px; -} diff --git a/src/shared/sass/variables/_spacing.scss b/src/shared/sass/variables/_spacing.scss deleted file mode 100644 index 530dffeca..000000000 --- a/src/shared/sass/variables/_spacing.scss +++ /dev/null @@ -1,13 +0,0 @@ -:root { - // Spacing - not ems because the font size of the element itself caused a cascade - --newspack-ui-spacer-base: 8px; - --newspack-ui-spacer-2: calc( var( --newspack-ui-spacer-base ) * 1.5 ); // 12px - --newspack-ui-spacer-3: calc( var( --newspack-ui-spacer-base ) * 2 ); // 16px - --newspack-ui-spacer-4: calc( var( --newspack-ui-spacer-base ) * 2.5 ); // 20px - --newspack-ui-spacer-5: calc( var( --newspack-ui-spacer-base ) * 3 ); // 24px - --newspack-ui-spacer-6: calc( var( --newspack-ui-spacer-base ) * 4 ); // 32px - TODO: clamp? - --newspack-ui-spacer-7: calc( var( --newspack-ui-spacer-base ) * 5 ); // 40px - TODO: clamp? - --newspack-ui-spacer-8: calc( var( --newspack-ui-spacer-base ) * 6 ); // 48px - TODO: clamp? - --newspack-ui-spacer-9: calc( var( --newspack-ui-spacer-base ) * 8 ); // 64px - TODO: clamp? -} - From 7adeceea90944b0cf9d5a9911e3cb41bba59c094 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Tue, 23 Jan 2024 19:01:30 -0500 Subject: [PATCH 03/13] feat(modal-checkout): update thankyou form classes --- includes/class-modal-checkout.php | 36 +++++++------ src/modal-checkout/modal.js | 4 +- src/modal-checkout/templates/thankyou-v2.php | 53 +++++++++----------- 3 files changed, 44 insertions(+), 49 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index d2f92ab18..75a628d2e 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -290,23 +290,21 @@ public static function render_modal_markup() { */ $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); ?> -
-
-
-

- - - - -
-
-
- -
-
-
+
+
+

+ + + + +
+
+
+ +
+
diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 85852a611..0510e4eab 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -44,13 +44,13 @@ function closeCheckout() { window.newspackCloseModalCheckout = closeCheckout; -const MODAL_CLASSNAME_BASE = '.newspack-blocks-modal'; +const MODAL_CLASSNAME_BASE = '.newspack-ui__modal'; domReady( () => { /** * Initialize modal checkout. */ - const modalCheckout = document.querySelector( '.newspack-blocks-checkout-modal' ); + const modalCheckout = document.querySelector( '#newspack-blocks-checkout-modal' ); if ( ! modalCheckout ) { return; } diff --git a/src/modal-checkout/templates/thankyou-v2.php b/src/modal-checkout/templates/thankyou-v2.php index 224cee749..af69c3d60 100644 --- a/src/modal-checkout/templates/thankyou-v2.php +++ b/src/modal-checkout/templates/thankyou-v2.php @@ -50,35 +50,32 @@ function newspack_blocks_replace_login_with_order_summary() { $is_success = ! $order->has_status( 'failed' ); ?> -
- -
-

- - - -

- -
- -
-

- -

- - - - - -
+ +
+

+ + + +

+
+ + +
+

+ +

+
+ + + -
- Date: Wed, 24 Jan 2024 10:52:06 -0500 Subject: [PATCH 04/13] feat(modal-checkout): fix visibility toggling --- includes/class-modal-checkout.php | 4 +- src/modal-checkout/modal.js | 9 ++- src/modal-checkout/modal.scss | 100 +++++------------------------- 3 files changed, 23 insertions(+), 90 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 75a628d2e..629df46c3 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -293,12 +293,12 @@ public static function render_modal_markup() {

- +
diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 0510e4eab..1953569ed 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -1,3 +1,8 @@ +/** + * Internal dependencies + */ +import './modal.scss'; + /** * Specify a function to execute when the DOM is fully loaded. * @@ -34,7 +39,7 @@ function closeCheckout() { if ( iframeResizeObserver ) { iframeResizeObserver.disconnect(); } - Array.from( document.querySelectorAll( '.newspack-blocks-modal' ) ).forEach( el => { + Array.from( document.querySelectorAll( '.newspack-ui__modal' ) ).forEach( el => { el.classList.remove( 'open' ); if ( el.overlayId && window.newspackReaderActivation?.overlays ) { window.newspackReaderActivation?.overlays.remove( el.overlayId ); @@ -54,7 +59,7 @@ domReady( () => { if ( ! modalCheckout ) { return; } - const spinner = document.querySelector( `${ MODAL_CLASSNAME_BASE }__spinner` ); + const spinner = document.querySelector( `${ MODAL_CLASSNAME_BASE } .spinner` ); const iframeName = 'newspack_modal_checkout'; const modalCheckoutInput = document.createElement( 'input' ); modalCheckoutInput.type = 'hidden'; diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index 346ce78e5..2f2cfa502 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -1,78 +1,22 @@ -@use '../shared/sass/colors'; -@use '../shared/sass/variables'; +@use '../shared/colors'; -@keyframes spin { - 0% { - transform: rotate( 0deg ); - } - 50% { - transform: rotate( 180deg ); - } - 100% { - transform: rotate( 360deg ); - } -} - -.newspack-blocks-modal { - position: fixed; - top: 0; - left: 0; +// Modal visibility and animation. +#newspack-blocks-checkout-modal { width: 100%; height: 100%; - background: rgba( 0, 0, 0, 0.75 ); visibility: hidden; pointer-events: none; z-index: -1; opacity: 0; transition: opacity 0.2s ease-in-out; - &__container { - border-radius: 6px; - background: colors.$color__background-body; - position: absolute; - top: 50%; - left: 50%; - width: calc( 100vw - 32px ); - max-width: 600px; - min-height: 300px; - max-height: 90vh; - display: flex; - flex-direction: column; - justify-content: space-between; - transform: translate( -50%, -50% ) translateY( 50px ); - transition: transform 0.2s ease-in-out; - } &.open { z-index: 99999; visibility: visible; pointer-events: auto; opacity: 1; - .newspack-blocks-modal__container { - transform: translate( -50%, -50% ); - } - } - &__header { - padding: 24px; - box-sizing: border-box; - height: 64px; - border-bottom: 1px solid #ddd; - display: flex; - align-items: center; - justify-content: space-between; - h2 { - font-size: 16px; - } } - &__content { - position: relative; - flex-grow: 1; - > * { - width: 100%; - height: 100%; - border: 0; - border-radius: 6px; - } - } - &__spinner { + + &.spinner { align-items: center; background: #fff; border-radius: 5px; @@ -93,20 +37,6 @@ margin-left: -12.5px; } } - &__close { - padding: 8px; - border: 0; - background: transparent; - color: colors.$color__text-main; - cursor: pointer; - &:focus, - &:hover { - color: colors.$color__text-light; - } - svg { - display: block; - } - } } .newspack-blocks-variation-modal { @@ -174,16 +104,14 @@ } } -@media ( max-width: 600px ) { - .newspack-blocks-modal { - &__container { - max-width: 100%; - width: 100%; - border-radius: 0; - top: auto; - bottom: 0; - left: 0; - transform: none !important; - } +@keyframes spin { + 0% { + transform: rotate( 0deg ); + } + 50% { + transform: rotate( 180deg ); + } + 100% { + transform: rotate( 360deg ); } } From c24716c484d531b34bab8dc0eb372b98e9c75c7f Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Wed, 24 Jan 2024 13:34:18 -0500 Subject: [PATCH 05/13] feat(modal-checkout): modal fixes --- includes/class-modal-checkout.php | 54 ++++++------ src/modal-checkout/modal.js | 33 +++++--- src/modal-checkout/modal.scss | 56 ++----------- src/modal-checkout/templates/thankyou-v2.php | 81 ------------------ src/modal-checkout/templates/thankyou.php | 87 +++++++------------- 5 files changed, 87 insertions(+), 224 deletions(-) delete mode 100644 src/modal-checkout/templates/thankyou-v2.php diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 629df46c3..ec6388fd8 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -290,21 +290,24 @@ public static function render_modal_markup() { */ $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); ?> -
-
-

- -
-
-
- -
-
+
+
+
+
+

+ +
+
+
+ +
+
+
- + 'src/modal-checkout/templates/form-checkout.php', 'checkout/form-coupon.php' => 'src/modal-checkout/templates/form-coupon.php', 'checkout/form-gift-subscription.php' => 'src/modal-checkout/templates/form-gift-subscription.php', - 'checkout/thankyou.php' => 'src/modal-checkout/templates/' . ( $is_newspack_plugin_active ? 'thankyou-v2' : 'thankyou' ) . '.php', + ]; + + // If Newspack UI is present, use our templates. + if ( class_exists( '\Newspack\Newspack_UI' ) ) { + $custom_templates['checkout/thankyou.php'] = 'src/modal-checkout/templates/thankyou.php'; // Replace the login form with the order summary if using the modal checkout. This is // for the case where the reader used an existing email address. - 'global/form-login.php' => 'src/modal-checkout/templates/' . ( $is_newspack_plugin_active ? 'thankyou-v2' : 'thankyou' ) . '.php', - ]; + $custom_templates['global/form-login.php'] = 'src/modal-checkout/templates/thankyou.php'; + } // Only show the woocommerce-subscriptions-gifting fields when we want to. if ( 'html-add-recipient.php' === $template_name ) { @@ -827,17 +833,17 @@ private static function render_after_success_button() { $button_label = ! empty( $_REQUEST['after_success_button_label'] ) ? urldecode( wp_unslash( $_REQUEST['after_success_button_label'] ) ) : __( 'Continue browsing', 'newspack-blocks' ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized $url = ! empty( $_REQUEST['after_success_url'] ) ? urldecode( wp_unslash( $_REQUEST['after_success_url'] ) ) : ''; // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?> - onclick="parent.newspackCloseModalCheckout(this);" href="" target="_top" - class="newspack-blocks-ui__button newspack-ui__button--primary newspack-ui__button--wide" + class="newspack-ui__button newspack-ui__button--primary newspack-ui__button--wide" > - + { - el.classList.remove( 'open' ); + Array.from( document.querySelectorAll( '.newspack-ui__modal-container' ) ).forEach( el => { + closeModal( el ); if ( el.overlayId && window.newspackReaderActivation?.overlays ) { window.newspackReaderActivation?.overlays.remove( el.overlayId ); } } ); } +function openModal( el ) { + el.setAttribute( 'data-state', 'open' ); +} + +function closeModal( el ) { + el.setAttribute( 'data-state', 'closed' ); +} + window.newspackCloseModalCheckout = closeCheckout; const MODAL_CLASSNAME_BASE = '.newspack-ui__modal'; @@ -55,12 +62,12 @@ domReady( () => { /** * Initialize modal checkout. */ - const modalCheckout = document.querySelector( '#newspack-blocks-checkout-modal' ); + const modalCheckout = document.querySelector( '.newspack-ui__modal-container' ); if ( ! modalCheckout ) { return; } - const spinner = document.querySelector( `${ MODAL_CLASSNAME_BASE } .spinner` ); - const iframeName = 'newspack_modal_checkout'; + const spinner = document.querySelector( '.newspack-ui__spinner' ); + const iframeName = 'newspack_modal_checkout_iframe'; const modalCheckoutInput = document.createElement( 'input' ); modalCheckoutInput.type = 'hidden'; modalCheckoutInput.name = 'modal_checkout'; @@ -129,7 +136,9 @@ domReady( () => { form.addEventListener( 'submit', ev => { const formData = new FormData( form ); // Clear any open variation modal. - variationModals.forEach( variationModal => variationModal.classList.remove( 'open' ) ); + variationModals.forEach( variationModal => { + closeModal( variationModal ); + } ); // Trigger variation modal if variation is not selected. if ( formData.get( 'is_variable' ) && ! formData.get( 'variation_id' ) ) { const variationModal = [ ...variationModals ].find( @@ -154,15 +163,13 @@ domReady( () => { } ); // Open the variations modal. ev.preventDefault(); - document.body.classList.add( 'newspack-modal-checkout-open' ); - variationModal.classList.add( 'open' ); + openModal( variationModal ); return; } } // Continue with checkout modal. spinner.style.display = 'flex'; - modalCheckout.classList.add( 'open' ); - document.body.classList.add( 'newspack-modal-checkout-open' ); + openModal( modalCheckout ); if ( window.newspackReaderActivation?.overlays ) { modalCheckout.overlayId = window.newspackReaderActivation?.overlays.add(); } @@ -173,11 +180,13 @@ domReady( () => { const contentRect = entries[ 0 ].contentRect; if ( contentRect ) { modalContent.style.height = contentRect.top + contentRect.bottom + 'px'; + iframe.style.height = contentRect.top + contentRect.bottom + 'px'; } } ); } ); } ); } ); + iframe.addEventListener( 'load', () => { const location = iframe.contentWindow.location; // If RAS is available, set the front-end authentication. diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index 2f2cfa502..245289b55 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -1,44 +1,3 @@ -@use '../shared/colors'; - -// Modal visibility and animation. -#newspack-blocks-checkout-modal { - width: 100%; - height: 100%; - visibility: hidden; - pointer-events: none; - z-index: -1; - opacity: 0; - transition: opacity 0.2s ease-in-out; - &.open { - z-index: 99999; - visibility: visible; - pointer-events: auto; - opacity: 1; - } - - &.spinner { - align-items: center; - background: #fff; - border-radius: 5px; - display: flex; - justify-content: center; - position: absolute; - top: 0; - bottom: 0; - width: 100%; - > span { - animation: spin 1s infinite linear; - border: 2px solid colors.$color__background-body; - border-top-color: colors.$color__text-light; - border-radius: 50%; - height: 25px; - width: 25px; - margin-top: -12.5px; - margin-left: -12.5px; - } - } -} - .newspack-blocks-variation-modal { .newspack-blocks-modal { &__content { @@ -104,14 +63,11 @@ } } -@keyframes spin { - 0% { - transform: rotate( 0deg ); - } - 50% { - transform: rotate( 180deg ); - } - 100% { - transform: rotate( 360deg ); +// Checkout modal specific styles. +.newspack-ui__modal-container { + iframe[name="newspack_modal_checkout_iframe"] { + width: 100%; + height: 100%; + border: none; } } diff --git a/src/modal-checkout/templates/thankyou-v2.php b/src/modal-checkout/templates/thankyou-v2.php deleted file mode 100644 index af69c3d60..000000000 --- a/src/modal-checkout/templates/thankyou-v2.php +++ /dev/null @@ -1,81 +0,0 @@ -get_order_key(), $key ); // Validate order key to prevent CSRF. - - // Handle the newsletter signup form. - $newsletter_confirmation = \Newspack_Blocks\Modal_Checkout::confirm_newsletter_signup(); - $is_error = \is_wp_error( $newsletter_confirmation ); - $no_selected_lists = $is_error && 'newspack_no_lists_selected' === $newsletter_confirmation->get_error_code(); - if ( true === $newsletter_confirmation || $no_selected_lists ) { - echo \Newspack_Blocks\Modal_Checkout::render_newsletter_confirmation( $no_selected_lists ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - return; - } elseif ( $is_error ) { - echo esc_html( $newsletter_confirmation->get_error_message() ); - return; - } - - if ( ! $is_valid ) { - return; - } - - $is_success = ! $order->has_status( 'failed' ); - ?> - - -
-

- - - -

-
- - -
-

- -

-
- - - - - has_status( 'failed' ); - $order_item_name = array_values( $order->get_items() )[0]->get_name(); - + $is_success = ! $order->has_status( 'failed' ); ?> -
- -

-
    -
  • - - get_date_created() ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> -
  • - - get_billing_email() ) : ?> - - - -
  • - - get_formatted_order_total(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> -
  • - - get_payment_method_title() ) : ?> -
  • - - get_payment_method_title() ); ?> -
  • - - -
  • - - -
  • - -
  • - - get_order_number(); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> -
  • -
- -

- + +

+ + + + +

+ + +

- -

- - - - +

+ + +
+

+

+
+ + + -
- - - - - - Date: Thu, 25 Jan 2024 14:35:48 -0500 Subject: [PATCH 06/13] feat(modal-checkout): fix iframe height bug --- src/modal-checkout/checkout.scss | 307 +------------------------------ src/modal-checkout/index.js | 4 + src/modal-checkout/modal.js | 11 +- src/modal-checkout/modal.scss | 10 +- 4 files changed, 16 insertions(+), 316 deletions(-) diff --git a/src/modal-checkout/checkout.scss b/src/modal-checkout/checkout.scss index 355d39b0a..1a7f0a60b 100644 --- a/src/modal-checkout/checkout.scss +++ b/src/modal-checkout/checkout.scss @@ -1,315 +1,10 @@ @use '../shared/sass/boxes'; @use '../shared/sass/buttons'; -/* stylelint-disable-next-line */ -#newspack_modal_checkout { - padding: 24px; - h3 { - font-size: 16px; - margin: 0 0 8px; - } - p { - margin: 0 0 16px; - } - .woocommerce-message, - .woocommerce-error, - .woocommerce-info { - border-radius: 6px; - svg { - display: none; - } - li { - font-size: 14px; - } - } - .woocommerce-info, - .woocommerce-message { - background-color: #f6f7f7; - color: #757575; - } - .wc-block-components-notice-banner__content { - font-size: 14px; - } - // Avoid duplicate styling when block components notice is inside the legacy - // notice-group. - .woocommerce-NoticeGroup .wc-block-components-notice-banner { - background: transparent; - border: 0; - padding: 0 !important; - margin: 0; - color: inherit; - } - input[type='text'], - input[type='email'], - input[type='tel'], - input[type='number'], - input[type='password'], - input[type='submit'], - select, - textarea { - border-radius: 6px; - padding: 12px 16px; - font-size: 14px; - line-height: 24px; - border-color: #ddd; - &:focus { - box-shadow: 0 0 0 1px #36f inset; - } - } - // Custom styles for Select2. - .select2-container .select2-selection--single .select2-selection__rendered { - padding-left: 16px; - padding-right: 16px; - font-size: 14px; - } - .select2-results { - font-size: 14px; - } - .select2-dropdown, - .woocommerce-checkout .select2-container--focus .select2-selection, - .select2-container--default .select2-selection--single { - border-color: #ddd; - } - input[type='checkbox'] { - border-radius: 6px; - } - input[type='checkbox']:checked { - background-color: var( --newspack-theme-color-primary ); - border-color: var( --newspack-theme-color-primary ); - } - // Inline input validation - .form-row .woocommerce-error { - padding: 0; - margin: 0.25rem 0 0; - color: #cc1818; - background: transparent; - font-size: 14px; - } - .button { - font-size: 14px; - background-color: transparent; - color: inherit; - border: 1px solid #ddd; - } - .order-details-summary { - background: #f6f7f7; - text-align: center; - padding: 24px; - border-radius: 6px; - margin: 0 0 24px; - h2 { - font-size: 16px; - line-height: 24px; - margin: 0; - } - } - #ship-to-different-address { - label { - display: flex; - align-items: center; - margin: 0 0 24px; - span::before, - span::after { - display: none; - } - input[type='checkbox'] { - display: inline-grid; - margin-right: 8px; - } - } - } - /* stylelint-disable-next-line */ - #customer_details { - .woocommerce-billing-fields { - p { - margin: 8px 0 24px; - /* stylelint-disable-next-line */ - &#billing_address_1_field { - margin-bottom: 8px; - } - } - label { - font-size: 14px; - line-height: 20px; - font-weight: 600; - margin-bottom: 8px; - } - } - } - #payment { - .wc_payment_methods { - margin: 0 0 24px; - } - .wc_payment_method { - border: 1px solid #ddd; - border-radius: 6px; - padding: 16px; - margin: 0 0 16px; - font-size: 14px; - line-height: 20px; - > label { - font-weight: 600; - } - &.selected { - background-color: #f5fdff; - border-color: #36f; - } - input.input-radio[name='payment_method'] + label::before { - box-shadow: 0 0 0 1px #ddd; - } - input.input-radio[name='payment_method']:checked + label::before { - background: #36f; - box-shadow: 0 0 0 1px #36f; - } - .payment_box { - font-size: 14px; - line-height: 20px; - padding: 0; - background: transparent; - margin: 16px 0 0; - } - > label:first-of-type { - margin: 0; - } - } - // Hide radio button if there's only one payment method. - .wc_payment_method:first-child:nth-last-child( 1 ) { - label:first-of-type::before { - display: none; - } - } - .wc-saved-payment-methods { - margin: 0; - padding: 0 0 0 8px; - li input[type='radio'] { - margin-right: 8px; - } - } - .wc-payment-form { - margin: 16px 0 0; - } - .newspack-cover-fees, - .woocommerce-SavedPaymentMethods-saveNew { - display: flex; - margin: 16px 0 0; - input { - margin-right: 8px; - } - } - } +#newspack_modal_checkout { /* stylelint-disable-line */ .order-review-wrapper.hidden { display: none; } - /* stylelint-disable-next-line */ - #order_review { - margin: 0 0 24px; - padding: 16px 24px; - border-radius: 6px; - background: #f6f7f7; - table { - font-size: 14px; // Prevent relative font size - line-height: 24px; - border: 0; - margin: 0; - &.empty { - display: none; - margin: 0; - padding: 0; - } - th, - td { - font-size: 14px; // Prevent relative font size - padding: 4px 0; - vertical-align: top; - border-color: #ddd; - > * { - white-space: nowrap; - } - } - th { - background-color: inherit; - font-weight: 600; - text-align: left; - } - td:last-child { - width: 1%; - } - tr.cart-subtotal { - th { - font-weight: normal; - } - } - tr.recurring-totals { - th { - padding-top: 24px; - } - } - tfoot tr:last-child { - th, - td { - border-bottom: 0; - } - } - } - } - .woocommerce-terms-and-conditions-wrapper { - margin: 0; - .woocommerce-privacy-policy-text { - font-size: 14px; - line-height: 20px; - color: #757575; - } - } - .woocommerce-form-coupon { - margin: 0 0 24px; - p { - display: flex; - align-items: center; - input[type='text'] { - margin-right: 8px; - flex-grow: 1; - } - } - p.result { - margin: 0; - font-size: 14px; - &.error { - color: #cc1818; - } - } - } - /* stylelint-disable-next-line */ - #checkout_details { - display: flex; - margin: 0 0 24px; - > * { - flex: 1 1 100%; - gap: 16px; - } - p { - font-size: 14px; - margin: 0; - } - } - /* stylelint-disable-next-line */ - #checkout_continue, - /* stylelint-disable-next-line */ - #place_order { - background-color: var( --newspack-theme-color-primary ); - color: #fff; /* TODO: Fix dynamic contrast */ - font-size: 14px; - font-weight: 600; - display: block; - width: 100%; - border: 0; - } - /* stylelint-disable-next-line */ - #checkout_back { - border: 0; - width: 100%; - background: transparent; - color: inherit; - } /* Remove support for "Allow customers to log into an existing account during checkout" */ .woocommerce-form-login-toggle { display: none; diff --git a/src/modal-checkout/index.js b/src/modal-checkout/index.js index 7b267d1ba..8215ce142 100644 --- a/src/modal-checkout/index.js +++ b/src/modal-checkout/index.js @@ -1,4 +1,8 @@ /* globals newspackBlocksModalCheckout, jQuery, wc_checkout_params */ +/** + * Style dependencies + */ +import './checkout.scss'; ( function ( $ ) { if ( ! $ ) { diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index e7cf1f016..14544bfcc 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -76,6 +76,7 @@ domReady( () => { const initialHeight = modalContent.clientHeight + 'px'; const iframe = document.createElement( 'iframe' ); iframe.name = iframeName; + iframe.scrolling = 'no'; modalContent.appendChild( iframe ); modalCheckout.addEventListener( 'click', ev => { if ( ev.target === modalCheckout ) { @@ -177,10 +178,12 @@ domReady( () => { if ( ! entries || ! entries.length ) { return; } - const contentRect = entries[ 0 ].contentRect; - if ( contentRect ) { - modalContent.style.height = contentRect.top + contentRect.bottom + 'px'; - iframe.style.height = contentRect.top + contentRect.bottom + 'px'; + + const iframeHeight = iframe.contentDocument.documentElement.offsetHeight; + if ( iframeHeight ) { + // Account for newspack ui modal content padding. + modalContent.style.height = iframeHeight + 48 + 'px'; + iframe.style.height = iframeHeight + 'px'; } } ); } ); diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index 245289b55..24dd896eb 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -64,10 +64,8 @@ } // Checkout modal specific styles. -.newspack-ui__modal-container { - iframe[name="newspack_modal_checkout_iframe"] { - width: 100%; - height: 100%; - border: none; - } +iframe[name="newspack_modal_checkout_iframe"] { + width: 100%; + height: 100%; + border: none; } From 9cf857c64f71aa3eb409a2a5a106553e6623ae36 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Thu, 25 Jan 2024 16:42:22 -0500 Subject: [PATCH 07/13] feat(modal-checkout): apply default styles --- includes/class-modal-checkout.php | 28 ++++-- src/modal-checkout/modal.js | 26 +++--- src/modal-checkout/modal.scss | 146 +++++++++++++++++++++++++++++- 3 files changed, 175 insertions(+), 25 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index ec6388fd8..f84b240e8 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -288,22 +288,27 @@ public static function render_modal_markup() { * * @param string $title The title. */ - $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); + $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); + $class_prefix = 'newspack-blocks'; + + if ( class_exists( '\Newspack\Newspack_UI' ) ) { + $class_prefix = 'newspack-ui'; + } ?> -
-
-
-
+
+
+
+

-
-
-
+
+
@@ -458,6 +463,13 @@ public static function enqueue_modal( $product_id = null ) { \NEWSPACK_BLOCKS__VERSION, true ); + wp_localize_script( + 'newspack-blocks-modal', + 'newspackBlocksModal', + [ + 'has_newspack_ui' => class_exists( '\Newspack\Newspack_UI' ), + ] + ); wp_enqueue_style( 'newspack-blocks-modal', plugins_url( 'dist/modal.css', \NEWSPACK_BLOCKS__PLUGIN_FILE ), diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 14544bfcc..cbda5189b 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -1,3 +1,5 @@ +/* globals newspackBlocksModal */ + /** * Internal dependencies */ @@ -25,6 +27,9 @@ function domReady( callback ) { document.addEventListener( 'DOMContentLoaded', callback ); } +const CLASSNAME_BASE = newspackBlocksModal.has_newspack_ui ? 'newspack-ui' : 'newspack-blocks'; +const MODAL_CLASSNAME_BASE = `${ CLASSNAME_BASE }__modal`; + const triggers = '.wpbnbd.wpbnbd--platform-wc,.wp-block-newspack-blocks-checkout-button,.newspack-blocks-variation-modal'; @@ -38,7 +43,7 @@ function closeCheckout() { if ( iframeResizeObserver ) { iframeResizeObserver.disconnect(); } - Array.from( document.querySelectorAll( '.newspack-ui__modal-container' ) ).forEach( el => { + Array.from( document.querySelectorAll( `.${ MODAL_CLASSNAME_BASE }-container` ) ).forEach( el => { closeModal( el ); if ( el.overlayId && window.newspackReaderActivation?.overlays ) { window.newspackReaderActivation?.overlays.remove( el.overlayId ); @@ -46,44 +51,41 @@ function closeCheckout() { } ); } -function openModal( el ) { - el.setAttribute( 'data-state', 'open' ); -} - function closeModal( el ) { el.setAttribute( 'data-state', 'closed' ); } -window.newspackCloseModalCheckout = closeCheckout; +function openModal( el ) { + el.setAttribute( 'data-state', 'open' ); +} -const MODAL_CLASSNAME_BASE = '.newspack-ui__modal'; +window.newspackCloseModalCheckout = closeCheckout; domReady( () => { /** * Initialize modal checkout. */ - const modalCheckout = document.querySelector( '.newspack-ui__modal-container' ); + const modalCheckout = document.querySelector( `.${ MODAL_CLASSNAME_BASE }-container` ); if ( ! modalCheckout ) { return; } - const spinner = document.querySelector( '.newspack-ui__spinner' ); + const spinner = document.querySelector( `.${ CLASSNAME_BASE }__spinner` ); const iframeName = 'newspack_modal_checkout_iframe'; const modalCheckoutInput = document.createElement( 'input' ); modalCheckoutInput.type = 'hidden'; modalCheckoutInput.name = 'modal_checkout'; modalCheckoutInput.value = '1'; - const modalContent = modalCheckout.querySelector( `${ MODAL_CLASSNAME_BASE }__content` ); + const modalContent = modalCheckout.querySelector( `.${ MODAL_CLASSNAME_BASE }__content` ); const initialHeight = modalContent.clientHeight + 'px'; const iframe = document.createElement( 'iframe' ); iframe.name = iframeName; - iframe.scrolling = 'no'; modalContent.appendChild( iframe ); modalCheckout.addEventListener( 'click', ev => { if ( ev.target === modalCheckout ) { closeCheckout(); } } ); - const closeButtons = modalCheckout.querySelectorAll( `${ MODAL_CLASSNAME_BASE }__close` ); + const closeButtons = modalCheckout.querySelectorAll( `.${ MODAL_CLASSNAME_BASE }__close` ); closeButtons.forEach( button => { button.addEventListener( 'click', ev => { ev.preventDefault(); diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index 24dd896eb..fe09d1a84 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -1,3 +1,132 @@ +@use '../shared/sass/colors'; +@use '../shared/sass/variables'; + +// Checkout modal specific styles. +iframe[name="newspack_modal_checkout_iframe"] { + width: 100%; + height: 100%; + border: none; +} + +// Default modal styles when newspack ui is not present. +.newspack-blocks { + &__modal-container { + position: fixed; + z-index: -1; + inset: 0; + overflow: hidden; + display: flex; + align-items: center; + justify-content: center; + visibility: hidden; + pointer-events: none; + + &__overlay { + position: absolute; + z-index: 1; + inset: 0; + opacity: 0; + background: rgba( 0, 0, 0, 0.5 ); + transition: opacity 0.1s linear; + } + + &[data-state='open'] { + z-index: 99999; + visibility: visible; + pointer-events: auto; + .newspack-blocks__modal-container__overlay { + opacity: 1; + } + .newspack-blocks__modal { + opacity: 1; + transform: translateY( 0 ); + } + } + + & .newspack-blocks { + &__modal { + position: relative; + z-index: 2; + width: 100%; + transform: translateY( 50px ); + opacity: 0; + transition: transform 0.1s linear, opacity 0.1s linear; + border-radius: 6px; + background: colors.$color__background-body; + max-width: 600px; + max-height: 90vh; + min-height: 300px; + display: flex; + flex-direction: column; + justify-content: space-between; + overflow: auto; + + &__header { + padding: 24px; + box-sizing: border-box; + height: 64px; + border-bottom: 1px solid #ddd; + display: flex; + align-items: center; + justify-content: space-between; + h2 { + font-size: 16px; + } + } + + &__content { + padding: 24px; + position: relative; + flex-grow: 1; + > * { + width: 100%; + height: 100%; + border: 0; + border-radius: 6px; + } + } + + &__close { + padding: 8px; + border: 0; + background: transparent; + color: colors.$color__text-main; + cursor: pointer; + &:focus, + &:hover { + color: colors.$color__text-light; + } + svg { + display: block; + } + } + } + + &__spinner { + align-items: center; + background: #fff; + border-radius: 5px; + display: flex; + justify-content: center; + position: absolute; + top: 0; + bottom: 0; + width: calc( 100% - 24px ); + > span { + animation: spin 1s infinite linear; + border: 2px solid colors.$color__background-body; + border-top-color: colors.$color__text-light; + border-radius: 50%; + height: 25px; + width: 25px; + margin-top: -12.5px; + margin-left: -12.5px; + } + } + } + } +} + .newspack-blocks-variation-modal { .newspack-blocks-modal { &__content { @@ -63,9 +192,16 @@ } } -// Checkout modal specific styles. -iframe[name="newspack_modal_checkout_iframe"] { - width: 100%; - height: 100%; - border: none; + +@keyframes spin { + 0% { + transform: rotate( 0deg ); + } + 50% { + transform: rotate( 180deg ); + } + 100% { + transform: rotate( 360deg ); + } } + From 11da777eb248eae901f66354b2859ee48a57b1c7 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Fri, 26 Jan 2024 10:28:27 -0500 Subject: [PATCH 08/13] feat(modal-checkout): various ui fixes --- includes/class-modal-checkout.php | 7 ++++++- src/modal-checkout/modal.js | 12 ++++++------ src/modal-checkout/modal.scss | 6 ++++-- src/modal-checkout/templates/thankyou.php | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index f84b240e8..40e2c065b 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -495,6 +495,11 @@ public static function get_checkout_template( $template ) { if ( ! self::is_modal_checkout() ) { return $template; } + $class_prefix = 'newspack-blocks'; + if ( class_exists( '\Newspack\Newspack_UI' ) ) { + $class_prefix = 'newspack-ui'; + } + $classnames = "$class_prefix {$class_prefix}__iframe {$class_prefix}__modal__content"; ob_start(); ?> @@ -505,7 +510,7 @@ public static function get_checkout_template( $template ) { - + { if ( ! entries || ! entries.length ) { return; } - - const iframeHeight = iframe.contentDocument.documentElement.offsetHeight; - if ( iframeHeight ) { - // Account for newspack ui modal content padding. - modalContent.style.height = iframeHeight + 48 + 'px'; - iframe.style.height = iframeHeight + 'px'; + const contentRect = entries[ 0 ].contentRect; + if ( contentRect ) { + const iframeHeight = contentRect.top + contentRect.bottom + 'px'; + // Match iframe and modal content heights to avoid inner iframe scollbar. + modalContent.style.height = iframeHeight; + iframe.style.height = iframeHeight; } } ); } ); diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index fe09d1a84..2232c4d9e 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -3,9 +3,11 @@ // Checkout modal specific styles. iframe[name="newspack_modal_checkout_iframe"] { - width: 100%; - height: 100%; border: none; + height: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); + margin: calc( -1 * var( --newspack-ui-spacer-5, 24px ) ); + max-width: unset; + width: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); } // Default modal styles when newspack ui is not present. diff --git a/src/modal-checkout/templates/thankyou.php b/src/modal-checkout/templates/thankyou.php index 7c6595781..d4a96573d 100644 --- a/src/modal-checkout/templates/thankyou.php +++ b/src/modal-checkout/templates/thankyou.php @@ -53,7 +53,7 @@ function newspack_blocks_replace_login_with_order_summary() {
- + From 2b81581f333dd3cda25b8e4f7f1710e4e618aa75 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Fri, 26 Jan 2024 12:08:57 -0500 Subject: [PATCH 09/13] feat(modal-checkout): fix variable modal checkout --- includes/class-modal-checkout.php | 65 +++++++------- src/modal-checkout/checkout.scss | 11 +++ src/modal-checkout/modal.js | 7 +- src/modal-checkout/modal.scss | 136 +++++++++++++++--------------- 4 files changed, 119 insertions(+), 100 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 40e2c065b..e3d82ab10 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -289,26 +289,22 @@ public static function render_modal_markup() { * @param string $title The title. */ $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); - $class_prefix = 'newspack-blocks'; - - if ( class_exists( '\Newspack\Newspack_UI' ) ) { - $class_prefix = 'newspack-ui'; - } + $class_prefix = self::get_class_prefix(); ?> -
-
-
-
+
"> +
">
+
"> +
">

-
-
-
+
"> +
">
@@ -346,37 +342,42 @@ public static function render_variation_selection() { * * @param string $title The title. */ - $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); - $products = array_keys( self::$products ); + $title = apply_filters( 'newspack_blocks_modal_checkout_title', __( 'Complete your transaction', 'newspack-blocks' ) ); + $products = array_keys( self::$products ); + $class_prefix = self::get_class_prefix(); foreach ( $products as $product_id ) { $product = wc_get_product( $product_id ); if ( ! $product->is_type( 'variable' ) ) { continue; } ?> -
-
-
+
" + data-product-id="" + > +
">
+
"> +
">

- +
-
-
+
"> +
" data-product-id="">

get_name() ); ?>

-
    +
      "> get_available_variations( 'objects' ); foreach ( $variations as $variation ) : $name = wc_get_formatted_variation( $variation, true ); $price = $variation->get_price_html(); ?> -
    • +
    • ">
      @@ -467,7 +468,7 @@ public static function enqueue_modal( $product_id = null ) { 'newspack-blocks-modal', 'newspackBlocksModal', [ - 'has_newspack_ui' => class_exists( '\Newspack\Newspack_UI' ), + 'has_newspack_ui' => self::get_class_prefix() === 'newspack-ui', ] ); wp_enqueue_style( @@ -495,11 +496,8 @@ public static function get_checkout_template( $template ) { if ( ! self::is_modal_checkout() ) { return $template; } - $class_prefix = 'newspack-blocks'; - if ( class_exists( '\Newspack\Newspack_UI' ) ) { - $class_prefix = 'newspack-ui'; - } - $classnames = "$class_prefix {$class_prefix}__iframe {$class_prefix}__modal__content"; + $class_prefix = self::get_class_prefix(); + $classnames = "$class_prefix {$class_prefix}__iframe {$class_prefix}__modal__content"; ob_start(); ?> @@ -598,7 +596,7 @@ public static function wc_get_template( $located, $template_name ) { ]; // If Newspack UI is present, use our templates. - if ( class_exists( '\Newspack\Newspack_UI' ) ) { + if ( self::get_class_prefix() === 'newspack-ui' ) { $custom_templates['checkout/thankyou.php'] = 'src/modal-checkout/templates/thankyou.php'; // Replace the login form with the order summary if using the modal checkout. This is // for the case where the reader used an existing email address. @@ -1232,5 +1230,12 @@ public static function jetpack_active_modules( $modules ) { } return $modules; } + + /** + * Get the relevant class prefix (newspack-blocks or newspack-ui)depending on whether Newpack plugin is active. + */ + private static function get_class_prefix() { + return class_exists( '\Newspack\Newspack_UI' ) ? 'newspack-ui' : 'newspack-blocks'; + } } Modal_Checkout::init(); diff --git a/src/modal-checkout/checkout.scss b/src/modal-checkout/checkout.scss index 1a7f0a60b..b9e0d300c 100644 --- a/src/modal-checkout/checkout.scss +++ b/src/modal-checkout/checkout.scss @@ -2,6 +2,8 @@ @use '../shared/sass/buttons'; #newspack_modal_checkout { /* stylelint-disable-line */ + padding: 24px; + .order-review-wrapper.hidden { display: none; } @@ -39,4 +41,13 @@ } } } + + + // Modal Checkout already has spacing to account for the header, so we need to remove it from the form. + .woocommerce .order-details-summary { + // Removes redundant margin from top of modal checkout form. + h2 { + margin-top: 0; + } + } } diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 5e57e6922..6c873a11d 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -30,8 +30,7 @@ function domReady( callback ) { const CLASSNAME_BASE = newspackBlocksModal.has_newspack_ui ? 'newspack-ui' : 'newspack-blocks'; const MODAL_CLASSNAME_BASE = `${ CLASSNAME_BASE }__modal`; -const triggers = - '.wpbnbd.wpbnbd--platform-wc,.wp-block-newspack-blocks-checkout-button,.newspack-blocks-variation-modal'; +const triggers = `.wpbnbd.wpbnbd--platform-wc,.wp-block-newspack-blocks-checkout-button,.${ CLASSNAME_BASE }__modal-variation`; let iframeResizeObserver; @@ -98,14 +97,14 @@ domReady( () => { /** * Variation modals. */ - const variationModals = document.querySelectorAll( '.newspack-blocks-variation-modal' ); + const variationModals = document.querySelectorAll( `.${ MODAL_CLASSNAME_BASE }-variation` ); variationModals.forEach( variationModal => { variationModal.addEventListener( 'click', ev => { if ( ev.target === variationModal ) { closeCheckout(); } } ); - variationModal.querySelectorAll( '.newspack-blocks-modal__close' ).forEach( button => { + variationModal.querySelectorAll( `.${ MODAL_CLASSNAME_BASE }__close` ).forEach( button => { button.addEventListener( 'click', ev => { ev.preventDefault(); closeCheckout(); diff --git a/src/modal-checkout/modal.scss b/src/modal-checkout/modal.scss index 2232c4d9e..1c03036d1 100644 --- a/src/modal-checkout/modal.scss +++ b/src/modal-checkout/modal.scss @@ -2,12 +2,14 @@ @use '../shared/sass/variables'; // Checkout modal specific styles. -iframe[name="newspack_modal_checkout_iframe"] { - border: none; - height: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); - margin: calc( -1 * var( --newspack-ui-spacer-5, 24px ) ); - max-width: unset; - width: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); +.newspack-ui { + iframe[name="newspack_modal_checkout_iframe"] { + border: none; + height: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); + margin: calc( -1 * var( --newspack-ui-spacer-5, 24px ) ); + max-width: unset; + width: calc( 100% + var( --newspack-ui-spacer-8, 48px ) ); + } } // Default modal styles when newspack ui is not present. @@ -77,7 +79,6 @@ iframe[name="newspack_modal_checkout_iframe"] { } &__content { - padding: 24px; position: relative; flex-grow: 1; > * { @@ -127,74 +128,77 @@ iframe[name="newspack_modal_checkout_iframe"] { } } } -} -.newspack-blocks-variation-modal { - .newspack-blocks-modal { - &__content { - padding: 32px; - overflow: auto; - border-radius: 5px; - h3 { - font-size: 16px; - margin: 0; - } - p { - font-size: 0.8em; - } - } - } - &__options { - list-style: none; - display: flex; - flex-wrap: wrap; - gap: 16px; - margin: 0; - padding: 0; - &__item { - border: 1px solid #ddd; - border-radius: 6px; - text-align: center; - flex: 1 1 100%; - @media ( min-width: 600px ) { - flex: 1 1 30%; - max-width: calc( 33.3333% - 10px ); - &:first-child:nth-last-child( 2 ), - &:first-child:nth-last-child( 2 ) ~ li { - flex: 1 1 40%; - max-width: calc( 50% - 10px ); - } - } - .summary { - font-size: 14px; - padding: 12px; - border-bottom: 1px solid #ddd; - bdi { - display: block; - font-weight: 600; - font-size: 32px; + &__modal-variation { + .newspack-blocks { + &__modal { + &__content { + padding: 24px; + overflow: auto; + border-radius: 5px; + h3 { + font-size: 16px; + margin: 0; + } + p { + font-size: 0.8em; + } } } - .variation { - padding: 12px; - font-size: 14px; - line-height: 1.5; - border-bottom: 1px solid #ddd; - font-weight: 600; - } - form { - padding: 12px; - button { - display: block; - width: 100%; - font-size: 14px; + + &__options { + list-style: none; + display: flex; + flex-wrap: wrap; + gap: 16px; + margin: 0; + padding: 0; + + &__item { + border: 1px solid #ddd; + border-radius: 6px; + text-align: center; + flex: 1 1 100%; + @media ( min-width: 600px ) { + flex: 1 1 30%; + max-width: calc( 33.3333% - 10px ); + &:first-child:nth-last-child( 2 ), + &:first-child:nth-last-child( 2 ) ~ li { + flex: 1 1 40%; + max-width: calc( 50% - 10px ); + } + } + .summary { + font-size: 14px; + padding: 12px; + border-bottom: 1px solid #ddd; + bdi { + display: block; + font-weight: 600; + font-size: 32px; + } + } + .variation { + padding: 12px; + font-size: 14px; + line-height: 1.5; + border-bottom: 1px solid #ddd; + font-weight: 600; + } + form { + padding: 12px; + button { + display: block; + width: 100%; + font-size: 14px; + } + } } } } } } - @keyframes spin { 0% { transform: rotate( 0deg ); From 82638d44b09405e24440c1f1ebf945da8fec394c Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Fri, 26 Jan 2024 12:53:22 -0500 Subject: [PATCH 10/13] feat(modal-checkout): remove redundant class --- includes/class-modal-checkout.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index e3d82ab10..366f3b059 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -497,7 +497,6 @@ public static function get_checkout_template( $template ) { return $template; } $class_prefix = self::get_class_prefix(); - $classnames = "$class_prefix {$class_prefix}__iframe {$class_prefix}__modal__content"; ob_start(); ?> @@ -508,7 +507,7 @@ public static function get_checkout_template( $template ) { - + " id="newspack_modal_checkout"> Date: Tue, 30 Jan 2024 11:15:22 -0500 Subject: [PATCH 11/13] feat(modal-checkout): pass class prefix directly --- includes/class-modal-checkout.php | 2 +- src/modal-checkout/modal.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 366f3b059..3ac46d3f7 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -468,7 +468,7 @@ public static function enqueue_modal( $product_id = null ) { 'newspack-blocks-modal', 'newspackBlocksModal', [ - 'has_newspack_ui' => self::get_class_prefix() === 'newspack-ui', + 'newspack_class_prefix' => self::get_class_prefix(), ] ); wp_enqueue_style( diff --git a/src/modal-checkout/modal.js b/src/modal-checkout/modal.js index 6c873a11d..3a27dcf87 100644 --- a/src/modal-checkout/modal.js +++ b/src/modal-checkout/modal.js @@ -27,7 +27,7 @@ function domReady( callback ) { document.addEventListener( 'DOMContentLoaded', callback ); } -const CLASSNAME_BASE = newspackBlocksModal.has_newspack_ui ? 'newspack-ui' : 'newspack-blocks'; +const CLASSNAME_BASE = newspackBlocksModal.newspack_class_prefix; const MODAL_CLASSNAME_BASE = `${ CLASSNAME_BASE }__modal`; const triggers = `.wpbnbd.wpbnbd--platform-wc,.wp-block-newspack-blocks-checkout-button,.${ CLASSNAME_BASE }__modal-variation`; From 1544407747d81b4b248b9957aacaf0e349d83369 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Tue, 30 Jan 2024 11:24:11 -0500 Subject: [PATCH 12/13] chore(modal-checkout): fix stray merge bugs --- includes/class-modal-checkout.php | 2 ++ src/modal-checkout/checkout.scss | 3 --- src/modal-checkout/templates/thankyou.php | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 3ac46d3f7..478444dcb 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -55,6 +55,8 @@ public static function init() { add_filter( 'woocommerce_enable_order_notes_field', [ __CLASS__, 'enable_order_notes_field' ] ); add_action( 'woocommerce_checkout_process', [ __CLASS__, 'wcsg_apply_gift_subscription' ] ); add_filter( 'woocommerce_order_received_verify_known_shoppers', '__return_false' ); + // TODO: Remove once we apply auth flow to checkout modal. + add_filter( 'newspack_reader_activation_should_render_auth', '__return_false' ); /** Custom handling for registered users. */ add_filter( 'woocommerce_checkout_customer_id', [ __CLASS__, 'associate_existing_user' ] ); diff --git a/src/modal-checkout/checkout.scss b/src/modal-checkout/checkout.scss index b9e0d300c..3d7a953ec 100644 --- a/src/modal-checkout/checkout.scss +++ b/src/modal-checkout/checkout.scss @@ -1,6 +1,3 @@ -@use '../shared/sass/boxes'; -@use '../shared/sass/buttons'; - #newspack_modal_checkout { /* stylelint-disable-line */ padding: 24px; diff --git a/src/modal-checkout/templates/thankyou.php b/src/modal-checkout/templates/thankyou.php index d4a96573d..51a86bc89 100644 --- a/src/modal-checkout/templates/thankyou.php +++ b/src/modal-checkout/templates/thankyou.php @@ -51,7 +51,7 @@ function newspack_blocks_replace_login_with_order_summary() { ?> -
      +
      -
      +

      From 6fa14705166d8070e6f3139fe2f6cb6ce61c7c37 Mon Sep 17 00:00:00 2001 From: Rasmy Nguyen Date: Tue, 30 Jan 2024 11:41:45 -0500 Subject: [PATCH 13/13] chore(modal-checkout): fix docblock typo --- includes/class-modal-checkout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/class-modal-checkout.php b/includes/class-modal-checkout.php index 478444dcb..9f4ea3d7f 100644 --- a/includes/class-modal-checkout.php +++ b/includes/class-modal-checkout.php @@ -1233,7 +1233,7 @@ public static function jetpack_active_modules( $modules ) { } /** - * Get the relevant class prefix (newspack-blocks or newspack-ui)depending on whether Newpack plugin is active. + * Get the relevant class prefix (newspack-blocks or newspack-ui) depending on whether Newpack plugin is active. */ private static function get_class_prefix() { return class_exists( '\Newspack\Newspack_UI' ) ? 'newspack-ui' : 'newspack-blocks';