Skip to content

Commit 4b4f44f

Browse files
add carbon ads and update scroll behavior
1 parent ec5c28a commit 4b4f44f

File tree

5 files changed

+145
-10
lines changed

5 files changed

+145
-10
lines changed

components/home/terminal.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ export default function Terminal() {
136136
!item.content.includes("💬") &&
137137
!item.content.includes("🚨") && (
138138
<button
139-
className="ml-2 rounded-md bg-slate px-2 py-2 transition-all duration-75 ease-in hover:bg-black-400 focus:outline-none focus:ring-2 focus:ring-gray"
139+
className="ml-2 rounded-md bg-slate px-2 py-2 transition-all duration-75 ease-in hover:bg-black-400 focus:outline-none focus-visible:ring-2 focus-visible:ring-gray"
140140
onClick={() => {
141141
navigator.clipboard.writeText(item.content);
142142
toast("Git command copied to clipboard.", {

components/layout/index.tsx

+20-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Link from "next/link";
2-
import { ReactNode } from "react";
2+
import React, { useState } from "react";
3+
import { ReactNode, useEffect } from "react";
34
import Meta from "./meta";
45

56
export default function Layout({
@@ -13,6 +14,20 @@ export default function Layout({
1314
};
1415
children: ReactNode;
1516
}) {
17+
const [terminalRef, setTerminalRef] = useState<null | HTMLElement>(null);
18+
19+
useEffect(() => {
20+
return () => {
21+
setTerminalRef(document.getElementById("terminal"));
22+
};
23+
}, []);
24+
25+
const scrollToTerminal = () => {
26+
if (terminalRef !== null) {
27+
terminalRef.scrollIntoView({ behavior: "smooth" });
28+
}
29+
};
30+
1631
return (
1732
<>
1833
<Meta {...meta} />
@@ -28,11 +43,11 @@ export default function Layout({
2843
</Link>
2944

3045
<div>
31-
<a href="https://gitfluence.com/#terminal">
46+
<button onClick={scrollToTerminal}>
3247
<p className="bg-gradient-to-r from-yellow to-amber bg-clip-text text-base text-transparent hover:from-yellow-400 hover:to-amber-400">
3348
Get Started
3449
</p>
35-
</a>
50+
</button>
3651
</div>
3752
</div>
3853
</header>
@@ -51,11 +66,11 @@ export default function Layout({
5166
</p>
5267

5368
<ul className="order-1 flex flex-wrap items-center text-sm md:order-2">
54-
<li>
69+
{/* <li>
5570
<Link href="/privacy" className="mr-4 hover:underline md:mr-6">
5671
Privacy Policy
5772
</Link>
58-
</li>
73+
</li> */}
5974
<li>
6075
<a
6176
href="mailto:[email protected]"

components/shared/carbonAds.tsx

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
import Script from "next/script";
2+
import { useEffect, useRef } from "react";
3+
4+
const carbonStyle = `
5+
#carbonads {
6+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
7+
Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial,
8+
sans-serif;
9+
}
10+
11+
#carbonads {
12+
display: block;
13+
overflow: hidden;
14+
max-width: 728px;
15+
position: relative;
16+
background-color: hsl(0, 0%, 12%);
17+
border: solid 1px hsl(0, 0%, 15%);
18+
font-size: 22px;
19+
box-sizing: content-box;
20+
color: hsl(0, 0%, 90%);
21+
}
22+
23+
#carbonads > span {
24+
display: block;
25+
}
26+
27+
#carbonads a {
28+
color: inherit;
29+
text-decoration: none;
30+
}
31+
32+
#carbonads a:hover {
33+
color: inherit;
34+
}
35+
36+
.carbon-wrap {
37+
display: flex;
38+
align-items: center;
39+
}
40+
41+
.carbon-img {
42+
display: block;
43+
margin: 0;
44+
line-height: 1;
45+
}
46+
47+
.carbon-img img {
48+
display: block;
49+
height: 100px;
50+
width: auto;
51+
}
52+
53+
.carbon-text {
54+
display: block;
55+
padding: 0 1em;
56+
line-height: 1.35;
57+
text-align: left;
58+
}
59+
60+
.carbon-poweredby {
61+
display: block;
62+
position: absolute;
63+
bottom: 0;
64+
right: 0;
65+
padding: 6px 10px;
66+
background: hsl(0, 0%, 15%);
67+
color: hsl(0, 0%, 90%);
68+
text-align: center;
69+
text-transform: uppercase;
70+
letter-spacing: 0.5px;
71+
font-weight: 600;
72+
font-size: 8px;
73+
border-top-left-radius: 4px;
74+
line-height: 1;
75+
}
76+
77+
@media only screen and (min-width: 320px) and (max-width: 759px) {
78+
.carbon-text {
79+
font-size: 14px;
80+
}
81+
}
82+
`;
83+
84+
export default function CarbonAds() {
85+
const dataFetch = useRef(false);
86+
const containerRef = useRef<HTMLDivElement>(null);
87+
88+
useEffect(() => {
89+
if (dataFetch.current) return;
90+
dataFetch.current = true;
91+
92+
const script = document.createElement("script");
93+
script.id = "_carbonads_js";
94+
script.src = `//cdn.carbonads.com/carbon.js?serve=CWYDC53J&placement=gitfluencecom'`;
95+
containerRef.current?.appendChild(script);
96+
}, []);
97+
98+
return (
99+
<>
100+
<style dangerouslySetInnerHTML={{ __html: carbonStyle }} />
101+
<div
102+
className="mt-2 mb-10 flex w-full max-w-screen-xl animate-[slide-down-fade_0.5s_ease-in-out] justify-center px-5 xl:px-0"
103+
ref={containerRef}
104+
/>
105+
</>
106+
);
107+
}

pages/_document.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Html, Head, Main, NextScript } from "next/document";
22

33
export default function Document() {
44
return (
5-
<Html lang="en" className="scroll-smooth">
5+
<Html lang="en">
66
<Head />
77
<body>
88
<Main />

pages/index.tsx

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,21 @@
11
import Terminal from "@/components/home/terminal";
22
import Layout from "@/components/layout";
3+
import CarbonAds from "@/components/shared/carbonAds";
34
import { Copy, Keyboard, Prompt } from "@/components/shared/icons";
45
import classNames from "classnames";
6+
import { useRef } from "react";
57
import { Toaster } from "react-hot-toast";
68
import Balancer from "react-wrap-balancer";
79

810
export default function Home() {
11+
const terminalRef = useRef<null | HTMLDivElement>(null);
12+
13+
const scrollToTerminal = () => {
14+
if (terminalRef.current !== null) {
15+
terminalRef.current.scrollIntoView({ behavior: "smooth" });
16+
}
17+
};
18+
919
return (
1020
<Layout>
1121
<div className="max-w-3xl px-5 xl:px-0">
@@ -24,20 +34,21 @@ export default function Home() {
2434
</Balancer>
2535
</p>
2636
<div className="mx-auto mt-10 flex items-center justify-center space-x-5">
27-
<a
37+
<button
2838
className="relative flex max-w-fit translate-y-[-1rem] animate-fade-in items-center justify-center rounded-md border border-amber-700 bg-black-600 px-14 py-3 text-sm opacity-0 transition-colors [--animation-delay:300ms] hover:border-amber-600 hover:bg-black-700"
29-
href="#terminal"
39+
onClick={scrollToTerminal}
3040
>
3141
<p className="bg-gradient-to-r from-yellow to-amber bg-clip-text text-base text-transparent hover:from-yellow-400 hover:to-amber-400">
3242
Get Started
3343
</p>
34-
</a>
44+
</button>
3545
</div>
3646
</div>
3747

3848
<div
3949
className="relative w-full max-w-screen-xl -scroll-mt-10 pt-20 pb-8 xl:w-8/12 xl:-scroll-mt-16 xl:pt-36"
4050
id="terminal"
51+
ref={terminalRef}
4152
>
4253
<Toaster
4354
position="bottom-right"
@@ -50,6 +61,8 @@ export default function Home() {
5061
<div className="absolute -bottom-44 -left-12 right-0 h-full w-full max-w-screen-xl rounded-[1000px] bg-feature-pattern opacity-10 blur-[160px] xl:h-[278px] xl:w-[748px] xl:opacity-30" />
5162
</div>
5263

64+
<CarbonAds />
65+
5366
<div className="my-10 grid w-full max-w-screen-xl animate-[slide-down-fade_0.5s_ease-in-out] grid-cols-1 gap-12 px-5 md:grid-cols-3 xl:w-8/12 xl:gap-12 xl:px-0">
5467
{steps.map(({ icon, title, description }, index) => (
5568
<div

0 commit comments

Comments
 (0)