Compare commits

...

7 Commits

Author SHA1 Message Date
Wahyu Kurniawan
9170b73862
📝 docs: add todo to experiment using Link componnt 2024-02-28 16:48:09 +07:00
Wahyu Kurniawan
6f04e4e97e
🎨 style: add transition when hover 2024-02-28 16:44:47 +07:00
Wahyu Kurniawan
608af57a0d
♻️ refactor: move wavy border class to project card theme 2024-02-28 16:40:59 +07:00
Wahyu Kurniawan
07f229e33f
🎨 style: adjust hovered background for wavy border 2024-02-28 16:30:35 +07:00
Wahyu Kurniawan
12d5fd82b2
Merge branch 'main' of https://github.com/snowball-tools/snowballtools-base into ayungavis/T-4921-home-update-project-card 2024-02-28 16:23:27 +07:00
Wahyu Kurniawan
6396b066c8
️ feat: make the whole card clickable 2024-02-28 15:06:25 +07:00
Wahyu Kurniawan
0ffdbd3304
🎨 style: add hover interaction to the card 2024-02-28 15:05:58 +07:00
3 changed files with 33 additions and 12 deletions

View File

@ -8,6 +8,7 @@ export const projectCardTheme = tv({
'rounded-2xl',
'flex',
'flex-col',
'group',
],
upperContent: ['px-4', 'py-4', 'flex', 'items-start', 'gap-3', 'relative'],
content: ['flex', 'flex-col', 'gap-1', 'flex-1'],
@ -20,13 +21,15 @@ export const projectCardTheme = tv({
description: ['text-xs', 'text-elements-low-em'],
icons: ['flex', 'items-center', 'gap-1'],
lowerContent: [
'bg-surface-card-hovered',
'transition-colors',
'duration-150',
'px-4',
'py-4',
'flex',
'flex-col',
'gap-2',
'rounded-b-2xl',
'group-hover:bg-surface-card-hovered',
],
latestDeployment: ['flex', 'items-center', 'gap-2'],
deploymentStatusContainer: [
@ -46,6 +49,12 @@ export const projectCardTheme = tv({
'items-center',
'gap-2',
],
wavyBorder: [
'bg-surface-card',
'transition-colors',
'duration-150',
'group-hover:bg-surface-card-hovered',
],
},
variants: {
status: {

View File

@ -1,4 +1,8 @@
import React, { ComponentPropsWithoutRef, MouseEvent } from 'react';
import React, {
ComponentPropsWithoutRef,
MouseEvent,
useCallback,
} from 'react';
import { ProjectCardTheme, projectCardTheme } from './ProjectCard.theme';
import { Project } from 'gql-client';
import { Button } from 'components/shared/Button';
@ -11,7 +15,7 @@ import {
WarningDiamondIcon,
} from 'components/shared/CustomIcon';
import { relativeTimeMs } from 'utils/time';
import { Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
import { Avatar } from 'components/shared/Avatar';
import { getInitials } from 'utils/geInitials';
import {
@ -27,6 +31,8 @@ export interface ProjectCardProps
project: Project;
}
// TODO: Update the whole component to use `Link` from `react-router-dom` and remove the `useNavigate` hook,
// currently it's not possible to use `Link` because the dot menu is not a direct child of the `Link` component
export const ProjectCard = ({
className,
project,
@ -38,14 +44,24 @@ export const ProjectCard = ({
// TODO: Update this to use the actual status from the API
const hasError = status === 'failure';
const navigate = useNavigate();
const handleOptionsClick = (
e: MouseEvent<HTMLButtonElement, globalThis.MouseEvent>,
) => {
e.stopPropagation();
};
const handleClick = useCallback(() => {
navigate(`projects/${project.id}`);
}, [project.id, navigate]);
return (
<div {...props} className={theme.wrapper({ className })}>
<div
{...props}
className={theme.wrapper({ className })}
onClick={handleClick}
>
{/* Upper content */}
<div className={theme.upperContent()}>
{/* Icon container */}
@ -54,14 +70,13 @@ export const ProjectCard = ({
imageSrc={project.icon}
initials={getInitials(project.name)}
/>
{/* </div> */}
{/* Title and website */}
<Link to={`projects/${project.id}`} className={theme.content()}>
<div className={theme.content()}>
<p className={theme.title()}>{project.name}</p>
<p className={theme.description()}>
{project.deployments[0]?.domain?.name ?? 'No domain'}
</p>
</Link>
</div>
{/* Icons */}
<div className={theme.icons()}>
{hasError && <WarningDiamondIcon className="text-elements-danger" />}
@ -87,10 +102,7 @@ export const ProjectCard = ({
</div>
</div>
{/* Wave */}
<WavyBorder
variant="stroke-and-fill"
className="bg-surface-card-hovered"
/>
<WavyBorder variant="stroke-and-fill" className={theme.wavyBorder()} />
{/* Lower content */}
<div className={theme.lowerContent()}>
{/* Latest deployment */}

View File

@ -1,7 +1,7 @@
import React from 'react';
import templates from 'assets/templates';
import { RepositoryList } from 'components/projects/create/RepositoryList';
import RepositoryList from 'components/projects/create/RepositoryList';
import ConnectAccount from 'components/projects/create/ConnectAccount';
import { useOctokit } from 'context/OctokitContext';
import { Heading } from 'components/shared/Heading';