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" : "/";
))}
+
diff --git a/src/components/ui/LanguagePicker.astro b/src/components/ui/LanguagePicker.astro
new file mode 100644
index 0000000..8a78cb7
--- /dev/null
+++ b/src/components/ui/LanguagePicker.astro
@@ -0,0 +1,79 @@
+---
+import { languages } from "@/utils//ui";
+import Icon from "./icons/Icon.astro";
+---
+
+
+
+
+
+ {
+ Object.entries(languages).map(([lang, label]) => (
+
+ {label}
+
+ ))
+ }
+
+
+
+
+
+
+
+
diff --git a/src/components/ui/icons/icons.ts b/src/components/ui/icons/icons.ts
index 5669891..8e55dd0 100644
--- a/src/components/ui/icons/icons.ts
+++ b/src/components/ui/icons/icons.ts
@@ -406,4 +406,19 @@ export const Icons = {
strokeLinejoin: "round",
stroke: "currentColor",
},
+ earth: {
+ paths: [
+ {
+ d: "m20.893 13.393-1.135-1.135a2.252 2.252 0 0 1-.421-.585l-1.08-2.16a.414.414 0 0 0-.663-.107.827.827 0 0 1-.812.21l-1.273-.363a.89.89 0 0 0-.738 1.595l.587.39c.59.395.674 1.23.172 1.732l-.2.2c-.212.212-.33.498-.33.796v.41c0 .409-.11.809-.32 1.158l-1.315 2.191a2.11 2.11 0 0 1-1.81 1.025 1.055 1.055 0 0 1-1.055-1.055v-1.172c0-.92-.56-1.747-1.414-2.089l-.655-.261a2.25 2.25 0 0 1-1.383-2.46l.007-.042a2.25 2.25 0 0 1 .29-.787l.09-.15a2.25 2.25 0 0 1 2.37-1.048l1.178.236a1.125 1.125 0 0 0 1.302-.795l.208-.73a1.125 1.125 0 0 0-.578-1.315l-.665-.332-.091.091a2.25 2.25 0 0 1-1.591.659h-.18c-.249 0-.487.1-.662.274a.931.931 0 0 1-1.458-1.137l1.411-2.353a2.25 2.25 0 0 0 .286-.76m11.928 9.869A9 9 0 0 0 8.965 3.525m11.928 9.868A9 9 0 1 1 8.965 3.525",
+ },
+ ],
+ class:
+ "w-4 h-4 flex-shrink-0",
+ viewBox: "0 0 24 24",
+ fill: "none",
+ strokeWidth: "1.5",
+ strokeLinecap: "round",
+ strokeLinejoin: "round",
+ stroke: "currentColor",
+ },
};
diff --git a/src/components/ui/links/NavLink.astro b/src/components/ui/links/NavLink.astro
index dc17b0c..e1c5411 100644
--- a/src/components/ui/links/NavLink.astro
+++ b/src/components/ui/links/NavLink.astro
@@ -16,7 +16,7 @@ We assign an ID matching the URL for easy reference in our script.
If URL is '/' (home page), assign ID as 'home'
-->
diff --git a/src/utils/fr/navigation.ts b/src/utils/fr/navigation.ts
index df1086e..06ae24b 100644
--- a/src/utils/fr/navigation.ts
+++ b/src/utils/fr/navigation.ts
@@ -20,7 +20,7 @@ const footerLinks = [
section: "Société",
links: [
{ name: "À propos de nous", url: "#" },
- { name: "Blog", url: "#" },
+ { name: "Blog", url: "/fr/blog" },
{ name: "Carrières", url: "#" },
{ name: "Clients", url: "#" },
],
diff --git a/src/utils/navigation.ts b/src/utils/navigation.ts
index d324f9b..3124a97 100644
--- a/src/utils/navigation.ts
+++ b/src/utils/navigation.ts
@@ -20,7 +20,7 @@ const footerLinks = [
section: "Company",
links: [
{ name: "About us", url: "#" },
- { name: "Blog", url: "#" },
+ { name: "Blog", url: "/blog" },
{ name: "Careers", url: "#" },
{ name: "Customers", url: "#" },
],
diff --git a/src/utils/ui.ts b/src/utils/ui.ts
new file mode 100644
index 0000000..ba9ba6a
--- /dev/null
+++ b/src/utils/ui.ts
@@ -0,0 +1,4 @@
+export const languages = {
+ en: "English",
+ fr: "Français",
+};
\ No newline at end of file