From 1779e4d1c5fb7465106a57d32ff8792c7705b2a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ricles=20Emanuel?= Date: Tue, 9 Jan 2024 02:58:52 -0300 Subject: [PATCH] feat: minor optimization --- components/nrf/Faq.tsx | 34 +++++++++++++++++++++- fresh.gen.ts | 2 -- islands/NRF/Faq.tsx | 33 ---------------------- islands/NRF/Header.tsx | 64 +----------------------------------------- 4 files changed, 34 insertions(+), 99 deletions(-) delete mode 100644 islands/NRF/Faq.tsx diff --git a/components/nrf/Faq.tsx b/components/nrf/Faq.tsx index dc5c42e8..dc578007 100644 --- a/components/nrf/Faq.tsx +++ b/components/nrf/Faq.tsx @@ -1,4 +1,36 @@ -import { FaqItem, Question } from "deco-sites/starting/islands/NRF/Faq.tsx"; +import Icon from "deco-sites/starting/components/ui/Icon.tsx"; + +export interface Question { + question: string; + /** + * @format textarea + */ + answer: string; +} + +export function FaqItem({ question, answer }: Question) { + return ( +
+ +
+ +
+

+ {question} +

+
+

+ {answer} +

+
+ ); +} export interface Props { questions: Question[]; diff --git a/fresh.gen.ts b/fresh.gen.ts index 887b01c8..87223b16 100644 --- a/fresh.gen.ts +++ b/fresh.gen.ts @@ -28,7 +28,6 @@ import * as $LiveProjects from "./islands/LiveProjects.tsx"; import * as $NRF_BackgroundGrid from "./islands/NRF/BackgroundGrid.tsx"; import * as $NRF_Editor from "./islands/NRF/Editor.tsx"; import * as $NRF_EditorMobile from "./islands/NRF/EditorMobile.tsx"; -import * as $NRF_Faq from "./islands/NRF/Faq.tsx"; import * as $NRF_Features from "./islands/NRF/Features.tsx"; import * as $NRF_FeaturesWithImage from "./islands/NRF/FeaturesWithImage.tsx"; import * as $NRF_Header from "./islands/NRF/Header.tsx"; @@ -74,7 +73,6 @@ const manifest = { "./islands/NRF/BackgroundGrid.tsx": $NRF_BackgroundGrid, "./islands/NRF/Editor.tsx": $NRF_Editor, "./islands/NRF/EditorMobile.tsx": $NRF_EditorMobile, - "./islands/NRF/Faq.tsx": $NRF_Faq, "./islands/NRF/Features.tsx": $NRF_Features, "./islands/NRF/FeaturesWithImage.tsx": $NRF_FeaturesWithImage, "./islands/NRF/Header.tsx": $NRF_Header, diff --git a/islands/NRF/Faq.tsx b/islands/NRF/Faq.tsx deleted file mode 100644 index b37b9bc0..00000000 --- a/islands/NRF/Faq.tsx +++ /dev/null @@ -1,33 +0,0 @@ -import Icon from "deco-sites/starting/components/ui/Icon.tsx"; - -export interface Question { - question: string; - /** - * @format textarea - */ - answer: string; -} - -export function FaqItem({ question, answer }: Question) { - return ( -
- -
- -
-

- {question} -

-
-

- {answer} -

-
- ); -} diff --git a/islands/NRF/Header.tsx b/islands/NRF/Header.tsx index 5364a3ef..128e9545 100644 --- a/islands/NRF/Header.tsx +++ b/islands/NRF/Header.tsx @@ -1,7 +1,5 @@ -import { IS_BROWSER } from "https://deno.land/x/fresh@1.1.4/src/runtime/utils.ts"; import { useSignal } from "@preact/signals"; import { useState } from "preact/hooks"; -import { useId } from "deco-sites/starting/sdk/useId.ts"; import { Dropdown } from "deco-sites/starting/components/nrf/Dropdown.tsx"; export interface Alert { @@ -22,11 +20,7 @@ export interface Props { }; menuLinks: MenuLink[]; idiom: string; - pt: { label: string; url: string; selected?: boolean }; - eng: { label: string; url: string; selected?: boolean }; pageInitial: string; - mkt?: { label: string; url: string; selected?: boolean }; - dev?: { label: string; url: string; selected?: boolean }; demo?: { label: string; url: string }; login: { label: string; url: string }; sign: { label: string; url: string }; @@ -112,69 +106,13 @@ function MenuLink({ href, label, targetBlank, nested, ...props }: MenuLink) { export default function Header(props: Props) { const [open, setOpen] = useState(false); - const urlPortuguese = useSignal(""); - const urlEnglish = useSignal(""); - const urlMarketers = useSignal(""); - const urlDevelopers = useSignal(""); - const showSwitcher = useSignal(false); - const openSwitcher = useSignal(false); - const openLanguage = useSignal(false); - - const currentLanguageLink = props.eng.selected ? "/en" : "/pt"; - - if (IS_BROWSER) { - urlPortuguese.value = window.location.pathname.replace("en", "pt"); - urlEnglish.value = window.location.pathname.replace("pt", "en"); - - const urlPage = window.location.pathname; - - urlMarketers.value = urlPage.includes("en") ? "/en" : "/pt"; - urlDevelopers.value = urlPage.includes("en") ? "/en/dev" : "/pt/dev"; - - if (urlPage.includes("dev") && props.mkt && props.dev) { - props.pageInitial = urlPage.includes("en") - ? "for developers" - : "para desenvolvedores"; - props.mkt.selected = false; - props.dev.selected = true; - } - - const homePageHas = ["/en", "/pt", "/en/dev", "/pt/dev"]; - - if (homePageHas.includes(urlPage)) { - showSwitcher.value = true; - } - } - - const handleMenu = () => { - if (openSwitcher.value == false) { - openSwitcher.value = true; - } else { - openSwitcher.value = false; - } - }; - - const handleLanguage = () => { - if (openLanguage.value == false) { - openLanguage.value = true; - } else { - openLanguage.value = false; - } - }; - - const idMobile = useId(); - const idDesktop = useId(); - const alerts = props.alerts; return (