Skip to content

Commit

Permalink
feat: editor tabbed
Browse files Browse the repository at this point in the history
  • Loading branch information
0xHericles committed Jan 5, 2024
1 parent 7b7e35a commit 958725d
Show file tree
Hide file tree
Showing 13 changed files with 7,992 additions and 292 deletions.
871 changes: 871 additions & 0 deletions components/nrf/hero/FullCodeEditor.tsx

Large diffs are not rendered by default.

1,733 changes: 1,733 additions & 0 deletions components/nrf/hero/Monitoring.tsx

Large diffs are not rendered by default.

2,108 changes: 2,108 additions & 0 deletions components/nrf/hero/NoCodeEditor.tsx

Large diffs are not rendered by default.

2,876 changes: 2,876 additions & 0 deletions components/nrf/hero/SectionLibrary.tsx

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions fresh.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import * as $NRF_Faq from "./islands/NRF/Faq.tsx";
import * as $NRF_Features from "./islands/NRF/Features.tsx";
import * as $NRF_Header from "./islands/NRF/Header.tsx";
import * as $NRF_HeroEditor from "./islands/NRF/HeroEditor.tsx";
import * as $NRF_HeroEditorTabbed from "./islands/NRF/HeroEditorTabbed.tsx";
import * as $NRF_PageWrapper from "./islands/NRF/PageWrapper.tsx";
import * as $NRF_TextLines from "./islands/NRF/TextLines.tsx";
import * as $OnThisPage from "./islands/OnThisPage.tsx";
Expand Down Expand Up @@ -77,6 +78,7 @@ const manifest = {
"./islands/NRF/Features.tsx": $NRF_Features,
"./islands/NRF/Header.tsx": $NRF_Header,
"./islands/NRF/HeroEditor.tsx": $NRF_HeroEditor,
"./islands/NRF/HeroEditorTabbed.tsx": $NRF_HeroEditorTabbed,
"./islands/NRF/PageWrapper.tsx": $NRF_PageWrapper,
"./islands/NRF/TextLines.tsx": $NRF_TextLines,
"./islands/OnThisPage.tsx": $OnThisPage,
Expand Down
8 changes: 4 additions & 4 deletions islands/NRF/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export default function Editor({ features }: Props) {
}, []);

