Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. class DropdownBar extends React.Component {
  2. constructor(props) {
  3. super(props);
  4. }
  5.  
  6. render () {
  7. return (
  8. <div>
  9. <div className="top-bar">
  10. <Row>
  11. <div style={{marginTop: 15, marginBottom:15}}>
  12. <Col span={8}><FirstDropdown practice={this.props.practice} /></Col>
  13. <Col span={8}><SecondDropdown /></Col>
  14.  
  15. </div>
  16. </Row>
  17. </div>
  18. </div>
  19. )
  20. }
  21.  
  22.  
  23.  
  24.  
  25.  
  26. class FirstDropdown extends React.Component {
  27. constructor() {
  28. super();
  29. this.state = {
  30. practices: [
  31. name = 'Jon',
  32. name = 'potato',
  33. name = 'stark',
  34. ],
  35. practice: 'stark'
  36. }
  37. }
  38.  
  39. onChangePractice(value) {
  40. console.log(`selected ${value}`);
  41. this.setState({
  42. practice: value
  43. })
  44. }
  45.  
  46.  
  47. render () {
  48. const {practices} = this.state
  49.  
  50. return (
  51. <div>
  52. <Row>
  53. <div className="First-dropdown">
  54. <Col span={8}><div className="dropdown-title">Research: </div></Col>
  55. <Col span={14}>
  56. <Select
  57. showSearch
  58. style={{ width: '100%' }}
  59. placeholder="Select a Something"
  60. optionFilterProp="children"
  61. onChange={this.onChangePractice.bind(this)}
  62. onFocus={onFocus}
  63. onBlur={onBlur}
  64. onSearch={onSearch}
  65. filterOption={(input, option) =>
  66. option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
  67. }
  68. >
  69. {practices.map(practice => (
  70. <Option
  71. value={practice}
  72. key={practice}
  73. data-automation={practice.name}
  74. >{practice}</Option>
  75. ))}
  76. </Select>
  77. </Col>
  78. </div>
  79. </Row>
  80. </div>
  81.  
  82. )
  83. }
  84.  
  85.  
  86.  
  87. class SecondDropdown extends React.Component {
  88. constructor(props) {
  89. super(props);
  90. this.state = {
  91. modules: [
  92. name = 'Drogon',
  93. name = 'Rhaegal',
  94. name = 'Viserion',
  95. ]
  96. }
  97. }
  98. componentDidUpdate(prevProps) {
  99. console.log(this.props.practice)
  100. if (!equal(this.props.practice, prevProps.practice))
  101. {
  102. this.updatePractice();
  103.  
  104. }
  105. }
  106.  
  107. render () {
  108. const {modules} = this.state
  109. console.log(this.props.practice )
  110. let practice = this.props.practice;
  111.  
  112. if (practice === 'stark') {
  113. return (
  114. <div>
  115. <Row>
  116. <div className="benchmark-dropdown">
  117. <Col span={4}><div className="dropdown-title">Module: </div></Col>
  118. <Col span={16}>
  119. <Select
  120. showSearch
  121. style={{ width: '100%' }}
  122. placeholder="Select Something"
  123. optionFilterProp="children"
  124. onChange={onChange}
  125. onFocus={onFocus}
  126. onBlur={onBlur}
  127. onSearch={onSearch}
  128. filterOption={(input, option) =>
  129. option.props.children.toLowerCase().indexOf(input.toLowerCase()) >= 0
  130. }
  131. >
  132. {modules.map(item => (
  133. <Option
  134. value={item}
  135. key={item}
  136. >{item}</Option>
  137. ))}
  138. </Select>
  139. </Col>
  140. </div>
  141. </Row>
  142. </div>
  143.  
  144. )
  145. } else {
  146. return <div> NOOOOO </div>
  147. }
  148.  
  149. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement