Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

7 - Revamp - add pages components #108

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions src/components/contribute/ContributeContent.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import { useEffect, useRef, useState } from "react";
import * as Tabs from "@radix-ui/react-tabs";
import gsap from "gsap";
import { useGSAP } from "@gsap/react";
import Image from "next/image";
import { useTranslation } from "next-i18next";

import Button from "@/components/solutions/Button";
import { MotionSlideIn } from "@/components/shared/Motions";
import { AnimatedText } from "@/components/shared/Text";

import styles from "./ContributeContent.module.scss";

const ContributeContent = ({ tabs }) => {
const container = useRef(null);
const [value, setValue] = useState("tab1");
let tabsContent = useRef(null);
const { t } = useTranslation();

useGSAP(
() => {
if (tabsContent.current) {
const activeTab = tabsContent.current.find(
(tab) => tab.getAttribute("data-state") === "active",
);
gsap.fromTo(
activeTab,
{
autoAlpha: 0,
y: 100,
},
{
autoAlpha: 1,
y: 0,
overwrite: true,
},
);
}
},
{ scope: container, dependencies: [value] },
);

useEffect(() => {
tabsContent.current = gsap.utils.toArray(".hero-tab-content");
}, []);

return (
<>
<Tabs.Root
ref={container}
className={styles.TabsRoot}
defaultValue="tab1"
value={value}
>
<Tabs.List
className={styles.TabsList}
aria-label={t("contribute.tabs-list-aria-label")}
>
<Tabs.Trigger
className={styles.TabsTrigger}
value="tab1"
onClick={() => setValue("tab1")}
>
{t("contribute.tabs.0.trigger")}
</Tabs.Trigger>
<Tabs.Trigger
className={styles.TabsTrigger}
value="tab2"
onClick={() => setValue("tab2")}
>
{t("contribute.tabs.1.trigger")}
</Tabs.Trigger>
</Tabs.List>

<Tabs.Content
className={`${styles.TabsContent} hero-tab-content`}
value="tab1"
>
<section className={styles.TabCallout}>
<div className={styles.CalloutContainer}>
<div className={styles.TextWrapper}>
<AnimatedText element="h2" as="heading">
{tabs[0].callout.title}
</AnimatedText>
<AnimatedText element="p">{tabs[0].callout.text}</AnimatedText>
<MotionSlideIn>
<Button
text={tabs[0].callout.button}
url="https://github.com/solana-foundation/solana-com/blob/main/CONTRIBUTING.md"
target="_blank"
/>
</MotionSlideIn>
</div>

<div className={styles.MediaWrapper}>
<Image
src="/src/img/contribute/tab-1.svg"
alt={tabs[0].callout.title}
fill
/>
</div>
</div>
</section>

<section className={styles.TabsDetails}>
<div className={styles.DetailsContainer}>
{tabs[0].details.map((detail, i) => (
<div className={styles.Detail} key={i}>
<MotionSlideIn>
<h5>{detail.title}</h5>
<p>{detail.text}</p>
</MotionSlideIn>
</div>
))}
</div>
</section>
</Tabs.Content>

<Tabs.Content
className={`${styles.TabsContent} hero-tab-content`}
value="tab2"
>
<section className={styles.TabCallout}>
<div className={styles.CalloutContainer}>
<div className={styles.TextWrapper}>
<AnimatedText element="h2" as="heading">
{tabs[1].callout.title}
</AnimatedText>
<AnimatedText element="p">{tabs[1].callout.text}</AnimatedText>
<MotionSlideIn>
<Button
text={tabs[1].callout.button}
url="https://solanafoundation.typeform.com/to/JDtGdIoy"
target="_blank"
/>
</MotionSlideIn>
</div>

<div className={styles.MediaWrapper}>
<Image
src="/src/img/contribute/tab-2.png"
alt={tabs[1].callout.title}
fill
/>
</div>
</div>
</section>

<section className={styles.TabsDetails}>
<div className={styles.DetailsContainer}>
{tabs[1].details.map((detail, i) => (
<div className={styles.Detail} key={i}>
<MotionSlideIn>
<h5>{detail.title}</h5>
<p>{detail.text}</p>
</MotionSlideIn>
</div>
))}
</div>
</section>
</Tabs.Content>
</Tabs.Root>
</>
);
};

