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

Tweaks #41

Merged
merged 56 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
4430403
Use higher quality mountain image
itexpert120 Aug 8, 2024
1436216
Remove search modal trigger at the end of each page, and improve imag…
itexpert120 Aug 8, 2024
4bf473f
Use higher quality mountain image
itexpert120 Aug 8, 2024
a3629f8
Remove search modal trigger at the end of each page, and improve imag…
itexpert120 Aug 8, 2024
0d1f4d5
Merge branch '6-aug-issues' of https://github.com/NEARBuilders/near-d…
itexpert120 Aug 8, 2024
85bb3fc
Add blur placeholder to static images
itexpert120 Aug 8, 2024
ad1c4c1
Add static imports and remove unused suspense
itexpert120 Aug 8, 2024
c8223d8
Fix accessibility error
itexpert120 Aug 8, 2024
3f015a6
Improve project page performance
itexpert120 Aug 8, 2024
ec761a5
Improve category page performance
itexpert120 Aug 8, 2024
8c74c8d
Improve bookmarks page
itexpert120 Aug 8, 2024
c4c671b
Improve site.url handling
itexpert120 Aug 8, 2024
403775a
Fix base URL
itexpert120 Aug 8, 2024
f977dca
Fix tests
itexpert120 Aug 8, 2024
5eb16d7
Add background to project card image
itexpert120 Aug 8, 2024
b3b7f63
Select search input on modal open
itexpert120 Aug 8, 2024
51ed49b
Update hot projects scrolling logic
itexpert120 Aug 8, 2024
76d1b03
Improve bookmarks
itexpert120 Aug 9, 2024
c91969a
Improve auto focus logic
itexpert120 Aug 9, 2024
0574d9e
Revert project list back
itexpert120 Aug 9, 2024
9e63b8b
Remove unused prop
itexpert120 Aug 9, 2024
1d03ebf
Better infinite projects feed
itexpert120 Aug 9, 2024
68708a0
Change name to NEAR Catalog
itexpert120 Aug 9, 2024
d33ecbb
Change logo
itexpert120 Aug 9, 2024
bc8615b
Remove Bookmarks
itexpert120 Aug 9, 2024
1d8a70c
Add footer links
itexpert120 Aug 9, 2024
ef038b5
Change favicon
itexpert120 Aug 9, 2024
0b8d52e
Change readme logo
itexpert120 Aug 9, 2024
4d210fb
Add opengraph image to home page
itexpert120 Aug 9, 2024
a776ea9
Only show projects in search bar when searched
itexpert120 Aug 9, 2024
c4a4715
Consistent opengraph images
itexpert120 Aug 9, 2024
7a7707c
Use different searchKeys for modal and page
itexpert120 Aug 9, 2024
a3f30a5
Add cookie and privacy policy pages
itexpert120 Aug 9, 2024
1537d89
Fix padding
itexpert120 Aug 9, 2024
8ad3216
Metadata
itexpert120 Aug 9, 2024
edd7f73
Fix keywords in main layout
itexpert120 Aug 9, 2024
c21d516
Add max width to policy pages
itexpert120 Aug 9, 2024
d8f00b9
Change markdown font size
itexpert120 Aug 9, 2024
d752034
Add remark plugin to all markdown contents
itexpert120 Aug 9, 2024
4b261c7
Better category page metadata
itexpert120 Aug 9, 2024
1af936e
Implement max width for search modal
itexpert120 Aug 9, 2024
87f7c39
Fix og image alt
itexpert120 Aug 9, 2024
aab586c
Rework search
itexpert120 Aug 9, 2024
b8fac82
Remove duplicate tags
itexpert120 Aug 9, 2024
79f3bfc
Tag click moves to top
itexpert120 Aug 9, 2024
7d4694a
Remove even more duplication
itexpert120 Aug 9, 2024
aa93a5f
Change font location for og image
itexpert120 Aug 9, 2024
e088c3c
Optimize imports
itexpert120 Aug 9, 2024
5938b20
Fix tests
itexpert120 Aug 9, 2024
42dfbdc
Fix test
itexpert120 Aug 9, 2024
5b5b5f9
Hidden Tags on mobile view
itexpert120 Aug 9, 2024
c18b8ab
Merge branch 'tweaks' of https://github.com/NEARBuilders/near-directo…
itexpert120 Aug 9, 2024
c514e20
Improve twitter timeline
itexpert120 Aug 9, 2024
f6306cd
Revert unwanted changes
itexpert120 Aug 9, 2024
37c4617
Remove console log
itexpert120 Aug 9, 2024
899d852
fix tests
itexpert120 Aug 9, 2024
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
51 changes: 27 additions & 24 deletions app/bookmarks/_components/bookmarks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ import { useEffect, useState } from "react";
import { fetchAllProjects } from "@/lib/near-catalog";
import { ProjectId, ProjectRecord } from "@/lib/types";
import ProjectCard from "@/components/ui/project-card";
import ErrorImage from "@/public/assets/images/error.webp";
import { getBookmarkedProjects } from "@/lib/bookmark-project";
import ProjectSkeleton from "@/components/ui/project-skeleton";

