Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions apps/web/src/components/photo/PhotoPreview.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -132,3 +132,37 @@
background: var(--accent-bg);
transform: translateY(-2px);
}

.loading-container {
display: flex;
flex-direction: column;
align-items: center;
gap: 16px;
padding: 20px;
}

.loading-spinner {
width: 40px;
height: 40px;
border: 4px solid var(--accent-bg);
border-top: 4px solid var(--warm-brown);
border-radius: 50%;
animation: spin 1s linear infinite;
}

.loading-text {
font-size: 16px;
color: var(--text-primary);
font-weight: 500;
text-align: center;
margin: 0;
}

@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
47 changes: 33 additions & 14 deletions apps/web/src/components/photo/PhotoPreview.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useCallback } from 'react';
import { useCallback, useState } from 'react';
import { useNavigate } from 'react-router-dom';

import clsx from 'clsx';
Expand All @@ -17,12 +17,16 @@ interface PhotoPreviewProps {
export const PhotoPreview = (props: PhotoPreviewProps) => {
const { onConfirm, onRetake } = props;

const [isLoading, setIsLoading] = useState(false);

const navigate = useNavigate();
const handleConfirm = useCallback(() => {
if (onConfirm) {
onConfirm();
}

setIsLoading(true);

// localStorage から theme と difficulty と base64 のデータを取得し、リクエストボディに含める
const themesData = JSON.parse(
localStorage.getItem('currentThemes') || '{"themes": []}',
Expand Down Expand Up @@ -67,6 +71,7 @@ export const PhotoPreview = (props: PhotoPreviewProps) => {
navigate('/result');
} catch (e) {
console.error(e);
setIsLoading(false);
}
};

Expand Down Expand Up @@ -119,19 +124,33 @@ export const PhotoPreview = (props: PhotoPreviewProps) => {

{/* アクションボタン */}
<div className={styles['preview-actions']}>
<button
className={clsx(styles['preview-button'], styles['btn-confirm'])}
onClick={handleConfirm}
>
この写真で決定!
</button>
{parseInt(localStorage.getItem('countDown') || '0', 10) > 1 && (
<button
className={clsx(styles['preview-button'], styles['btn-retake'])}
onClick={handleRetake}
>
撮り直す
</button>
{isLoading ? (
<div className={styles['loading-container']}>
<div className={styles['loading-spinner']}></div>
</div>
) : (
<>
<button
className={clsx(
styles['preview-button'],
styles['btn-confirm'],
)}
onClick={handleConfirm}
>
この写真で決定!
</button>
{parseInt(localStorage.getItem('countDown') || '0', 10) > 1 && (
<button
className={clsx(
styles['preview-button'],
styles['btn-retake'],
)}
onClick={handleRetake}
>
撮り直す
</button>
)}
</>
)}
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/web/src/components/result/ResultScreen.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@
}

.character-image {
width: 52%;
height: 52%;
width: 42%;
height: 42%;
object-fit: contain;
object-position: center;
border-radius: 64px;
Expand Down