return (
<div class="editor bg-black text-white py-32">
<div class="editor bg-black text-white py-32 z-0">
<div class="flex flex-col items-center">
<div class="relative w-full right-container ml-auto flex gap-20">
<div class="hidden sticky h-screen top-0 lg:flex items-center justify-center">
Expand All @@ -149,10 +149,10 @@ export default function Editor({ features }: Props) {
<div class="feature-text flex-1 flex gap-20 min-h-screen items-center">
<div
id={`feature-text-${idx}`}
class="opacity-0 max-w-[344px] flex flex-col h-screen items-center justify-center fixed top-0 gap-6"
class="opacity-0 max-w-[344px] flex flex-col h-screen items-center justify-center fixed top-0 gap-6 pointer-events-none"
>
<h2 class="text-5xl font-semibold">{title}</h2>
<p>{subtitle}</p>
<p class="text-zinc-400">{subtitle}</p>
</div>
</div>
))}
Expand All @@ -162,7 +162,7 @@ export default function Editor({ features }: Props) {
{svgs.map((Component, idx) => (
<div
id={`feature-image-${idx}`}
class="opacity-0 feature-image fixed h-screen left-[calc(50%+3.75rem)] top-0 flex items-center justify-center"
class="opacity-0 feature-image fixed h-screen left-[calc(50%+1.5rem)] top-0 flex items-center justify-center pointer-events-none"
>
<Component class="editor-feature" width="1090" height="745" />
</div>
Expand Down
11 changes: 5 additions & 6 deletions islands/NRF/Features.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ export interface Props {
}

function FeatureCard({ icon, title, text }: Card) {

return (
<div class="feature-card transform translate-y-16 group border-l border-transparent duration-200 w-full flex flex-col gap-8 py-10 px-12 whitespace-pre-line opacity-0">
<div class="feature-card transform translate-y-16 group border-l border-transparent group-hover:-translate-y-3 duration-200 w-full flex flex-col gap-8 py-10 px-12 whitespace-pre-line opacity-0 z-40">
{icon && (
<div class="p-6 rounded-full bg-[#113032] text-[#02F67C]">
<Icon id={icon} size={48} />
Expand All @@ -31,10 +32,7 @@ function FeatureCard({ icon, title, text }: Card) {
class="text-2xl font-semibold leading-[110%]"
dangerouslySetInnerHTML={{ __html: title }}
/>
<p
class="leading-[120%]"
dangerouslySetInnerHTML={{ __html: text }}
/>
<p class="leading-[120%]" dangerouslySetInnerHTML={{ __html: text }} />
</div>
</div>
);
Expand All @@ -58,7 +56,7 @@ export default function Features({ title, cards }: Props) {
}, []);

return (
<section class="bg-black text-white py-20">
<section class="relative bg-black text-white py-20">
<div class="mx-6 lg:container lg:mx-auto flex justify-center items-center flex-col gap-20">
<h2 class="font-medium text-[36px] lg:text-[72px] leading-[100%] text-center max-w-4xl">
{title}
Expand All @@ -69,6 +67,7 @@ export default function Features({ title, cards }: Props) {
))}
</div>
</div>
<div class="ellipse-3" />
</section>
);
}
33 changes: 19 additions & 14 deletions islands/NRF/HeroEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,34 @@ import { HERO_ANIMATION_SEQUENCE } from "deco-sites/starting/animations/timeline

export default function HeroEditorIsland() {
useEffect(() => {
// @ts-ignore
scroll(
({ y }: { y: { progress: number } }) => {
const rotation = Math.max(y.progress * 0.05 * 360);
// @ts-ignore
animate(".hero-inner", {
rotateX: -rotation,
duration: 0,
allowWebkitAcceleration: true,
easing: "linear",
});
animate(
".hero-inner",
{ rotateX: -rotation },
{
duration: 0,
allowWebkitAcceleration: true,
easing: "linear",
}
);
},
{
target: document.querySelector(".hero-container"),
target: document.querySelector(".hero-container")!,
offset: ["120% 1", "150% 1"],
}
);

inView("#hero-editor", () => {
timeline(HERO_ANIMATION_SEQUENCE);
}, {
margin: "0px 0px -500px 0px",
});
inView(
"#hero-editor",
() => {
timeline(HERO_ANIMATION_SEQUENCE);
},
{
margin: "0px 0px -500px 0px",
}
);
}, []);

return (
Expand Down
81 changes: 81 additions & 0 deletions islands/NRF/HeroEditorTabbed.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { useSignal } from "@preact/signals";
import { SectionLibrary } from "deco-sites/starting/components/nrf/hero/SectionLibrary.tsx";
import { NoCodeEditor } from "deco-sites/starting/components/nrf/hero/NoCodeEditor.tsx";
import { FullCodeEditor } from "deco-sites/starting/components/nrf/hero/FullCodeEditor.tsx";
import { WebAnalytics } from "deco-sites/starting/components/nrf/hero/WebAnalytics.tsx";
import { Monitoring } from "deco-sites/starting/components/nrf/hero/Monitoring.tsx";
import { useEffect } from "preact/hooks";
import { scroll, animate } from "motion";

const TABS = [
"Section Library",
"No Code Editor",
"Full Code Editor",
"Web Analytics",
"Monitoring",
];

const PANELS = [
SectionLibrary,
NoCodeEditor,
FullCodeEditor,
WebAnalytics,
Monitoring,
];

export const HeroEditorTabbed = () => {
const selectedTab = useSignal(0);

useEffect(() => {

const element = document.querySelector("#hero");

if (!element) {
return;
}

scroll(
({ y }) => {
console.log(y.progress)
animate(".ellipse-1", {
top: `${y.progress * 250 - 250}px`,
}, {
duration: 0,
});

animate(".ellipse-2", {
top: `calc(60% - ${y.progress * 50}px)`,
}, {
duration: 0,
});
},
{
target: element,
offset: ["0 0", "end end"],
}
);
}, []);

return (
<div class="lg:w-full lg:max-w-6xl py-4 lg:py-2 p-2 bg-white/5 border border-white/5 rounded-lg lg:rounded-3xl space-y-2 mx-2 lg:mx-0 z-40">
<div class="flex justify-center gap-x-8 gap-2 lg:gap-x-2 text-white flex-wrap items-center">
{TABS.map((tab, index) => (
<button
onClick={() => {
selectedTab.value = index;
console.log(selectedTab.value);
}}
class={`text-[12px] lg:text-[18px] lg:px-[18px] py-2 font-medium ${
index === selectedTab.value
? "text-[#02F67C] border-b border-[#02F67C]"
: "text-white"
}`}
>
{tab}
</button>
))}
</div>
<div>{PANELS[selectedTab.value]()} </div>
</div>
);
};
Loading

0 comments on commit 958725d

Please sign in to comment.