From 3f3fc2e6318df18ec164becd8fb2d9b5109108a7 Mon Sep 17 00:00:00 2001 From: John Angel Date: Fri, 13 Sep 2024 11:38:50 +0200 Subject: [PATCH 1/4] style: Modal rounded corners in mobile --- src/components/Modal.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index c5ee363f6..afb5f0b44 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -32,7 +32,7 @@ const ModalContent = React.forwardRef Date: Fri, 13 Sep 2024 11:39:10 +0200 Subject: [PATCH 2/4] feat: Remove native-base from SwitchLanguageModal --- src/components/SwitchLanguageButton.tsx | 2 +- src/modals/SwitchLanguageModal.tsx | 65 +++++++++++-------------- src/pages/Settings.tsx | 2 +- 3 files changed, 30 insertions(+), 39 deletions(-) diff --git a/src/components/SwitchLanguageButton.tsx b/src/components/SwitchLanguageButton.tsx index da7076224..1ead5f244 100644 --- a/src/components/SwitchLanguageButton.tsx +++ b/src/components/SwitchLanguageButton.tsx @@ -15,7 +15,7 @@ const SwitchLanguageButton: React.FC = () => { - setShowSwitchLanguage(false)} /> + ); }; diff --git a/src/modals/SwitchLanguageModal.tsx b/src/modals/SwitchLanguageModal.tsx index d9951fc94..a1249ca2f 100644 --- a/src/modals/SwitchLanguageModal.tsx +++ b/src/modals/SwitchLanguageModal.tsx @@ -1,49 +1,40 @@ -import { VStack, useTheme, Button, Modal, useBreakpointValue } from 'native-base'; +import { Modal, ModalHeader, ModalTitle } from '@/components/Modal'; +import { Toggle } from '@/components/Toggle'; import { switchLanguage, languageList, languageIcons } from '../I18n'; type Props = { isOpen: boolean; - onCloseModal: () => any; + onIsOpenChange: (value: boolean) => void; }; -export const SwitchLanguageModal: React.FC = ({ isOpen, onCloseModal }) => { - const { space } = useTheme(); +export const SwitchLanguageModal: React.FC = ({ isOpen, onIsOpenChange }) => { const storageLanguage = localStorage.getItem('lernfair-language'); - - const widthButtonText = useBreakpointValue({ - base: '55%', - md: '35%', - }); - return ( - - - - - Sprache wechseln / Choose language - - - {languageList.map((button, i) => { - const Icon = languageIcons[button.short as keyof typeof languageIcons]; + + + Sprache wechseln / Choose language + +
+ {languageList.map((button, i) => { + const Icon = languageIcons[button.short as keyof typeof languageIcons]; - return ( - - ); - })} - - + return ( + { + switchLanguage(button.short); + onIsOpenChange(false); + }} + key={i} + className="justify-center pl-[5%]" + > + {button.name} + + ); + })} +
); }; diff --git a/src/pages/Settings.tsx b/src/pages/Settings.tsx index 0fa050763..650b7f666 100644 --- a/src/pages/Settings.tsx +++ b/src/pages/Settings.tsx @@ -134,7 +134,7 @@ const Settings: React.FC = () => {
setShowDeactivate(false)} /> - setShowSwitchLanguage(false)} /> + ); }; From 6cac516cdb458a734153e0c122728353dfe6b69a Mon Sep 17 00:00:00 2001 From: John Angel Date: Fri, 13 Sep 2024 13:10:54 +0200 Subject: [PATCH 3/4] fix: Allow toast to appear on top of modal overlay --- src/components/Modal.tsx | 6 ++++++ src/components/Toaster.tsx | 10 ++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/Modal.tsx b/src/components/Modal.tsx index afb5f0b44..1e1b59e91 100644 --- a/src/components/Modal.tsx +++ b/src/components/Modal.tsx @@ -36,6 +36,12 @@ const ModalContent = React.forwardRef { + const { originalEvent } = e.detail; + if (originalEvent.target instanceof Element && originalEvent.target.closest('.group.toast')) { + e.preventDefault(); + } + }} > {children} diff --git a/src/components/Toaster.tsx b/src/components/Toaster.tsx index 2f1b56784..a74517970 100644 --- a/src/components/Toaster.tsx +++ b/src/components/Toaster.tsx @@ -1,19 +1,20 @@ +import { createPortal } from 'react-dom'; import { Toaster as Sonner } from 'sonner'; type ToasterProps = React.ComponentProps; const Toaster = ({ ...props }: ToasterProps) => { - return ( + return createPortal( { }, }} {...props} - /> + />, + document.body ); }; From 439a9d314527206e697dd28ffa12a0152be64cc7 Mon Sep 17 00:00:00 2001 From: John Angel Date: Fri, 13 Sep 2024 13:11:34 +0200 Subject: [PATCH 4/4] feat: Remove native-base from AppFeedbackModal --- src/components/Label.tsx | 2 +- src/components/SideBarMenu.tsx | 2 +- src/modals/AppFeedbackModal.tsx | 128 ++++++++++++++++---------------- 3 files changed, 65 insertions(+), 67 deletions(-) diff --git a/src/components/Label.tsx b/src/components/Label.tsx index 5c1117cf4..d64a4d17b 100644 --- a/src/components/Label.tsx +++ b/src/components/Label.tsx @@ -2,7 +2,7 @@ import * as React from 'react'; import { cva, type VariantProps } from 'class-variance-authority'; import { cn } from '@/lib/Tailwind'; -const labelVariants = cva('text-form leading-4 font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70'); +const labelVariants = cva('text-form font-medium leading-2 peer-disabled:cursor-not-allowed peer-disabled:opacity-70'); export interface LabelProps extends React.LabelHTMLAttributes, VariantProps {} diff --git a/src/components/SideBarMenu.tsx b/src/components/SideBarMenu.tsx index a3cb09ece..db98c3906 100644 --- a/src/components/SideBarMenu.tsx +++ b/src/components/SideBarMenu.tsx @@ -84,7 +84,7 @@ const SideBarMenu: React.FC = ({ navItems, unreadMessagesCount }) => { {t('appFeedback.giveFeedbackButton')} - setIsOpen(false)} /> + ); }; diff --git a/src/modals/AppFeedbackModal.tsx b/src/modals/AppFeedbackModal.tsx index d44f4249a..52cbc3828 100644 --- a/src/modals/AppFeedbackModal.tsx +++ b/src/modals/AppFeedbackModal.tsx @@ -1,18 +1,23 @@ +import { Button } from '@/components/Button'; +import { Modal, ModalFooter, ModalHeader, ModalTitle } from '@/components/Modal'; import { useMutation } from '@apollo/client'; -import { useTheme, Row, Button, Modal, Text, FormControl, TextArea, Heading, Radio, Box, useToast } from 'native-base'; import { ChangeEventHandler, useEffect, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { gql } from '../gql'; +import { toast } from 'sonner'; +import { Label } from '@/components/Label'; +import { TextArea } from '@/components/TextArea'; +import { Input } from '@/components/Input'; +import { RadioGroup, RadioGroupItem } from '@/components/RadioGroup'; +import { Typography } from '@/components/Typography'; interface AddFeedbackModalProps { - isOpen?: boolean; - onClose: () => any; + isOpen: boolean; + onIsOpenChange: (value: boolean) => any; } -const AppFeedbackModal = ({ isOpen, onClose }: AddFeedbackModalProps) => { - const { space } = useTheme(); +const AppFeedbackModal = ({ isOpen, onIsOpenChange }: AddFeedbackModalProps) => { const { t } = useTranslation(); - const toast = useToast(); const [notes, setNotes] = useState(''); const [isSending, setIsSending] = useState(false); @@ -53,7 +58,7 @@ const AppFeedbackModal = ({ isOpen, onClose }: AddFeedbackModalProps) => { const handleOnSubmit = async () => { const MAX_FILE_SIZE = 2 * 1024 * 1024; if (file?.size && file.size > MAX_FILE_SIZE) { - toast.show({ description: t('appFeedback.screenshotShouldNotBeBiggerThan', { size: '2' }) }); + toast.error(t('appFeedback.screenshotShouldNotBeBiggerThan', { size: '2' })); return; } @@ -73,68 +78,61 @@ const AppFeedbackModal = ({ isOpen, onClose }: AddFeedbackModalProps) => { : undefined, }, }); - toast.show({ description: t('appFeedback.feedbackSuccessfullySent') }); - onClose(); + + toast.success(t('appFeedback.feedbackSuccessfullySent')); + onIsOpenChange(false); setIsSending(false); }; return ( - - - - - {`💬 ${t('appFeedback.modal.title')}`} - - - {t('appFeedback.modal.description')} - - - {t('appFeedback.modal.notesLabel')}* -