From 2710e4cf26b4c8dc2c08c47e736bf03d50f31ec6 Mon Sep 17 00:00:00 2001 From: Cecilia Sanare Date: Thu, 12 Sep 2024 16:27:53 -0500 Subject: [PATCH] chore: component restructure --- src/App.tsx | 2 +- .../{NewAppBadge.tsx => app/AppBadges.tsx} | 4 ++-- src/components/{ => app}/AppImage.module.css | 0 src/components/{ => app}/AppImage.tsx | 8 +++---- src/components/{ => common}/Button.module.css | 0 src/components/{ => common}/Button.tsx | 2 +- .../{ => common}/ButtonGroup.module.css | 0 src/components/{ => common}/ButtonGroup.tsx | 0 src/components/{ => common}/Card.tsx | 2 +- src/components/{ => common}/Code.module.css | 0 src/components/{ => common}/Code.tsx | 2 +- src/components/{ => common}/Divider.tsx | 0 src/components/{ => common}/IconTooltip.tsx | 0 src/components/{ => common}/Input.tsx | 2 +- src/components/{ => common}/Label.tsx | 0 src/components/common/Modal.tsx | 12 ++++++++++ .../{ => common}/PageSpinner.module.css | 0 src/components/{ => common}/PageSpinner.tsx | 0 src/components/{ => common}/Pill.tsx | 0 src/components/{ => common}/Spinner.tsx | 0 src/components/layout/AppEditButton.tsx | 22 +++++++++++++++++++ src/components/{ => layout}/AppFooter.tsx | 2 +- src/components/{ => layout}/AppHeader.tsx | 20 +++++------------ src/pages/SplashPage.tsx | 6 ++--- src/pages/apps/AppPage.tsx | 16 +++++++------- src/pages/apps/Layout.tsx | 2 +- src/pages/apps/SearchPage.tsx | 8 +++---- 27 files changed, 68 insertions(+), 42 deletions(-) rename src/components/{NewAppBadge.tsx => app/AppBadges.tsx} (81%) rename src/components/{ => app}/AppImage.module.css (100%) rename src/components/{ => app}/AppImage.tsx (87%) rename src/components/{ => common}/Button.module.css (100%) rename src/components/{ => common}/Button.tsx (98%) rename src/components/{ => common}/ButtonGroup.module.css (100%) rename src/components/{ => common}/ButtonGroup.tsx (100%) rename src/components/{ => common}/Card.tsx (89%) rename src/components/{ => common}/Code.module.css (100%) rename src/components/{ => common}/Code.tsx (97%) rename src/components/{ => common}/Divider.tsx (100%) rename src/components/{ => common}/IconTooltip.tsx (100%) rename src/components/{ => common}/Input.tsx (97%) rename src/components/{ => common}/Label.tsx (100%) create mode 100644 src/components/common/Modal.tsx rename src/components/{ => common}/PageSpinner.module.css (100%) rename src/components/{ => common}/PageSpinner.tsx (100%) rename src/components/{ => common}/Pill.tsx (100%) rename src/components/{ => common}/Spinner.tsx (100%) create mode 100644 src/components/layout/AppEditButton.tsx rename src/components/{ => layout}/AppFooter.tsx (96%) rename src/components/{ => layout}/AppHeader.tsx (78%) diff --git a/src/App.tsx b/src/App.tsx index 7490c38..5469202 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,7 @@ import { type FC } from 'react'; import { Outlet } from 'react-router-dom'; import { Toaster } from 'sonner'; -import { AppFooter } from './components/AppFooter'; +import { AppFooter } from '@/components/layout/AppFooter'; import * as styles from './App.module.css'; export const Component: FC = () => { diff --git a/src/components/NewAppBadge.tsx b/src/components/app/AppBadges.tsx similarity index 81% rename from src/components/NewAppBadge.tsx rename to src/components/app/AppBadges.tsx index f2faeb7..56b576e 100644 --- a/src/components/NewAppBadge.tsx +++ b/src/components/app/AppBadges.tsx @@ -1,14 +1,14 @@ import { useMemo, type FC } from 'react'; import type { ComputedApp, ThinApp } from '@/types'; import { BadgePlus } from 'lucide-react'; -import { IconTooltip } from './IconTooltip'; +import { IconTooltip } from '@/components/common/IconTooltip'; import { isAfter, parseISO, subWeeks } from 'date-fns'; type Props = { app: ComputedApp; }; -export const NewAppBadge: FC = ({ app }) => { +export const AppBadges: FC = ({ app }) => { const isNew = useMemo(() => isAfter(parseISO(app.created_at), subWeeks(new Date(), 1)), [app.created_at]); if (!isNew) return null; diff --git a/src/components/AppImage.module.css b/src/components/app/AppImage.module.css similarity index 100% rename from src/components/AppImage.module.css rename to src/components/app/AppImage.module.css diff --git a/src/components/AppImage.tsx b/src/components/app/AppImage.tsx similarity index 87% rename from src/components/AppImage.tsx rename to src/components/app/AppImage.tsx index 0040831..89b994f 100644 --- a/src/components/AppImage.tsx +++ b/src/components/app/AppImage.tsx @@ -1,9 +1,9 @@ import { type FC } from 'react'; import { Link } from 'react-router-dom'; -import { cn } from '../utils/cn'; +import { cn } from '@/utils/cn'; import * as styles from './AppImage.module.css'; import type { ComputedApp, ThinApp } from '@/types'; -import { NewAppBadge } from './NewAppBadge'; +import { AppBadges } from './AppBadges'; type Props = { className?: string; @@ -14,7 +14,7 @@ type Props = { export const AppImage: FC = ({ className, app, to }) => { return to ? ( - +
{app.name}
@@ -26,7 +26,7 @@ export const AppImage: FC = ({ className, app, to }) => { ) : (
- +
diff --git a/src/components/Button.module.css b/src/components/common/Button.module.css similarity index 100% rename from src/components/Button.module.css rename to src/components/common/Button.module.css diff --git a/src/components/Button.tsx b/src/components/common/Button.tsx similarity index 98% rename from src/components/Button.tsx rename to src/components/common/Button.tsx index be7ed00..8f8bf18 100644 --- a/src/components/Button.tsx +++ b/src/components/common/Button.tsx @@ -1,6 +1,6 @@ import { type ComponentProps, type FC, type ReactNode } from 'react'; import { Link } from 'react-router-dom'; -import { cn } from '../utils/cn'; +import { cn } from '@/utils/cn'; import * as styles from './Button.module.css'; type SharedProps = { diff --git a/src/components/ButtonGroup.module.css b/src/components/common/ButtonGroup.module.css similarity index 100% rename from src/components/ButtonGroup.module.css rename to src/components/common/ButtonGroup.module.css diff --git a/src/components/ButtonGroup.tsx b/src/components/common/ButtonGroup.tsx similarity index 100% rename from src/components/ButtonGroup.tsx rename to src/components/common/ButtonGroup.tsx diff --git a/src/components/Card.tsx b/src/components/common/Card.tsx similarity index 89% rename from src/components/Card.tsx rename to src/components/common/Card.tsx index 277a4a7..0077c57 100644 --- a/src/components/Card.tsx +++ b/src/components/common/Card.tsx @@ -1,5 +1,5 @@ import type { FC, ReactNode } from 'react'; -import { cn } from '../utils/cn'; +import { cn } from '@/utils/cn'; type Props = { className?: string; diff --git a/src/components/Code.module.css b/src/components/common/Code.module.css similarity index 100% rename from src/components/Code.module.css rename to src/components/common/Code.module.css diff --git a/src/components/Code.tsx b/src/components/common/Code.tsx similarity index 97% rename from src/components/Code.tsx rename to src/components/common/Code.tsx index 0726ccd..20689c9 100644 --- a/src/components/Code.tsx +++ b/src/components/common/Code.tsx @@ -1,5 +1,5 @@ import { useState, type FC, type ReactNode } from 'react'; -import { cn } from '../utils/cn'; +import { cn } from '@/utils/cn'; import { toast } from 'sonner'; import { delay } from '@ribbon-studios/js-utils'; import { Clipboard } from 'lucide-react'; diff --git a/src/components/Divider.tsx b/src/components/common/Divider.tsx similarity index 100% rename from src/components/Divider.tsx rename to src/components/common/Divider.tsx diff --git a/src/components/IconTooltip.tsx b/src/components/common/IconTooltip.tsx similarity index 100% rename from src/components/IconTooltip.tsx rename to src/components/common/IconTooltip.tsx diff --git a/src/components/Input.tsx b/src/components/common/Input.tsx similarity index 97% rename from src/components/Input.tsx rename to src/components/common/Input.tsx index d90f318..d1fbd27 100644 --- a/src/components/Input.tsx +++ b/src/components/common/Input.tsx @@ -1,5 +1,5 @@ import { type FC, type ComponentProps } from 'react'; -import { cn } from '../utils/cn'; +import { cn } from '@/utils/cn'; import { X } from 'lucide-react'; import { useCachedState } from '@ribbon-studios/react-utils'; diff --git a/src/components/Label.tsx b/src/components/common/Label.tsx similarity index 100% rename from src/components/Label.tsx rename to src/components/common/Label.tsx diff --git a/src/components/common/Modal.tsx b/src/components/common/Modal.tsx new file mode 100644 index 0000000..24522b8 --- /dev/null +++ b/src/components/common/Modal.tsx @@ -0,0 +1,12 @@ +import { type FC, type ReactNode } from 'react'; +import { createPortal } from 'react-dom'; + +type Props = { + children?: ReactNode; + className?: string; + disabled?: boolean; +}; + +export const Modal: FC = ({ ...props }) => { + return createPortal(
, document.body); +}; diff --git a/src/components/PageSpinner.module.css b/src/components/common/PageSpinner.module.css similarity index 100% rename from src/components/PageSpinner.module.css rename to src/components/common/PageSpinner.module.css diff --git a/src/components/PageSpinner.tsx b/src/components/common/PageSpinner.tsx similarity index 100% rename from src/components/PageSpinner.tsx rename to src/components/common/PageSpinner.tsx diff --git a/src/components/Pill.tsx b/src/components/common/Pill.tsx similarity index 100% rename from src/components/Pill.tsx rename to src/components/common/Pill.tsx diff --git a/src/components/Spinner.tsx b/src/components/common/Spinner.tsx similarity index 100% rename from src/components/Spinner.tsx rename to src/components/common/Spinner.tsx diff --git a/src/components/layout/AppEditButton.tsx b/src/components/layout/AppEditButton.tsx new file mode 100644 index 0000000..0086195 --- /dev/null +++ b/src/components/layout/AppEditButton.tsx @@ -0,0 +1,22 @@ +import { type FC } from 'react'; +import { Edit } from 'lucide-react'; +import { Button } from '../common/Button'; + +type Props = { + id?: string; +}; + +export const AppQuickEdit: FC = ({ id }) => { + return ( + + ); +}; diff --git a/src/components/AppFooter.tsx b/src/components/layout/AppFooter.tsx similarity index 96% rename from src/components/AppFooter.tsx rename to src/components/layout/AppFooter.tsx index 30416cb..3a54f8b 100644 --- a/src/components/AppFooter.tsx +++ b/src/components/layout/AppFooter.tsx @@ -1,7 +1,7 @@ import { type FC } from 'react'; import { Link } from 'react-router-dom'; import { Bug, Code2 } from 'lucide-react'; -import { Button } from './Button'; +import { Button } from '@/components/common/Button'; export const AppFooter: FC = () => { return ( diff --git a/src/components/AppHeader.tsx b/src/components/layout/AppHeader.tsx similarity index 78% rename from src/components/AppHeader.tsx rename to src/components/layout/AppHeader.tsx index 5ee44f5..b347832 100644 --- a/src/components/AppHeader.tsx +++ b/src/components/layout/AppHeader.tsx @@ -1,10 +1,11 @@ import { useEffect, type FC, useState } from 'react'; -import { useSearch } from '../context/search'; +import { useSearch } from '../../context/search'; import { Link, useParams } from 'react-router-dom'; import { ArrowUp, Edit } from 'lucide-react'; -import { cn } from '../utils/cn'; -import { Button } from './Button'; -import { Input } from './Input'; +import { cn } from '@/utils/cn'; +import { Button } from '../common/Button'; +import { Input } from '../common/Input'; +import { AppQuickEdit } from './AppEditButton'; type Props = { onChange?: (value: string) => void; @@ -46,16 +47,7 @@ export const AppHeader: FC = ({ onChange }) => {
- +