Skip to content

Commit

Permalink
Refactor: Splide interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchayan721 committed Sep 8, 2023
1 parent 6237604 commit 707c439
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 29 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,10 @@
import { CarouselData } from "@components/Carousel/carouselData";
import { CarouselCardProps } from "@interfaces/CardProps";
import { CarouselCardProps, CarouselDataCardProps } from "@interfaces/CardProps";
import { Card, Typography, alpha, styled } from "@mui/material";
import { navbar } from "@theme/constants";
import React from "react";
import ProgressBar from "./ProgressBar";
import { SplideInstance } from "../..";

interface CarouselDataCardProps extends CarouselCardProps {
link: CarouselData['link'];
tagline: CarouselData['tagline'];
title: CarouselData['title'];
description: CarouselData['description'];
pauseTime: CarouselData['pauseTime'];
splide?: SplideInstance | null;
};

const Tagline = styled(Typography)(({ theme }) => ({
color: theme.palette.text.secondary,
Expand Down
6 changes: 1 addition & 5 deletions src/components/Carousel/DynamicSlides/UnitSlide/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CarouselData } from '../../carouselData';
import { styled } from '@mui/material';
import { SplideSlide } from '@splidejs/react-splide';
import CarouselDataCard from './CarouselDataCard';
import { SplideInstance } from '..';
import { UnitSlideProps } from '@interfaces/SplideInterface';


const StyledImage = styled(Image)(({ theme }) => ({
Expand All @@ -13,10 +13,6 @@ const StyledImage = styled(Image)(({ theme }) => ({
objectFit: 'cover',
}));

interface UnitSlideProps extends CarouselData {
splide: SplideInstance | null;
};

const UnitSlide: React.FC<UnitSlideProps> = ({
image,
tagline,
Expand Down
15 changes: 1 addition & 14 deletions src/components/Carousel/DynamicSlides/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,7 @@ import { Splide, SplideProps, SplideTrack } from '@splidejs/react-splide';
import '@splidejs/splide/dist/css/themes/splide-default.min.css';
import ProgressBarPlaceholder from './ProgressBarPlaceholder';
import theme from '@theme/index';

export interface SplideInstance {
index: number;
length: number;
Components: {
Autoplay: {
pause: () => void;
play: () => void;
mount: () => void;
isPaused: () => boolean;
destroy: () => void;
}
}
};
import { SplideInstance } from '@interfaces/SplideInterface';

const options: SplideProps["options"] = {
type: 'loop',
Expand Down
11 changes: 11 additions & 0 deletions src/interfaces/CardProps.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { CarouselData } from '@components/Carousel/carouselData';
import { CardProps as MuiCardProps } from '@mui/material';
import { SplideInstance } from './SplideInterface';

export interface CardProps extends MuiCardProps {
component?: React.ElementType;
Expand All @@ -24,4 +26,13 @@ export interface ThemeChangerWrapperProps extends CardProps {
export interface CarouselCardProps extends CardProps {
elevation?: number;
active?: boolean;
};

export interface CarouselDataCardProps extends CarouselCardProps {
link: CarouselData['link'];
tagline: CarouselData['tagline'];
title: CarouselData['title'];
description: CarouselData['description'];
pauseTime: CarouselData['pauseTime'];
splide?: SplideInstance | null;
};
19 changes: 19 additions & 0 deletions src/interfaces/SplideInterface.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { CarouselData } from "@components/Carousel/carouselData";

export interface SplideInstance {
index: number;
length: number;
Components: {
Autoplay: {
pause: () => void;
play: () => void;
mount: () => void;
isPaused: () => boolean;
destroy: () => void;
}
}
};

export interface UnitSlideProps extends CarouselData {
splide: SplideInstance | null;
};

0 comments on commit 707c439

Please sign in to comment.