Eulis

accommodations.jsx

Sep 13th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.39 KB | None | 0 0
  1. import React, { Component } from 'react';
  2. import Slider from "react-slick";
  3. import { Link } from 'react-router-dom';
  4. import CardAcomodacoes from '../CardAcomodacoes/CardAcomodacoes';
  5. import leftArrow from './arrow_left.svg'
  6. import './acomodacoes.css';
  7.  
  8. function NextArrowa(props) {
  9. const { onClick } = props;
  10. return (
  11. <img src={leftArrow} onClick={ onClick } className="acomodacoes-arrow next-arrow" alt=""/>
  12. );
  13. }
  14.  
  15. function PrevArrow(props) {
  16. const { onClick } = props;
  17. return (
  18. <img src={leftArrow} onClick={ onClick } className="acomodacoes-arrow prev-arrow" alt=""/>
  19. );
  20. }
  21.  
  22. class Acomodacoes extends Component {
  23. state = { // Remember to CHANGE when backend is done!
  24. locations: [
  25. {
  26. id: 0,
  27. title: 'bangolow',
  28. subtitle: 'família',
  29. text: 'Nosso bungalow família tem 80 m2 distribuídos em 03 quartos (com ar condicionado split), sendo 01 térreo e 02 no 1 piso.',
  30. image: 'https://public-v2links.adobecc.com/577c0731-419a-41a4-5a2a-1f7416306b25/component?params=component_id:c14c3e1d-ba91-4e8f-8fcf-7beebdd293a5&params=version:0&token=1559488146_da39a3ee_a6728efce877840defbb941032099bb56eda0ba4&api_key=CometServer1',
  31. link: '/1'
  32. },
  33. {
  34. id: 1,
  35. title: 'quarto',
  36. subtitle: 'casal',
  37. text: 'Quarto para casal com 42 m2, banheira, varanda, televisão e muita privacidade.',
  38. image: 'https://images.unsplash.com/photo-1559311745-a57f6233488e?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1417&q=80',
  39. link: '/2'
  40. },
  41. {
  42. id: 2,
  43. title: 'mansão',
  44. subtitle: 'todo mundo',
  45. text: 'Casa gigantesca com tudo que é necessárioo para disfrutar de um final de semana inesquecível na praia dos carneiros.',
  46. image: 'https://public-v2links.adobecc.com/577c0731-419a-41a4-5a2a-1f7416306b25/component?params=component_id:74257cde-e0b5-4a6b-9335-2d8c21d672be&params=version:0&token=1559488146_da39a3ee_a6728efce877840defbb941032099bb56eda0ba4&api_key=CometServer1',
  47. link: '/3'
  48. }
  49. ],
  50. shownImage: 0,
  51. }
  52.  
  53. render() {
  54. let settings = {
  55. dots: true,
  56. dotsClass: 'acomodacoes-dots',
  57. appendDots: dots => <div>{dots}</div>,
  58. infinite: true,
  59. speed: 500,
  60. slidesToShow: 1,
  61. slidesToScroll: 1,
  62. beforeChange: (current, next) => this.setState({ shownImage: next }),
  63. prevArrow: <PrevArrow />,
  64. nextArrow: <NextArrow />
  65. };
  66.  
  67. let settingsMobile = {
  68. dots: true,
  69. dotsClass: 'acomodacoes-dots',
  70. appendDots: dots => <div>{dots}</div>,
  71. infinite: true,
  72. speed: 500,
  73. slidesToShow: 1,
  74. slidesToScroll: 1,
  75. beforeChange: (current, next) => this.setState({ shownImage: next }),
  76. arrows: false,
  77. centerMode: true,
  78. centerPadding: '15px',
  79. };
  80.  
  81.  
  82. return (
  83. <section className="acomodacoes">
  84.  
  85. {/* Desktop version */}
  86. <div className="acomodacoes-container">
  87. <div className="acomodacoes-text">
  88. <h3 className="acomodacoes-title">acomodações</h3>
  89. <div className="acomodacoes-content">
  90. <Slider {...settings} className="acomodacoes-slider" >
  91. {this.state.locations.map(location => {
  92. return(
  93. <CardAcomodacoes
  94. key={location.id}
  95. title={location.title}
  96. subtitle={location.subtitle}
  97. text={location.text}
  98. link={location.link}/>
  99. )
  100. })}
  101. </Slider>
  102. </div>
  103. </div>
  104. {this.state.locations.map((location, index) => {
  105. return(
  106. <img src={location.image}
  107. key={location.id}
  108. style={(index===this.state.shownImage) ? {display: 'block'} : {display: 'none'}}
  109. className="acomodacoes-image"
  110. alt="Imagem da acomodação atual"/>
  111. );
  112. })}
  113. </div>
  114.  
  115. {/* Mobile Version */}
  116. <div className="acomodacoes-mobile">
  117. <h3 className="acomodacoes-title">acomodações</h3>
  118. <div className="acomodacoes-mobile-top">
  119. <Slider {...settingsMobile} className="acomodacoes-mobile-slider" >
  120. {this.state.locations.map(location => {
  121. return(
  122. <div className="acomodacoes-mobile-image-box">
  123. <img src={location.image}
  124. className="acomodacoes-mobile-image"
  125. alt="Imagem da acomodação atual"/>
  126. </div>
  127. );
  128. })}
  129. </Slider>
  130. </div>
  131. <div className="acomodacoes-mobile-bottom">
  132. {this.state.locations.map((location, index) => {
  133. return(
  134. <div className="acomodacoes-mobile-card-box" style={(index===this.state.shownImage) ? {display: 'flex'} : {display: 'none'}}>
  135. <CardAcomodacoes
  136. key={location.id}
  137. title={location.title}
  138. subtitle={location.subtitle}
  139. text={location.text}
  140. link={location.link}/>
  141. </div>
  142. );
  143. })}
  144. </div>
  145.  
  146. </div>
  147.  
  148. </section>
  149. );
  150. }
  151. }
  152.  
  153. export default Acomodacoes;
Advertisement
Add Comment
Please, Sign In to add comment