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

refactor: add cta-slot to grant-item component #65

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 0 additions & 12 deletions src/grants/components/grant-card.tsx

This file was deleted.

38 changes: 38 additions & 0 deletions src/grants/components/grant-card/grant-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
interface Props {
id: string;
}

export const GrantCard = ({ id }: Props) => {
// TODO: JOB-678
return (
<div className="flex flex-col gap-3 rounded-lg bg-gradient-to-l from-[#0D0D0D] to-primary p-6 py-16 transition-all duration-300 hover:bg-white/10">
<span className="font-bold">{`Grant Program ${id}`}</span>
</div>
);
};

// TODO: Extract to cta-slot for grant-item component
{
/* <div className="flex flex-col gap-3">
<div className="flex size-32 items-center justify-center bg-white/5">
<span>LOGO HERE: {logo}</span>
</div>
<div className="flex items-center gap-3">
{url && (
<Button size="sm" as={Link} href={url} isIconOnly>
<WebIcon />
</Button>
)}
{discord && (
<Button size="sm" as={Link} href={discord} isIconOnly>
<DiscordIcon />
</Button>
)}
{twitter && (
<Button size="sm" as={Link} href={twitter} isIconOnly>
<TwitterIcon />
</Button>
)}
</div>
</div>; */
}
1 change: 1 addition & 0 deletions src/grants/components/grant-card/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './grant-card';
1 change: 1 addition & 0 deletions src/grants/components/grant-item/grant-item.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const meta: Meta<typeof GrantItem> = {
component: GrantItem,
args: {
grant: fakeGrant,
cta: null,
},
};

Expand Down
36 changes: 5 additions & 31 deletions src/grants/components/grant-item/grant-item.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import Link from 'next/link';

import { Avatar, AvatarGroup, Button } from '@nextui-org/react';
import { Avatar, AvatarGroup } from '@nextui-org/react';

import { formatNumber } from '@/shared/utils/format-number';

import { GRANT_TEST_IDS } from '@/grants/core/constants';
import { Grant } from '@/grants/core/types';
import { DiscordIcon } from '@/grants/components/icons/discord-icon';
import { TwitterIcon } from '@/grants/components/icons/twitter-icon';
import { WebIcon } from '@/grants/components/icons/web-icon';

interface Props {
grant: Grant;
grant: Omit<Grant, 'logo' | 'url' | 'discord' | 'twitter'>;
cta: React.ReactNode;
}

export const GrantItem = (props: Props) => {
Expand All @@ -28,11 +26,8 @@ export const GrantItem = (props: Props) => {
categories,
type,
reputations,
logo,
url,
discord,
twitter,
},
cta,
} = props;

const href = `/grants/${id}`;
Expand Down Expand Up @@ -95,28 +90,7 @@ export const GrantItem = (props: Props) => {
</div>
</div>

<div className="flex flex-col gap-3">
<div className="flex size-32 items-center justify-center bg-white/5">
<span>LOGO HERE: {logo}</span>
</div>
<div className="flex items-center gap-3">
{url && (
<Button size="sm" as={Link} href={url} isIconOnly>
<WebIcon />
</Button>
)}
{discord && (
<Button size="sm" as={Link} href={discord} isIconOnly>
<DiscordIcon />
</Button>
)}
{twitter && (
<Button size="sm" as={Link} href={twitter} isIconOnly>
<TwitterIcon />
</Button>
)}
</div>
</div>
{cta}
</Link>
);
};
31 changes: 31 additions & 0 deletions src/grants/components/grant-list/cta.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Button } from '@nextui-org/react';

const CaretRightIcon = () => (
<svg
width="32"
height="33"
viewBox="0 0 32 33"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12.2929 10.7929C12.6834 10.4024 13.3166 10.4024 13.7071 10.7929L18.7071 15.7929C19.0976 16.1834 19.0976 16.8166 18.7071 17.2071L13.7071 22.2071C13.3166 22.5976 12.6834 22.5976 12.2929 22.2071C11.9024 21.8166 11.9024 21.1834 12.2929 20.7929L16.5858 16.5L12.2929 12.2071C11.9024 11.8166 11.9024 11.1834 12.2929 10.7929Z"
fill="#F9FAFB"
/>
</svg>
);

export const GrantListCTA = () => {
return (
<div className="flex size-40 items-center justify-center">
<div className="flex items-center gap-4">
<Button color="primary">
<span>Apply</span>
</Button>
<CaretRightIcon />
</div>
</div>
);
};
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { GrantItem } from '@/grants/components/grant-item';

import { fakeGrant } from '@/grants/testutils/fake-grant';

import { GrantItem } from './grant-item';
import { GrantListCTA } from './cta';

export const GrantList = () => {
// TODO: JOB-682

return (
<div className="flex flex-col gap-4">
{Array.from({ length: 64 }).map((_, index) => (
<GrantItem key={index} grant={fakeGrant} />
<GrantItem key={index} grant={fakeGrant} cta={<GrantListCTA />} />
))}
</div>
);
Expand Down
1 change: 1 addition & 0 deletions src/grants/components/grant-list/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './grant-list';
2 changes: 1 addition & 1 deletion src/grants/pages/grant-list-page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GrantList } from '@/grants/components/grant-list';
import { GrantList } from '@/grants/components/grant-list/grant-list';

export const GrantListPage = () => {
return (
Expand Down
Loading