@automattic/newspack-blocks 2.6.2 → 3.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.cache/babel/135eb7c6e583be53418b26a29fcc4d81.json.gz +0 -0
- package/.cache/babel/2bec24377bb9890c2268bcd4c8f3953c.json.gz +0 -0
- package/.cache/babel/9ba57ee86df44178ceb255eaf0e770e3.json.gz +0 -0
- package/.cache/babel/a804bf1963e56137e59e37a567cb5e2e.json.gz +0 -0
- package/.cache/babel/b94e6dc0852876a37bd23ec88c5b2583.json.gz +0 -0
- package/.cache/babel/c04d2af94bb0f10f408a15534301cc86.json.gz +0 -0
- package/.cache/babel/c8d4b9ae4be3002e8507d71f1136ebc6.json.gz +0 -0
- package/.cache/babel/d21f5515648ce2a2349b0ee5cc787fce.json.gz +0 -0
- package/.cache/babel/d3eee0c40fc44bc734dee21a645a4f7d.json.gz +0 -0
- package/.cache/babel/d661309b03e38954105e706a32ef09f6.json.gz +0 -0
- package/.cache/babel/e2dd36051554e75a2bf087b85c11e43d.json.gz +0 -0
- package/.hooks/pre-push +2 -2
- package/CHANGELOG.md +21 -0
- package/composer.lock +38 -36
- package/dist/donate/view.asset.php +1 -1
- package/dist/donate/view.css +1 -1
- package/dist/donate/view.rtl.css +1 -1
- package/dist/editor.asset.php +1 -1
- package/dist/editor.css +1 -1
- package/dist/editor.js +11 -11
- package/dist/editor.rtl.css +1 -1
- package/dist/frequencyBased.asset.php +1 -1
- package/dist/frequencyBased.css +1 -1
- package/dist/frequencyBased.rtl.css +1 -1
- package/dist/modalCheckout.asset.php +1 -1
- package/dist/modalCheckout.css +1 -1
- package/dist/modalCheckout.rtl.css +1 -1
- package/dist/tiersBased.asset.php +1 -1
- package/dist/tiersBased.css +1 -1
- package/dist/tiersBased.js +1 -1
- package/dist/tiersBased.rtl.css +1 -1
- package/includes/class-modal-checkout.php +11 -14
- package/includes/class-newspack-blocks.php +87 -43
- package/languages/newspack-blocks-de_DE.po +0 -40
- package/languages/newspack-blocks-es_ES.po +0 -40
- package/languages/newspack-blocks-fr_BE.po +0 -40
- package/languages/newspack-blocks-pt_PT.po +0 -40
- package/languages/newspack-blocks.pot +0 -38
- package/newspack-blocks.php +2 -14
- package/package.json +7 -8
- package/src/blocks/checkout-button/edit.js +5 -1
- package/src/blocks/donate/block.json +0 -12
- package/src/blocks/donate/edit/FrequencyBasedLayout.tsx +61 -106
- package/src/blocks/donate/edit/TierBasedLayout.tsx +7 -26
- package/src/blocks/donate/edit/components/index.tsx +0 -1
- package/src/blocks/donate/edit/index.tsx +157 -152
- package/src/blocks/donate/frequency-based/style.scss +5 -0
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-base.php +33 -147
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-frequency-based.php +21 -10
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer-tiers-based.php +3 -50
- package/src/blocks/donate/frontend/class-newspack-blocks-donate-renderer.php +1 -14
- package/src/blocks/donate/styles/editor.scss +6 -28
- package/src/blocks/donate/styles/style-variations.scss +17 -8
- package/src/blocks/donate/styles/view.scss +9 -0
- package/src/blocks/donate/tiers-based/style.scss +0 -11
- package/src/blocks/donate/tiers-based/utils.test.js +38 -0
- package/src/blocks/donate/tiers-based/utils.ts +1 -2
- package/src/blocks/donate/tiers-based/view.ts +0 -33
- package/src/blocks/donate/types.ts +0 -16
- package/src/blocks/donate/utils.ts +31 -0
- package/src/blocks/homepage-articles/block.json +18 -0
- package/src/blocks/homepage-articles/class-wp-rest-newspack-articles-controller.php +1 -1
- package/src/blocks/homepage-articles/edit.js +3 -0
- package/src/blocks/homepage-articles/utils.ts +4 -0
- package/src/blocks/homepage-articles/view.php +4 -4
- package/src/components/query-controls.js +41 -8
- package/src/modal-checkout/checkout.scss +4 -5
- package/src/types/index.d.ts +4 -3
- package/vendor/autoload.php +1 -1
- package/vendor/composer/autoload_real.php +4 -4
- package/vendor/composer/autoload_static.php +2 -2
- package/vendor/composer/installed.php +2 -2
- package/webpack.config.js +0 -1
- package/.cache/babel/18dda1142078f066419138e7284f03bf.json.gz +0 -0
- package/.cache/babel/1f43960564787ebde7c6d44957cddf0e.json.gz +0 -0
- package/.cache/babel/225618337c609eed2be110274ff82be1.json.gz +0 -0
- package/.cache/babel/29d960d2fc51492a4bea1f4f165810fb.json.gz +0 -0
- package/.cache/babel/2f22325668b5763f8f2c9557833af36f.json.gz +0 -0
- package/.cache/babel/39bcc541624feefe54d1493493ae1ce8.json.gz +0 -0
- package/.cache/babel/4d450b37d365154f05b17cbf6a009255.json.gz +0 -0
- package/.cache/babel/87e2dc4a961b25b0de8d1a8ac88eea13.json.gz +0 -0
- package/.cache/babel/91884d41523f3790da70ea305ee187f2.json.gz +0 -0
- package/.cache/babel/b1ac90699e641ff99e1449b5d7b686e5.json.gz +0 -0
- package/.cache/babel/c5a441fdf7d90d45d2cbeb89967c61fe.json.gz +0 -0
- package/.cache/babel/c7cfb8590e887722a3e715c72ee99bac.json.gz +0 -0
- package/.cache/babel/e1d8932bb19afa36f476f107dbc6ca39.json.gz +0 -0
- package/.cache/babel/f60f8c23ec2b4448cb2815d79207d8c0.json.gz +0 -0
- package/dist/donateStreamlined.asset.php +0 -1
- package/dist/donateStreamlined.css +0 -1
- package/dist/donateStreamlined.js +0 -1
- package/dist/donateStreamlined.rtl.css +0 -1
- package/src/blocks/donate/class-wp-rest-newspack-donate-controller.php +0 -206
- package/src/blocks/donate/edit/components/AdditionalFields.tsx +0 -282
- package/src/blocks/donate/streamlined/index.test.js +0 -132
- package/src/blocks/donate/streamlined/index.ts +0 -356
- package/src/blocks/donate/streamlined/style.scss +0 -306
- package/src/blocks/donate/streamlined/utils.test.js +0 -18
- package/src/blocks/donate/streamlined/utils.ts +0 -217
- package/src/blocks/donate/tiers-based/view.test.js +0 -209
|
@@ -743,30 +743,6 @@ msgstr ""
|
|
|
743
743
|
msgid "Paused"
|
|
744
744
|
msgstr ""
|
|
745
745
|
|
|
746
|
-
#: dist/donateStreamlined.js:1
|
|
747
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
748
|
-
msgid "Email address is invalid."
|
|
749
|
-
msgstr ""
|
|
750
|
-
|
|
751
|
-
#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
|
|
752
|
-
#: dist/donateStreamlined.js:1
|
|
753
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
754
|
-
msgid "Amount must be at least %d."
|
|
755
|
-
msgstr ""
|
|
756
|
-
|
|
757
|
-
#: dist/donateStreamlined.js:1
|
|
758
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
759
|
-
msgid "Full name should be provided."
|
|
760
|
-
msgstr ""
|
|
761
|
-
|
|
762
|
-
#. Translators: %s is the email address of the current user.
|
|
763
|
-
#: dist/donateStreamlined.js:1
|
|
764
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
765
|
-
msgid ""
|
|
766
|
-
"Your payment has been processed. Thank you for your contribution! You will "
|
|
767
|
-
"receive a confirmation email at %s."
|
|
768
|
-
msgstr ""
|
|
769
|
-
|
|
770
746
|
#: dist/editor.js:41 release/newspack-blocks/dist/editor.js:2541
|
|
771
747
|
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
|
|
772
748
|
#: release/newspack-blocks/src/blocks/author-list/edit.js:109
|
|
@@ -1885,22 +1861,6 @@ msgstr ""
|
|
|
1885
1861
|
msgid "Remove Block"
|
|
1886
1862
|
msgstr ""
|
|
1887
1863
|
|
|
1888
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
1889
|
-
msgid "Error loading the reCaptcha library."
|
|
1890
|
-
msgstr ""
|
|
1891
|
-
|
|
1892
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
1893
|
-
msgid "Error processing captcha request."
|
|
1894
|
-
msgstr ""
|
|
1895
|
-
|
|
1896
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
1897
|
-
msgid "Something went wrong with the payment. Please try again later."
|
|
1898
|
-
msgstr ""
|
|
1899
|
-
|
|
1900
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
1901
|
-
msgid "Processing payment…"
|
|
1902
|
-
msgstr ""
|
|
1903
|
-
|
|
1904
1864
|
#: release/newspack-blocks/dist/editor.js:2541
|
|
1905
1865
|
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
|
|
1906
1866
|
#: src/blocks/author-list/edit.js:224
|
|
@@ -759,28 +759,6 @@ msgstr ""
|
|
|
759
759
|
msgid "Paused"
|
|
760
760
|
msgstr ""
|
|
761
761
|
|
|
762
|
-
#: dist/donateStreamlined.js:1
|
|
763
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
764
|
-
msgid "Email address is invalid."
|
|
765
|
-
msgstr ""
|
|
766
|
-
|
|
767
|
-
#. Translators: %d is minimum donation amount set in Reader Revenue wizard or block attributes.
|
|
768
|
-
#: dist/donateStreamlined.js:1
|
|
769
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
770
|
-
msgid "Amount must be at least %d."
|
|
771
|
-
msgstr ""
|
|
772
|
-
|
|
773
|
-
#: dist/donateStreamlined.js:1
|
|
774
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
775
|
-
msgid "Full name should be provided."
|
|
776
|
-
msgstr ""
|
|
777
|
-
|
|
778
|
-
#. Translators: %s is the email address of the current user.
|
|
779
|
-
#: dist/donateStreamlined.js:1
|
|
780
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:72
|
|
781
|
-
msgid "Your payment has been processed. Thank you for your contribution! You will receive a confirmation email at %s."
|
|
782
|
-
msgstr ""
|
|
783
|
-
|
|
784
762
|
#: dist/editor.js:41
|
|
785
763
|
#: release/newspack-blocks/dist/editor.js:2541
|
|
786
764
|
#: release/newspack-blocks/src/blocks/author-list/edit.js:105
|
|
@@ -2085,22 +2063,6 @@ msgstr ""
|
|
|
2085
2063
|
msgid "Remove Block"
|
|
2086
2064
|
msgstr ""
|
|
2087
2065
|
|
|
2088
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
2089
|
-
msgid "Error loading the reCaptcha library."
|
|
2090
|
-
msgstr ""
|
|
2091
|
-
|
|
2092
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
2093
|
-
msgid "Error processing captcha request."
|
|
2094
|
-
msgstr ""
|
|
2095
|
-
|
|
2096
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
2097
|
-
msgid "Something went wrong with the payment. Please try again later."
|
|
2098
|
-
msgstr ""
|
|
2099
|
-
|
|
2100
|
-
#: release/newspack-blocks/dist/donateStreamlined.js:61
|
|
2101
|
-
msgid "Processing payment…"
|
|
2102
|
-
msgstr ""
|
|
2103
|
-
|
|
2104
2066
|
#: release/newspack-blocks/dist/editor.js:2541
|
|
2105
2067
|
#: release/newspack-blocks/src/blocks/author-list/edit.js:224
|
|
2106
2068
|
#: src/blocks/author-list/edit.js:224
|
package/newspack-blocks.php
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Author URI: https://newspack.com/
|
|
8
8
|
* Text Domain: newspack-blocks
|
|
9
9
|
* Domain Path: /languages
|
|
10
|
-
* Version:
|
|
10
|
+
* Version: 3.0.0-alpha.1
|
|
11
11
|
*
|
|
12
12
|
* @package Newspack_Blocks
|
|
13
13
|
*/
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
define( 'NEWSPACK_BLOCKS__PLUGIN_FILE', __FILE__ );
|
|
16
16
|
define( 'NEWSPACK_BLOCKS__BLOCKS_DIRECTORY', 'dist/' );
|
|
17
17
|
define( 'NEWSPACK_BLOCKS__PLUGIN_DIR', plugin_dir_path( NEWSPACK_BLOCKS__PLUGIN_FILE ) );
|
|
18
|
-
define( 'NEWSPACK_BLOCKS__VERSION', '
|
|
18
|
+
define( 'NEWSPACK_BLOCKS__VERSION', '3.0.0-alpha.1' );
|
|
19
19
|
|
|
20
20
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks.php';
|
|
21
21
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'includes/class-newspack-blocks-api.php';
|
|
@@ -31,9 +31,6 @@ require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/author-profile/class-wp-r
|
|
|
31
31
|
// REST Controller for Author List Block.
|
|
32
32
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/author-list/class-wp-rest-newspack-author-list-controller.php';
|
|
33
33
|
|
|
34
|
-
// REST Controller for Donate Block.
|
|
35
|
-
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/donate/class-wp-rest-newspack-donate-controller.php';
|
|
36
|
-
|
|
37
34
|
// REST Controller for Iframe Block.
|
|
38
35
|
require_once NEWSPACK_BLOCKS__PLUGIN_DIR . 'src/blocks/iframe/class-wp-rest-newspack-iframe-controller.php';
|
|
39
36
|
|
|
@@ -64,15 +61,6 @@ function newspack_author_list_block_register_rest_routes() { // phpcs:ignore Wor
|
|
|
64
61
|
}
|
|
65
62
|
add_action( 'rest_api_init', 'newspack_author_list_block_register_rest_routes' );
|
|
66
63
|
|
|
67
|
-
/**
|
|
68
|
-
* Registers Donate block routes.
|
|
69
|
-
*/
|
|
70
|
-
function newspack_donate_block_register_rest_routes() { // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedFunctionFound
|
|
71
|
-
$donate_controller = new WP_REST_Newspack_Donate_Controller();
|
|
72
|
-
$donate_controller->register_routes();
|
|
73
|
-
}
|
|
74
|
-
add_action( 'rest_api_init', 'newspack_donate_block_register_rest_routes' );
|
|
75
|
-
|
|
76
64
|
/**
|
|
77
65
|
* Registers Iframe block routes.
|
|
78
66
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@automattic/newspack-blocks",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.1",
|
|
4
4
|
"author": "Automattic",
|
|
5
5
|
"devDependencies": {
|
|
6
6
|
"@rushstack/eslint-patch": "^1.5.1",
|
|
@@ -12,22 +12,21 @@
|
|
|
12
12
|
"fetch-mock-jest": "^1.5.1",
|
|
13
13
|
"html-entities": "^2.4.0",
|
|
14
14
|
"identity-obj-proxy": "^3.0.0",
|
|
15
|
-
"lint-staged": "^
|
|
16
|
-
"newspack-scripts": "^5.
|
|
15
|
+
"lint-staged": "^15.2.2",
|
|
16
|
+
"newspack-scripts": "^5.3.0",
|
|
17
17
|
"postcss-scss": "^4.0.9",
|
|
18
18
|
"prettier": "npm:wp-prettier@^2.6.2-beta-1",
|
|
19
19
|
"stylelint": "^15.11.0"
|
|
20
20
|
},
|
|
21
21
|
"description": "=== Newspack Blocks === Contributors: (this should be a list of wordpress.org userid's) Donate link: https://example.com/ Tags: comments, spam Requires at least: 4.5 Tested up to: 5.1.1 Stable tag: 0.1.0 License: GPLv2 or later License URI: https://www.gnu.org/licenses/gpl-2.0.html",
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"
|
|
24
|
-
"classnames": "^2.3.2",
|
|
23
|
+
"classnames": "^2.5.1",
|
|
25
24
|
"lodash": "^4.17.21",
|
|
26
|
-
"newspack-components": "^2.1
|
|
25
|
+
"newspack-components": "^2.2.1",
|
|
27
26
|
"react": "^17.0.2",
|
|
28
27
|
"redux": "^4.2.1",
|
|
29
|
-
"redux-saga": "^1.
|
|
30
|
-
"regenerator-runtime": "^0.14.
|
|
28
|
+
"redux-saga": "^1.3.0",
|
|
29
|
+
"regenerator-runtime": "^0.14.1",
|
|
31
30
|
"swiper": "10.3.1"
|
|
32
31
|
},
|
|
33
32
|
"scripts": {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @wordpress/no-unsafe-wp-apis */
|
|
2
|
+
/* globals newspack_blocks_data */
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* External dependencies
|
|
4
6
|
*/
|
|
@@ -47,7 +49,9 @@ function getVariationName( variation ) {
|
|
|
47
49
|
|
|
48
50
|
function getNYP( product ) {
|
|
49
51
|
return {
|
|
50
|
-
isNYP:
|
|
52
|
+
isNYP:
|
|
53
|
+
newspack_blocks_data?.can_use_name_your_price &&
|
|
54
|
+
product?.meta_data?.some( meta => meta.key === '_nyp' && meta.value === 'yes' ),
|
|
51
55
|
suggestedPrice: product?.meta_data?.find( meta => meta.key === '_suggested_price' )?.value,
|
|
52
56
|
minPrice: product?.meta_data?.find( meta => meta.key === '_min_price' )?.value,
|
|
53
57
|
maxPrice: product?.meta_data?.find( meta => meta.key === '_maximum_price' )?.value,
|
|
@@ -28,14 +28,6 @@
|
|
|
28
28
|
"type": "string",
|
|
29
29
|
"default": "Donate Now"
|
|
30
30
|
},
|
|
31
|
-
"buttonWithCCText": {
|
|
32
|
-
"type": "string",
|
|
33
|
-
"default": "Donate with card"
|
|
34
|
-
},
|
|
35
|
-
"paymentRequestType": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"default": "donate"
|
|
38
|
-
},
|
|
39
31
|
"defaultFrequency": {
|
|
40
32
|
"type": "string",
|
|
41
33
|
"default": "month"
|
|
@@ -87,10 +79,6 @@
|
|
|
87
79
|
}
|
|
88
80
|
]
|
|
89
81
|
},
|
|
90
|
-
"additionalFields": {
|
|
91
|
-
"type": "array",
|
|
92
|
-
"default": []
|
|
93
|
-
},
|
|
94
82
|
"afterSuccessBehavior": {
|
|
95
83
|
"type": "string"
|
|
96
84
|
},
|
|
@@ -8,26 +8,15 @@ import classNames from 'classnames';
|
|
|
8
8
|
*/
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
10
|
import { useMemo, useEffect, useRef, useState } from '@wordpress/element';
|
|
11
|
-
import { SelectControl } from '@wordpress/components';
|
|
12
11
|
import { RichText } from '@wordpress/block-editor';
|
|
13
12
|
|
|
14
13
|
/**
|
|
15
14
|
* Internal dependencies
|
|
16
15
|
*/
|
|
17
16
|
import { AmountValueInput } from './components';
|
|
18
|
-
import { getColorForContrast } from '../utils';
|
|
17
|
+
import { getColorForContrast, getFrequencyLabel } from '../utils';
|
|
19
18
|
import { FREQUENCIES } from '../consts';
|
|
20
|
-
import type {
|
|
21
|
-
|
|
22
|
-
const PAYMENT_REQUEST_BUTTON_TYPE_OPTIONS: {
|
|
23
|
-
label: string;
|
|
24
|
-
value: DonateBlockAttributes[ 'paymentRequestType' ];
|
|
25
|
-
}[] = [
|
|
26
|
-
{ label: __( 'Donate', 'newspack-blocks' ), value: 'donate' },
|
|
27
|
-
{ label: __( 'Pay', 'newspack-blocks' ), value: 'default' },
|
|
28
|
-
{ label: __( 'Book', 'newspack-blocks' ), value: 'book' },
|
|
29
|
-
{ label: __( 'Buy', 'newspack-blocks' ), value: 'buy' },
|
|
30
|
-
];
|
|
19
|
+
import type { ComponentProps, DonationFrequencySlug } from '../types';
|
|
31
20
|
|
|
32
21
|
const FrequencyBasedLayout = ( props: { isTiered: boolean } & ComponentProps ) => {
|
|
33
22
|
// Unique identifier to prevent collisions with other Donate blocks' labels.
|
|
@@ -65,11 +54,8 @@ const FrequencyBasedLayout = ( props: { isTiered: boolean } & ComponentProps ) =
|
|
|
65
54
|
}
|
|
66
55
|
}, [ attributes.defaultFrequency ] );
|
|
67
56
|
|
|
68
|
-
const isRenderingStripePaymentForm =
|
|
69
|
-
window.newspack_blocks_data?.is_rendering_stripe_payment_form;
|
|
70
|
-
|
|
71
57
|
const [ selectedFrequency, setSelectedFrequency ] = useState( attributes.defaultFrequency );
|
|
72
|
-
|
|
58
|
+
const canUseNameYourPrice = window.newspack_blocks_data?.can_use_name_your_price;
|
|
73
59
|
const renderFrequencySelect = ( frequencySlug: DonationFrequencySlug ) => (
|
|
74
60
|
<>
|
|
75
61
|
<input
|
|
@@ -110,31 +96,59 @@ const FrequencyBasedLayout = ( props: { isTiered: boolean } & ComponentProps ) =
|
|
|
110
96
|
<div className="wp-block-newspack-blocks-donate__options">
|
|
111
97
|
<div className="wp-block-newspack-blocks-donate__frequencies frequencies">
|
|
112
98
|
<div className="tab-container">{ availableFrequencies.map( renderTab ) }</div>
|
|
113
|
-
{ availableFrequencies.map( frequencySlug =>
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
99
|
+
{ availableFrequencies.map( frequencySlug => {
|
|
100
|
+
const untieredAmount = amounts[ frequencySlug ][ 3 ];
|
|
101
|
+
return (
|
|
102
|
+
<div
|
|
103
|
+
className="wp-block-newspack-blocks-donate__frequency frequency"
|
|
104
|
+
key={ frequencySlug }
|
|
105
|
+
>
|
|
106
|
+
{ renderFrequencySelect( frequencySlug ) }
|
|
107
|
+
<div className="input-container">
|
|
108
|
+
{ canUseNameYourPrice ? (
|
|
109
|
+
<>
|
|
110
|
+
<label
|
|
111
|
+
className="donate-label"
|
|
112
|
+
htmlFor={ 'newspack-' + frequencySlug + '-' + uid + '-untiered-input' }
|
|
113
|
+
>
|
|
114
|
+
{ __( 'Donation amount', 'newspack-blocks' ) }
|
|
115
|
+
</label>
|
|
116
|
+
<div className="wp-block-newspack-blocks-donate__money-input money-input">
|
|
117
|
+
<span className="currency">{ settings.currencySymbol }</span>
|
|
118
|
+
<AmountValueInput
|
|
119
|
+
{ ...props }
|
|
120
|
+
frequencySlug={ frequencySlug }
|
|
121
|
+
tierIndex={ 3 }
|
|
122
|
+
id={ `newspack-${ frequencySlug }-${ uid }-untiered-input` }
|
|
123
|
+
/>
|
|
124
|
+
</div>
|
|
125
|
+
</>
|
|
126
|
+
) : (
|
|
127
|
+
<>
|
|
128
|
+
<input
|
|
129
|
+
type="radio"
|
|
130
|
+
value={ untieredAmount }
|
|
131
|
+
className={ 'frequency-input' }
|
|
132
|
+
id={ `newspack-${ frequencySlug }-${ uid }-untiered-input` }
|
|
133
|
+
name={ `donation_value_${ frequencySlug }` }
|
|
134
|
+
defaultChecked={ true }
|
|
135
|
+
/>
|
|
136
|
+
<label
|
|
137
|
+
className="tier-select-label tier-label"
|
|
138
|
+
htmlFor={ `newspack-${ frequencySlug }-${ uid }-untiered-input` }
|
|
139
|
+
>
|
|
140
|
+
<div
|
|
141
|
+
dangerouslySetInnerHTML={ {
|
|
142
|
+
__html: getFrequencyLabel( untieredAmount, frequencySlug ),
|
|
143
|
+
} }
|
|
144
|
+
/>
|
|
145
|
+
</label>
|
|
146
|
+
</>
|
|
147
|
+
) }
|
|
134
148
|
</div>
|
|
135
149
|
</div>
|
|
136
|
-
|
|
137
|
-
|
|
150
|
+
);
|
|
151
|
+
} ) }
|
|
138
152
|
</div>
|
|
139
153
|
</div>
|
|
140
154
|
);
|
|
@@ -208,31 +222,15 @@ const FrequencyBasedLayout = ( props: { isTiered: boolean } & ComponentProps ) =
|
|
|
208
222
|
color: getColorForContrast( attributes.buttonColor ),
|
|
209
223
|
} }
|
|
210
224
|
>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
/>
|
|
218
|
-
) : (
|
|
219
|
-
<RichText
|
|
220
|
-
onChange={ ( value: string ) => setAttributes( { buttonText: value } ) }
|
|
221
|
-
placeholder={ __( 'Button text…', 'newspack-blocks' ) }
|
|
222
|
-
value={ attributes.buttonText }
|
|
223
|
-
tagName="span"
|
|
224
|
-
/>
|
|
225
|
-
) }
|
|
225
|
+
<RichText
|
|
226
|
+
onChange={ ( value: string ) => setAttributes( { buttonText: value } ) }
|
|
227
|
+
placeholder={ __( 'Button text…', 'newspack-blocks' ) }
|
|
228
|
+
value={ attributes.buttonText }
|
|
229
|
+
tagName="span"
|
|
230
|
+
/>
|
|
226
231
|
</div>
|
|
227
232
|
);
|
|
228
233
|
|
|
229
|
-
const selectedPaymentRequestTypeOption = PAYMENT_REQUEST_BUTTON_TYPE_OPTIONS.find(
|
|
230
|
-
option => option.value === attributes.paymentRequestType
|
|
231
|
-
);
|
|
232
|
-
const selectedPaymentRequestType = selectedPaymentRequestTypeOption
|
|
233
|
-
? selectedPaymentRequestTypeOption.value
|
|
234
|
-
: 'donate';
|
|
235
|
-
|
|
236
234
|
const renderFooter = () => (
|
|
237
235
|
<>
|
|
238
236
|
<p className="wp-block-newspack-blocks-donate__thanks thanks">
|
|
@@ -243,50 +241,7 @@ const FrequencyBasedLayout = ( props: { isTiered: boolean } & ComponentProps ) =
|
|
|
243
241
|
tagName="span"
|
|
244
242
|
/>
|
|
245
243
|
</p>
|
|
246
|
-
{
|
|
247
|
-
<div className="wp-block-newspack-blocks-donate__stripe stripe-payment">
|
|
248
|
-
<div className="stripe-payment__inputs">
|
|
249
|
-
<input
|
|
250
|
-
className="stripe-payment__element stripe-payment__card"
|
|
251
|
-
type="text"
|
|
252
|
-
placeholder={ __( 'Card number', 'newspack-blocks' ) }
|
|
253
|
-
/>
|
|
254
|
-
<div className="stripe-payment__row stripe-payment__row--flex">
|
|
255
|
-
<input required placeholder="Email" type="email" name="email" />
|
|
256
|
-
<input required placeholder="Full Name" type="text" name="full_name" />
|
|
257
|
-
</div>
|
|
258
|
-
<div className="stripe-payment__row stripe-payment__row--additional-fields">
|
|
259
|
-
{ attributes.additionalFields.map( ( field, index ) => (
|
|
260
|
-
<input
|
|
261
|
-
key={ index }
|
|
262
|
-
type="text"
|
|
263
|
-
name={ field.name }
|
|
264
|
-
placeholder={ field.label }
|
|
265
|
-
style={ { width: `calc(${ field.width }% - 0.5rem)` } }
|
|
266
|
-
/>
|
|
267
|
-
) ) }
|
|
268
|
-
</div>
|
|
269
|
-
</div>
|
|
270
|
-
|
|
271
|
-
<div className="stripe-payment__row stripe-payment__row--flex stripe-payment__footer">
|
|
272
|
-
<div className="stripe-payment__methods">
|
|
273
|
-
<div className="stripe-payment__request-button">
|
|
274
|
-
<SelectControl
|
|
275
|
-
options={ PAYMENT_REQUEST_BUTTON_TYPE_OPTIONS }
|
|
276
|
-
value={ selectedPaymentRequestType }
|
|
277
|
-
onChange={ (
|
|
278
|
-
paymentRequestType: DonateBlockAttributes[ 'paymentRequestType' ]
|
|
279
|
-
) => setAttributes( { paymentRequestType } ) }
|
|
280
|
-
/>
|
|
281
|
-
{ __( 'with Apple/Google Pay', 'newspack-blocks' ) }
|
|
282
|
-
</div>
|
|
283
|
-
{ renderButton() }
|
|
284
|
-
</div>
|
|
285
|
-
</div>
|
|
286
|
-
</div>
|
|
287
|
-
) : (
|
|
288
|
-
renderButton()
|
|
289
|
-
) }
|
|
244
|
+
{ renderButton() }
|
|
290
245
|
</>
|
|
291
246
|
);
|
|
292
247
|
|
|
@@ -9,26 +9,10 @@ import classNames from 'classnames';
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
|
-
import type {
|
|
13
|
-
|
|
14
|
-
DonationFrequencySlug,
|
|
15
|
-
DonateBlockAttributes,
|
|
16
|
-
TierBasedOptionValue,
|
|
17
|
-
} from '../types';
|
|
18
|
-
import { getColorForContrast } from '../utils';
|
|
12
|
+
import type { ComponentProps, DonateBlockAttributes, TierBasedOptionValue } from '../types';
|
|
13
|
+
import { getColorForContrast, getFrequencyLabel } from '../utils';
|
|
19
14
|
import { FREQUENCIES, DISABLED_IN_TIERS_BASED_LAYOUT_TIER_INDEX } from '../consts';
|
|
20
15
|
|
|
21
|
-
const getFrequencyLabel = ( frequencySlug: DonationFrequencySlug ) => {
|
|
22
|
-
switch ( frequencySlug ) {
|
|
23
|
-
case 'once':
|
|
24
|
-
return __( 'once', 'newspack-blocks' );
|
|
25
|
-
case 'month':
|
|
26
|
-
return __( 'per month', 'newspack-blocks' );
|
|
27
|
-
case 'year':
|
|
28
|
-
return __( 'per year', 'newspack-blocks' );
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
|
|
32
16
|
const TierBasedLayout = ( props: ComponentProps ) => {
|
|
33
17
|
const { amounts, availableFrequencies, attributes } = props;
|
|
34
18
|
const [ currentFrequency, setCurrencyFrequency ] = useState( availableFrequencies[ 0 ] );
|
|
@@ -108,14 +92,11 @@ const TierBasedLayout = ( props: ComponentProps ) => {
|
|
|
108
92
|
</h3>
|
|
109
93
|
</div>
|
|
110
94
|
<div className="wpbnbd__tiers__amount">
|
|
111
|
-
<
|
|
112
|
-
{
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
{ ' ' }
|
|
117
|
-
{ getFrequencyLabel( currentFrequency ) }
|
|
118
|
-
</span>
|
|
95
|
+
<div
|
|
96
|
+
dangerouslySetInnerHTML={ {
|
|
97
|
+
__html: getFrequencyLabel( amount, currentFrequency ),
|
|
98
|
+
} }
|
|
99
|
+
/>
|
|
119
100
|
</div>
|
|
120
101
|
<div
|
|
121
102
|
className="submit-button"
|