From 04e8089294b4c365bc8a21558d732c2ca8ddcb52 Mon Sep 17 00:00:00 2001
From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com>
Date: Sun, 18 Feb 2024 07:39:17 +0400
Subject: [PATCH] Refactor several component files for improved maintainability
This commit refactors multiple component files for better understandability and maintainability. Detailed comments are added for enhanced readability. The data source is defined using Astro.js to simplify the process of acquiring data for the components. Unnecessary files like 'preline.js' from the vendor scripts directory are deleted as part of clean-up.
---
src/components/Authentication.astro | 9 ++-
src/components/ui/avatars/Avatar.astro | 2 +
src/components/ui/avatars/AvatarBlog.astro | 7 +-
.../ui/avatars/AvatarBlogLarge.astro | 20 +++--
...2.astro => AvatarTestimonialSection.astro} | 0
src/components/ui/blocks/AccordionItem.astro | 40 ++++++----
src/components/ui/buttons/AuthBtn.astro | 16 ++--
src/components/ui/buttons/Btn404.astro | 33 +++++----
src/components/ui/cards/CardBlog.astro | 13 +++-
src/components/ui/cards/CardBlogRecent.astro | 15 ++--
src/components/ui/cards/CardInsight.astro | 74 +++++++++++++------
src/components/ui/cards/CardRelated.astro | 11 ++-
src/components/ui/cards/CardSmall.astro | 15 ++--
src/components/ui/cards/CardWide.astro | 15 ++--
src/pages/404.astro | 18 +++--
src/pages/blog/[...slug].astro | 23 ++++--
src/pages/insights/[...slug].astro | 50 ++++++-------
src/pages/products/[...slug].astro | 37 +++++++---
18 files changed, 256 insertions(+), 142 deletions(-)
rename src/components/ui/avatars/{AvatarTestimonialSection2.astro => AvatarTestimonialSection.astro} (100%)
diff --git a/src/components/Authentication.astro b/src/components/Authentication.astro
index 7e0a8fd..69a9e79 100644
--- a/src/components/Authentication.astro
+++ b/src/components/Authentication.astro
@@ -1,15 +1,16 @@
---
-// Import the necessary dependencies from individual component files
+// Import the necessary components from their respective component files
import LoginModal from "./ui/forms/LoginModal.astro";
import RegisterModal from "./ui/forms/RegisterModal.astro";
import RecoverModal from "./ui/forms/RecoverModal.astro";
import LoginBtn from "./ui/buttons/LoginBtn.astro";
---
+
{content}
diff --git a/src/components/ui/buttons/AuthBtn.astro b/src/components/ui/buttons/AuthBtn.astro index 52cf9ce..7aad2a7 100644 --- a/src/components/ui/buttons/AuthBtn.astro +++ b/src/components/ui/buttons/AuthBtn.astro @@ -1,11 +1,14 @@ --- +// Destructure the properties from Astro.props const { title } = Astro.props; +// Define TypeScript interface for the properties interface Props { title: string; } - -const baseClasses = "inline-flex w-full items-center justify-center gap-x-2 rounded-lg px-4 py-3 text-sm font-bold text-neutral-700 focus-visible:ring outline-none transition duration-300"; +// Define CSS classes for styling the button +const baseClasses = + "inline-flex w-full items-center justify-center gap-x-2 rounded-lg px-4 py-3 text-sm font-bold text-neutral-700 focus-visible:ring outline-none transition duration-300"; const borderClasses = "border border-transparent"; const bgColorClasses = "bg-yellow-400 dark:focus:outline-none"; const hoverClasses = "hover:bg-yellow-500"; @@ -13,7 +16,10 @@ const fontSizeClasses = "2xl:text-base"; const disabledClasses = "disabled:pointer-events-none disabled:opacity-50"; const ringClasses = "ring-zinc-500 dark:ring-zinc-200"; --- + + \ No newline at end of file + type="submit" + class={`${baseClasses} ${borderClasses} ${bgColorClasses} ${hoverClasses} ${fontSizeClasses} ${disabledClasses} ${ringClasses}`} + >{title} diff --git a/src/components/ui/buttons/Btn404.astro b/src/components/ui/buttons/Btn404.astro index dc46d43..8026ef4 100644 --- a/src/components/ui/buttons/Btn404.astro +++ b/src/components/ui/buttons/Btn404.astro @@ -1,18 +1,22 @@ --- +// Destructure the properties from Astro.props const { title, id, noArrow } = Astro.props; - +// Define TypeScript interface for the properties interface Props { - title?: string; - id?: string; - noArrow?: boolean; + title?: string; + id?: string; + noArrow?: boolean; } - -const baseClasses = "group inline-flex items-center justify-center gap-x-2 rounded-lg px-4 py-3 text-sm font-bold text-neutral-50 ring-zinc-500 transition duration-300 focus-visible:ring outline-none"; +// Define CSS classes for styling the button +const baseClasses = + "group inline-flex items-center justify-center gap-x-2 rounded-lg px-4 py-3 text-sm font-bold text-neutral-50 ring-zinc-500 transition duration-300 focus-visible:ring outline-none"; const borderClasses = "border border-transparent"; -const bgColorClasses = "bg-[#fa5a15] hover:bg-[#e14d0b] active:bg-[#e14d0b] dark:focus:outline-none"; +const bgColorClasses = + "bg-[#fa5a15] hover:bg-[#e14d0b] active:bg-[#e14d0b] dark:focus:outline-none"; const disableClasses = "disabled:pointer-events-none disabled:opacity-50"; const fontSizeClasses = "2xl:text-base"; const ringClasses = "dark:ring-zinc-200"; +// SVG for an arrow icon const arrowSVG = `