diff --git a/package.json b/package.json index d1951d7f9..0b23b907f 100644 --- a/package.json +++ b/package.json @@ -54,6 +54,7 @@ "css-loader": "3.4.2", "dotenv": "8.2.0", "dotenv-expand": "5.1.0", + "element-resize-detector": "^1.2.1", "eslint": "^6.6.0", "eslint-config-react-app": "^5.2.1", "eslint-loader": "3.0.3", @@ -98,6 +99,7 @@ "react-image-gallery": "^1.0.8", "react-redux": "^7.2.1", "react-router-dom": "^5.2.0", + "react-slick": "^0.27.12", "react-web3": "^1.2.0", "redux": "^4.0.5", "redux-logger": "^3.0.6", diff --git a/src/assets/img/carousel/sakeswap.jpg b/src/assets/img/carousel/sakeswap.jpg new file mode 100644 index 000000000..79977bdf4 Binary files /dev/null and b/src/assets/img/carousel/sakeswap.jpg differ diff --git a/src/assets/img/carousel/sfinance.jpg b/src/assets/img/carousel/sfinance.jpg new file mode 100644 index 000000000..2d366e2a5 Binary files /dev/null and b/src/assets/img/carousel/sfinance.jpg differ diff --git a/src/assets/img/carousel/wepiggy.jpg b/src/assets/img/carousel/wepiggy.jpg new file mode 100644 index 000000000..de8dc61cf Binary files /dev/null and b/src/assets/img/carousel/wepiggy.jpg differ diff --git a/src/assets/jss/material-kit-pro-react/components/customCarouselStyle.js b/src/assets/jss/material-kit-pro-react/components/customCarouselStyle.js new file mode 100644 index 000000000..13c5d14e6 --- /dev/null +++ b/src/assets/jss/material-kit-pro-react/components/customCarouselStyle.js @@ -0,0 +1,48 @@ +const customCarouselStyle = { + container: { + borderRadius: "6px", + overflow: "hidden", + backgroundColor: "#42475A", + }, + slider: { + width: "100%", + height: "100%", + lineHeight: "0", + // "& img": { + // borderRadius: "6px", + // overflow: "hidden", + // }, + // "& .slick-list": { + // borderRadius: "6px", + // overflow: "hidden", + // }, + }, + dots: { + textAlign: "right", + bottom: "20px", + paddingRight: "30px", + margin: "0", + "& li": { + width: "8px", + height: "8px", + borderRadius: "8px", + overflow: "hidden", + backgroundColor: "rgba(255, 255, 255, 0.3)", + margin: "0 4px", + }, + "& li.slick-active": { + width: "16px", + backgroundColor: "rgba(255, 255, 255, 0.7)", + }, + "& li button": { + // visibility: "hidden", + opacity: "0", + padding: "0", + width: "8px", + height: "8px", + // backgroundColor: "transparent", + }, + }, +}; + +export default customCarouselStyle; diff --git a/src/components/CustomCarousel/CustomCarousel.js b/src/components/CustomCarousel/CustomCarousel.js new file mode 100644 index 000000000..b64abd7f2 --- /dev/null +++ b/src/components/CustomCarousel/CustomCarousel.js @@ -0,0 +1,162 @@ +// import _ from 'lodash'; +import React from "react"; +// import PropTypes from 'prop-types'; +// import ClassNames from 'classnames'; +import { makeStyles } from "@material-ui/core/styles"; +import Slider from "react-slick"; +import ElementResizeDetector from "element-resize-detector"; + +import ImgWePiggy from "assets/img/carousel/wepiggy.jpg"; +import ImgSFinance from "assets/img/carousel/sfinance.jpg"; +import ImgSakeSwap from "assets/img/carousel/sakeswap.jpg"; + +import styles from "assets/jss/material-kit-pro-react/components/customCarouselStyle.js"; + +const useStyles = makeStyles(styles); + +function useResize() { + const reSizer = React.useRef( + ElementResizeDetector({ + strategy: "scroll", // <- For ultra performance. + }) + ); + + const refDom = React.useRef(null); + + const [rect, setRect] = React.useState({ + x: 0, + y: 0, + width: 0, + height: 0, + top: 0, + right: 0, + bottom: 0, + left: 0, + }); + + React.useEffect(() => { + // console.log('Mount'); + return () => { + // console.log('unMount'); + const uninstall = reSizer.current.uninstall; + if (uninstall && refDom.current) { + uninstall(refDom.current); + } + + refDom.current = undefined; + reSizer.current = undefined; + }; + }, []); + + const ref = React.useCallback((dom) => { + const listenTo = reSizer.current.listenTo; + if (dom && listenTo) { + console.log("0000", dom); + refDom.current = dom; + listenTo(refDom.current, (element) => + setRect(element.getBoundingClientRect()) + ); + } + }, []); + + return [ref, rect]; +} + +function CustomCarousel(props) { + // const { } = props; + + const classes = useStyles(); + + const [ref, rect] = useResize(); + console.log(rect); + + const { width } = rect; + const height = width / (1200 / 300); + + const sliderProps = { + accessibility: true, + adaptiveHeight: true, + // afterChange: , + // appendDots: , + arrows: false, + // asNavFor: , + autoplaySpeed: 3000, + autoplay: true, + // beforeChange: , + // centerMode: true, + // centerPadding: "50px", + // customPaging: , + dotsClass: `slick-dots ${classes.dots}`, + dots: true, + draggable: true, + easing: "linear", + fade: false, + focusOnSelect: false, + infinite: true, + initialSlide: 0, + lazyLoad: true, + // onEdge: , + // onInit: , + // onLazyLoad: , + // onReInit: , + // onSwipe: , + // pauseOnDotsHover: , + // pauseOnFocus: , + // pauseOnHover: , + // responsive: , + rows: 1, + rtl: false, + slide: "div", + slidesPerRow: 1, + slidesToScroll: 1, + slidesToShow: 1, + speed: 500, + swipeToSlide: false, + swipe: true, + touchMove: true, + touchThreshold: 5, + useCSS: true, + useTransform: true, + variableWidth: false, + vertical: false, + }; + + return ( +
+ ); +} + +export default React.memo(CustomCarousel); diff --git a/src/features/liquidity/LiquidityPage.js b/src/features/liquidity/LiquidityPage.js index e9012017e..db2640401 100644 --- a/src/features/liquidity/LiquidityPage.js +++ b/src/features/liquidity/LiquidityPage.js @@ -1,12 +1,13 @@ -import React, { useEffect } from 'react'; -import { useTranslation } from 'react-i18next'; +import React, { useEffect } from "react"; +import { useTranslation } from "react-i18next"; // @material-ui/core components // @material-ui/icons // import Close from "@material-ui/icons/Close"; // core components // sections for this page -import { SectionTitle, SectionPools } from '.'; +import { SectionTitle, SectionPools } from "."; import SnackbarContent from "components/Snackbar/SnackbarContent.js"; +import CustomCarousel from "components/CustomCarousel/CustomCarousel.js"; // hooks export default function LiquidityPage() { @@ -19,15 +20,19 @@ export default function LiquidityPage() { <>