Advertisement
azad_rpi

Gutenberg inspector controls for Countdown block

Sep 2nd, 2018
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * Internal block libraries
  3.  */
  4. const { __ } = wp.i18n;
  5. const { Component } = wp.element;
  6. const {
  7.     InspectorControls,
  8.     ColorPalette,
  9. } = wp.editor;
  10. const {
  11.     Button,
  12.     PanelBody,
  13.     PanelColor,
  14.     TextControl,
  15.     SelectControl,
  16.     RangeControl,
  17. } = wp.components;
  18.  
  19.  
  20. /**
  21.  * Create an Inspector Controls wrapper Component
  22.  */
  23. export default class Inspector extends Component {
  24.  
  25.     constructor() {
  26.         super( ...arguments );
  27.     }
  28.  
  29.     render() {
  30.         const { attributes: { uniqueID, style, date, textBgColor, numberBgColor, textColor, numberColor, borderColor, colonColor }, setAttributes } = this.props;
  31.  
  32.         return [
  33.             <InspectorControls>
  34.                 <PanelBody>
  35.                     <TextControl
  36.                         label={ __( 'Unique Number', 'prefixx' ) }
  37.                         help={ __( 'Please provide a unique number for this block. Ex: 1/23/500 etc (any number) Otherwise the styles you apply will not work properly.', 'prefixx' ) }
  38.                         value={ uniqueID }
  39.                         onChange={ uniqueID => setAttributes( { uniqueID } ) }
  40.                     />
  41.                     <TextControl
  42.                         label={ __( 'Date', 'prefixx' ) }
  43.                         help={ __( 'Please put your date like this example: 2020/08/25 (Y/M/D)', 'prefixx' ) }
  44.                         value={ date }
  45.                         onChange={ date => setAttributes( { date } ) }
  46.                     />
  47.                     <SelectControl
  48.                         label={ __( 'Style', 'prefixx' ) }
  49.                         value={ style }
  50.                         options={ [
  51.                             { value: '1',         label: ' Style 1'},
  52.                             { value: '2',         label: ' Style 2'},
  53.                             { value: '3',         label: ' Style 3'},
  54.                             { value: '4',         label: ' Style 4'},
  55.                             { value: '5',         label: ' Style 5'},
  56.                             { value: '6',         label: ' Style 6'},
  57.                             { value: '7',         label: ' Style 7'},
  58.                         ]}
  59.                         onChange={ style => setAttributes( { style } ) }
  60.                     />
  61.                     <PanelColor
  62.                         title={ __( 'Text Bg Color', 'prefixx' ) }
  63.                         colorValue={ textBgColor }
  64.                         initialOpen={ false }
  65.                     >
  66.                         <ColorPalette
  67.                             value={ textBgColor }
  68.                             onChange={ textBgColor => setAttributes( { textBgColor } ) }
  69.                         />
  70.                     </PanelColor>
  71.                     <PanelColor
  72.                         title={ __( 'Number Bg Color', 'prefixx' ) }
  73.                         colorValue={ numberBgColor }
  74.                         initialOpen={ false }
  75.                     >
  76.                         <ColorPalette
  77.                             value={ numberBgColor }
  78.                             onChange={ numberBgColor => setAttributes( { numberBgColor } ) }
  79.                         />
  80.                     </PanelColor>
  81.                     <PanelColor
  82.                         title={ __( 'Text Color', 'prefixx' ) }
  83.                         colorValue={ textColor }
  84.                         initialOpen={ false }
  85.                     >
  86.                         <ColorPalette
  87.                             value={ textColor }
  88.                             onChange={ textColor => setAttributes( { textColor } ) }
  89.                         />
  90.                     </PanelColor>
  91.                     <PanelColor
  92.                         title={ __( 'Number Color', 'prefixx' ) }
  93.                         colorValue={ numberColor }
  94.                         initialOpen={ false }
  95.                     >
  96.                         <ColorPalette
  97.                             value={ numberColor }
  98.                             onChange={ numberColor => setAttributes( { numberColor } ) }
  99.                         />
  100.                     </PanelColor>
  101.                     <PanelColor
  102.                         title={ __( 'Border Color', 'prefixx' ) }
  103.                         colorValue={ borderColor }
  104.                         initialOpen={ false }
  105.                     >
  106.                         <ColorPalette
  107.                             value={ borderColor }
  108.                             onChange={ borderColor => setAttributes( { borderColor } ) }
  109.                         />
  110.                     </PanelColor>
  111.                     <PanelColor
  112.                         title={ __( 'Colon Color', 'prefixx' ) }
  113.                         colorValue={ colonColor }
  114.                         initialOpen={ false }
  115.                     >
  116.                         <ColorPalette
  117.                             value={ colonColor }
  118.                             onChange={ colonColor => setAttributes( { colonColor } ) }
  119.                         />
  120.                     </PanelColor>
  121.                 </PanelBody>
  122.             </InspectorControls>
  123.         ];
  124.     }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement