Skip to content

Commit

Permalink
feat: minor optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHericles committed Jan 9, 2024
1 parent f02007e commit 1779e4d
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 99 deletions.
34 changes: 33 additions & 1 deletion components/nrf/Faq.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<details class="border-b first:border-t border-solid border-[#131614]">
<summary class="flex flex-row py-5 gap-[16px] group cursor-pointer">
<div class="flex-none pt-[6px]">
<Icon
class="text-white"
id="ChevronRight"
width={15}
height={15}
strokeWidth={"3"}
/>
</div>
<p class="font-normal not-italic text-[22px] leading-[1.3] text-white md:text-[32px] md:leading-[38.73px]">
{question}
</p>
</summary>
<p class="pl-[32px] pb-5 font-normal not-italic text-[16px] leading-[1.9] text-white md:text-[20px] md:leading-[30px]">
{answer}
</p>
</details>
);
}

export interface Props {
questions: Question[];
Expand Down
2 changes: 0 additions & 2 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
33 changes: 0 additions & 33 deletions islands/NRF/Faq.tsx

This file was deleted.

64 changes: 1 addition & 63 deletions islands/NRF/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { IS_BROWSER } from "https://deno.land/x/[email protected]/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 {
Expand All @@ -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 };
Expand Down Expand Up @@ -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 (
<section class="lg:container rounded-full bg-white/5 backdrop-blur-xl fixed top-2 lg:top-6 z-50 w-[calc(100vw-16px)] lg:w-full left-1/2 transform -translate-x-1/2 shadow-[0px_4px_16px_0px_rgba(0,0,0,0.10)]">
<nav class="flex flex-row gap-16 items-center h-[63px] pb-[2px] max-w-screen-2xl m-auto relative">
<ul class="h-full flex items-center">
<li class="h-full">
<a
class="flex items-center h-full pl-4 lg:pl-8 pb-[6px]"
href={currentLanguageLink}
>
<a class="flex items-center h-full pl-4 lg:pl-8 pb-[6px]" href="/">
<svg
xmlns="http://www.w3.org/2000/svg"
width="77"
Expand Down

0 comments on commit 1779e4d

Please sign in to comment.