Guest User

Untitled

a guest
Apr 26th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. const { el } = wp.element.createElement
  2. const { Component } = wp.element;
  3. const { decodeEntities } = wp.utils;
  4. const { __ } = wp.i18n;
  5. const { RichText } = wp.blocks;
  6.  
  7. class TestDisplay extends Component {
  8. constructor(props) {
  9. super( props );
  10. this.onChangeHeading = this.onChangeHeading.bind(this);
  11. this.onChangeDescription = this.onChangeDescription.bind(this);
  12. }
  13.  
  14. onChangeHeading(value, i) {
  15. var newHeadings = this.props.attributes.headings;
  16. newHeadings[i] = {};
  17. newHeadings[i].text = value[0];
  18. this.props.setAttributes( { headings: newHeadings } );
  19. }
  20.  
  21. onChangeDescription(value, i) {
  22. var newDescriptions = this.props.attributes.descriptions;
  23. newDescriptions[i] = {};
  24. newDescriptions[i].text = value[0];
  25. this.props.setAttributes( { descriptions: newDescriptions } );
  26. }
  27.  
  28. render() {
  29.  
  30. var props = this.props;
  31.  
  32. var columns = props.attributes.columns
  33. var headings = props.attributes.headings
  34. var descriptions = props.attributes.descriptions
  35.  
  36. var output = [];
  37.  
  38. for( let i = 0; i < columns; i = i + 1 ) {
  39. output.push(
  40. <div className="pricing-table__column">
  41. <RichText
  42. tagName="h3"
  43. value={ headings[i] && headings[i].text }
  44. placeholder={ 'Column Heading' }
  45. onChange={ ( value ) => this.onChangeHeading( value, i ) }
  46. className="pricing-table__heading"
  47. formattingControls={[]}
  48. />
  49. <RichText
  50. tagName="span"
  51. value={ descriptions[i] && descriptions[i].text }
  52. placeholder={ 'Column Heading' }
  53. onChange={ ( value ) => this.onChangeDescription( value, i ) }
  54. className="pricing-table__description"
  55. formattingControls={[]}
  56. />
  57. </div>
  58. );
  59. }
  60.  
  61. return (
  62. <div className={props.className}>{output}</div>
  63. );
  64. };
  65. }
  66.  
  67. export default TestDisplay;
Add Comment
Please, Sign In to add comment