-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Add featured image settings to the Latest Posts block #39257
Changes from 14 commits
447f2a8
49a5824
e49d8ef
0ad7afe
61d12b7
30c62ac
9278d5f
466c655
ae2d3ae
9d99ffa
f81bb40
28235ad
21e52a1
b5dbeec
0fe02e6
19b0e21
c0799d1
40765b4
ec59670
dac3698
9fb7b38
abf44c8
30db2b0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,25 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
import { | ||
alignNone, | ||
positionCenter, | ||
positionLeft, | ||
positionRight, | ||
} from '@wordpress/icons'; | ||
|
||
export const MIN_EXCERPT_LENGTH = 10; | ||
export const MAX_EXCERPT_LENGTH = 100; | ||
export const MAX_POSTS_COLUMNS = 6; | ||
|
||
export const BLOCK_ALIGNMENTS_CONTROLS = [ | ||
{ value: undefined, label: __( 'None' ), icon: alignNone }, | ||
{ value: 'left', label: __( 'Align left' ), icon: positionLeft }, | ||
{ | ||
value: 'center', | ||
label: __( 'Align center' ), | ||
icon: positionCenter, | ||
}, | ||
{ value: 'right', label: __( 'Align right' ), icon: positionRight }, | ||
]; | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,14 +20,19 @@ import { | |
ToggleControl, | ||
RangeControl, | ||
QueryControls, | ||
BottomSheetSelectControl, | ||
} from '@wordpress/components'; | ||
import { store as blocksStore } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import styles from './style.scss'; | ||
import { MIN_EXCERPT_LENGTH, MAX_EXCERPT_LENGTH } from './constants'; | ||
import { | ||
MIN_EXCERPT_LENGTH, | ||
MAX_EXCERPT_LENGTH, | ||
BLOCK_ALIGNMENTS_CONTROLS, | ||
} from './constants'; | ||
|
||
class LatestPostsEdit extends Component { | ||
constructor() { | ||
|
@@ -43,6 +48,15 @@ class LatestPostsEdit extends Component { | |
); | ||
this.onSetExcerptLength = this.onSetExcerptLength.bind( this ); | ||
this.onSetDisplayPostDate = this.onSetDisplayPostDate.bind( this ); | ||
this.onSetDisplayFeaturedImage = this.onSetDisplayFeaturedImage.bind( | ||
this | ||
); | ||
this.onSetFeaturedImageAlign = this.onSetFeaturedImageAlign.bind( | ||
this | ||
); | ||
this.onSetAddLinkToFeaturedImage = this.onSetAddLinkToFeaturedImage.bind( | ||
this | ||
); | ||
this.onSetOrder = this.onSetOrder.bind( this ); | ||
this.onSetOrderBy = this.onSetOrderBy.bind( this ); | ||
this.onSetPostsToShow = this.onSetPostsToShow.bind( this ); | ||
|
@@ -95,6 +109,21 @@ class LatestPostsEdit extends Component { | |
setAttributes( { displayPostDate: value } ); | ||
} | ||
|
||
onSetDisplayFeaturedImage( value ) { | ||
const { setAttributes } = this.props; | ||
setAttributes( { displayFeaturedImage: value } ); | ||
} | ||
|
||
onSetAddLinkToFeaturedImage( value ) { | ||
const { setAttributes } = this.props; | ||
setAttributes( { addLinkToFeaturedImage: value } ); | ||
} | ||
|
||
onSetFeaturedImageAlign( value ) { | ||
const { setAttributes } = this.props; | ||
setAttributes( { featuredImageAlign: value } ); | ||
} | ||
|
||
onSetOrder( value ) { | ||
const { setAttributes } = this.props; | ||
setAttributes( { order: value } ); | ||
|
@@ -124,6 +153,9 @@ class LatestPostsEdit extends Component { | |
displayPostContentRadio, | ||
excerptLength, | ||
displayPostDate, | ||
displayFeaturedImage, | ||
featuredImageAlign, | ||
addLinkToFeaturedImage, | ||
order, | ||
orderBy, | ||
postsToShow, | ||
|
@@ -166,6 +198,31 @@ class LatestPostsEdit extends Component { | |
onChange={ this.onSetDisplayPostDate } | ||
/> | ||
</PanelBody> | ||
|
||
<PanelBody title={ __( 'Featured image settings' ) }> | ||
<ToggleControl | ||
label={ __( 'Display featured image' ) } | ||
checked={ displayFeaturedImage } | ||
onChange={ this.onSetDisplayFeaturedImage } | ||
/> | ||
{ displayFeaturedImage && ( | ||
<> | ||
<BottomSheetSelectControl | ||
label={ __( 'Image alignment' ) } | ||
options={ BLOCK_ALIGNMENTS_CONTROLS } | ||
onChange={ this.onSetFeaturedImageAlign } | ||
value={ featuredImageAlign } | ||
/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the future, it would be great if I was checking the previous commits where you introduced There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thank you very much @SiobhyB for tackling this 🙇. I'd like to clarify that with my previous comment I didn't want to imply that we had to do the refactor in this PR, but I'm happy to see you sorted it out 😊. I'll try to take a look as soon as possible at the latest changes. |
||
<ToggleControl | ||
label={ __( 'Add link to featured image' ) } | ||
checked={ addLinkToFeaturedImage } | ||
onChange={ this.onSetAddLinkToFeaturedImage } | ||
separatorType={ 'topFullWidth' } | ||
/> | ||
</> | ||
) } | ||
</PanelBody> | ||
|
||
<PanelBody title={ __( 'Sorting and filtering' ) }> | ||
<QueryControls | ||
{ ...{ order, orderBy } } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should expose a native-only constant in the constants file, if it's going to be used only in the
edit.native.js
file I might consider defining the constant there, wdyt?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes to this shared constants file have been removed following the recent refactor. 👍