Skip to content

Commit

Permalink
Added table & map visualizations with visx
Browse files Browse the repository at this point in the history
  • Loading branch information
steven-tey committed Sep 1, 2022
1 parent af0b395 commit aa313ed
Show file tree
Hide file tree
Showing 16 changed files with 2,463 additions and 49 deletions.
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/data/world-topo.json
12 changes: 4 additions & 8 deletions components/home/link-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import CopyButton from "@/components/shared/copy-button";
import LoadingDots from "@/components/shared/loading-dots";
import { useRouter } from "next/router";
import useSWR from "swr";
import { fetcher, nFormatter } from "@/lib/utils";
import { fetcher, nFormatter, linkConstructor } from "@/lib/utils";
import Link from "next/link";

export default function LinkCard({
Expand All @@ -15,13 +15,7 @@ export default function LinkCard({
_key: string;
url: string;
}) {
const shortURL = `${
process.env.NEXT_PUBLIC_DEMO_APP === "1"
? "https://dub.sh"
: process.env.NEXT_PUBLIC_VERCEL === "1"
? process.env.NEXT_PUBLIC_VERCEL_URL
: "http://localhost:3000"
}/${key}`; // if you're self-hosting you can just replace this with your own domain
const shortURL = linkConstructor(key);

const urlHostname = new URL(url).hostname;

Expand Down Expand Up @@ -59,6 +53,8 @@ export default function LinkCard({
className="flex items-center border border-gray-200 dark:border-gray-600 hover:border-black dark:hover:border-white p-3 rounded-md transition-all"
>
<StatsModal
_key={stats as string}
stats={[]}
showStatsModal={showStatsModal}
setShowStatsModal={setShowStatsModal}
/>
Expand Down
37 changes: 37 additions & 0 deletions components/stats/index.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
.bar {
transform-origin: bottom !important;
fill: #0070f3;
}

.tooltip {
z-index: 40;
width: 200px;
padding: 1rem !important;
border-radius: 5px !important;
box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px !important;
}

.tooltip::after {
content: "";
position: absolute;
width: 0px;
height: 0px;
margin: auto;

border: 7px solid transparent;
border-top-color: white;

top: 100%;
left: 95px;
}

@media (prefers-color-scheme: dark) {
.tooltip {
background-color: black !important;
border: solid 1px #eaeaea;
box-shadow: none !important;
}
.tooltip::after {
border-top-color: black;
}
}
27 changes: 27 additions & 0 deletions components/stats/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import dynamic from "next/dynamic";
import { Suspense } from "react";
import { RawStatsProps } from "@/lib/stats";
import StatsChart from "@/components/stats/stats-chart";
const StatsMap = dynamic(() => import("@/components/stats/stats-map"), {
suspense: true,
}); // the map takes a while to load so we'll dynamically import it with suspense

export default function Stats({
_key,
stats,
}: {
_key: string;
stats: RawStatsProps[];
}) {
return (
<div className="flex flex-col justify-center items-center my-36">
{/* @ts-ignore */}
<StatsChart _key={_key} stats={stats} />
<div className="h-20" />
<Suspense fallback={<div>Loading...</div>}>
{/* @ts-ignore */}
<StatsMap _key={_key} stats={stats} />
</Suspense>
</div>
);
}
Loading

0 comments on commit aa313ed

Please sign in to comment.