diff --git a/src/components/Card.tsx b/src/components/Card.tsx index 11089f8..49818fc 100644 --- a/src/components/Card.tsx +++ b/src/components/Card.tsx @@ -1,5 +1,5 @@ -import React, { Children } from "react"; import classNames from "classnames"; +import React from "react"; /* -------------------------------------------------------------------------- */ /* Components */ @@ -27,7 +27,7 @@ const Card = ({ children, className }: Props) => {
{children} @@ -35,69 +35,71 @@ const Card = ({ children, className }: Props) => { ); }; -// Avatar props and function +// Avatar function type AvatarProps = { children?: React.ReactNode; }; Card.Avatar = function CardAvatar({ children }: AvatarProps) { - return <>{children}; + return
{children}
; }; -// The end of Body props and function -// Title props and function +// Title function Card.Title = function CardTitle({ children, className }: Props) { return ( - + {children} ); }; -// The end Title props and function -// Body props and function +// SubTitle function +Card.SubTitle = function CardSubTitle({ children, className }: Props) { + return ( + {children} + ); +}; + +// Body function Card.Body = function CardTitle({ children, className }: Props) { return ( - {children} ); }; -// The end of Body props and function -// Cardheader props and function -Card.Cardheader = function CardCardheader({ children, className }: Props) { +// Cardheader function +Card.CardHeader = function CardCardHeader({ children, className }: Props) { return ( -
+
{children}
); }; -// The end of Cardheader props and function -// Cardcontent props and function -Card.Cardcontent = function CardCardcontent({ children, className }: Props) { +// Cardcontent function +Card.CardContent = function CardCardContent({ children, className }: Props) { return ( -
+
{children}
); }; -// The end of Cardcontent props and function -// Cardaction props and function -type CardactionProps = { +// Cardaction function +type CardActionProps = { children: React.ReactNode; className?: string | undefined; href?: string; }; -Card.Cardaction = function CardCardaction({ +Card.CardAction = function CardCardAction({ children, className, href = "#", -}: CardactionProps) { +}: CardActionProps) { return ( ); }; -// The end of Cardaction props and function + +// CardMedia function +type CardMediaProps = { + children?: React.ReactNode; + className?: string | undefined; + src?: string; +}; +Card.CardMedia = function CardCardMedia({ + className, + src = "#", +}: CardMediaProps) { + return ( + + ); +}; export default Card; diff --git a/src/components/FeaturedArticales.tsx b/src/components/FeaturedArticales.tsx new file mode 100644 index 0000000..37eaef6 --- /dev/null +++ b/src/components/FeaturedArticales.tsx @@ -0,0 +1,188 @@ +import { useRef } from "react"; + +/* -------------------------------------------------------------------------- */ +/* Skeleton */ +/* -------------------------------------------------------------------------- */ +import "react-loading-skeleton/dist/skeleton.css"; + +/* -------------------------------------------------------------------------- */ +/* Components */ +/* -------------------------------------------------------------------------- */ +import Typography from "./typography/Typography"; +import SkeletonCard from "./SkeletonCard"; +import AspectRatio from "./AspectRatio"; +import Card from "./Card"; +import Link from "./Link"; + +/* -------------------------------------------------------------------------- */ +/* Data */ +/* -------------------------------------------------------------------------- */ +import Articales from "./Articales.json"; + +/* -------------------------------------------------------------------------- */ +/* Icons */ +/* -------------------------------------------------------------------------- */ +import { ReactComponent as SVGArrowRight } from "assets/svg/arrow-right.svg"; +import { ReactComponent as SVGCaretRight } from "assets/svg/caret-right.svg"; +import { ReactComponent as SVGArrowLeft } from "assets/svg/arrow-left.svg"; + +/* -------------------------------------------------------------------------- */ +/* Swiper */ +/* -------------------------------------------------------------------------- */ +import { Swiper, SwiperSlide } from "swiper/react"; +import SwiperCore, { Navigation } from "swiper"; +import { Pagination } from "swiper"; +import "swiper/css/pagination"; +import "swiper/css/navigation"; +import "./styles.css"; +import "swiper/css"; + +/* -------------------------------------------------------------------------- */ +/* How many Skeleton cards should be added to the design */ +/* -------------------------------------------------------------------------- */ +let twoCards: boolean = false; +let threeCards: boolean = false; +console.log(`Number of cards ${Articales.length}`); +if (Articales.length == 2) { + twoCards = true; +} else if (Articales.length == 3) { + threeCards = true; +} + +SwiperCore.use([Navigation]); + +const FeaturedArticales = () => { + const navigationPrevRef = useRef(null); + const navigationNextRef = useRef(null); + const paginationRef = useRef(null); + + return ( +
+
+
+ +
+
+ +
+
+ + 4 ? true : false} + pagination={{ el: ".pagination", clickable: true }} + navigation={{ + prevEl: ".prev", + nextEl: ".next", + }} + breakpoints={{ + 768: { + slidesPerView: 2, + slidesPerGroup: 2, + }, + 1024: { + slidesPerView: 2, + slidesPerGroup: 2, + }, + 1280: { + slidesPerView: 4, + slidesPerGroup: 4, + }, + 1580: { + slidesPerView: 4, + slidesPerGroup: 4, + }, + }} + spaceBetween={25} + loopFillGroupWithBlank={true} + modules={[Pagination, Navigation]} + > + {Articales.map((Articale) => ( + + + + + + + + + + + {Articale.Body} + + + + + + + Read More + + + + + + + ))} + + {twoCards && [ + + + + + + + + + + + , + + + + + + + + + + + + , + ]} + + {threeCards && [ + + + + + + + + + + + , + ]} + + +
+
+ ); +}; + +export default FeaturedArticales;