App.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import React, { Component, useState } from 'react'
  2. import './App.css'
  3. // import Header from './components/Header';
  4. // import Navbar from './components/Navbar';
  5. // import Profile from './components/Profile';
  6. const Input = () => {
  7. const [value, setValue] = useState('asdf')
  8. return (
  9. <>
  10. <input value={value} onChange={e => setValue(e.target.value)}/>
  11. <p>{value.toUpperCase()}</p>
  12. </>
  13. )
  14. }
  15. const Spoiler = ({children, header:Header}) => {
  16. const [show, setShow] = useState(false)
  17. return (
  18. <>
  19. <Header onClick={() => setShow(!show)}/>
  20. {show && children}
  21. </>
  22. )
  23. }
  24. const RangeInput = ({min, max}) => {
  25. const [el, setColor] = useState();
  26. return (
  27. <>
  28. <Input></Input>
  29. </>
  30. )
  31. }
  32. const App = () => {
  33. return (
  34. <>
  35. <div className = "spoiler">
  36. <Spoiler header={({ ...props }) => <h2 {...props}>Show</h2>}>
  37. <Input/>
  38. <Input />
  39. <Spoiler header={({ onClick }) => <button onClick={onClick}>Show</button>}>
  40. <Input />
  41. <Input />
  42. </Spoiler>
  43. </Spoiler>
  44. </div>
  45. </>
  46. //<RangeInput min={2} max={10} />
  47. );
  48. }
  49. export default App;