From 7e2d94fdc026c5e8ef6e2eb2ce0c453f3b5eb240 Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sat, 23 Aug 2025 18:40:03 +0900 Subject: [PATCH] #49 --- frontend/src/App.tsx | 6 ++- frontend/src/components/ErrorScreen.tsx | 6 ++- frontend/src/components/MenuSeparator.tsx | 7 +++- frontend/src/components/NicoViewer.tsx | 6 +-- frontend/src/components/PostEditForm.tsx | 10 +++-- frontend/src/components/PostList.tsx | 7 ++-- frontend/src/components/TagDetailSidebar.tsx | 6 ++- frontend/src/components/TagLink.tsx | 14 +++---- frontend/src/components/TagSearch.tsx | 40 ++++++++++---------- frontend/src/components/TagSearchBox.tsx | 6 ++- frontend/src/components/TagSidebar.tsx | 6 ++- frontend/src/components/TopNav.tsx | 6 ++- frontend/src/components/TopNavUser.tsx | 6 ++- frontend/src/components/WikiBody.tsx | 5 ++- frontend/src/components/common/Form.tsx | 6 ++- 15 files changed, 80 insertions(+), 57 deletions(-) diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index c402103..d1b1e28 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -20,10 +20,12 @@ import WikiHistoryPage from '@/pages/wiki/WikiHistoryPage' import WikiNewPage from '@/pages/wiki/WikiNewPage' import WikiSearchPage from '@/pages/wiki/WikiSearchPage' +import type { FC } from 'react' + import type { User } from '@/types' -export default () => { +export default (() => { const [user, setUser] = useState (null) const [status, setStatus] = useState (200) @@ -91,4 +93,4 @@ export default () => { ) -} +}) satisfies FC diff --git a/frontend/src/components/ErrorScreen.tsx b/frontend/src/components/ErrorScreen.tsx index 1398645..b77c7f9 100644 --- a/frontend/src/components/ErrorScreen.tsx +++ b/frontend/src/components/ErrorScreen.tsx @@ -5,10 +5,12 @@ import errorImg from '@/assets/images/not-found.gif' import MainArea from '@/components/layout/MainArea' import { SITE_TITLE } from '@/config' +import type { FC } from 'react' + type Props = { status: number } -export default ({ status }: Props) => { +export default (({ status }: Props) => { const [message, rightMsg, leftMsg]: [string, string, string] = (() => { switch (status) { @@ -56,4 +58,4 @@ export default ({ status }: Props) => {

