[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/js/bp-blogs/js/blocks/recent-posts/ -> edit.js (source)

   1  /**
   2   * WordPress dependencies.
   3   */
   4  const {
   5      blockEditor: {
   6          InspectorControls,
   7      },
   8      components: {
   9          Disabled,
  10          PanelBody,
  11          RangeControl,
  12          TextControl,
  13          ToggleControl,
  14      },
  15      element: {
  16          Fragment,
  17          createElement,
  18      },
  19      i18n: {
  20          __,
  21      },
  22      serverSideRender: ServerSideRender,
  23  } = wp;
  24  
  25  const editRecentPostsBlock = ( { attributes, setAttributes } ) => {
  26      const { title, maxPosts, linkTitle } = attributes;
  27  
  28      return (
  29          <Fragment>
  30              <InspectorControls>
  31                  <PanelBody title={ __( 'Settings', 'buddypress' ) } initialOpen={ true }>
  32                      <TextControl
  33                          label={ __( 'Title', 'buddypress' ) }
  34                          value={ title }
  35                          onChange={ ( text ) => {
  36                              setAttributes( { title: text } );
  37                          } }
  38                      />
  39                      <RangeControl
  40                          label={ __( 'Max posts to show', 'buddypress' ) }
  41                          value={ maxPosts }
  42                          onChange={ ( value ) =>
  43                              setAttributes( { maxPosts: value } )
  44                          }
  45                          min={ 1 }
  46                          max={ 10 }
  47                          required
  48                      />
  49                      <ToggleControl
  50                          label={ __( 'Link block title to Blogs directory', 'buddypress' ) }
  51                          checked={ !! linkTitle }
  52                          onChange={ () => {
  53                              setAttributes( { linkTitle: ! linkTitle } );
  54                          } }
  55                      />
  56                  </PanelBody>
  57              </InspectorControls>
  58              <Disabled>
  59                  <ServerSideRender block="bp/recent-posts" attributes={ attributes } />
  60              </Disabled>
  61          </Fragment>
  62      );
  63  };
  64  
  65  export default editRecentPostsBlock;


Generated: Fri May 5 01:01:24 2023 Cross-referenced by PHPXref 0.7.1