-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
1,455 additions
and
697 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ on: | |
types: [opened, synchronize] | ||
|
||
env: | ||
NODE_VERSION: 18.16.0 | ||
NODE_VERSION: 21.5.0 | ||
|
||
jobs: | ||
linting: | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { useState } from 'react'; | ||
|
||
import useLanguage from '@/shared/Context/hooks'; | ||
import FilledTonalButton from '@/shared/ui/FilledTonalButton'; | ||
|
||
import ConfirmModal from './ConfirmModal'; | ||
import ConfirmOverlay from './ConfirmOverlay'; | ||
|
||
const ClearStorageComp = () => { | ||
const [isModalShown, setIsModalShown] = useState(false); | ||
const { translation } = useLanguage(); | ||
|
||
return ( | ||
<> | ||
<div className="mt-6 flex items-center justify-between pb-6"> | ||
<div className="flex flex-col justify-between"> | ||
<h4 className="text-[22px]">{translation.settingsPage.clear.title}</h4> | ||
<p className="mt-4">{translation.settingsPage.clear.subtitle}</p> | ||
</div> | ||
<FilledTonalButton data-clear-btn className="text-primary" onClick={() => setIsModalShown((prev) => !prev)}> | ||
{translation.settingsPage.clear.btn} | ||
</FilledTonalButton> | ||
</div> | ||
<ConfirmOverlay isShown={isModalShown} setIsShown={setIsModalShown}> | ||
<ConfirmModal | ||
setIsShown={setIsModalShown} | ||
locales={{ ...translation.settingsPage.clear.modal, ...translation.settingsPage.clear.undo }} | ||
/> | ||
</ConfirmOverlay> | ||
</> | ||
); | ||
}; | ||
|
||
export default ClearStorageComp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { useEffect, useState } from 'react'; | ||
|
||
type UndoPropsType = { | ||
closeToast: () => void; | ||
title: string; | ||
btn: string; | ||
}; | ||
|
||
const ClearUndo = (props: UndoPropsType) => { | ||
const { closeToast, title, btn } = props; | ||
const [deleteDataTimeout, setDeleteDataTimeout] = useState(null as unknown as NodeJS.Timeout); | ||
|
||
const dataClearance = () => { | ||
localStorage.clear(); | ||
}; | ||
|
||
useEffect(() => { | ||
const timeoutId = setTimeout(() => { | ||
dataClearance(); | ||
}, 2000); | ||
|
||
setDeleteDataTimeout(timeoutId); | ||
|
||
return () => { | ||
clearTimeout(timeoutId); | ||
}; | ||
}, []); | ||
|
||
const handleClick = () => { | ||
clearTimeout(deleteDataTimeout); | ||
closeToast(); | ||
}; | ||
|
||
return ( | ||
<div className="flex items-center justify-around text-sm"> | ||
<p className="font-[400] text-inverse-on-surface">{title}</p> | ||
<button className="font-[500] text-inverse-primary" type="button" onClick={handleClick}> | ||
{btn} | ||
</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ClearUndo; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { Dispatch, FC, SetStateAction } from 'react'; | ||
|
||
import { toast } from 'react-toastify'; | ||
|
||
import FilledTonalButton from '@/shared/ui/FilledTonalButton'; | ||
import Icon from '@/shared/ui/Icon'; | ||
import TextButton from '@/shared/ui/TextButton'; | ||
|
||
import ClearUndo from './ClearUndo'; | ||
|
||
type PropsType = { | ||
setIsShown: Dispatch<SetStateAction<boolean>>; | ||
locales: { | ||
title: string; | ||
subtitle: string; | ||
cancel: string; | ||
confirm: string; | ||
undoTitle: string; | ||
cancelBtn: string; | ||
}; | ||
}; | ||
|
||
const ConfirmModal: FC<PropsType> = ({ setIsShown, locales }) => { | ||
const { title, subtitle, cancel, confirm, undoTitle, cancelBtn } = locales; | ||
return ( | ||
<div className="w-[312px] rounded-4xl bg-surface-container-high p-6 text-center font-[500] text-on-surface"> | ||
<Icon>delete</Icon> | ||
<h3 className="mt-4 text-2xl">{title}</h3> | ||
<p className="mt-4 text-start text-sm text-on-surface-variant">{subtitle}</p> | ||
<div className="mt-6 flex justify-end gap-2"> | ||
<TextButton onClick={() => setIsShown((prev) => !prev)}>{cancel}</TextButton> | ||
<FilledTonalButton | ||
onClick={() => { | ||
toast(<ClearUndo closeToast={() => {}} title={undoTitle} btn={cancelBtn} />); | ||
setIsShown((prev) => !prev); | ||
}} | ||
> | ||
{confirm} | ||
</FilledTonalButton> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConfirmModal; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
type PropsType = { | ||
setIsShown: React.Dispatch<React.SetStateAction<boolean>>; | ||
isShown: boolean; | ||
children: JSX.Element; | ||
}; | ||
|
||
const ConfirmOverlay = ({ isShown, setIsShown, children }: PropsType) => { | ||
function closeHandler(e: React.MouseEvent<HTMLDivElement, MouseEvent> | React.KeyboardEvent<HTMLDivElement>) { | ||
if ((e.target as HTMLButtonElement).hasAttribute('data-overlay')) { | ||
setIsShown((prev) => !prev); | ||
} | ||
} | ||
if (!isShown) { | ||
return null; | ||
} | ||
return ( | ||
<div | ||
data-testid="overlay" | ||
data-overlay | ||
onClick={(e) => closeHandler(e)} | ||
onKeyDown={(e) => closeHandler(e)} | ||
className="overlay absolute left-0 top-0 z-10 flex h-full w-full items-center justify-center bg-black/60" | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ConfirmOverlay; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { useState } from 'react'; | ||
|
||
import localStorageKeys from '@/shared/constants/localStorageKeys'; | ||
import useLanguage from '@/shared/Context/hooks'; | ||
import colorThemeSwitcher from '@/shared/helpers/colorThemeSwitcher'; | ||
import Switch from '@/shared/ui/Switch'; | ||
|
||
const DarkModeComp = () => { | ||
const { translation } = useLanguage(); | ||
const [isDarkMode, setIsDarkMode] = useState(() => !localStorage.getItem(localStorageKeys.LIGHT_THEME)); | ||
|
||
function handleThemeSwitch() { | ||
if (isDarkMode) { | ||
colorThemeSwitcher.setLight(); | ||
} else { | ||
colorThemeSwitcher.setDark(); | ||
} | ||
setIsDarkMode((prev) => !prev); | ||
} | ||
return ( | ||
<div className="mt-6 flex items-center justify-between border-b-[1px] border-outline-variant pb-6"> | ||
<div className="flex flex-col justify-between"> | ||
<h4 className="text-[22px]">{translation.settingsPage.mode.title}</h4> | ||
<p className="mt-4">{translation.settingsPage.mode.subtitle}</p> | ||
</div> | ||
<Switch selected={isDarkMode} onClick={() => handleThemeSwitch()} data-testid="themeSwitcher" /> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DarkModeComp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { FC } from 'react'; | ||
|
||
import useLanguage from '@/shared/Context/hooks'; | ||
import FilledTextField from '@/shared/ui/FilledTextField'; | ||
import Icon from '@/shared/ui/Icon'; | ||
import IconButton from '@/shared/ui/IconButton'; | ||
|
||
type PropsType = { | ||
endpoint: string; | ||
saveEndpoint: (value: string) => void; | ||
}; | ||
|
||
const EndpointComp: FC<PropsType> = ({ endpoint, saveEndpoint }) => { | ||
const { translation } = useLanguage(); | ||
return ( | ||
<div className="mt-6 flex items-center justify-between border-b-[1px] border-outline-variant pb-6"> | ||
<div className="flex flex-col justify-between"> | ||
<h4 className="text-[22px]">{translation.settingsPage.endpoint.title}</h4> | ||
<p className="mt-4">{translation.settingsPage.endpoint.subtitle}</p> | ||
</div> | ||
<FilledTextField | ||
className="relative h-[68px] w-[360px] text-base" | ||
label="API endpoint" | ||
value={endpoint} | ||
name="endpoint" | ||
onChange={(e) => saveEndpoint((e?.target as HTMLInputElement).value)} | ||
> | ||
<IconButton className="absolute right-0 top-[10px]" slot="trailing-icon" onClick={() => saveEndpoint('')}> | ||
<Icon>cancel</Icon> | ||
</IconButton> | ||
</FilledTextField> | ||
</div> | ||
); | ||
}; | ||
|
||
export default EndpointComp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { FC } from 'react'; | ||
|
||
import cn from '@/shared/lib/helpers/cn'; | ||
import Icon from '@/shared/ui/Icon'; | ||
|
||
type PropsType = { | ||
language: string; | ||
changeLanguage: (lang: 'en' | 'ru') => void; | ||
}; | ||
|
||
const LangBtns: FC<PropsType> = ({ language, changeLanguage }) => { | ||
const isEnglish = language === 'en'; | ||
|
||
return ( | ||
<> | ||
<button | ||
onClick={() => changeLanguage('en')} | ||
type="button" | ||
className={cn( | ||
'flex w-[104px] items-center justify-center gap-[10px] rounded-l-3xl border border-outline transition-all duration-200 hover:bg-outline-variant', | ||
{ | ||
'bg-secondary-container': isEnglish, | ||
}, | ||
)} | ||
> | ||
{isEnglish && <Icon>check</Icon>}English | ||
</button> | ||
<button | ||
type="button" | ||
className={cn( | ||
'flex w-[104px] items-center justify-center gap-[10px] rounded-r-3xl border-[1px] border-outline transition-all duration-200 hover:bg-outline-variant', | ||
{ | ||
'bg-secondary-container': !isEnglish, | ||
}, | ||
)} | ||
onClick={() => changeLanguage('ru')} | ||
> | ||
Русский{!isEnglish && <Icon>check</Icon>} | ||
</button> | ||
</> | ||
); | ||
}; | ||
|
||
export default LangBtns; |
Oops, something went wrong.