Hide gallery button in feedback notification
This commit is contained in:
parent
1a4d7477cb
commit
c43122dfba
@ -111,4 +111,36 @@
|
||||
margin: 0 var(--spacing-large);
|
||||
max-width: 90vw;
|
||||
}
|
||||
|
||||
/* Улучшения для работы с файлами на iOS */
|
||||
.fileInput {
|
||||
-webkit-appearance: none;
|
||||
font-size: 16px; /* Предотвращает масштабирование на iOS */
|
||||
}
|
||||
|
||||
.addImageButton {
|
||||
padding: 12px 16px; /* Увеличенная область нажатия для мобильных устройств */
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.imagePreview {
|
||||
width: 70px; /* Немного меньше для мобильных устройств */
|
||||
height: 70px;
|
||||
}
|
||||
|
||||
.removeImageButton {
|
||||
width: 24px; /* Увеличенная область нажатия для кнопки удаления */
|
||||
height: 24px;
|
||||
}
|
||||
}
|
||||
|
||||
/* Медиа-запрос для мобильных устройств */
|
||||
@media (max-width: 480px) {
|
||||
.imagePreviewContainer {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.textarea {
|
||||
min-height: 80px;
|
||||
}
|
||||
}
|
||||
|
||||
@ -45,14 +45,39 @@ const FeedbackModal: React.FC<FeedbackModalProps> = ({ isVisible, onClose, onSub
|
||||
}
|
||||
};
|
||||
|
||||
// Функция для обработки выбранного файла
|
||||
const handleFileSelect = (file: File) => {
|
||||
console.log('Обработка выбранного файла:', file.name, file.type);
|
||||
|
||||
// Проверяем, что это изображение
|
||||
if (file && file.type.startsWith('image/')) {
|
||||
console.log('Файл является изображением, добавляем в список');
|
||||
|
||||
// Добавляем файл в список изображений
|
||||
setImages(prevImages => [...prevImages, file]);
|
||||
} else {
|
||||
console.error('Выбранный файл не является изображением');
|
||||
setError('Пожалуйста, выберите файл изображения (JPEG, PNG и т.д.)');
|
||||
}
|
||||
};
|
||||
|
||||
// Обработчик добавления изображений
|
||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.target.files && e.target.files.length > 0) {
|
||||
const newFiles = Array.from(e.target.files);
|
||||
setImages(prevImages => [...prevImages, ...newFiles]);
|
||||
console.log('Событие выбора файла сработало');
|
||||
|
||||
try {
|
||||
const file = e.target.files?.[0];
|
||||
console.log('Выбранный файл:', file ? `${file.name} (${file.type})` : 'нет файла');
|
||||
|
||||
// Сбрасываем значение input, чтобы можно было выбрать тот же файл повторно
|
||||
e.target.value = '';
|
||||
if (file) {
|
||||
handleFileSelect(file);
|
||||
|
||||
// Сбрасываем значение input, чтобы можно было выбрать тот же файл повторно
|
||||
e.target.value = '';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('Ошибка при обработке выбранного файла:', err);
|
||||
setError('Произошла ошибка при выборе файла. Пожалуйста, попробуйте еще раз.');
|
||||
}
|
||||
};
|
||||
|
||||
@ -132,7 +157,6 @@ const FeedbackModal: React.FC<FeedbackModalProps> = ({ isVisible, onClose, onSub
|
||||
accept="image/*"
|
||||
onChange={handleFileChange}
|
||||
className={feedbackStyles.fileInput}
|
||||
multiple
|
||||
disabled={isLoading}
|
||||
/>
|
||||
|
||||
|
||||
@ -9,6 +9,7 @@ interface NotificationModalProps {
|
||||
promptText?: string;
|
||||
onGalleryClick: () => void;
|
||||
onContinueClick: () => void;
|
||||
showGalleryButton?: boolean; // Новый параметр для управления видимостью кнопки "В галерею"
|
||||
}
|
||||
|
||||
const NotificationModal: React.FC<NotificationModalProps> = ({
|
||||
@ -18,7 +19,8 @@ const NotificationModal: React.FC<NotificationModalProps> = ({
|
||||
isLoading = false,
|
||||
promptText,
|
||||
onGalleryClick,
|
||||
onContinueClick
|
||||
onContinueClick,
|
||||
showGalleryButton = true // По умолчанию кнопка видима
|
||||
}) => {
|
||||
if (!isVisible) return null;
|
||||
|
||||
@ -41,14 +43,16 @@ const NotificationModal: React.FC<NotificationModalProps> = ({
|
||||
)}
|
||||
|
||||
<div className={styles.buttons}>
|
||||
{showGalleryButton && (
|
||||
<button
|
||||
className={`${styles.button} ${styles.primaryButton}`}
|
||||
onClick={onGalleryClick}
|
||||
>
|
||||
В галерею
|
||||
</button>
|
||||
)}
|
||||
<button
|
||||
className={`${styles.button} ${styles.primaryButton}`}
|
||||
onClick={onGalleryClick}
|
||||
>
|
||||
В галерею
|
||||
</button>
|
||||
<button
|
||||
className={`${styles.button} ${styles.secondaryButton}`}
|
||||
className={`${styles.button} ${!showGalleryButton ? styles.primaryButton : styles.secondaryButton}`}
|
||||
onClick={onContinueClick}
|
||||
>
|
||||
Продолжить
|
||||
|
||||
@ -44,6 +44,7 @@ const Home: React.FC = () => {
|
||||
const [notificationMessage, setNotificationMessage] = useState('');
|
||||
const [isLoading, setIsLoading] = useState(false);
|
||||
const [promptText, setPromptText] = useState('');
|
||||
const [showGalleryButton, setShowGalleryButton] = useState(true);
|
||||
|
||||
// Состояние для хранения данных о последней успешной генерации
|
||||
const [lastGenerationData, setLastGenerationData] = useState<LastGenerationData>({});
|
||||
@ -81,6 +82,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Внимание');
|
||||
setNotificationMessage('Сначала загрузите изображение');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||
setIsNotificationVisible(true);
|
||||
return;
|
||||
}
|
||||
@ -90,6 +92,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Внимание');
|
||||
setNotificationMessage('Выберите образ для генерации');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||
setIsNotificationVisible(true);
|
||||
return;
|
||||
}
|
||||
@ -99,6 +102,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Внимание');
|
||||
setNotificationMessage('Введите текст промпта');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||
setIsNotificationVisible(true);
|
||||
return;
|
||||
}
|
||||
@ -132,6 +136,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Внимание');
|
||||
setNotificationMessage('Нельзя отправить одну и ту же комбинацию изображения и образа подряд. Пожалуйста, измените изображение или выберите другой образ.');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||
setIsNotificationVisible(true);
|
||||
return;
|
||||
}
|
||||
@ -142,6 +147,7 @@ const Home: React.FC = () => {
|
||||
setNotificationMessage('Отправка запроса...');
|
||||
setIsLoading(true);
|
||||
setPromptText('');
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений о генерации
|
||||
setIsNotificationVisible(true);
|
||||
|
||||
// Если выбран "Свой промпт" и введен текст, используем его
|
||||
@ -202,6 +208,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Ошибка');
|
||||
setNotificationMessage('Не удалось начать генерацию');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(true); // Показываем кнопку "В галерею" для уведомлений
|
||||
setIsNotificationVisible(true);
|
||||
}
|
||||
return;
|
||||
@ -299,6 +306,7 @@ const Home: React.FC = () => {
|
||||
promptText={promptText}
|
||||
onGalleryClick={handleGalleryClick}
|
||||
onContinueClick={handleContinueClick}
|
||||
showGalleryButton={showGalleryButton}
|
||||
/>
|
||||
|
||||
{/* Компонент обработки обратной связи */}
|
||||
@ -309,6 +317,7 @@ const Home: React.FC = () => {
|
||||
setNotificationTitle('Спасибо за обратную связь');
|
||||
setNotificationMessage('Ваше сообщение успешно отправлено');
|
||||
setIsLoading(false);
|
||||
setShowGalleryButton(false); // Скрываем кнопку "В галерею" для уведомления об обратной связи
|
||||
setIsNotificationVisible(true);
|
||||
}}
|
||||
/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user