Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.26 KB | None | 0 0
  1. import React, { useState } from 'react';
  2. import ContentLoader from 'react-content-loader';
  3. import styled from 'styled-components';
  4. import { shell } from 'electron';
  5.  
  6. const Carousel = styled.div`
  7. width: 788px;
  8. height: 100%;
  9. overflow: hidden;
  10. border-radious: 2px;
  11. ...props.style;
  12. `;
  13.  
  14. const ImageSlider = styled.div`
  15. display: flex;
  16. flex-direction: row;
  17. overflow: hidden;
  18. justify-content: space-between;
  19. padding: 0;
  20. margin: 0;
  21. margin: 0 auto 0 auto;
  22. width: 1000%;
  23. height: 100%;
  24. z-index: 0;
  25. `;
  26.  
  27. const Slide = styled.div`
  28. display: inline-block;
  29. position: relative;
  30. top: 0;
  31. height: 158px%;
  32. width: 100%;
  33. margin0 2px 0 2px;
  34. background-size: cover;
  35. background-position: center;
  36. z-index: 0;
  37. `;
  38.  
  39. const ImageSlide = styled.img`
  40. position: absolute;
  41. display: block;
  42. top: 0;
  43. height: 100%;
  44. width: 100%;
  45. background-image: url(${props => (props.image ? props.image : null)});
  46. background-size: cover;
  47. background-position: center;
  48. flex-shrink: 0;
  49. z-index: -1;
  50. `;
  51.  
  52. const Gradient = styled.div`
  53. height: 100%;
  54. width: 100%;
  55. border-radious: 2px;
  56. background-image: linear-gradient(
  57. 0deg,
  58. rgba(0, 0, 0, 1) 0%,
  59. rgba(165, 165, 165, 0) 80%
  60. );
  61. opacity: 0.9;
  62. z-index: 1;
  63. `;
  64.  
  65. const Select = styled.div`
  66. display: flex;
  67. justify-content: space-between;
  68. position: absolute;
  69. bottom: 15px;
  70. padding: 0;
  71. margin: 0;
  72. width: 158px;
  73. height: 5px;
  74. left: 50%;
  75. margin-left: -79px;
  76. z-index: 2;
  77. `;
  78.  
  79. const SelectElement = styled.div`
  80. width: 16px;
  81. height: 5px;
  82. flex: 1;
  83. margin: 0 2px 0 2px;
  84. background: ${props => props.theme.secondaryColor_shade_1};
  85. opacity: 0.6;
  86. transition: flex-grow 0.2s ease-in-out;
  87. border-radius: 2px;
  88. &:hover {
  89. margin: 0 2px 0 2px;
  90. flex-grow: 2;
  91. background: ${props => props.theme.secondaryColor_shade_1};
  92. opacity: 0.79;
  93. vertical-align: middle;
  94. }
  95. &:active {
  96. margin: 0 2px 0 2px;
  97. flex-grow: 2;
  98. background: ${props => props.theme.secondaryColor_shade_1};
  99. opacity: 1;
  100. vertical-align: middle;
  101. }
  102. `;
  103.  
  104. const Title = styled.h1`
  105. position: absolute;
  106. bottom: 50px;
  107. left: 15px;
  108. z-index: 2;
  109. `;
  110.  
  111. const SubTitle = styled.p`
  112. position: absolute;
  113. bottom: 30px;
  114. left: 15px;
  115. z-index: 2;
  116. `;
  117.  
  118. type Props = {
  119. title: string,
  120. news: Object,
  121. description: string
  122. };
  123.  
  124. function openNews(inf) {
  125. console.log(inf.url);
  126. }
  127.  
  128. function ImageList(props) {
  129. const news = props.news;
  130. const listImages = news.map((inf, i) => (
  131. <Slide key={i} onCLick={openNews(inf)}>
  132. <Title>{inf.title}</Title>
  133. <SubTitle>{inf.description}</SubTitle>
  134. <Gradient />
  135. <ImageSlide image={inf.image} />
  136. </Slide>
  137. ));
  138.  
  139. return <ImageSlider>{listImages}</ImageSlider>;
  140. }
  141. function News(props: Props) {
  142. const [currentImageIndex, setCurrentImageIndex] = useState(0);
  143.  
  144. return (
  145. <Carousel style={props.style}>
  146. <Select>
  147. <SelectElement />
  148. <SelectElement />
  149. <SelectElement />
  150. <SelectElement />
  151. <SelectElement />
  152. <SelectElement />
  153. <SelectElement />
  154. <SelectElement />
  155. </Select>
  156. <ImageList news={props.news} />
  157. </Carousel>
  158. );
  159. }
  160.  
  161. export default News;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement