Compare commits

...

6 Commits

Author SHA1 Message Date
Sushan Yadav
c57bf61b37 chore: use Heading component 2024-02-28 13:29:04 +05:45
Sushan Yadav
6b948d47e8 Merge branch 'main' into sushan/T-4916-project-overview-activity-section 2024-02-28 13:26:44 +05:45
Sushan Yadav
ae1e3455e4 comment fixes 2024-02-28 13:15:57 +05:45
Sushan Yadav
951fd9a3f3 chore: limit commit message to 4 line 2024-02-28 12:24:14 +05:45
Sushan Yadav
97fea83582 feat: add sepeator calc in comment 2024-02-28 11:56:22 +05:45
Sushan Yadav
47cd8079e4 feat: reskin w/ new design system 2024-02-28 11:50:38 +05:45
4 changed files with 109 additions and 56 deletions

View File

@ -1,45 +1,85 @@
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom';
import { Typography, IconButton, Avatar } from '@material-tailwind/react';
import { relativeTimeISO } from '../../../utils/time';
import { GitCommitWithBranch } from '../../../types'; import { GitCommitWithBranch } from '../../../types';
import { Avatar } from 'components/shared/Avatar';
import { Button } from 'components/shared/Button';
import {
ArrowRightCircleFilledIcon,
BranchIcon,
} from 'components/shared/CustomIcon';
import { formatDistance } from 'date-fns';
import { getInitials } from 'utils/geInitials';
interface ActivityCardProps { interface ActivityCardProps {
activity: GitCommitWithBranch; activity: GitCommitWithBranch;
} }
const ActivityCard = ({ activity }: ActivityCardProps) => { const ActivityCard = ({ activity }: ActivityCardProps) => {
const formattedDate = formatDistance(
new Date(activity.commit.author!.date!),
new Date(),
{
addSuffix: true,
},
);
return ( return (
<div className="group flex gap-2 hover:bg-gray-200 rounded mt-1"> <>
<div className="w-8"> <Link
to={activity.html_url}
target="_blank"
className="p-3 gap-2 focus-within:ring-2 focus-within:ring-controls-primary/40 focus:outline-none rounded-xl transition-colors hover:bg-base-bg-alternate flex group"
>
<div>
<Avatar <Avatar
src={activity.author?.avatar_url} type="orange"
variant="rounded" size={36}
size="sm" initials={getInitials(activity.commit.author?.name ?? '')}
placeholder={''} imageSrc={activity.author?.avatar_url}
/> />
</div> </div>
<div className="grow"> <div className="flex-1">
<Typography placeholder={''}>{activity.commit.author?.name}</Typography> <span className="text-elements-high-em text-sm font-medium tracking-tight">
<Typography variant="small" color="gray" placeholder={''}> {activity.commit.author?.name}
{relativeTimeISO(activity.commit.author!.date!)} ^{' '} </span>
{activity.branch.name} <span className="text-elements-low-em text-xs flex items-center gap-2">
</Typography> <span title={formattedDate} className="whitespace-nowrap">
<Typography variant="small" color="gray" placeholder={''}> {formattedDate}
{activity.commit.message} </span>
</Typography> {/* Dot */}
<span className="w-0.5 h-0.5 rounded-full bg-border-interactive-hovered"></span>
<span className="flex justify-center items-center gap-1.5">
<div>
<BranchIcon />
</div> </div>
<div className="mr-2 self-center hidden group-hover:block"> <span
<IconButton title={activity.branch.name}
size="sm" // pseudo to increase hover area
className="rounded-full bg-gray-600" className="before:absolute relative before:h-5 before:-top-4 before:inset-x-0"
placeholder={''}
> >
{'>'} <span className="line-clamp-1">{activity.branch.name}</span>
</IconButton> </span>
</div> </span>
</span>
<p
title={activity.commit.message}
className="text-sm line-clamp-4 tracking-tight text-elements-mid-em mt-2"
>
{activity.commit.message}
</p>
</div> </div>
<Button
aria-label="Go to commit"
variant="unstyled"
tabIndex={-1}
className="p-0 text-elements-low-em group-focus-within:opacity-100 group-hover:opacity-100 opacity-0 transition-all"
leftIcon={<ArrowRightCircleFilledIcon className="w-5 h-5" />}
/>
</Link>
{/* Separator calc => 100% - 36px (avatar) - 12px (padding-left) - 8px (gap)
*/}
<div className="pt-2 mb-2 ml-auto h-1 w-[calc(100%-36px-12px-8px)] border-b border-border-separator last:border-b-transparent"></div>
</>
); );
}; };

View File