export default function Bookmarks() {
const [projects, setProjects] = useState<Record<string, ProjectRecord>>();
const [loading, setLoading] = useState(false);
const [loading, setLoading] = useState(true);
const [starredProjects, setStarredProjects] = useState<ProjectId[]>([]);

useEffect(() => {
Expand All @@ -26,31 +28,32 @@ export default function Bookmarks() {

return (
<>
{starredProjects.length === 0 ? (
<div className="my-32 flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<Image
src={"/assets/images/error.webp"}
alt={"Not found error"}
width={182}
height={144}
/>
<h2>No bookmarked projects found</h2>
</div>
) : (
<>
{loading || !projects ? (
<div className="my-32 flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<i className="bi bi-arrow-repeat animate-spin text-2xl"></i>
</div>
) : (
<div className="mt-4 grid max-w-full grid-cols-1 place-items-center items-stretch gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{starredProjects.map((pid: ProjectId) => (
<ProjectCard key={pid} project={projects[pid]} maxWidth />
))}
{loading
? null
: starredProjects.length === 0 && (
<div className="mt-8 flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<Image
src={ErrorImage}
alt={"Not found error"}
width={182}
placeholder="blur"
height={144}
/>
<h2>No bookmarked projects found</h2>
</div>
)}
</>
)}
<div className="projects mt-8 grid max-w-full grid-cols-1 place-items-center items-stretch gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{starredProjects.length > 0 &&
typeof projects === "object" &&
starredProjects.map((pid: ProjectId) => (
<ProjectCard key={pid} project={projects[pid]} maxWidth />
))}
{loading
? Array.from({ length: 4 }).map((_, index) => (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I felt it was smoother before -- and I think the loading section showing project skeletons -> "no bookmarks found" is a a bit jarring; seems to take longer to load too with loading state defaulting to true.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, thinking more about it -- especially since this is dependent on local storage starred projects, rather than the "fetchAllProjects" -- we shouldn't be getting hung up on this fetch. Either there are no starredProjects, or there are and then we need fetch

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll revert

<ProjectSkeleton key={index} />
))
: null}
</div>
</>
);
}
51 changes: 51 additions & 0 deletions app/category/[cid]/_components/category-projects-list.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"use client";

import { useState, useEffect } from "react";
import { useInView } from "react-intersection-observer";
import { ProjectId, ProjectRecord } from "@/lib/types";
import ProjectsList from "@/components/ui/project-list";
import { useSearchStore } from "@/store/search-store";

const ITEMS_PER_PAGE = 12;

interface CategoryProjectsListProps {
projects: Record<ProjectId, ProjectRecord>;
}

export default function CategoryProjectsList({
projects,
}: CategoryProjectsListProps) {
const [projectsList, setProjectsList] = useState<ProjectRecord[]>([]);
const [displayedProjects, setDisplayedProjects] = useState<ProjectRecord[]>(
[],
);
const { setTags, setSearchKey } = useSearchStore();
const [page, setPage] = useState(1);
const [hasMore, setHasMore] = useState(true);
const { ref, inView } = useInView();

useEffect(() => {
setProjectsList(Object.values(projects));
setTags([]);
setSearchKey("");
}, [projects, setTags, setSearchKey]);

useEffect(() => {
const endIndex = page * ITEMS_PER_PAGE;
setDisplayedProjects(projectsList.slice(0, endIndex));
setHasMore(endIndex < projectsList.length);
}, [projectsList, page]);

useEffect(() => {
if (inView && hasMore) {
setPage((prevPage) => prevPage + 1);
}
}, [inView, hasMore]);

return (
<>
<ProjectsList projects={displayedProjects} />
{hasMore && <div ref={ref} style={{ height: "20px" }}></div>}
</>
);
}
28 changes: 5 additions & 23 deletions app/category/[cid]/loading.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,6 @@
import Image from "next/image";
import SearchImage from "@/public/assets/images/search.webp";

const ProjectSkeleton = ({ maxWidth }: { maxWidth?: boolean }) => {
return (
<div
className={`grow-1 h-92 flex w-full ${maxWidth ? "" : "max-w-[20rem]"} shrink-0 animate-pulse flex-col items-start justify-start gap-3 rounded-[2rem] bg-[#11141B] px-8 py-7`}
style={{ userSelect: "none" }}
>
<div className="flex h-full w-full items-center gap-2 md:h-auto md:flex-col md:items-start">
<div className="size-[6rem] h-24 w-24 shrink-0 rounded-full bg-gray-700 md:size-[7.5rem]"></div>
<div className="flex w-full flex-col gap-1">
<div className="h-8 w-3/4 rounded-md bg-gray-700"></div>
</div>
</div>
<div className="h-4 w-5/6 rounded-md bg-gray-700"></div>
<div className="mt-auto flex w-full flex-wrap items-center gap-2">
<div className="h-6 w-16 rounded-full bg-gray-700"></div>
<div className="h-6 w-16 rounded-full bg-gray-700"></div>
<div className="h-6 w-16 rounded-full bg-gray-700"></div>
</div>
</div>
);
};
import ProjectSkeleton from "@/components/ui/project-skeleton";

export default function LoadingPage() {
return (
Expand All @@ -30,15 +9,18 @@ export default function LoadingPage() {
className="absolute right-1/2 top-0 z-0 h-[8.75rem] w-[13.75rem] -translate-y-1/3 translate-x-1/2 object-cover md:right-0 md:h-[13.875rem] md:w-[21.6875rem] md:translate-x-0"
src={SearchImage}
alt={"Discover All Projects"}
placeholder="blur"
width={347}
loading="lazy"
height={222}
sizes="(min-width: 768px) 221px, 347px"
/>
<div className="flex animate-pulse flex-col items-center justify-center gap-3 px-2">
<div className="h-10 w-1/2 rounded-md bg-gray-700 md:h-12"></div>
</div>
<div className="mt-4 grid max-w-full grid-cols-1 place-items-center items-stretch gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{Array.from({ length: 4 }).map((_, index) => (
<ProjectSkeleton key={index} maxWidth />
<ProjectSkeleton key={index} />
))}
</div>
</div>
Expand Down
27 changes: 16 additions & 11 deletions app/category/[cid]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import ProjectCard from "@/components/ui/project-card";
import SectionHeading from "@/components/ui/section-heading";
import { fetchProjectCategory } from "@/lib/near-catalog";
import { ProjectCategory } from "@/lib/types";
import SearchImage from "@/public/assets/images/search.webp";
import ErrorImage from "@/public/assets/images/error.webp";
import Image from "next/image";
import CategoryProjectsList from "./_components/category-projects-list";

interface CategoryPageProps {
params: {
Expand Down Expand Up @@ -45,10 +46,13 @@ export default async function CategoryPage({ params }: CategoryPageProps) {
return (
<div className="my-32 flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<Image
src={"/assets/images/error.webp"}
src={ErrorImage}
alt={"Not found error"}
width={182}
priority
placeholder="blur"
height={144}
sizes="182px"
/>
<h2>Sorry, we could not find the category:</h2>
<p className="text-2xl uppercase">{cid}</p>
Expand All @@ -57,23 +61,24 @@ export default async function CategoryPage({ params }: CategoryPageProps) {
}

return (
<main className="container relative mx-auto flex flex-col gap-4 px-4 py-12">
<main className="container relative mx-auto px-4 py-12">
<Image
className="absolute right-1/2 top-0 z-0 h-[8.8125rem] w-[13.8125rem] -translate-y-1/3 translate-x-1/2 object-cover md:right-0 md:h-[13.875rem] md:w-[21.6875rem] md:translate-x-0"
src={SearchImage}
alt={"Discover All Projects"}
style={{ userSelect: "none" }}
placeholder="blur"
width={347}
priority
height={222}
sizes="(min-width: 768px) 221px, 347px"
/>
<SectionHeading
title={categoryData.cat_title}
description={categoryData.cat_description}
/>
<div className="projects mt-4 grid max-w-full grid-cols-1 place-items-center items-stretch gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
{Object.values(categoryData.data).map((project: any) => (
<ProjectCard key={project.slug} project={project} maxWidth />
))}
<div className="projects relative z-[1] flex flex-col gap-4">
<SectionHeading
title={categoryData.cat_title}
description={categoryData.cat_description}
/>
<CategoryProjectsList projects={categoryData.data} />
</div>
</main>
);
Expand Down
6 changes: 4 additions & 2 deletions app/project/[pid]/_components/discover-more.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { fetchRelatedProjects } from "@/lib/near-catalog";
import Image from "next/image";
import Link from "next/link";
import ErrorImage from "@/public/assets/images/error.webp";

interface DiscoverMoreProps {
pid: string;
Expand All @@ -20,7 +21,7 @@ function ProjectCard({ project }: { project: any }) {
width={64}
height={64}
/>
<div className="flex flex-col gap-1">
<div className="flex flex-col gap-1 overflow-hidden">
<h3 className="text-base font-bold">{project.profile.name}</h3>
<p className="text-sm font-medium">{project.profile.tagline}</p>
</div>
Expand All @@ -38,9 +39,10 @@ export default async function DiscoverMore({
return (
<div className="flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<Image
src={"/assets/images/error.webp"}
src={ErrorImage}
alt={"Not found error"}
width={182}
placeholder="blur"
height={144}
/>
<h2>Sorry, we could not find the results for:</h2>
Expand Down
3 changes: 2 additions & 1 deletion app/project/[pid]/_components/share-dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export default function ShareDropdown({ project }: ShareDropdownProps) {
<>
<button
onClick={toggleOpen}
aria-label="Share dropdown"
className={`flex items-center justify-center gap-1 rounded-lg px-2 py-1 text-xs font-bold text-[#80E9E5] transition-opacity duration-300 ease-in-out hover:opacity-50 ${open ? "bg-[#80E9E5]/40 text-black" : ""}`}
>
<i className="bi bi-three-dots-vertical text-xl text-[#80E9E5]"></i>
Expand All @@ -28,7 +29,7 @@ export default function ShareDropdown({ project }: ShareDropdownProps) {
<div className="absolute right-0 top-full mt-2 flex w-fit flex-col gap-2 rounded-lg bg-[#1c1b2a] p-2 shadow-lg ring-1 ring-white ring-opacity-5 focus:outline-none">
<div className="flex min-w-fit shrink-0">
<Link
href={`https://x.com/intent/post?text=Check out ${project.profile.name} - ${project.profile.tagline}%0A${site.url}project/${project.slug}%0A📒@nearcatalog`}
href={`https://x.com/intent/post?text=Check out ${project.profile.name} - ${project.profile.tagline}%0A${site.url}/project/${project.slug}%0A📒@nearcatalog`}
target="_blank"
className="flex w-full shrink-0 items-center gap-1 rounded-lg px-2 py-1 hover:bg-[#80E9E5]/40"
>
Expand Down
7 changes: 6 additions & 1 deletion app/project/[pid]/_components/twitter-embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,17 @@ export default function TwitterTimelineEmbed({
data-height="500"
data-tweet-limit="10"
href={href}
aria-label="Twitter Timeline"
>
<div className="my-4 flex flex-col items-center justify-center gap-2">
<Loader />
</div>
</a>
<Script defer src="https://platform.twitter.com/widgets.js" />
<Script
async
src="https://platform.twitter.com/widgets.js"
strategy="beforeInteractive"
/>
</div>
</div>
);
Expand Down
4 changes: 3 additions & 1 deletion app/project/[pid]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import ProjectHeader from "./_components/project-header";
import TokenInfo from "./_components/token-info";
import TwitterTimelineEmbed from "./_components/twitter-embed";
import Markdown from "react-markdown";
import ErrorImage from "@/public/assets/images/error.webp";

interface ProjectPageProps {
params: {
Expand All @@ -22,10 +23,11 @@ export default async function ProjectPage({ params }: ProjectPageProps) {
return (
<div className="my-32 flex flex-col items-center justify-center gap-4 font-medium text-[#BEBDBE]">
<Image
src={"/assets/images/error.webp"}
src={ErrorImage}
alt={"Not found error"}
width={182}
height={144}
placeholder="blur"
/>
<h2>Sorry, we could not find the results for:</h2>
<p className="text-2xl uppercase">{pid}</p>
Expand Down
12 changes: 9 additions & 3 deletions app/sitemap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,30 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
const uniqueTags = Array.from(new Set(tags)).sort();

const projectRoutes = projectSlugs.map((slug) => ({
url: `${BASE_URL}project/${slug}`,
url: `${BASE_URL}/project/${slug}`,
lastModified: new Date(),
priority: 0.5,
}));

const categoryRoutes = uniqueTags.map((slug) => ({
url: `${BASE_URL}category/${slug}`,
url: `${BASE_URL}/category/${slug}`,
lastModified: new Date(),
priority: 0.5,
}));

return [
{
url: `${BASE_URL}`,
url: `${BASE_URL}/`,
priority: 0.9,
// changeFrequency: "always",
lastModified: new Date(),
},
{
url: `${BASE_URL}/bookmarks`,
priority: 0.5,
// changeFrequency: "always",
lastModified: new Date(),
},
...projectRoutes,
...categoryRoutes,
];
Expand Down
1 change: 1 addition & 0 deletions components/home/discover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export default async function Discover() {
className="absolute right-1/2 top-0 z-0 h-[8.8125rem] w-[13.8125rem] -translate-y-1/3 translate-x-1/2 object-cover md:right-0 md:h-[13.875rem] md:w-[21.6875rem] md:translate-x-0"
src={SearchImage}
alt={"Discover All Projects"}
placeholder="blur"
width={347}
height={222}
/>
Expand Down
7 changes: 6 additions & 1 deletion components/home/ecosystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@ export default function EcosystemSupport() {
src={Mountains}
alt={"Mountains"}
priority
sizes="(max-width: 768px) 100vw, 1200px"
placeholder="blur"
className="absolute left-0 top-0 z-[0] h-full w-full object-cover"
sizes="100vw"
style={{
maskImage:
"linear-gradient(to bottom, rgba(0,0,0,0), rgba(0, 0, 0, 1) ,rgba(0,0,0,0))",
}}
/>
<div className="container z-[1] mx-auto flex flex-col items-center justify-center gap-12">
<SectionHeading
Expand Down
5 changes: 3 additions & 2 deletions components/home/ecosystem/project.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ export default function Project({ pid }: ProjectProps) {
: description;

return (
<div
<button
role="link"
onClick={() => router.push(`/project/${pid}#top`, { scroll: true })}
className="flex w-full max-w-60 shrink-0 cursor-pointer flex-col items-center justify-center gap-2 rounded-lg bg-black p-4 pt-2"
style={{
Expand All @@ -73,6 +74,6 @@ export default function Project({ pid }: ProjectProps) {
<p className="max-w-full text-center text-xs font-medium text-[#7E7E7E]">
{truncatedDescription}
</p>
</div>
</button>
);
}
Loading
Loading