From 7821ef382ac4e6a1c101d60a22bd1464b343708e Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Fri, 22 Mar 2024 04:43:19 +0400 Subject: [PATCH] Refactor features section to use flexible data and Icon components Refactored the features section of the website to use externally-defined data alongside reusable Icon components. Now, tabs and feature blocks' content is dictated by passed-in props, improving the modularity and adaptability of the code. Individual SVG icons are also now handled by a single Icon component, simplifying the codebase and enhancing maintainability. --- .../sections/features/FeaturesGeneral.astro | 123 ++++++----------- .../sections/features/FeaturesNavs.astro | 129 +++++++----------- 2 files changed, 87 insertions(+), 165 deletions(-) diff --git a/src/components/sections/features/FeaturesGeneral.astro b/src/components/sections/features/FeaturesGeneral.astro index 8551372..be4c6d2 100644 --- a/src/components/sections/features/FeaturesGeneral.astro +++ b/src/components/sections/features/FeaturesGeneral.astro @@ -1,13 +1,24 @@ --- // Import the necessary dependencies import { Image } from "astro:assets"; -import featureImage from "../../../images/features-image.avif"; import IconBlock from "../../ui/blocks/IconBlock.astro"; +import Icon from "../../ui/icons/Icon.astro"; -// Define the string variables `title` and `subTitle` for the main heading and sub-heading text -const title: string = "Meeting Industry Demands"; -const subTitle: string = - "At ScrewFast, we tackle the unique challenges encountered in the hardware and construction sectors. From cutting-edge tools to expert services, we're dedicated to helping you overcome obstacles and achieve your goals."; +interface Feature { + heading: string; + content: string; + svg: string; +} + +interface Props { + title?: string; + subTitle?: string; + features?: Feature[]; + src?: any; + alt?: string; +} +// Define props from Astro +const { title, subTitle, src, alt, features } = Astro.props; ---
- ScrewFast products in floating boxes + { + src && alt && ( + {alt} + ) + }
@@ -36,12 +51,12 @@ const subTitle: string = {title} - {subTitle && -

- {subTitle} -

+ { + subTitle && ( +

+ {subTitle} +

+ ) } @@ -49,69 +64,13 @@ const subTitle: string =
- - - - - - - - - - - - - - - - - - - + { features && + features.map((feature) => ( + + + + )) + }
diff --git a/src/components/sections/features/FeaturesNavs.astro b/src/components/sections/features/FeaturesNavs.astro index 3793548..96c215a 100644 --- a/src/components/sections/features/FeaturesNavs.astro +++ b/src/components/sections/features/FeaturesNavs.astro @@ -2,12 +2,27 @@ // Import the necessary dependencies import TabNav from "../../ui/blocks/TabNav.astro"; import TabContent from "../../ui/blocks/TabContent.astro"; -import construction from "../../../images/construction-image.avif"; -import tools from "../../../images/automated-tools.avif"; -import dashboard from "../../../images/dashboard-image.avif"; +import Icon from "../../ui/icons/Icon.astro"; -// Define the variable for the section's heading -const title: string = `Customize ScrewFast's offerings to perfectly suit your hardware and construction needs.`; +// Define props from Astro +const { title, tabs } = Astro.props; + +// Define TypeScript interface for tab object +interface Tab { + heading: string; + content: string; + svg: string; + src: any; + alt: string; + first?: boolean; + second?: boolean; +} + +// Define TypeScript interface for props +interface Props { + title?: string; + tabs: Tab[]; +} ---