Skip to content

Commit

Permalink
filter out non-event folders from home screen
Browse files Browse the repository at this point in the history
  • Loading branch information
ichub committed Jul 24, 2024
1 parent 9c76b72 commit 092a742
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 16 deletions.
37 changes: 25 additions & 12 deletions apps/passport-client/components/screens/HomeScreen/Folder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { CSSProperties, useCallback } from "react";
import styled from "styled-components";
import { usePCDsInFolder } from "../../../src/appHooks";
import { cn } from "../../../src/util";
import { EVENT_DATES } from "./utils";
import { EVENTS } from "./utils";

export function FolderCard({
folder,
Expand All @@ -20,8 +20,9 @@ export function FolderCard({

const pcds = usePCDsInFolder(folder);

const startDate = EVENT_DATES[folder]?.start;
const endDate = EVENT_DATES[folder]?.end;
const startDate = EVENTS[folder]?.start;
const endDate = EVENTS[folder]?.end;
const img = EVENTS[folder]?.image;

let dateStr = null;

Expand All @@ -34,21 +35,33 @@ export function FolderCard({
style={style}
onClick={onClick}
className={cn(
"flex flex-row gap-2",
"bg-green-700 py-2 px-4 cursor-pointer hover:bg-green-600 transition-all duration-100",
"rounded font-bold shadow-lg select-none active:ring-2 active:ring-offset-4 active:ring-white ring-opacity-60 ring-offset-[#19473f]",
"border-none text-lg"
)}
>
{getNameFromPath(folder)}
<div className="font-normal text-sm">
{pcds.length} ticket{pcds.length > 1 ? "s" : ""}
{dateStr && (
<span>
{" · "}
{dateStr}
</span>
)}
<div className="flex-grow">
{getNameFromPath(folder)}
<div className="font-normal text-sm">
{pcds.length} ticket{pcds.length > 1 ? "s" : ""}
{dateStr && (
<span>
{" · "}
{dateStr}
</span>
)}
</div>
</div>
{img && (
<div
className="w-[100px] rounded"
style={{
backgroundImage: `url(${img})`,
backgroundSize: "cover"
}}
></div>
)}
</FolderEntryContainer>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
FolderEntryContainer,
FolderExplorerContainer
} from "./Folder";
import { isEvent } from "./utils";

export const HomeScreen = React.memo(HomeScreenImpl);

Expand Down Expand Up @@ -187,6 +188,7 @@ export function HomeScreenImpl(): JSX.Element | null {
// /FrogCrypto is a special and rendered by <FrogFolder />
(folder) => folder !== FrogCryptoFolderName
)
.filter(isEvent)
.sort((a, b) => a.localeCompare(b))
.map((folder) => {
return (
Expand Down
26 changes: 23 additions & 3 deletions apps/passport-client/components/screens/HomeScreen/utils.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,29 @@
export const EVENT_DATES: Record<string, { start: string; end: string }> = {
export interface EventInfo {
start: string;
end: string;
image?: string;
}

export const EVENTS: Record<string, EventInfo> = {
"ETH Berlin 04": { start: "2023-04-01", end: "2023-04-03" },
"0xPARC Summer '24": { start: "2023-05-15", end: "2023-05-18" },
"Edge Esmeralda": { start: "2023-06-10", end: "2023-06-12" },
"Edge Esmeralda": {
start: "2023-06-10",
end: "2023-06-12",
image:
"https://cdn.prod.website-files.com/65e8d8e39d148666896efd73/65e8d9c0db3e30b4fd35b335_kuri%201-c.png"
},
"ETH Prague 2024": { start: "2023-07-22", end: "2023-07-25" },
"ETH LATAM SPS": { start: "2023-08-05", end: "2023-08-07" },
"ETH Berlin 09": { start: "2023-09-18", end: "2023-09-21" },
"Edge City": { start: "2023-10-18", end: "2023-10-21" }
"Edge City": {
start: "2023-10-18",
end: "2023-10-21",
image:
"https://cdn.prod.website-files.com/65b2cb5abdecf7cd7747e170/65c139390d09b586db66b032_bg-image_v01.png"
}
};

export function isEvent(folder: string): folder is keyof typeof EVENTS {
return EVENTS[folder] !== undefined;
}
4 changes: 3 additions & 1 deletion apps/passport-client/components/shared/PCDCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ function PCDCardImpl({
style={!expanded ? { padding: "8px 12px", cursor: "pointer" } : {}}
>
{expanded ? (
<CardOutlineExpanded className={"border-4 border-blue-950 rounded-lg"}>
<CardOutlineExpanded
className={"border-4 border-blue-950 rounded-lg shadow-lg"}
>
{!hideHeader && (
<CardHeader
isMainIdentity={isMainIdentity}
Expand Down

0 comments on commit 092a742

Please sign in to comment.