{message}

) -} +}) satisfies FC diff --git a/frontend/src/components/MenuSeparator.tsx b/frontend/src/components/MenuSeparator.tsx index a482ae3..8c7b5d3 100644 --- a/frontend/src/components/MenuSeparator.tsx +++ b/frontend/src/components/MenuSeparator.tsx @@ -1,6 +1,9 @@ -export default () => ( +import type { FC } from 'react' + + +export default (() => ( <> |
- ) + )) satisfies FC diff --git a/frontend/src/components/NicoViewer.tsx b/frontend/src/components/NicoViewer.tsx index 784ded5..a71acb5 100644 --- a/frontend/src/components/NicoViewer.tsx +++ b/frontend/src/components/NicoViewer.tsx @@ -4,10 +4,10 @@ type Props = { id: string, height: number, style?: CSSProperties } -import type { CSSProperties } from 'react' +import type { CSSProperties, FC } from 'react' -export default (props: Props) => { +export default ((props: Props) => { const { id, width, height, style = { } } = props const iframeRef = useRef (null) @@ -108,4 +108,4 @@ export default (props: Props) => { style={margedStyle} allowFullScreen allow="autoplay"/>) -} +}) satisfies FC diff --git a/frontend/src/components/PostEditForm.tsx b/frontend/src/components/PostEditForm.tsx index 50d474a..e40c09e 100644 --- a/frontend/src/components/PostEditForm.tsx +++ b/frontend/src/components/PostEditForm.tsx @@ -6,13 +6,15 @@ import TextArea from '@/components/common/TextArea' import { Button } from '@/components/ui/button' import { API_BASE_URL } from '@/config' +import type { FC } from 'react' + import type { Post } from '@/types' -type Props = { post: Post - onSave: (newPost: Post) => void } +type Props = { post: Post + onSave: (newPost: Post) => void } -export default ({ post, onSave }: Props) => { +export default (({ post, onSave }: Props) => { const [title, setTitle] = useState (post.title) const [tags, setTags] = useState (post.tags .filter (t => t.category !== 'nico') @@ -55,4 +57,4 @@ export default ({ post, onSave }: Props) => { 更新 ) -} +}) satisfies FC diff --git a/frontend/src/components/PostList.tsx b/frontend/src/components/PostList.tsx index 10fdd29..31cce00 100644 --- a/frontend/src/components/PostList.tsx +++ b/frontend/src/components/PostList.tsx @@ -1,13 +1,14 @@ import { Link } from 'react-router-dom' -import type { MouseEvent } from 'react' +import type { FC, MouseEvent } from 'react' + import type { Post } from '@/types' type Props = { posts: Post[] onClick?: (event: MouseEvent) => void } -export default ({ posts, onClick }: Props) => ( +export default (({ posts, onClick }: Props) => (
{posts.map ((post, i) => ( ( decoding="async" className="object-none w-full h-full" /> ))} -
) + )) satisfies FC diff --git a/frontend/src/components/TagDetailSidebar.tsx b/frontend/src/components/TagDetailSidebar.tsx index 9ea42ef..91d7092 100644 --- a/frontend/src/components/TagDetailSidebar.tsx +++ b/frontend/src/components/TagDetailSidebar.tsx @@ -6,6 +6,8 @@ import SubsectionTitle from '@/components/common/SubsectionTitle' import SidebarComponent from '@/components/layout/SidebarComponent' import { CATEGORIES } from '@/consts' +import type { FC } from 'react' + import type { Category, Post, Tag } from '@/types' type TagByCategory = { [key in Category]: Tag[] } @@ -13,7 +15,7 @@ type TagByCategory = { [key in Category]: Tag[] } type Props = { post: Post | null } -export default ({ post }: Props) => { +export default (({ post }: Props) => { const [tags, setTags] = useState ({ } as TagByCategory) const categoryNames: Record = { @@ -58,4 +60,4 @@ export default ({ post }: Props) => { ))} ) -} +}) satisfies FC diff --git a/frontend/src/components/TagLink.tsx b/frontend/src/components/TagLink.tsx index 881ce03..0734d4d 100644 --- a/frontend/src/components/TagLink.tsx +++ b/frontend/src/components/TagLink.tsx @@ -3,7 +3,7 @@ import { Link } from 'react-router-dom' import { LIGHT_COLOUR_SHADE, DARK_COLOUR_SHADE, TAG_COLOUR } from '@/consts' import { cn } from '@/lib/utils' -import type { ComponentProps, HTMLAttributes } from 'react' +import type { ComponentProps, FC, HTMLAttributes } from 'react' import type { Tag } from '@/types' @@ -20,11 +20,11 @@ type PropsWithoutLink = type Props = PropsWithLink | PropsWithoutLink -export default ({ tag, - linkFlg = true, - withWiki = true, - withCount = true, - ...props }: Props) => { +export default (({ tag, + linkFlg = true, + withWiki = true, + withCount = true, + ...props }: Props) => { const spanClass = cn ( `text-${ TAG_COLOUR[tag.category] }-${ LIGHT_COLOUR_SHADE }`, `dark:text-${ TAG_COLOUR[tag.category] }-${ DARK_COLOUR_SHADE }`) @@ -57,4 +57,4 @@ export default ({ tag, {withCount && ( {tag.postCount})} ) -} +}) satisfies FC diff --git a/frontend/src/components/TagSearch.tsx b/frontend/src/components/TagSearch.tsx index 600a6b4..fc5723f 100644 --- a/frontend/src/components/TagSearch.tsx +++ b/frontend/src/components/TagSearch.tsx @@ -6,10 +6,12 @@ import { API_BASE_URL } from '@/config' import TagSearchBox from './TagSearchBox' +import type { FC } from 'react' + import type { Tag } from '@/types' -const TagSearch: React.FC = () => { +export default (() => { const location = useLocation () const navigate = useNavigate () @@ -24,8 +26,8 @@ const TagSearch: React.FC = () => { const q = ev.target.value.trim ().split (' ').at (-1) if (!(q)) { - setSuggestions ([]) - return + setSuggestions ([]) + return } const res = await axios.get (`${ API_BASE_URL }/tags/autocomplete`, { params: { q } }) @@ -52,7 +54,7 @@ const TagSearch: React.FC = () => { case 'Enter': if (activeIndex < 0) - break + break ev.preventDefault () const selected = suggestions[activeIndex] selected && handleTagSelect (selected) @@ -65,8 +67,8 @@ const TagSearch: React.FC = () => { } if (ev.key === 'Enter' && (!(suggestionsVsbl) || activeIndex < 0)) { - navigate (`/posts?${ (new URLSearchParams ({ tags: search })).toString () }`) - setSuggestionsVsbl (false) + navigate (`/posts?${ (new URLSearchParams ({ tags: search })).toString () }`) + setSuggestionsVsbl (false) } } @@ -86,18 +88,16 @@ const TagSearch: React.FC = () => { return (
- setSuggestionsVsbl (true)} - onBlur={() => setSuggestionsVsbl (false)} - onKeyDown={handleKeyDown} - className="w-full px-3 py-2 border rounded dark:border-gray-600 dark:bg-gray-800 dark:text-white"/> - + setSuggestionsVsbl (true)} + onBlur={() => setSuggestionsVsbl (false)} + onKeyDown={handleKeyDown} + className="w-full px-3 py-2 border rounded dark:border-gray-600 dark:bg-gray-800 dark:text-white"/> +
) -} - -export default TagSearch +}) satisfies FC diff --git a/frontend/src/components/TagSearchBox.tsx b/frontend/src/components/TagSearchBox.tsx index 381d908..2a40b5f 100644 --- a/frontend/src/components/TagSearchBox.tsx +++ b/frontend/src/components/TagSearchBox.tsx @@ -1,5 +1,7 @@ import { cn } from '@/lib/utils' +import type { FC } from 'react' + import type { Tag } from '@/types' type Props = { suggestions: Tag[] @@ -7,7 +9,7 @@ type Props = { suggestions: Tag[] onSelect: (tag: Tag) => void } -export default ({ suggestions, activeIndex, onSelect }: Props) => { +export default (({ suggestions, activeIndex, onSelect }: Props) => { if (!(suggestions.length)) return @@ -25,4 +27,4 @@ export default ({ suggestions, activeIndex, onSelect }: Props) => { {{tag.postCount}} ))} ) -} +}) satisfies FC diff --git a/frontend/src/components/TagSidebar.tsx b/frontend/src/components/TagSidebar.tsx index 9dba8a9..a4b5b1e 100644 --- a/frontend/src/components/TagSidebar.tsx +++ b/frontend/src/components/TagSidebar.tsx @@ -10,6 +10,8 @@ import { API_BASE_URL } from '@/config' import { CATEGORIES } from '@/consts' import { cn } from '@/lib/utils' +import type { FC } from 'react' + import type { Post, Tag } from '@/types' type TagByCategory = Record @@ -17,7 +19,7 @@ type TagByCategory = Record type Props = { posts: Post[] } -export default ({ posts }: Props) => { +export default (({ posts }: Props) => { const navigate = useNavigate () const [tagsVsbl, setTagsVsbl] = useState (false) @@ -101,4 +103,4 @@ export default ({ posts }: Props) => { {tagsVsbl ? '▲▲▲ タグ一覧を閉じる ▲▲▲' : '▼▼▼ タグ一覧を表示 ▼▼▼'} ) -} +}) satisfies FC diff --git a/frontend/src/components/TopNav.tsx b/frontend/src/components/TopNav.tsx index ce1519d..84e113d 100644 --- a/frontend/src/components/TopNav.tsx +++ b/frontend/src/components/TopNav.tsx @@ -9,12 +9,14 @@ import { API_BASE_URL } from '@/config' import { WikiIdBus } from '@/lib/eventBus/WikiIdBus' import { cn } from '@/lib/utils' +import type { FC } from 'react' + import type { Menu, Tag, User, WikiPage } from '@/types' type Props = { user: User | null } -export default ({ user }: Props) => { +export default (({ user }: Props) => { const location = useLocation () const [menuOpen, setMenuOpen] = useState (false) @@ -167,4 +169,4 @@ export default ({ user }: Props) => { ) -} +}) satisfies FC diff --git a/frontend/src/components/TopNavUser.tsx b/frontend/src/components/TopNavUser.tsx index ea704bd..18a68f3 100644 --- a/frontend/src/components/TopNavUser.tsx +++ b/frontend/src/components/TopNavUser.tsx @@ -3,13 +3,15 @@ import { Link } from 'react-router-dom' import Separator from '@/components/MenuSeparator' import { cn } from '@/lib/utils' +import type { FC } from 'react' + import type { User } from '@/types' type Props = { user: User | null, sp?: boolean } -export default ({ user, sp }: Props) => { +export default (({ user, sp }: Props) => { if (!(user)) return @@ -27,4 +29,4 @@ export default ({ user, sp }: Props) => { {user.name || '名もなきニジラー'} ) -} +}) satisfies FC diff --git a/frontend/src/components/WikiBody.tsx b/frontend/src/components/WikiBody.tsx index 62ffbc3..7e96488 100644 --- a/frontend/src/components/WikiBody.tsx +++ b/frontend/src/components/WikiBody.tsx @@ -9,6 +9,7 @@ import SectionTitle from '@/components/common/SectionTitle' import SubsectionTitle from '@/components/common/SubsectionTitle' import { API_BASE_URL } from '@/config' +import type { FC } from 'react' import type { Components } from 'react-markdown' import type { WikiPage } from '@/types' @@ -31,7 +32,7 @@ const mdComponents = { h1: ({ children }) => {children}))) } as const satisfies Components -export default ({ title, body }: Props) => { +export default (({ title, body }: Props) => { const [pageNames, setPageNames] = useState ([]) const [realBody, setRealBody] = useState ('') @@ -101,4 +102,4 @@ export default ({ title, body }: Props) => { {realBody || `このページは存在しません。[新規作成してください](/wiki/new?title=${ encodeURIComponent (title) })。`} ) -} +}) satisfies FC diff --git a/frontend/src/components/common/Form.tsx b/frontend/src/components/common/Form.tsx index 73169d3..efb6a5f 100644 --- a/frontend/src/components/common/Form.tsx +++ b/frontend/src/components/common/Form.tsx @@ -1,9 +1,11 @@ import React from 'react' +import type { FC } from 'react' + type Props = { children: React.ReactNode } -export default ({ children }: Props) => ( +export default (({ children }: Props) => (
{children} -
) + )) satisfies FC