Skip to content

Commit c4c29f2

Browse files
committed
fix: update styles
1 parent dbfb271 commit c4c29f2

File tree

4 files changed

+44
-59
lines changed

4 files changed

+44
-59
lines changed

src/blocks/content-gate-countdown/block.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"name": "newspack/content-gate-countdown",
33
"category": "newspack",
4-
"attributes": {
5-
"text": {
6-
"type": "string"
7-
}
8-
},
4+
"attributes": {},
95
"supports": {
106
"html": false,
117
"color": {

src/blocks/content-gate-countdown/class-content-gate-countdown-block.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ public static function render_block( array $attributes, string $content, $block
6767
Metering::get_metering_period()
6868
);
6969
$text = isset( $attributes['text'] ) ? $attributes['text'] : __( 'Get unlimited access.', 'newspack-plugin' );
70-
$buttons = '';
70+
$actions = '';
7171
foreach ( $block->inner_blocks as $inner_block ) {
72-
$buttons .= $inner_block->render();
72+
$actions .= $inner_block->render();
7373
}
7474
$block_wrapper_attributes = get_block_wrapper_attributes(
7575
[
@@ -79,12 +79,11 @@ public static function render_block( array $attributes, string $content, $block
7979
$block_content = "<div $block_wrapper_attributes>
8080
<div class='newspack-content-gate-countdown__content'>
8181
<div class='newspack-content-gate-countdown__notice'>
82-
<span class='newspack-content-gate-countdown__views'>$remaining_views / $total_views</span>
82+
<span class='newspack-content-gate-countdown__countdown'>$remaining_views / $total_views</span>
8383
<p>$notice</p>
8484
</div>
8585
<div class='newspack-content-gate-countdown__actions'>
86-
<p>$text</p>
87-
$buttons
86+
$actions
8887
</div>
8988
</div>
9089
</div>";

src/blocks/content-gate-countdown/edit.jsx

Lines changed: 13 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,33 @@
11
/**
22
* WordPress dependencies
33
*/
4-
import { useBlockProps, InspectorControls, InnerBlocks, RichText } from '@wordpress/block-editor';
5-
import { PanelBody, TextareaControl } from '@wordpress/components';
4+
import { useBlockProps, InspectorControls, InnerBlocks } from '@wordpress/block-editor';
65
import { __ } from '@wordpress/i18n';
76

87
/**
98
* Edit function for the Content Gate Countdown block.
109
*
11-
* @param {Object} props The block properties.
12-
* @param {Object} props.attributes The block attributes.
13-
* @param {Function} props.setAttributes The block attributes setter.
14-
*
1510
* @return {JSX.Element} The Content Gate Countdown block.
1611
*/
17-
export default function Edit( { attributes, setAttributes } ) {
12+
export default function Edit() {
1813
const blockProps = useBlockProps();
19-
const { text } = attributes;
20-
21-
const handleChange = ( key, value ) => {
22-
setAttributes( { [ key ]: value } );
23-
};
2414

2515
return (
2616
<>
27-
<InspectorControls>
28-
<PanelBody title={ __( 'Content Gate Countdown Settings', 'newspack-plugin' ) }>
29-
<TextareaControl
30-
label={ __( 'Text', 'newspack-plugin' ) }
31-
value={ text }
32-
onChange={ value => handleChange( 'text', value ) }
33-
placeholder={ __( 'Get unlimited access.', 'newspack-plugin' ) }
34-
help={ __( 'The call to action text that appears above the subscribe button.', 'newspack-plugin' ) }
35-
/>
36-
</PanelBody>
37-
</InspectorControls>
38-
39-
<div { ...blockProps }>
40-
<div className="wp-block-newspack-content-gate-countdown__content">
41-
<div className="wp-block-newspack-content-gate-countdown__notice">
42-
{ ' ' }
43-
<span className="wp-block-newspack-content-gate-countdown__views">3 / 3</span>
17+
<InspectorControls />
18+
<div className="newspack-content-gate-countdown" { ...blockProps }>
19+
<div className="newspack-content-gate-countdown__content">
20+
<div className="newspack-content-gate-countdown__notice">
21+
<span className="newspack-content-gate-countdown__countdown">3 / 3</span>
4422
<p>{ __( 'remaining articles this month.', 'newspack-plugin' ) }</p>
4523
</div>
46-
<div className="wp-blocks-newspack-content-gate-countdown__actions">
47-
<RichText
48-
tagName="div"
49-
className="wp-block-newspack-blocks-content-gate-countdown__text"
50-
value={ text }
51-
onChange={ value => handleChange( 'text', value ) }
52-
placeholder={ __( 'CTA text…', 'newspack-plugin' ) }
53-
allowedFormats={ [] }
54-
/>
24+
<div className="newspack-content-gate-countdown__actions">
5525
<InnerBlocks
56-
allowedBlocks={ [ 'newspack-blocks/checkout-button', 'core/buttons' ] }
57-
template={ [ [ 'newspack-blocks/checkout-button', { text: __( 'Subscribe now', 'newspack-plugin' ) } ] ] }
26+
allowedBlocks={ [ 'newspack-blocks/checkout-button', 'core/buttons', 'core/paragraph' ] }
27+
template={ [
28+
[ 'core/paragraph', { content: __( 'Get unlimited access.', 'newspack-plugin' ) } ],
29+
[ 'newspack-blocks/checkout-button', { text: __( 'Subscribe now', 'newspack-plugin' ) } ],
30+
] }
5831
/>
5932
</div>
6033
</div>
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,36 @@
11
.newspack-content-gate-countdown {
22
width: 100%;
3-
padding: 1rem;
43

54
&__content {
5+
width: 100%;
6+
display: flex;
7+
flex-direction: row;
8+
align-items: center;
9+
justify-content: flex-start;
10+
padding: 1rem;
11+
}
12+
13+
&__notice {
14+
display: flex;
15+
flex-direction: row;
16+
align-items: center;
17+
justify-content: flex-start;
18+
}
19+
20+
&__countdown {
21+
display: flex;
22+
flex-direction: row;
23+
align-items: center;
24+
justify-content: flex-start;
25+
margin-left: 1rem;
26+
font-weight: bold;
27+
}
28+
29+
&__actions {
30+
width: 100%;
631
display: flex;
732
flex-direction: column;
833
align-items: center;
934
justify-content: center;
10-
flex: 1;
11-
12-
p {
13-
color: #333;
14-
margin: 0 0 0.5rem 0;
15-
font-size: 1rem;
16-
line-height: 1.4;
17-
}
1835
}
1936
}

0 commit comments

Comments
 (0)