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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
"type": "boolean",
"default": false
},
"displaySubtitle": {
"type": "boolean",
"default": true
Comment thread
laravdiemen marked this conversation as resolved.
},
"displayExcerpt": {
"type": "boolean",
"default": true
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/**
* WordPress dependencies
*/
import { ToggleControl } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

const DisplaySubtitleToggleControl = ( props ) => {
const { setAttributes, attributes } = props;
const { displaySubtitle } = attributes;

return (
<ToggleControl
label={ __( 'Toon subtitel', 'yard-query-block' ) }
checked={ displaySubtitle }
onChange={ () => {
setAttributes( { displaySubtitle: ! displaySubtitle } );
} }
/>
);
};

export default DisplaySubtitleToggleControl;
4 changes: 4 additions & 0 deletions assets/components/inspector.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DisplayDateToggleControl from './display-controls/display-date-toggle-con
import DisplayExcerptToggleControl from './display-controls/display-excerpt-toggle-control';
import DisplayImageToggleControl from './display-controls/display-image-toggle-control';
import DisplayLabelToggleControl from './display-controls/display-label-toggle-control';
import DisplaySubtitleToggleControl from './display-controls/display-subtitle-toggle-control';
import ExcludePostsSelectControl from './filters-controls/exclude-posts-select-control';
import ExcludePostsToggleControl from './filters-controls/exclude-posts-toggle-control';
import ManualSelectionOrderCheckboxControl from './filters-controls/manual-selection-order-checkbox-control';
Expand Down Expand Up @@ -145,6 +146,9 @@ const Inspector = ( props ) => {
{ inspectorConfig.showDisplayDateToggleControl && (
<DisplayDateToggleControl { ...props } />
) }
{ inspectorConfig.showDisplaySubtitleToggleControl && (
<DisplaySubtitleToggleControl { ...props } />
) }
{ inspectorConfig.showDisplayExcerptToggleControl && (
<DisplayExcerptToggleControl { ...props } />
) }
Expand Down
1 change: 1 addition & 0 deletions assets/config/inspector-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export const defaultConfig = {
showTemplateSelectControl: true,
showDisplayImageToggleControl: true,
showDisplayDateToggleControl: true,
showDisplaySubtitleToggleControl: true,
showDisplayExcerptToggleControl: true,
showDisplayLabelToggleControl: true,
};
Expand Down
4 changes: 4 additions & 0 deletions public/block.json
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@
"type": "boolean",
"default": false
},
"displaySubtitle": {
"type": "boolean",
"default": true
Comment thread
laravdiemen marked this conversation as resolved.
},
"displayExcerpt": {
"type": "boolean",
"default": true
Expand Down
2 changes: 1 addition & 1 deletion public/index.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-server-side-render'), 'version' => '323bb276aa92e8c7349f');
<?php return array('dependencies' => array('react', 'react-dom', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-data', 'wp-element', 'wp-hooks', 'wp-html-entities', 'wp-i18n', 'wp-server-side-render'), 'version' => '874f7a3a84f5264fbf77');
2 changes: 1 addition & 1 deletion public/index.js

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions src/Block/BlockAttributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ public function __construct(
public array $taxonomyTerms = [],
public string $taxonomyRelation = 'AND',
public string $order = 'desc',
public bool $displayImage = false,
public bool $displayImage = true,
public bool $displayDate = false,
public bool $displayExcerpt = false,
public bool $displaySubtitle = true,
public bool $displayExcerpt = true,
public bool $displayLabel = false,
public string $align = '',
public string $className = '',
Expand Down Expand Up @@ -287,6 +288,11 @@ public function displayDate(): bool
return $this->displayDate;
}

public function displaySubtitle(): bool
{
return $this->displaySubtitle;
}

public function displayExcerpt(): bool
{
return $this->displayExcerpt;
Expand Down
18 changes: 14 additions & 4 deletions tests/Block/BlockAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@
});

it('returns if it does not display the image', function () {
$attributes = BlockAttributes::from([]);
$attributes = BlockAttributes::from(['displayImage' => false]);
expect($attributes->displayImage())->toBeFalse();
});

Expand All @@ -240,17 +240,27 @@
});

it('returns if it does not display the date', function () {
$attributes = BlockAttributes::from([]);
$attributes = BlockAttributes::from(['displayDate' => false]);
expect($attributes->displayDate())->toBeFalse();
});

it('returns if it displays the subtitle', function () {
$attributes = BlockAttributes::from(['displaySubtitle' => true]);
expect($attributes->displaySubtitle())->toBeTrue();
});

it('returns if it does not display the subtitle', function () {
$attributes = BlockAttributes::from(['displaySubtitle' => false]);
expect($attributes->displaySubtitle())->toBeFalse();
Comment thread
laravdiemen marked this conversation as resolved.
});

it('returns if it displays the excerpt', function () {
$attributes = BlockAttributes::from(['displayExcerpt' => true]);
expect($attributes->displayExcerpt())->toBeTrue();
});

it('returns if it does not display the excerpt', function () {
$attributes = BlockAttributes::from([]);
$attributes = BlockAttributes::from(['displayExcerpt' => false]);
expect($attributes->displayExcerpt())->toBeFalse();
});

Expand All @@ -260,7 +270,7 @@
});

it('returns if it does not display the label', function () {
$attributes = BlockAttributes::from([]);
$attributes = BlockAttributes::from(['displayLabel' => false]);
expect($attributes->displayLabel())->toBeFalse();
});

Expand Down
Loading