From 49c82c626aff2105512b1a75a61b15fe50dfae2d Mon Sep 17 00:00:00 2001 From: miteruzo Date: Sun, 10 May 2026 06:11:57 +0900 Subject: [PATCH] #171 --- frontend/src/components/PostEmbed.tsx | 18 +++++-- frontend/src/components/PostFormTagsArea.tsx | 5 +- .../src/components/users/InheritDialogue.tsx | 35 +++++++++---- .../src/components/users/UserCodeDialogue.tsx | 50 +++++++++++++------ frontend/src/pages/posts/PostHistoryPage.tsx | 10 +++- 5 files changed, 81 insertions(+), 37 deletions(-) diff --git a/frontend/src/components/PostEmbed.tsx b/frontend/src/components/PostEmbed.tsx index 45a2a8e..1be00ce 100644 --- a/frontend/src/components/PostEmbed.tsx +++ b/frontend/src/components/PostEmbed.tsx @@ -3,6 +3,7 @@ import YoutubeEmbed from 'react-youtube' import NicoViewer from '@/components/NicoViewer' import TwitterEmbed from '@/components/TwitterEmbed' +import { useDialogue } from '@/components/dialogues/DialogueProvider' import type { FC, RefObject } from 'react' @@ -16,6 +17,8 @@ type Props = { export default (({ ref, post, onLoadComplete, onMetadataChange }: Props) => { + const dialogue = useDialogue () + const url = new URL (post.url) switch (url.hostname.split ('.').slice (-2).join ('.')) @@ -82,12 +85,17 @@ export default (({ ref, post, onLoadComplete, onMetadataChange }: Props) => { height={360}/>) : (
- { + { e.preventDefault () - setFramed (confirm ('未確認の外部ページを表示します。\n' - + '悪意のあるスクリプトが実行される可能性があります。\n' - + '表示しますか?')) - return + + setFramed (await dialogue.confirm ({ + title: '未確認の外部ページを表示します。', + description: ( +
+

悪意のあるスクリプトが実行される可能性があります。

+

表示しますか?

+
), + confirmText: '表示' })) }}> 外部ページを表示
diff --git a/frontend/src/components/PostFormTagsArea.tsx b/frontend/src/components/PostFormTagsArea.tsx index 58e0db4..7588202 100644 --- a/frontend/src/components/PostFormTagsArea.tsx +++ b/frontend/src/components/PostFormTagsArea.tsx @@ -36,7 +36,7 @@ type Props = Omit, 'value' | 'onChange' | ' setTags: (tags: string) => void } -export default (({ tags, setTags, onBlur, ...rest }: Props) => { +export default (({ tags, setTags, ...rest }: Props) => { const ref = useRef (null) const [bounds, setBounds] = useState<{ start: number; end: number }> ({ start: 0, end: 0 }) @@ -85,10 +85,9 @@ export default (({ tags, setTags, onBlur, ...rest }: Props) => { await recompute (pos) }} onFocus={() => setFocused (true)} - onBlur={ev => { + onBlur={() => { setFocused (false) setSuggestionsVsbl (false) - onBlur?.(ev) }}/> {focused && ( { + const dialogue = useDialogue () + const [inputCode, setInputCode] = useState ('') const handleTransfer = async () => { - if (!(confirm ('引継ぎを行ってもよろしいですか?\n現在のアカウントからはログアウトされます.'))) + if (!(await dialogue.confirm ({ + title: '引継ぎを行ってもよろしいですか?', + description: '現在のアカウントからはログアウトされます.', + confirmText: '引継ぐ', + variant: 'danger' }))) return try @@ -44,14 +53,18 @@ export default ({ visible, onVisibleChange, setUser }: Props) => { return ( - - ほかのブラウザから引継ぐ -
- setInputCode (ev.target.value)}/> - -
+ + + ほかのブラウザから引継ぐ + +
+ setInputCode (ev.target.value)}/> + +
+
+
) } diff --git a/frontend/src/components/users/UserCodeDialogue.tsx b/frontend/src/components/users/UserCodeDialogue.tsx index 202b3ca..0b76baf 100644 --- a/frontend/src/components/users/UserCodeDialogue.tsx +++ b/frontend/src/components/users/UserCodeDialogue.tsx @@ -1,6 +1,10 @@ +import { useDialogue } from '@/components/dialogues/DialogueProvider' import { Button } from '@/components/ui/button' import { Dialog, DialogContent, + DialogDescription, + DialogFooter, + DialogHeader, DialogTitle } from '@/components/ui/dialog' import { toast } from '@/components/ui/use-toast' import { apiPost } from '@/lib/api' @@ -14,11 +18,20 @@ type Props = { visible: boolean export default ({ visible, onVisibleChange, user, setUser }: Props) => { + const dialogue = useDialogue () + const handleChange = async () => { if (!(user)) return - if (!(confirm ('引継ぎコードを再発行しますか?\n再発行するとほかのブラウザからはログアウトされます.'))) + if (!(await dialogue.confirm ({ + title: '引継ぎコードを再発行しますか?', + description: ( +
+

再発行するとほかのブラウザからはログアウトされます.

+
), + confirmText: '再発行', + variant: 'danger' }))) return const data = await apiPost<{ code: string }> ('/users/code/renew', { }, @@ -33,21 +46,26 @@ export default ({ visible, onVisibleChange, user, setUser }: Props) => { return ( - - 引継ぎコード -
-

あなたの引継ぎコードはこちらです:

-
{user?.inheritanceCode}
-

- このコードはほかの人には教えないでください! -

-
- -
-
+ + + 引継ぎコード + + +
+

あなたの引継ぎコードはこちらです:

+
{user?.inheritanceCode}
+

+ このコードはほかの人には教えないでください! +

+
+
+
+ + + +
) } diff --git a/frontend/src/pages/posts/PostHistoryPage.tsx b/frontend/src/pages/posts/PostHistoryPage.tsx index 8e6f21e..cabebfc 100644 --- a/frontend/src/pages/posts/PostHistoryPage.tsx +++ b/frontend/src/pages/posts/PostHistoryPage.tsx @@ -8,6 +8,7 @@ import TagLink from '@/components/TagLink' import PrefetchLink from '@/components/PrefetchLink' import PageTitle from '@/components/common/PageTitle' import Pagination from '@/components/common/Pagination' +import { useDialogue } from '@/components/dialogues/DialogueProvider' import MainArea from '@/components/layout/MainArea' import { toast } from '@/components/ui/use-toast' import { SITE_TITLE } from '@/config' @@ -35,6 +36,8 @@ const renderDiff = (diff: { current: string | null; prev: string | null }) => ( export default (() => { + const dialogue = useDialogue () + const location = useLocation () const query = new URLSearchParams (location.search) const id = query.get ('id') @@ -66,8 +69,11 @@ export default (() => { const handleRevert = async (e: MouseEvent, change: PostVersion) => { e.preventDefault () - if (!(confirm (`『${ change.title.current || change.url.current }』を版 ${ - change.versionNo } に差戻します.\nよろしいですか?`))) + if (!(await dialogue.confirm ({ + title: '差戻の確認', + description: `『${ change.title.current || change.url.current }』を版 ${ + change.versionNo } に差戻します.\nよろしいですか?`, + confirmText: '差戻' }))) return try