export default ContributeContent;
214 changes: 214 additions & 0 deletions src/components/contribute/ContributeContent.module.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
@import "~@/scss/solutions/_variables.scss";

.TabsRoot {
display: flex;
flex-direction: column;
}

.TabsList {
flex-shrink: 0;
display: flex;
border-radius: 12px;
border: 4px solid var(--grey-500);
background-color: var(--grey-500);
max-width: 343px;
width: 100%;
margin: 0 auto;
}

.TabsTrigger {
font-family: inherit;
background-color: var(--grey-500);
padding: 0 20px;
height: 45px;
flex: 1;
display: flex;
align-items: center;
justify-content: center;
font-size: 16px;
line-height: 1;
color: var(--grey-250);
user-select: none;
font-weight: 700;

&[data-state="active"] {
color: var(--grey-100);
background: var(--grey-300);
border-radius: 4px;
}

&:focus {
position: relative;
}
}

.TabsContent {
flex-grow: 1;
outline: none;
max-width: 1068px;
margin: 0 auto;
}

.TabCallout {
padding-top: 64px;

@include breakpoint(lg) {
padding-top: 150px;
}
}

.CalloutContainer {
padding: 0 24px;

@include breakpoint(md) {
padding: 0 40px;
}

@include breakpoint(xl) {
padding: 0;
}
}

.TextWrapper {
text-align: center;

& > *:not(a) {
padding: 0;
margin: 0;
}

h2 {
font-size: 32px;
font-weight: 700;
line-height: 1.11;
letter-spacing: -0.32px;
}

p {
font-size: 18px;
font-weight: 700;
line-height: 1.16;
letter-spacing: -0.18px;
margin-top: 24px;
color: #a2a1b2;
}

a {
width: fit-content;
margin: 24px auto 0;
}

@include breakpoint(lg) {
text-align: left;

h2 {
font-size: 56px;
line-height: 1;
letter-spacing: -1.28px;
}

p {
font-size: 24px;
line-height: 1.15;
letter-spacing: -0.84px;
margin-top: 16px;
color: #a2a1b2;
}

a {
margin-top: 48px;
margin-left: 0;
}
}
}

.CalloutContainer {
display: grid;
grid-template-columns: 1fr;
gap: 40px;
align-items: center;
justify-content: center;

@include breakpoint(lg) {
grid-template-columns: 0.85fr 1fr;
gap: 150px;
}
}

.MediaWrapper {
aspect-ratio: 1 / 1;
position: relative;
width: 100%;
display: block;
}

.TabsDetails {
padding: 64px 0 128px;

@include breakpoint(lg) {
padding: 80px 0 128px;
}
}

.DetailsContainer {
padding: 0 24px;

display: grid;
grid-template-columns: 1fr;
grid-gap: 40px;

@include breakpoint(md) {
padding: 0 40px;
}

@include breakpoint(lg) {
grid-template-columns: repeat(3, 1fr);
grid-row-gap: 50px;
grid-column-gap: 80px;
}

@include breakpoint(xl) {
padding: 0;
}
}

.Detail {
text-align: center;
& > * {
padding: 0;
margin: 0;
}

h5 {
color: #eaebf0;
font-size: 18px;
font-weight: 700;
line-height: 1.16;
letter-spacing: -0.18px;
}

p {
color: #6c6a81;
font-size: 18px;
font-style: normal;
font-weight: 700;
line-height: 1.16;
letter-spacing: -0.18px;
}

@include breakpoint(lg) {
text-align: left;
h5 {
color: #fff;
font-size: 20px;
line-height: 1.12;
letter-spacing: -0.48px;
}

p {
font-size: 20px;
line-height: 1.12;
letter-spacing: -0.48px;
}
}
}
Loading
Loading