Advertisement
Guest User

src/pages/business.js

a guest
Jul 24th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.74 KB | None | 0 0
  1. import React, { useEffect } from "react"
  2. import styled from "styled-components"
  3. import { StaticQuery, graphql } from "gatsby"
  4. import { Box, Text, Heading, Image, Flex, Button, Link } from "rebass"
  5. import Download from "react-feather/dist/icons/download"
  6. import Swiper from "react-id-swiper"
  7.  
  8. import { isWindow } from "src/utils/checks"
  9. import { Helmet } from "src/features/Helmet"
  10. import { Layout } from "src/ui/Layout"
  11. import { Container } from "src/ui/Container"
  12.  
  13.  
  14. const BusinessPage = () => {
  15. useEffect(() => {
  16. if (isWindow()) {
  17. document.body.style = "overflow-x: hidden"
  18. }
  19.  
  20. return () => {
  21. if (isWindow()) {
  22. document.body.style = "overflow-x: auto"
  23. }
  24. }
  25. })
  26.  
  27. return (
  28. <StaticQuery
  29. query={query}
  30. render={({
  31. datoCmsBusinessPage: {
  32. title,
  33. description,
  34. button1Text,
  35. button1Link,
  36. featuresSectionTitle,
  37. featuresSectionDescription,
  38. featuresSectionImage: { url: featuresSectionImageUrl },
  39. features,
  40. subfeatures,
  41. callToActionSectionTitle,
  42. callToActionSectionDescription,
  43. callToActionSectionButtonText,
  44. callToActionSectionLink,
  45. reviews,
  46. additionalButtons,
  47. },
  48. }) => (
  49. <>
  50. <Helmet title={"Business page"} slider={true}></Helmet>
  51. <Layout>
  52. <Container>
  53. <Box pt={["6", "6", "6", "160px"]} pb={["6", "6", "6", "120px"]}>
  54. <Heading
  55. mb={"6"}
  56. as={"h1"}
  57. fontWeight={"600"}
  58. lineHeight={"140%"}
  59. textAlign={"center"}
  60. fontSize={["4", "4", "4", "7"]}
  61. >
  62. {title && title}
  63. </Heading>
  64. <Heading
  65. as={"h2"}
  66. color={"#808080"}
  67. fontWeight={"400"}
  68. px={[0, 7, 10, 10]}
  69. lineHeight={"140%"}
  70. textAlign={"center"}
  71. fontSize={["2", "2", "2", "4"]}
  72. >
  73. {description && description}
  74. </Heading>
  75. <Flex
  76. alignItems={"center"}
  77. flexDirection={"column"}
  78. mt={["6", "6", "6", "60px"]}
  79. >
  80. <ActionButton variant="primary">
  81. <a href={button1Link && button1Link}>
  82. {button1Text && button1Text}
  83. </a>
  84. </ActionButton>
  85. <Text
  86. mt={"10px"}
  87. color={"#808080"}
  88. fontSize={["1", "1", "1", "2"]}
  89. >
  90. Lorem ipsum dolor*
  91. </Text>
  92. </Flex>
  93. </Box>
  94. <Container px={["0", "0", "4", "4"]}>
  95. <FeatureFirst
  96. pt={[4, 6, 7, 8]}
  97. px={[2, 7, 9, 10]}
  98. pb={[4, "210px", "210px", 8]}
  99. mb={["240px", "240px", "330px", "90px"]}
  100. >
  101. <Heading
  102. as={"h2"}
  103. px={[0, 0, 0, 10]}
  104. fontWeight={"600"}
  105. lineHeight={"140%"}
  106. mb={["8", "8", "8", "60px"]}
  107. fontSize={["5", "5", "5", "36px"]}
  108. >
  109. {featuresSectionTitle && featuresSectionTitle}
  110. </Heading>
  111. <Text
  112. px={[0, 0, 0, 10]}
  113. lineHeight={"140%"}
  114. pb={["70px", "70px", "70px", "140px"]}
  115. fontSize={["2", "2", "2", "18px"]}
  116. >
  117. {featuresSectionDescription && featuresSectionDescription}
  118. </Text>
  119. {features &&
  120. features.map(({ title, body, id }) => (
  121. <Box
  122. key={id}
  123. width={[1, 1, 1, 1 / 2]}
  124. mb={["3", "3", "3", "45px"]}
  125. >
  126. <Heading
  127. as={"h3"}
  128. color={"red"}
  129. fontWeight={"600"}
  130. textAlign={"left"}
  131. lineHeight={"140%"}
  132. fontSize={["18px", "18px", "18px", "5"]}
  133. >
  134. {title}
  135. </Heading>
  136. <Text
  137. textAlign={"left"}
  138. lineHeight={"140%"}
  139. fontSize={["2", "2", "2", "18px"]}
  140. >
  141. {body}
  142. </Text>
  143. </Box>
  144. ))}
  145. <FeatureBg src={featuresSectionImageUrl}></FeatureBg>
  146. </FeatureFirst>
  147. <Box mb={"100px"}>
  148. {subfeatures &&
  149. subfeatures.map(
  150. ({
  151. image: { url },
  152. title,
  153. body,
  154. buttonText,
  155. buttonLink,
  156. id,
  157. }) => (
  158. <FeatureSecond
  159. key={id}
  160. alignItems={"center"}
  161. justifyContent={"space-between"}
  162. >
  163. <FeatureImage src={url}></FeatureImage>
  164. <Box width={[1, 1, 1, 1 / 2.5]} mb={"20px"}>
  165. <Heading
  166. as={"h3"}
  167. color={"red"}
  168. fontSize={"5"}
  169. textAlign={"left"}
  170. fontWeight={"600"}
  171. lineHeight={"140%"}
  172. >
  173. {title}
  174. </Heading>
  175. <Text
  176. textAlign={"left"}
  177. lineHeight={"140%"}
  178. fontSize={["2", "2", "2", "18px"]}
  179. my={["22px", "22px", "22px", "22px", "60px"]}
  180. >
  181. {body}
  182. </Text>
  183. <ActionButton variant="primary">
  184. <a href={buttonLink && buttonLink}>
  185. {buttonText}
  186. </a>
  187. </ActionButton>
  188. </Box>
  189. </FeatureSecond>
  190. )
  191. )}
  192. </Box>
  193. </Container>
  194. </Container>
  195. {reviews && reviews.length > 0 && (
  196. <Box bg={"black"} color={"white"}>
  197. <Container py={"95px"}>
  198. <Actions
  199. flexWrap={"wrap"}
  200. alignItems={"stretch"}
  201. justifyContent={"space-between"}
  202. >
  203. <Flex
  204. width={[1, 1, 1, 1 / 2]}
  205. flexDirection={"column"}
  206. alignItems={"flex-start"}
  207. justifyContent={"space-between"}
  208. >
  209. <Box>
  210. <Heading
  211. as={"h3"}
  212. mb={"2"}
  213. fontSize={"7"}
  214. fontWeight={"600"}
  215. >
  216. {/* Call to action block */}
  217. {callToActionSectionTitle && callToActionSectionTitle}
  218. </Heading>
  219. <Text fontSize={"18px"}>
  220. {callToActionSectionDescription &&
  221. callToActionSectionDescription}
  222. </Text>
  223. </Box>
  224.  
  225. <StyledButton variant="primary">
  226. <a
  227. href={
  228. callToActionSectionLink && callToActionSectionLink
  229. }
  230. >
  231. {callToActionSectionButtonText &&
  232. callToActionSectionButtonText}
  233. </a>
  234. </StyledButton>
  235. </Flex>
  236. <Box
  237. width={[1, 1, 1, 1 / 3]}
  238. mt={["45px", "45px", "45px", "0"]}
  239. mb={["60px", "60px", "60px", "0"]}
  240. >
  241. <Swiper
  242. {...swiperParams}
  243. containerClass={"swiper-container swiper-custom"}
  244. >
  245. {reviews.map(
  246. ({
  247. title,
  248. bodyNode: { childMarkdownRemark: html },
  249. signature,
  250. id,
  251. }) => {
  252. return (
  253. <Box key={id}>
  254. <Text
  255. fontWeight={"600"}
  256. fontSize={"18px"}
  257. mb={"28px"}
  258. >
  259. {title}
  260. </Text>
  261. <Text
  262. mb={"12px"}
  263. fontSize={"18px"}
  264. fontWeight={"300"}
  265. lineHeight={"160%"}
  266. dangerouslySetInnerHTML={{
  267. __html: html.html,
  268. }}
  269. >
  270. </Text>
  271. <Text
  272. mb={"24px"}
  273. fontSize={"2"}
  274. fontWeight={"500"}
  275. >
  276. {signature}
  277. </Text>
  278. </Box>
  279. )
  280. }
  281. )}
  282. </Swiper>
  283. </Box>
  284. </Actions>
  285. </Container>
  286. </Box>
  287. )}
  288. <Flex
  289. py={"8"}
  290. flexWrap={"wrap"}
  291. alignItems={"center"}
  292. justifyContent={"center"}
  293. >
  294. {additionalButtons &&
  295. additionalButtons.map(({ title, id }) => (
  296. <DownloadKit key={id} m={"3"} href="/">
  297. <Download size={30} color="black"></Download>
  298. <Text mt={"5"}>{title}</Text>
  299. </DownloadKit>
  300. ))}
  301. </Flex>
  302. </Layout>
  303. </>
  304. )}
  305. />
  306. )
  307. }
  308.  
  309. const query = graphql`
  310. {
  311. datoCmsBusinessPage {
  312. title
  313. description
  314. button1Text
  315. button1Link
  316. featuresSectionTitle
  317. featuresSectionDescription
  318. featuresSectionImage {
  319. id
  320. url
  321. }
  322. features {
  323. id
  324. title
  325. body
  326. }
  327. subfeatures {
  328. id
  329. title
  330. body
  331. buttonText
  332. buttonLink
  333. image {
  334. url
  335. }
  336. }
  337. callToActionSectionTitle
  338. callToActionSectionDescription
  339. callToActionSectionButtonText
  340. callToActionSectionLink
  341. reviews {
  342. title
  343. id
  344. author
  345. bodyNode {
  346. childMarkdownRemark {
  347. html
  348. }
  349. }
  350. }
  351. additionalButtons {
  352. id
  353. title
  354. link
  355. }
  356. }
  357. }
  358. `
  359.  
  360. const ActionButton = styled(Button)`
  361. padding: 16px 24px;
  362. `
  363.  
  364. const FeatureFirst = styled(Box)`
  365. background: #000;
  366. border-radius: 3px;
  367. color: #fff;
  368. position: relative;
  369. text-align: center;
  370. `
  371.  
  372. const FeatureSecond = styled(Flex)`
  373. &:nth-child(odd) {
  374. flex-direction: row-reverse;
  375. }
  376. `
  377.  
  378. const FeatureImage = styled(Image)`
  379. max-width: 300px;
  380. @media (max-width: ${({ theme }) => theme.breakpoints.m}) {
  381. display: none;
  382. }
  383. `
  384.  
  385. const FeatureBg = styled(Image)`
  386. position: absolute;
  387. bottom: 50px;
  388. right: -240px;
  389. max-width: 590px;
  390. @media (max-width: ${({ theme }) => theme.breakpoints.m}) {
  391. bottom: -240px;
  392. left: calc(50% - 225px);
  393. max-width: 450px;
  394. }
  395. @media (max-width: ${({ theme }) => theme.breakpoints.s}) {
  396. bottom: -150px;
  397. max-width: 320px;
  398. }
  399. `
  400.  
  401. const Actions = styled(Flex)`
  402. position: relative;
  403. `
  404.  
  405. const StyledButton = styled(Button)`
  406. padding: 16px 24px;
  407. @media (max-width: ${({ theme }) => theme.breakpoints.m}) {
  408. position: absolute;
  409. bottom: 0;
  410. }
  411. `
  412.  
  413. const DownloadKit = styled(Link)`
  414. align-items: center;
  415. display: flex;
  416. flex-direction: column;
  417. border: solid 3px #000;
  418. border-radius: 2px;
  419. color: black;
  420. padding: 47px 42px;
  421. transition: all ease 0.3s;
  422. &:hover {
  423. background: #ff003d;
  424. border-color: #ff003d;
  425. color: #fff;
  426. svg {
  427. stroke: #fff;
  428. }
  429. }
  430. `
  431.  
  432. const swiperParams = {
  433. lazy: true,
  434. pagination: {
  435. el: ".swiper-pagination",
  436. type: "bullets",
  437. clickable: true,
  438. },
  439. spaceBetween: 30,
  440. }
  441.  
  442. export default BusinessPage
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement