Skip to content

Commit 539ecdb

Browse files
committed
seperate types and interfaces
1 parent 0520d4f commit 539ecdb

File tree

4 files changed

+39
-33
lines changed

4 files changed

+39
-33
lines changed

src/components/Home/FeaturesAndBenefitsSection.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
import { SecondaryFeature } from "@/interfaces/HomePage";
12
import { Box, Card, CardContent, Container, Grid, Typography } from "@mui/material";
23
import { Blocks, BookOpen, Clock7, Link, LockKeyholeOpen, PencilRuler, Star, UsersRound } from "lucide-react";
34
import { useMemo } from "react";
45
import { useTranslation } from "react-i18next";
56

6-
type Feature = {
7-
Icon: React.ElementType;
8-
title: string;
9-
description: string;
10-
}
7+
118

129
export const HeadingAndDescription = ({ heading, description }: { heading: string; description: string }) => (
1310
<Box>
@@ -28,7 +25,7 @@ export const HeadingAndDescription = ({ heading, description }: { heading: strin
2825
</Box>
2926
);
3027

31-
const FeatureCard = ({ item }: { item: Feature }) => (
28+
const FeatureCard = ({ item }: { item: SecondaryFeature }) => (
3229
<Grid item xs={12} sm={6} md={3}>
3330
<Card sx={cardStyles}>
3431
<Box sx={iconWrapperStyles}>
@@ -51,7 +48,7 @@ export default function FeaturesAndBenefitsSection() {
5148

5249
const items = useMemo(() => {
5350
const icons = [BookOpen, LockKeyholeOpen, UsersRound, Star, Link, PencilRuler, Blocks, Clock7];
54-
const itemsTexts = t("features_section.features", { returnObjects: true }) as Feature[];
51+
const itemsTexts = t("features_section.features", { returnObjects: true }) as SecondaryFeature[];
5552
return icons.map((Icon, index) => ({ Icon, ...itemsTexts[index] }));
5653
}, [t]);
5754

src/components/Home/FeaturesAtGlance.tsx

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
11
import useIsDesktop from "@/hooks/useIsDesktop";
2+
import { FeatureItemProps, PrimaryFeature } from "@/interfaces/HomePage";
23
import { Box, Button, IconButton, Typography } from "@mui/material";
34
import { ArrowRight, Blocks, PaletteIcon, SparkleIcon, Sun } from "lucide-react";
45
import { FC, useState } from "react";
56
import { HeadingAndDescription } from "./FeaturesAndBenefitsSection";
67

7-
// Feature structure
8-
type Feature = {
9-
icon: JSX.Element;
10-
heading: string;
11-
description: string;
12-
actionText: string;
13-
}
148

159
// Feature list
16-
const features: Feature[] = [
10+
const features: PrimaryFeature[] = [
1711
{ icon: <Sun />, heading: "Dark/light mode toggle", description: "Easily fit your chatbot to common dark or light color themes", actionText: "Try it" },
1812
{ icon: <PaletteIcon />, heading: "Premade themes", description: "A growing selection of premade, free-to-use themes", actionText: "Swap theme" },
1913
{ icon: <Blocks />, heading: "Added functionality with plugins", description: "Easily implement additional features with plugins", actionText: "See example" },
@@ -45,11 +39,7 @@ const actionButtonStyles = {
4539
gap: 1
4640
};
4741

48-
// Props for FeatureItem components
49-
type FeatureItemProps = {
50-
onClick: () => void;
51-
selected: boolean;
52-
} & Feature
42+
5343

5444
// Desktop Feature Item
5545
const FeatureItem: FC<FeatureItemProps> = ({ icon, heading, description, actionText, onClick, selected }) => (

src/components/Home/TestimonialSection.tsx

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,10 @@
11
import useIsDesktop from "@/hooks/useIsDesktop";
2+
import { Testimonial, TestimonialCardProps } from "@/interfaces/HomePage";
23
import { Avatar, Box, Typography } from "@mui/material";
34
import Carousel from "react-multi-carousel";
45
import "react-multi-carousel/lib/styles.css";
56
import { HeadingAndDescription } from "./FeaturesAndBenefitsSection";
67

7-
type Testimonial = {
8-
avatar: string;
9-
name: string;
10-
username: string;
11-
text: string;
12-
}
13-
14-
type TestimonialCardProps = {
15-
avatar: string;
16-
name: string;
17-
username: string;
18-
text: string;
19-
}
208

219
const responsive = {
2210
superLargeDesktop: {

src/interfaces/HomePage.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
export type Testimonial = {
2+
avatar: string;
3+
name: string;
4+
username: string;
5+
text: string;
6+
}
7+
8+
export type TestimonialCardProps = {
9+
avatar: string;
10+
name: string;
11+
username: string;
12+
text: string;
13+
}
14+
15+
export interface PrimaryFeature {
16+
icon: JSX.Element;
17+
heading: string;
18+
description: string;
19+
actionText: string;
20+
}
21+
22+
export type FeatureItemProps = {
23+
onClick: () => void;
24+
selected: boolean;
25+
} & PrimaryFeature
26+
27+
export interface SecondaryFeature {
28+
Icon: React.ElementType;
29+
title: string;
30+
description: string;
31+
}

0 commit comments

Comments
 (0)