From 9bd4ff79ace32a66705494e1fc3f86ae1b5cf5d2 Mon Sep 17 00:00:00 2001 From: Emil Gulamov <125820963+mearashadowfax@users.noreply.github.com> Date: Sat, 30 Mar 2024 01:18:02 +0400 Subject: [PATCH] Add BrandLogo and LanguagePicker components Introduced two new components (BrandLogo and LanguagePicker) to the Navbar component. This refactor improves readability and maintainability of the code. Additionally, SVG icons are extracted into reusable components --- src/components/BrandLogo.astro | 61 ++++++++++++++++ src/components/sections/FooterSection.astro | 55 +------------- src/components/sections/Navbar.astro | 59 ++------------- src/components/ui/LanguagePicker.astro | 79 +++++++++++++++++++++ src/components/ui/icons/icons.ts | 15 ++++ src/components/ui/links/NavLink.astro | 43 ++++++----- src/utils/fr/navigation.ts | 2 +- src/utils/navigation.ts | 2 +- src/utils/ui.ts | 4 ++ 9 files changed, 193 insertions(+), 127 deletions(-) create mode 100644 src/components/BrandLogo.astro create mode 100644 src/components/ui/LanguagePicker.astro create mode 100644 src/utils/ui.ts diff --git a/src/components/BrandLogo.astro b/src/components/BrandLogo.astro new file mode 100644 index 0000000..3a65828 --- /dev/null +++ b/src/components/BrandLogo.astro @@ -0,0 +1,61 @@ +--- +const { width } = Astro.props; + +interface Props { + width: string; +} +--- + + + + + + + + + + diff --git a/src/components/sections/FooterSection.astro b/src/components/sections/FooterSection.astro index fddaf56..96fe575 100644 --- a/src/components/sections/FooterSection.astro +++ b/src/components/sections/FooterSection.astro @@ -5,6 +5,7 @@ import EmailFooterInput from "../ui/forms/input/EmailFooterInput.astro"; import enStrings from "@/utils/navigation.ts"; import frStrings from "@/utils/fr/navigation.ts"; import Icon from "../ui/icons/Icon.astro"; +import BrandLogo from "@/components/BrandLogo.astro"; import { SITE } from "@/data_files/constants"; // Select the correct translation based on the page's lang prop: @@ -24,59 +25,7 @@ const crafted: string = Astro.currentLocale === "fr" ? "Fabriqué par" : "Crafte
- - - - - - - - - +
{ diff --git a/src/components/sections/Navbar.astro b/src/components/sections/Navbar.astro index 4adadf0..babbf26 100644 --- a/src/components/sections/Navbar.astro +++ b/src/components/sections/Navbar.astro @@ -5,6 +5,8 @@ import NavLink from "../ui/links/NavLink.astro"; import Authentication from "./Authentication.astro"; import enStrings from "@/utils/navigation.ts"; import frStrings from "@/utils/fr/navigation.ts"; +import BrandLogo from "../BrandLogo.astro"; +import LanguagePicker from "../ui/LanguagePicker.astro"; // Select the correct translation based on the page's lang prop: const strings = Astro.currentLocale === "fr" ? frStrings : enStrings; @@ -27,59 +29,7 @@ const homeUrl = Astro.currentLocale === "fr" ? "/fr" : "/"; href={homeUrl} aria-label="Brand" > - - - - - - - - - +
@@ -133,7 +83,7 @@ const homeUrl = Astro.currentLocale === "fr" ? "/fr" : "/"; >
{strings.navBarLinks.map(link => ( @@ -141,6 +91,7 @@ const homeUrl = Astro.currentLocale === "fr" ? "/fr" : "/"; ))} +