Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: kudos-ink/portal
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: a0e968242876f237618c1cd63109c9f2c865ae9c
Choose a base ref
..
head repository: kudos-ink/portal
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 69299cbff236f3922087403df964ef684e61de88
Choose a head ref
Showing with 97 additions and 59 deletions.
  1. +1 −3 app/layout.tsx
  2. +6 −6 app/page.tsx
  3. +12 −10 components/contributions-table/row.tsx
  4. +2 −5 components/contributions-table/table.tsx
  5. +44 −27 components/filters/toolbar.tsx
  6. +1 −1 components/navbar.tsx
  7. +2 −1 data/config.ts
  8. +25 −0 hooks/useSticky.tsx
  9. +1 −1 types/contribution.ts
  10. +3 −5 utils/github.ts
4 changes: 1 addition & 3 deletions app/layout.tsx
Original file line number Diff line number Diff line change
@@ -73,9 +73,7 @@ export default function RootLayout({
<Providers themeProps={{ attribute: "class", defaultTheme: "kudos" }}>
<div className="bg-[radial-gradient(ellipse_at_center,_var(--tw-gradient-stops))] from-default from-0% to-background to-80% relative flex flex-col h-screen">
<Navbar />
<main className="container mx-auto max-w-7xl py-16 px-6 flex-grow">
{children}
</main>
<main className="py-16 flex-grow">{children}</main>
<footer className="py-6 px-6 md:px-8 md:py-0">
<div className="container flex flex-col items-center justify-between gap-4 md:h-24 md:flex-row">
<p className="text-balance text-center text-sm leading-loose text-muted-foreground md:text-left">
12 changes: 6 additions & 6 deletions app/page.tsx
Original file line number Diff line number Diff line change
@@ -27,24 +27,24 @@ export default async function Home({ searchParams }: IHomeProps) {
};

return (
<div>
<section className="flex flex-col items-center text-center pt-10 pb-20">
<>
<section className="flex flex-col items-center text-center pt-10 pb-24 px-6 container mx-auto max-w-7xl">
<h1 className={title()}>Find Collaborations,</h1>
<h1 className={title()}>Collect Kudos</h1>
</section>
<CtaBanner />
<div className="flex flex-col gap-4 pt-10">
<div className="flex flex-col pt-10">
<Toolbar searchParams={searchParams} />
<div>
<section className="px-6 container mx-auto max-w-7xl">
<ContributionsTable
items={items}
queries={{
page_size: 10,
filter,
}}
/>
</div>
</section>
</div>
</div>
</>
);
}
22 changes: 12 additions & 10 deletions components/contributions-table/row.tsx
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ import { useState, useRef, useEffect } from "react";
const MAX_LABEL_WIDTH = 192;

interface IProjectProps {
avatarSrc: string;
avatarSrc: string | null;
name: string;
repository: string;
}
@@ -25,20 +25,22 @@ export const Project = ({ avatarSrc, name, repository }: IProjectProps) => {

interface IAvatarProps {
alt: string;
src: string;
src: string | null;
}

const Avatar = ({ alt, src }: IAvatarProps) => {
return (
<div className="bg-foreground rounded-md min-w-[45px] shrink-0">
<MyImage
className="border"
src={src}
alt={alt}
radius="sm"
height={45}
width={45}
/>
{src !== null && (
<MyImage
className="border"
src={src}
alt={alt}
radius="sm"
height={45}
width={45}
/>
)}
</div>
);
};
7 changes: 2 additions & 5 deletions components/contributions-table/table.tsx
Original file line number Diff line number Diff line change
@@ -132,18 +132,15 @@ export const Table = ({ items, queries = {} }: ITableProps) => {

return (
<>
<div className="py-4 px-3 bg-default-100 border-small rounded-t-md">
<span className="text-lg font-bold">Good First Contributions</span>
</div>
<NuiTable
hideHeader
aria-label="Example table with infinite pagination"
classNames={{
table:
"w-full max-w-7xl border-spacing-0 rounded-b-md overflow-hidden",
"w-full bg-gradient-to-r from-background to-background-200 to-80% max-w-7xl border-spacing-0 rounded-b-md overflow-hidden",
wrapper:
"bg-background overflow-visible p-0 rounded-none border-small rounded-b-md",
tr: "relative bg-gradient-to-r from-background to-background-200 to-80% border-y-small border-y-overlay before:content-[''] before:absolute before:bg-hover-overlay before:opacity-0 before:w-full before:h-full before:transition-opacity before:duration-300 before:ease-in-out hover:before:opacity-100",
tr: "relative bg-red border-y-small border-y-overlay before:content-[''] before:absolute before:bg-hover-overlay before:opacity-0 before:w-full before:h-full before:transition-opacity before:duration-300 before:ease-in-out sm:before:max-h-[88px] md:before:max-h-[62px] hover:before:opacity-100",
td: "px-2 sm:px-inherit",
}}
>
71 changes: 44 additions & 27 deletions components/filters/toolbar.tsx
Original file line number Diff line number Diff line change
@@ -5,14 +5,19 @@ import {
PROJECTS_OPTIONS,
} from "@/data/filters";
import { useFilters } from "@/hooks/useFilters";
import useSticky from "@/hooks/useSticky";
import { SearchParams } from "@/types/filters";
import ClearFilters from "./clear-filters";
import SelectFilter from "./select-filter";
import { useRef } from "react";
interface IToolbarProps {
searchParams: SearchParams;
}

const Toolbar = ({ searchParams }: IToolbarProps) => {
const toolbarRef = useRef<HTMLDivElement>(null);
const isToolbarSticky = useSticky(toolbarRef);

const { filters, updateFilter, clearFilter, clearAllFilters } = useFilters({
initialParams: searchParams,
});
@@ -27,34 +32,46 @@ const Toolbar = ({ searchParams }: IToolbarProps) => {
const numberOfFilters = Object.keys(filters).length;

return (
<div className="flex flex-col gap-4 items-start overflow-hidden lg:flex-row lg:items-center">
<div className="flex flex-nowrap overflow-x-auto gap-4 w-full sm:w-auto">
<SelectFilter
placeholder="Languages"
mainEmoji="🌐"
options={LANGUAGES_OPTIONS}
selectedKey={filters.languages}
onSelect={handleSelect("languages")}
/>
<SelectFilter
placeholder="Interests"
mainEmoji="🪄"
options={INTERESTS_OPTIONS}
selectedKey={filters.interests}
onSelect={handleSelect("interests")}
/>
<SelectFilter
placeholder="Projects"
mainEmoji="🖥️"
options={PROJECTS_OPTIONS}
selectedKey={filters.projects}
onSelect={handleSelect("projects")}
/>
</div>
<div
className={`sticky top-0 z-10 bg-background ${
isToolbarSticky ? "bg-background" : "bg-transparent"
}`}
ref={toolbarRef}
>
<div className="container mx-auto max-w-7xl px-6 pt-6 flex flex-col gap-4">
<div className="flex flex-col gap-4 items-start overflow-hidden lg:flex-row lg:items-center">
<div className="flex flex-nowrap overflow-x-auto gap-4 w-full sm:w-auto">
<SelectFilter
placeholder="Languages"
mainEmoji="🌐"
options={LANGUAGES_OPTIONS}
selectedKey={filters.languages}
onSelect={handleSelect("languages")}
/>
<SelectFilter
placeholder="Interests"
mainEmoji="🪄"
options={INTERESTS_OPTIONS}
selectedKey={filters.interests}
onSelect={handleSelect("interests")}
/>
<SelectFilter
placeholder="Projects"
mainEmoji="🖥️"
options={PROJECTS_OPTIONS}
selectedKey={filters.projects}
onSelect={handleSelect("projects")}
/>
</div>

{numberOfFilters > 1 && (
<ClearFilters onClear={clearAllFilters} value="Clear all filters" />
)}
{numberOfFilters > 1 && (
<ClearFilters onClear={clearAllFilters} value="Clear all filters" />
)}
</div>
<div className="py-4 px-3 bg-default-100 border-small rounded-t-md">
<span className="text-lg font-bold">Good First Contributions</span>
</div>
</div>
</div>
);
};
2 changes: 1 addition & 1 deletion components/navbar.tsx
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@ import { SITE_CONFIG } from "@/data/config";

export const Navbar = () => {
return (
<NextUINavbar maxWidth="xl" position="sticky" isBordered>
<NextUINavbar maxWidth="xl" position="static" isBordered>
<NavbarContent className="basis-1/5 sm:basis-full" justify="start">
<NavbarBrand as="li" className="gap-3 max-w-fit">
<NextLink className="flex justify-start items-center gap-1" href="/">
3 changes: 2 additions & 1 deletion data/config.ts
Original file line number Diff line number Diff line change
@@ -7,7 +7,8 @@ export const SITE_CONFIG = {
twitter: "https://twitter.com/kudos_ink",
bugReport:
"https://github.com/kudos-ink/portal/issues/new?assignees=&labels=bug&projects=&template=bug_report.yml&title=",
includeProject: "https://github.com/kudos-ink/portal/issues",
includeProject:
"https://github.com/kudos-ink/repository-classification/issues/new?labels=new-project&template=NEW_PROJECT.yaml&title=%5BAdd%5D%3A+",
},
};

25 changes: 25 additions & 0 deletions hooks/useSticky.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { useState, useEffect, RefObject } from "react";

const useSticky = (ref: RefObject<HTMLElement>) => {
const [isSticky, setIsSticky] = useState(false);

useEffect(() => {
const handleScroll = () => {
if (ref.current) {
const boundingRect = ref.current.getBoundingClientRect();
const isElementTopAboveViewport = boundingRect.top <= 0;
setIsSticky(isElementTopAboveViewport);
}
};

window.addEventListener("scroll", handleScroll);

return () => {
window.removeEventListener("scroll", handleScroll);
};
}, [ref]);

return isSticky;
};

export default useSticky;
2 changes: 1 addition & 1 deletion types/contribution.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { PaginatedCustomDataResponse } from ".";

export type Contribution = {
id: number;
avatar: string;
avatar: string | null;
labels: string[];
languages: string[];
project: string;
8 changes: 3 additions & 5 deletions utils/github.ts
Original file line number Diff line number Diff line change
@@ -3,9 +3,7 @@ import { ProjectLogoImages } from "@/lib/notion/types";
export function getImagePath(
githubUrl: string,
projectLogos: ProjectLogoImages,
): string {
return (
"/images/" + projectLogos[githubUrl] ||
"https://avatars.githubusercontent.com/u/86160567?s=200&v=4"
);
): string | null {
const endpoint = projectLogos[githubUrl];
return endpoint ? "/images/" + endpoint : null;
}