import React, { useState } from 'react'; import styled from 'styled-components'; // @ts-ignore import CrossfadeImage from 'react-crossfade-image'; import { ProductCell } from '@Components/Product'; import Button from '@Components/Button'; import { VerticalHeading, H4, Label } from '@Typography'; import { dim } from '@dim'; import { mq } from '@tokensDir/media-query'; import * as tokens from '@tokens'; import { NavListProps, ComponentProps } from './interface'; import { ProductInterace } from '@Components/Product/interface'; const TRANSITION = '500'; const getArrowPosition = ({ activeTab, itemCount }: NavListProps) => { // Get height of one item; let stepGapPercent = 100 / itemCount; // Calculate position of active item let activeIndexPosition: number = activeTab * stepGapPercent; // Knock the positon back by half activeIndexPosition = activeIndexPosition - stepGapPercent / 2; // minus 1/4 of the heigh of the arrow to componsate activeIndexPosition = activeIndexPosition - 4; return activeIndexPosition; }; const StyledSection = styled.section` margin: ${dim(3)} auto; border-top: 1px solid ${tokens.colorGrey15}; border-bottom: 1px solid ${tokens.colorGrey15}; `; const VerticalTitle = styled(VerticalHeading)` grid-area: title; margin: ${dim(3)} auto; text-align: center; ${mq.sm` text-align: unset; `} ${mq.md` text-align: left; margin: ${dim(3)} 0; `} ${mq.lg` text-align: right; `} `; const CarouselSection = styled.div` display: grid; grid-template-areas: 'title title title' 'nav lifestyle lifestyle' 'product product product'; ${mq.md` grid-template-areas: 'title title title title' 'nav nav nav nav' 'lifestyle lifestyle product product' `}; ${mq.lg` grid-template-areas: 'title nav nav lifestyle lifestyle lifestyle lifestyle product product product product' `}; `; const ProductSection = styled.div` grid-area: product; padding: ${dim(5)} 0; text-align: center; width: 100%; ${mq.md` padding: ${dim(6)} 0; `} `; const Nav = styled.nav` grid-area: nav; `; const NavList = styled.ul` padding: 0; margin: 0; display: flex; flex-direction: column; justify-content: space-around; height: 100%; position: relative; ${mq.md` flex-direction: row; border-top: 1px solid ${tokens.colorGrey15}; border-bottom: 1px solid ${tokens.colorGrey15}; margin-bottom: ${dim(2)}; `} ${mq.lg` flex-direction: column; padding: 0 ${dim(2)}; border-left: 1px solid ${tokens.colorGrey15}; border-right: 1px solid ${tokens.colorGrey15}; border-top: none; border-bottom: none; margin: ${dim(2)}; `} &:after { content: ''; position: absolute; right: ${dim(-2)}; width: 0; height: 0; border-top: ${dim(2)} solid transparent; border-bottom: ${dim(2)} solid transparent; border-left: ${dim(2)} solid ${tokens.colorWhite}; clear: both; transition: all ease-out ${TRANSITION}ms; z-index: 1; ${(props: NavListProps) => `top: ${getArrowPosition(props)}%`}; ${mq.md` content: none; `} ${mq.lg` content: ''; right: ${dim(-4)}; `} } `; const NavItemLabel = styled(Label)` transition: color ease-out ${TRANSITION}ms; color: ${({ activeTab }: { activeTab: boolean }) => activeTab ? tokens.colorBlack : tokens.colorGrey40}; ${mq.md` width: 100%; `} `; const NavItem = styled.li` display: inline-flex; text-align: center; margin-right: ${dim(2)}; min-width: ${dim(14)}; align-items: center; height: 100%; &:hover { cursor: pointer; ${NavItemLabel} { color: ${tokens.colorPink}; } } & + & { border-top: 1px solid ${tokens.colorGrey15}; ${mq.md` border-top: none; border-left: 1px solid ${tokens.colorGrey15}; `} ${mq.lg` border-left: none; border-top: 1px solid ${tokens.colorGrey15}; `} } ${mq.md` margin: ${dim(2)} 0; padding: ${dim(5)} 0; width: 100%; text-align: center; `} `; const StyledButton = styled(Button)` margin-top: ${dim(5)}; `; const LifestyleImage = styled.aside` grid-area: lifestyle; ${mq.lg` margin: ${dim(4)} 0; `} `; const StoryProductCollection: React.FC = ({ products = [] }) => { const [activeTab, setActiveTab] = useState(1); const activeProduct = products[activeTab - 1]; const { name, lifestyle } = activeProduct; return (

Module Title

Shop Here
); }; export default StoryProductCollection;