From b1f318bbbda86031ae1e0cda2827f40b34f726eb Mon Sep 17 00:00:00 2001 From: Andre H Date: Thu, 7 Mar 2024 18:23:22 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20feat:=20implement=20mo?= =?UTF-8?q?ck=20connect=20git=20card?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../projects/create/MockConnectGitCard.tsx | 163 ++++++++++++++++++ 1 file changed, 163 insertions(+) create mode 100644 packages/frontend/src/components/projects/create/MockConnectGitCard.tsx diff --git a/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx new file mode 100644 index 00000000..5d214c94 --- /dev/null +++ b/packages/frontend/src/components/projects/create/MockConnectGitCard.tsx @@ -0,0 +1,163 @@ +import React, { useMemo } from 'react'; +import { SegmentedControls } from 'components/shared/SegmentedControls'; +import { useState } from 'react'; +import { + GithubIcon, + LockIcon, + TemplateIcon, + TemplateIconType, +} from 'components/shared/CustomIcon'; +import { relativeTimeISO } from 'utils/time'; +import { useMediaQuery } from 'usehooks-ts'; + +export const MockConnectGitCard = () => { + const [segmentedControlsValue, setSegmentedControlsValue] = + useState('import'); + + const isDesktopView = useMediaQuery('(min-width: 960px)'); // lg: + const segmentedControlsProps = isDesktopView ? {} : { size: 'sm' as const }; + + const fiveMinutesAgo = new Date(Date.now() - 1000 * 300).toISOString(); + + const SEGMENTED_CONTROLS_OPTIONS = [ + { + label: 'Import a repository', + value: 'import', + }, + { + label: 'Start with a template', + value: 'template', + }, + ]; + + const IMPORT_CONTENT = [ + { + full_name: 'snowball/igloo', + updated_at: fiveMinutesAgo, + }, + { + full_name: 'snowball/android-sdk', + updated_at: fiveMinutesAgo, + visibility: 'private', + }, + { + full_name: 'snowball/landing-page', + updated_at: fiveMinutesAgo, + }, + ]; + + const TEMPLATE_CONTENT = [ + { + name: 'Web app', + icon: 'web', + }, + { + name: 'Progressive Web App (PWA)', + icon: 'pwa', + }, + { + name: 'React Native', + icon: 'react-native', + }, + { + name: 'Kotlin', + icon: 'kotlin', + }, + { + name: 'Swift', + icon: 'swift', + }, + ]; + + const renderContent = useMemo(() => { + if (segmentedControlsValue === 'import') { + return ( +
+ {IMPORT_CONTENT.map((repo, index) => ( + <> + + {index !== IMPORT_CONTENT.length - 1 && ( +
+ )} + + ))} +
+ ); + } + return ( +
+ {TEMPLATE_CONTENT.map((template, index) => ( + + ))} +
+ ); + }, [segmentedControlsValue]); + + return ( +
+ {/* Content */} + + {renderContent} + + {/* Shade */} +
+
+ ); +}; + +const MockProjectCard = ({ + full_name, + updated_at, + visibility, +}: { + full_name: string; + updated_at?: string; + visibility?: string; +}) => { + return ( +
+ {/* Icon container */} +
+ +
+ {/* Content */} +
+
+

+ {full_name} +

+

+ {updated_at && relativeTimeISO(updated_at)} +

+
+ {visibility === 'private' && ( +
+ + Private +
+ )} +
+
+ ); +}; + +const MockTemplateCard = ({ icon, name }: { icon: string; name: string }) => { + return ( +
+ {/* Icon */} +
+ +
+ {/* Name */} +

+ {name} +

+
+ ); +}; From b922e632bf5dd46abb550afafc5e74d1499ccb83 Mon Sep 17 00:00:00 2001 From: Andre H Date: Thu, 7 Mar 2024 18:23:43 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=F0=9F=94=A7=20chore:=20add=20mock=20card?= =?UTF-8?q?=20to=20template?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frontend/src/components/projects/create/ConnectAccount.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/frontend/src/components/projects/create/ConnectAccount.tsx b/packages/frontend/src/components/projects/create/ConnectAccount.tsx index 1fc099a2..7c4e1e4e 100644 --- a/packages/frontend/src/components/projects/create/ConnectAccount.tsx +++ b/packages/frontend/src/components/projects/create/ConnectAccount.tsx @@ -13,6 +13,7 @@ import { import { useToast } from 'components/shared/Toast'; import { IconWithFrame } from 'components/shared/IconWithFrame'; import { Heading } from 'components/shared/Heading'; +import { MockConnectGitCard } from './MockConnectGitCard'; const SCOPES = 'repo user'; const GITHUB_OAUTH_URL = `https://github.com/login/oauth/authorize?client_id=${ @@ -93,6 +94,7 @@ const ConnectAccount: React.FC = ({
{/* TODO: Add ConnectAccountTabPanel */} + {/*
*/}