Clicks and views
This commit is contained in:
parent
ab544fc759
commit
fe4e61dd0c
|
@ -1,2 +1,4 @@
|
|||
venv
|
||||
links.db
|
||||
/.vs
|
||||
/.vscode
|
|
@ -0,0 +1,43 @@
|
|||
import React from "react";
|
||||
|
||||
const Question = (
|
||||
<svg
|
||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
color="#000"
|
||||
viewBox="0 0 16 16"
|
||||
className="sc-dkIXFM jmmNux"
|
||||
width="14"
|
||||
height="14"
|
||||
>
|
||||
<path d="M8 0a8 8 0 108 8 8 8 0 00-8-8zm0 15a7 7 0 117-7 7 7 0 01-7 7zm-.75-3.49h1.53V13H7.25zm3.54-7A3.05 3.05 0 0111 5.72a2.54 2.54 0 01-.1.76 2.9 2.9 0 01-.27.62 3.75 3.75 0 01-.38.51l-.44.45-.43.42a5.58 5.58 0 00-.38.46 2.33 2.33 0 00-.27.52 1.83 1.83 0 00-.11.64v.54H7.44V10a2.57 2.57 0 01.22-1 3 3 0 01.45-.73 6.25 6.25 0 01.57-.58 7.4 7.4 0 00.55-.57 2.42 2.42 0 00.4-.65 1.82 1.82 0 00.13-.87 1.81 1.81 0 00-.49-1.19A1.63 1.63 0 008.09 4a1.91 1.91 0 00-.86.18 1.74 1.74 0 00-.59.49 1.91 1.91 0 00-.36.71 3.7 3.7 0 00-.11.9H5A3.71 3.71 0 015.2 5a3.17 3.17 0 01.61-1.1 2.85 2.85 0 011-.69A3.21 3.21 0 018.09 3a3.4 3.4 0 011.18.19 2.71 2.71 0 01.92.53 2.6 2.6 0 01.6.83z"></path>
|
||||
</svg>
|
||||
);
|
||||
|
||||
const Chevron = (
|
||||
<svg
|
||||
xmlnsXlink="http://www.w3.org/1999/xlink"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 12 12"
|
||||
className="sc-hHftDr bphBpT"
|
||||
rotate="0"
|
||||
data-test="IconComponent"
|
||||
width="16"
|
||||
height="20"
|
||||
>
|
||||
<rect
|
||||
rotate="0"
|
||||
data-test="IconComponent"
|
||||
className="sc-fKFyDc gYoavR"
|
||||
fillOpacity="0"
|
||||
fill="#000000"
|
||||
></rect>
|
||||
<polygon
|
||||
transform="translate(5.949747, 4.949747) rotate(-45.000000) translate(-5.949747, -4.949747) "
|
||||
points="4.44974747 6.44974747 4.44974747 1.44974747 2.44974747 1.44974747 2.44974747 8.44974747 9.44974747 8.44974747 9.44974747 6.44974747"
|
||||
fill="#0A0B0D"
|
||||
></polygon>
|
||||
</svg>
|
||||
);
|
||||
|
||||
export { Question, Chevron };
|
|
@ -0,0 +1,50 @@
|
|||
import React from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { Question, Chevron } from "./assets";
|
||||
|
||||
const Analytics: React.FC = () => {
|
||||
const [viewCount, setViewCount] = useState(0);
|
||||
const [clickCount, setClickCount] = useState(0);
|
||||
|
||||
useEffect(() => {
|
||||
fetch("https://dog.ceo/api/breeds/list/all") // TODO: Change to '/api/editor/links'
|
||||
.then((results) => results.json())
|
||||
.then((data) => {
|
||||
console.log("Success:", data);
|
||||
// TODO: Assign the correct values here:
|
||||
// setViewCount(data.views);
|
||||
// setClickCount(data.clicks);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<div className="w-full h-12 lt-lg:h-16 mr-0 px-4 lt-lg:px-6 flex flex-row border-b border-analytics-border text-sm font-karla">
|
||||
<div className="w-full h-full flex-analytics flex flex-row justify-start items-center">
|
||||
<span className="mr-4 font-bold">Lifetime Analytics:</span>
|
||||
<div className="mr-8 flex flex-row justify-center items-center">
|
||||
<div className="h-2 w-2 mr-2 rounded bg-analytics-view-icon"></div>
|
||||
<div className="flex flex-col lt-lg:flex-row text-xs lt-lg:text-base font-normal">
|
||||
<p className="whitespace-pre">Views: </p>
|
||||
<p className="font-bold lt-lg:font-normal">{viewCount || "-"}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div className="mr-8 flex flex-row justify-center items-center">
|
||||
<div className="h-2 w-2 mr-2 rounded bg-analytics-click-icon"></div>
|
||||
<div className="flex flex-col lt-lg:flex-row text-xs lt-lg:text-base font-normal">
|
||||
<p className="whitespace-pre">Clicks: </p>
|
||||
<p className="font-bold lt-lg:font-normal">{clickCount || "-"}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div>{Question}</div>
|
||||
</div>
|
||||
<div className="w-full h-full flex-chevron flex flex-row justify-center items-center">
|
||||
{Chevron}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Analytics;
|
|
@ -1,8 +1,5 @@
|
|||
import React from "react";
|
||||
|
||||
const styles = {
|
||||
fontFamily: "Karla",
|
||||
};
|
||||
import { useEffect } from "react";
|
||||
|
||||
interface Link {
|
||||
name: string;
|
||||
|
@ -13,11 +10,29 @@ interface LinkProps {
|
|||
}
|
||||
|
||||
const Links: React.FC<LinkProps> = ({ links }) => {
|
||||
const postData = (url = ""): void => {
|
||||
fetch(url, {
|
||||
method: "POST",
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
console.log("Success:", data);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect((): void => {
|
||||
postData("https://dog.ceo/api/breeds/list/all"); // TODO: Change to '/api/view'
|
||||
}, []);
|
||||
|
||||
const handleClick = (): void => {
|
||||
postData("https://dog.ceo/api/breeds/list/all"); // TODO: Change to '/api/click'
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
className="text-s flex flex-col items-center w-full absolute top-6"
|
||||
style={styles}
|
||||
>
|
||||
<div className="text-s flex flex-col items-center w-full absolute top-6 font-karla">
|
||||
<img className="mb-3" src="csc_logo.png" alt="CSC Logo" width="100px" />
|
||||
<h1 className="font-bold">@uwcsclub</h1>
|
||||
<ul className="flex flex-col my-6 w-full">
|
||||
|
@ -30,6 +45,7 @@ const Links: React.FC<LinkProps> = ({ links }) => {
|
|||
href={url}
|
||||
target="_blank"
|
||||
rel="noreferrer"
|
||||
onClick={handleClick}
|
||||
>
|
||||
{name}
|
||||
</a>
|
||||
|
|
|
@ -7,10 +7,6 @@ const MyApp: React.FC<AppProps> = ({ Component, pageProps }) => (
|
|||
<>
|
||||
<Head>
|
||||
<title>@uwcsclub | LinkList</title>
|
||||
<link
|
||||
rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css2?family=Karla:wght@300;400;600;700&display=swap"
|
||||
></link>
|
||||
</Head>
|
||||
<Component {...pageProps} />
|
||||
</>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import Head from "next/head";
|
||||
import React from "react";
|
||||
import { GetStaticProps } from "next";
|
||||
import styles from "styles/Home.module.css";
|
||||
import Analytics from "components/Analytics/index";
|
||||
|
||||
export const getStaticProps: GetStaticProps = async () => {
|
||||
// TODO: Fetch links here
|
||||
|
@ -19,68 +18,8 @@ const Editor: React.FC = ({ data }: any) => {
|
|||
console.log({ data });
|
||||
|
||||
return (
|
||||
// TODO: Remove starter code
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
<main className={styles.main}>
|
||||
<div className="max-w-md mx-auto text-red-600 hover:text-red-700">
|
||||
<div>
|
||||
<h1 className={styles.title}>
|
||||
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className={styles.description}>
|
||||
Get started by editing{" "}
|
||||
<code className={styles.code}>pages/index.js</code>
|
||||
</p>
|
||||
|
||||
<div className={styles.grid}>
|
||||
<a href="https://nextjs.org/docs" className={styles.card}>
|
||||
<h3>Documentation →</h3>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<a href="https://nextjs.org/learn" className={styles.card}>
|
||||
<h3>Learn →</h3>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/vercel/next.js/tree/master/examples"
|
||||
className={styles.card}
|
||||
>
|
||||
<h3>Examples →</h3>
|
||||
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
>
|
||||
<h3>Deploy →</h3>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a public URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer className={styles.footer}>
|
||||
<a
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Powered by{" "}
|
||||
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
|
||||
</a>
|
||||
</footer>
|
||||
<div>
|
||||
<Analytics />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,73 +1,7 @@
|
|||
import Head from "next/head";
|
||||
import React from "react";
|
||||
import styles from "styles/Home.module.css";
|
||||
|
||||
const Login: React.FC = () => {
|
||||
return (
|
||||
// TODO: Remove starter code
|
||||
<div className={styles.container}>
|
||||
<Head>
|
||||
<title>Create Next App</title>
|
||||
<link rel="icon" href="/favicon.ico" />
|
||||
</Head>
|
||||
|
||||
<main className={styles.main}>
|
||||
<div className="max-w-md mx-auto text-red-600 hover:text-red-700">
|
||||
<div>
|
||||
<h1 className={styles.title}>
|
||||
Welcome to <a href="https://nextjs.org">Next.js!</a>
|
||||
</h1>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p className={styles.description}>
|
||||
Get started by editing{" "}
|
||||
<code className={styles.code}>pages/index.js</code>
|
||||
</p>
|
||||
|
||||
<div className={styles.grid}>
|
||||
<a href="https://nextjs.org/docs" className={styles.card}>
|
||||
<h3>Documentation →</h3>
|
||||
<p>Find in-depth information about Next.js features and API.</p>
|
||||
</a>
|
||||
|
||||
<a href="https://nextjs.org/learn" className={styles.card}>
|
||||
<h3>Learn →</h3>
|
||||
<p>Learn about Next.js in an interactive course with quizzes!</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://github.com/vercel/next.js/tree/master/examples"
|
||||
className={styles.card}
|
||||
>
|
||||
<h3>Examples →</h3>
|
||||
<p>Discover and deploy boilerplate example Next.js projects.</p>
|
||||
</a>
|
||||
|
||||
<a
|
||||
href="https://vercel.com/new?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
className={styles.card}
|
||||
>
|
||||
<h3>Deploy →</h3>
|
||||
<p>
|
||||
Instantly deploy your Next.js site to a public URL with Vercel.
|
||||
</p>
|
||||
</a>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<footer className={styles.footer}>
|
||||
<a
|
||||
href="https://vercel.com?utm_source=create-next-app&utm_medium=default-template&utm_campaign=create-next-app"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
Powered by{" "}
|
||||
<img src="/vercel.svg" alt="Vercel Logo" className={styles.logo} />
|
||||
</a>
|
||||
</footer>
|
||||
</div>
|
||||
);
|
||||
return <div></div>;
|
||||
};
|
||||
|
||||
export default Login;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import React from "react";
|
||||
import { GetStaticProps } from "next";
|
||||
import styles from "styles/Home.module.css";
|
||||
import { Links } from "components";
|
||||
|
||||
// TODO: change
|
||||
|
|
|
@ -1,122 +0,0 @@
|
|||
.container {
|
||||
min-height: 100vh;
|
||||
padding: 0 0.5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.main {
|
||||
padding: 5rem 0;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.footer {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
border-top: 1px solid #eaeaea;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.footer img {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.footer a {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.title a {
|
||||
color: #0070f3;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.title a:hover,
|
||||
.title a:focus,
|
||||
.title a:active {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.title {
|
||||
margin: 0;
|
||||
line-height: 1.15;
|
||||
font-size: 4rem;
|
||||
}
|
||||
|
||||
.title,
|
||||
.description {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.description {
|
||||
line-height: 1.5;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.code {
|
||||
background: #fafafa;
|
||||
border-radius: 5px;
|
||||
padding: 0.75rem;
|
||||
font-size: 1.1rem;
|
||||
font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono,
|
||||
Bitstream Vera Sans Mono, Courier New, monospace;
|
||||
}
|
||||
|
||||
.grid {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
flex-wrap: wrap;
|
||||
max-width: 800px;
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
.card {
|
||||
margin: 1rem;
|
||||
flex-basis: 45%;
|
||||
padding: 1.5rem;
|
||||
text-align: left;
|
||||
color: inherit;
|
||||
text-decoration: none;
|
||||
border: 1px solid #eaeaea;
|
||||
border-radius: 10px;
|
||||
transition: color 0.15s ease, border-color 0.15s ease;
|
||||
}
|
||||
|
||||
.card:hover,
|
||||
.card:focus,
|
||||
.card:active {
|
||||
color: #0070f3;
|
||||
border-color: #0070f3;
|
||||
}
|
||||
|
||||
.card h3 {
|
||||
margin: 0 0 1rem 0;
|
||||
font-size: 1.5rem;
|
||||
}
|
||||
|
||||
.card p {
|
||||
margin: 0;
|
||||
font-size: 1.25rem;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.logo {
|
||||
height: 1em;
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.grid {
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
/* ./your-css-folder/styles.css */
|
||||
@import url('https://fonts.googleapis.com/css2?family=Karla:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap');
|
||||
@tailwind base;
|
||||
@tailwind components;
|
||||
@tailwind utilities;
|
||||
|
|
|
@ -14,13 +14,28 @@ module.exports = {
|
|||
theme: {
|
||||
extend: {
|
||||
colors: {
|
||||
analytics: {
|
||||
border: "#d7dce1",
|
||||
"view-icon": "#39e09b",
|
||||
"click-icon": "#8a86e5",
|
||||
},
|
||||
gray: {
|
||||
450: "#3d3b3c",
|
||||
},
|
||||
},
|
||||
fontFamily: {
|
||||
karla: ["Karla", "Verdana", "sans-serif"],
|
||||
},
|
||||
fontSize: {
|
||||
s: ".82rem",
|
||||
},
|
||||
screens: {
|
||||
"lt-lg": "992px",
|
||||
},
|
||||
flex: {
|
||||
analytics: "1 0 0",
|
||||
chevron: "0 0 16px",
|
||||
},
|
||||
},
|
||||
minWidth: {
|
||||
"9/10": "90%",
|
||||
|
|
Loading…
Reference in New Issue