@ -0,0 +1,21 @@
import React from 'react';
import { CustomIcon, CustomIconProps } from './CustomIcon';
export const ArrowRightCircleFilledIcon = (props: CustomIconProps) => {
return (
<CustomIcon
{...props}
fill="none"
height="32"
viewBox="0 0 32 32"
width="32"
>
<path
clipRule="evenodd"
d="M29.3334 16C29.3334 8.63619 23.3638 2.66666 16 2.66666C8.63622 2.66666 2.66669 8.63619 2.66669 16C2.66669 23.3638 8.63622 29.3333 16 29.3333C23.3638 29.3333 29.3334 23.3638 29.3334 16ZM18.1144 17.3333L16.3905 19.0572C15.8698 19.5779 15.8698 20.4221 16.3905 20.9428C16.9112 21.4635 17.7555 21.4635 18.2762 20.9428L21.3334 17.8856C22.3748 16.8442 22.3748 15.1558 21.3334 14.1144L18.2762 11.0572C17.7555 10.5365 16.9112 10.5365 16.3905 11.0572C15.8698 11.5779 15.8698 12.4221 16.3905 12.9428L18.1144 14.6667H10.6667C9.93031 14.6667 9.33335 15.2636 9.33335 16C9.33335 16.7364 9.93031 17.3333 10.6667 17.3333H18.1144Z"
fill="currentColor"
fillRule="evenodd"
/>
</CustomIcon>
);
};

View File

@ -32,3 +32,4 @@ export * from './GitHubLogo';
export * from './ClockIcon'; export * from './ClockIcon';
export * from './HorizontalDotIcon'; export * from './HorizontalDotIcon';
export * from './WarningDiamondIcon'; export * from './WarningDiamondIcon';
export * from './ArrowRightCircleFilledIcon';

View File

@ -1,15 +1,9 @@
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { Domain, DomainStatus } from 'gql-client'; import { Domain, DomainStatus } from 'gql-client';
import { Link, useNavigate, useOutletContext } from 'react-router-dom'; import { useNavigate, useOutletContext } from 'react-router-dom';
import { RequestError } from 'octokit'; import { RequestError } from 'octokit';
import { import { Typography, Chip, Avatar, Tooltip } from '@material-tailwind/react';
Typography,
Button,
Chip,
Avatar,
Tooltip,
} from '@material-tailwind/react';
import ActivityCard from '../../../../components/projects/project/ActivityCard'; import ActivityCard from '../../../../components/projects/project/ActivityCard';
import { relativeTimeMs } from '../../../../utils/time'; import { relativeTimeMs } from '../../../../utils/time';
@ -17,6 +11,8 @@ import { useOctokit } from '../../../../context/OctokitContext';
import { GitCommitWithBranch, OutletContextType } from '../../../../types'; import { GitCommitWithBranch, OutletContextType } from '../../../../types';
import { useGQLClient } from '../../../../context/GQLClientContext'; import { useGQLClient } from '../../../../context/GQLClientContext';
import { formatAddress } from '../../../../utils/format'; import { formatAddress } from '../../../../utils/format';
import { Button } from 'components/shared/Button';
import { Heading } from 'components/shared/Heading';
const COMMITS_PER_PAGE = 4; const COMMITS_PER_PAGE = 4;
@ -107,9 +103,9 @@ const OverviewTabPanel = () => {
}, [project]); }, [project]);
return ( return (
<div className="grid grid-cols-5"> <div className="grid grid-cols-5 gap-[72px] mt-7">
<div className="col-span-3 p-2"> <div className="col-span-3">
<div className="flex items-center gap-2 p-2 "> <div className="flex items-center gap-2">
<Avatar <Avatar
src={project.icon || '/gray.png'} src={project.icon || '/gray.png'}
variant="rounded" variant="rounded"
@ -143,12 +139,11 @@ const OverviewTabPanel = () => {
/> />
<Button <Button
className="normal-case rounded-full" className="normal-case rounded-full"
color="blue" variant="primary"
size="sm" size="sm"
onClick={() => { onClick={() => {
navigate('settings/domains'); navigate('settings/domains');
}} }}
placeholder={''}
> >
Setup Setup
</Button> </Button>
@ -179,21 +174,17 @@ const OverviewTabPanel = () => {
<div>No current deployment found</div> <div>No current deployment found</div>
)} )}
</div> </div>
<div className="col-span-2 p-2"> <div className="col-span-2 mr-1">
<div className="flex justify-between"> <div className="flex items-center justify-between">
<Typography variant="h6" placeholder={''}> <Heading className="text-lg leading-6 font-medium">Activity</Heading>
Activity <Button variant="tertiary" size="sm">
</Typography>
<button className="text-xs bg-gray-300 rounded-full p-2">
See all See all
</button> </Button>
</div> </div>
<div className="p-2"> <div className="mt-5">
{activities.map((activity, index) => { {activities.map((activity, index) => {
return ( return (
<Link to={activity.html_url} target="_blank" key={index}> <ActivityCard activity={activity} key={`activity-${index}`} />
<ActivityCard activity={activity} />
</Link>
); );
})} })}
</div> </div>