Advertisement
joygabriel21

PastMeetup Component

Jan 21st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.66 KB | None | 0 0
  1. import React, {Component} from 'react';
  2. import Link from '../../atoms/Link';
  3. import Title from '../../atoms/Title';
  4. import Card from '../../molecules/Card';
  5. import './style.css';
  6. import TextGroup from '../../atoms/TextGroup';
  7.  
  8. export default class PastMeetup extends Component {
  9. constructor() {
  10. super();
  11.  
  12. this.state = {
  13. isOpened: false
  14. }
  15. }
  16.  
  17. renderSeeAll() {
  18. return this.props.schedule.map((eachSchedule, index) => {
  19. return (
  20. <Card
  21. key = {index}
  22. date = {eachSchedule.date}
  23. id = {eachSchedule.id}
  24. topic = {eachSchedule.topic}
  25. participants = {eachSchedule.participants}
  26. />
  27. )
  28. })
  29. }
  30.  
  31. renderCard() {
  32. return this.props.schedule.map((eachSchedule, index) => {
  33. if (index <=2) {
  34. return (
  35. <Card
  36. key = {index}
  37. date = {eachSchedule.date}
  38. id = {eachSchedule.id}
  39. topic = {eachSchedule.topic}
  40. participants = {eachSchedule.participants}
  41. />
  42. )
  43. }
  44. })
  45. }
  46.  
  47. renderContent() {
  48. if(this.state.isOpened) {
  49. return this.renderSeeAll();
  50. } else {
  51. return this.renderCard();
  52. }
  53. }
  54.  
  55. render() {
  56. // console.log(this.state);
  57. return (
  58. <div>
  59. <TextGroup className="PastMeetup">
  60. <Title text='Past Meetup' className='Subtitle'/>
  61. <Link text='See All' className='SeeAll' onClick={() => this.setState({isOpened: true})}/>
  62.  
  63. <TextGroup className = 'CardGroup'>
  64. {this.renderContent()}
  65. </TextGroup>
  66. </TextGroup>
  67. </div>
  68. )
  69. }
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement