⚡️ feat: restyling template card
This commit is contained in:
parent
39725c2be3
commit
01a752d1db
@ -2,31 +2,31 @@ export default [
|
|||||||
{
|
{
|
||||||
id: '1',
|
id: '1',
|
||||||
name: 'Progressive Web App (PWA)',
|
name: 'Progressive Web App (PWA)',
|
||||||
icon: '^',
|
icon: 'pwa',
|
||||||
repoFullName: `${process.env.REACT_APP_GITHUB_PWA_TEMPLATE_REPO}`,
|
repoFullName: `${process.env.REACT_APP_GITHUB_PWA_TEMPLATE_REPO}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '2',
|
id: '2',
|
||||||
name: 'Image Upload PWA',
|
name: 'Image Upload PWA',
|
||||||
icon: '^',
|
icon: 'pwa',
|
||||||
repoFullName: `${process.env.REACT_APP_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO}`,
|
repoFullName: `${process.env.REACT_APP_GITHUB_IMAGE_UPLOAD_PWA_TEMPLATE_REPO}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '3',
|
id: '3',
|
||||||
name: 'Kotlin',
|
name: 'Kotlin',
|
||||||
icon: '^',
|
icon: 'kotlin',
|
||||||
repoFullName: '',
|
repoFullName: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '4',
|
id: '4',
|
||||||
name: 'React Native',
|
name: 'React Native',
|
||||||
icon: '^',
|
icon: 'react-native',
|
||||||
repoFullName: '',
|
repoFullName: '',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: '5',
|
id: '5',
|
||||||
name: 'Swift',
|
name: 'Swift',
|
||||||
icon: '^',
|
icon: 'swift',
|
||||||
repoFullName: '',
|
repoFullName: '',
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
@ -1,53 +0,0 @@
|
|||||||
import React from 'react';
|
|
||||||
import toast from 'react-hot-toast';
|
|
||||||
|
|
||||||
import { IconButton, Typography } from '@material-tailwind/react';
|
|
||||||
|
|
||||||
import { Link } from 'react-router-dom';
|
|
||||||
|
|
||||||
interface TemplateDetails {
|
|
||||||
id: string;
|
|
||||||
name: string;
|
|
||||||
icon: string;
|
|
||||||
}
|
|
||||||
interface TemplateCardProps {
|
|
||||||
template: TemplateDetails;
|
|
||||||
isGitAuth: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
const CardDetails = ({ template }: { template: TemplateDetails }) => {
|
|
||||||
return (
|
|
||||||
<div className="h-14 group bg-gray-200 border-gray-200 rounded-lg shadow p-4 flex items-center justify-between">
|
|
||||||
<Typography className="grow" placeholder={''}>
|
|
||||||
{template.icon} {template.name}
|
|
||||||
</Typography>
|
|
||||||
<div>
|
|
||||||
<IconButton
|
|
||||||
size="sm"
|
|
||||||
className="rounded-full hidden group-hover:block"
|
|
||||||
placeholder={''}
|
|
||||||
>
|
|
||||||
{'>'}
|
|
||||||
</IconButton>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const TemplateCard: React.FC<TemplateCardProps> = ({ template, isGitAuth }) => {
|
|
||||||
return isGitAuth ? (
|
|
||||||
<Link to={`template?templateId=${template.id}`}>
|
|
||||||
<CardDetails template={template} />
|
|
||||||
</Link>
|
|
||||||
) : (
|
|
||||||
<a
|
|
||||||
onClick={() =>
|
|
||||||
toast.error('Connect Git account to start with a template')
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<CardDetails template={template} />
|
|
||||||
</a>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export default TemplateCard;
|
|
@ -0,0 +1,62 @@
|
|||||||
|
import { Button } from 'components/shared/Button';
|
||||||
|
import {
|
||||||
|
ArrowRightCircleIcon,
|
||||||
|
ClockOutlineIcon,
|
||||||
|
TemplateIcon,
|
||||||
|
TemplateIconType,
|
||||||
|
} from 'components/shared/CustomIcon';
|
||||||
|
import { Tag } from 'components/shared/Tag';
|
||||||
|
import React, { ComponentPropsWithoutRef, useCallback } from 'react';
|
||||||
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
import { useToast } from 'components/shared/Toast';
|
||||||
|
|
||||||
|
export interface TemplateDetail {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
icon: string;
|
||||||
|
repoFullName?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface TemplateCardProps extends ComponentPropsWithoutRef<'div'> {
|
||||||
|
template: TemplateDetail;
|
||||||
|
isGitAuth: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const TemplateCard = ({ template, isGitAuth }: TemplateCardProps) => {
|
||||||
|
const { toast, dismiss } = useToast();
|
||||||
|
const navigate = useNavigate();
|
||||||
|
|
||||||
|
const handleClick = useCallback(() => {
|
||||||
|
if (isGitAuth) {
|
||||||
|
return navigate(`/template?templateId=${template.id}`);
|
||||||
|
}
|
||||||
|
return toast({
|
||||||
|
id: 'connect-git-account',
|
||||||
|
title: 'Connect Git account to start with a template',
|
||||||
|
variant: 'error',
|
||||||
|
onDismiss: dismiss,
|
||||||
|
});
|
||||||
|
}, [isGitAuth, navigate, template.id, toast]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex items-center gap-3 px-3 py-3 bg-base-bg-alternate rounded-2xl">
|
||||||
|
{/* Icon */}
|
||||||
|
<div className="px-1 py-1 rounded-xl bg-base-bg border border-border-interactive shadow-card">
|
||||||
|
<TemplateIcon type={template.icon as TemplateIconType} />
|
||||||
|
</div>
|
||||||
|
{/* Name */}
|
||||||
|
<p className="flex-1 text-sm tracking-tighter text-elements-high-em">
|
||||||
|
{template.name}
|
||||||
|
</p>
|
||||||
|
{template?.repoFullName ? (
|
||||||
|
<Button variant="tertiary" size="sm" iconOnly onClick={handleClick}>
|
||||||
|
<ArrowRightCircleIcon />
|
||||||
|
</Button>
|
||||||
|
) : (
|
||||||
|
<Tag size="xs" type="neutral" leftIcon={<ClockOutlineIcon />}>
|
||||||
|
Soon
|
||||||
|
</Tag>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
@ -0,0 +1 @@
|
|||||||
|
export * from './TemplateCard';
|
@ -1,27 +1,32 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
import templates from '../../../../assets/templates';
|
import templates from 'assets/templates';
|
||||||
import TemplateCard from '../../../../components/projects/create/TemplateCard';
|
import RepositoryList from 'components/projects/create/RepositoryList';
|
||||||
import RepositoryList from '../../../../components/projects/create/RepositoryList';
|
import ConnectAccount from 'components/projects/create/ConnectAccount';
|
||||||
import ConnectAccount from '../../../../components/projects/create/ConnectAccount';
|
import { useOctokit } from 'context/OctokitContext';
|
||||||
import { useOctokit } from '../../../../context/OctokitContext';
|
import { Heading } from 'components/shared/Heading';
|
||||||
|
import { TemplateCard } from 'components/projects/create/TemplateCard';
|
||||||
|
|
||||||
const NewProject = () => {
|
const NewProject = () => {
|
||||||
const { octokit, updateAuth, isAuth } = useOctokit();
|
const { octokit, updateAuth, isAuth } = useOctokit();
|
||||||
|
|
||||||
return isAuth ? (
|
return isAuth ? (
|
||||||
<>
|
<>
|
||||||
<h5 className="mt-4 ml-4">Start with template</h5>
|
<div className="space-y-3">
|
||||||
<div className="grid grid-cols-3 p-4 gap-4">
|
<Heading as="h3" className="font-medium text-lg">
|
||||||
{templates.map((template) => {
|
Start with template
|
||||||
return (
|
</Heading>
|
||||||
<TemplateCard
|
<div className="grid grid-cols-1 sm:grid-cols-3 gap-3">
|
||||||
isGitAuth={Boolean(octokit)}
|
{templates.map((template) => {
|
||||||
template={template}
|
return (
|
||||||
key={template.id}
|
<TemplateCard
|
||||||
/>
|
isGitAuth={Boolean(octokit)}
|
||||||
);
|
template={template}
|
||||||
})}
|
key={template.id}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<h5 className="mt-4 ml-4">Import a repository</h5>
|
<h5 className="mt-4 ml-4">Import a repository</h5>
|
||||||
<RepositoryList octokit={octokit} />
|
<RepositoryList octokit={octokit} />
|
||||||
|
Loading…
Reference in New Issue
Block a user