-
-
Anime Universe
-
-
-
- setSearchValue(e.target.value)}
- onSearch={onSearch}
+
+
+
+
+
-
-
-
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
-
+
+ {isNarrowScreen && (
+
+
+
+
+ ),
+ },
+ ].concat(breadItems)
+ : [
+ {
+ key: '/',
+ title: (
+
+
+
+ ),
+ },
+ ]
+ }
+ />
+
+ )}
+
+
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+
+
-
-
-
+
+
+
)
}
diff --git a/src/Pages/HomePage/HomeContent.tsx b/src/Pages/HomePage/HomeContent.tsx
index 1c89505..37dfe6b 100644
--- a/src/Pages/HomePage/HomeContent.tsx
+++ b/src/Pages/HomePage/HomeContent.tsx
@@ -1,4 +1,3 @@
-import { Flex } from 'antd'
import { Content } from 'antd/es/layout/layout'
import { useCallback, useEffect, useState } from 'react'
import { useDispatch } from 'react-redux'
@@ -14,6 +13,7 @@ import { AnimeCardType, DispatchType } from '../../types'
import { determineCardsAmountByViewport } from '../../utils'
import { requestHomeCardsData } from '../../redux/slices/homeCards/thunk'
import { usePageResize, useTypedSelector } from '../../hooks'
+import { clearHomeFilters } from '../../redux/slices'
const initialCardsAmount = determineCardsAmountByViewport()
@@ -37,9 +37,13 @@ function HomeContent() {
dispatch(requestHomeCardsData(filters, 1, cardsAmount))
}, [cardsAmount, dispatch, filters])
+ useEffect(() => {
+ dispatch(clearHomeFilters())
+ }, [dispatch])
+
return (
-
+
-
+
)
}
diff --git a/src/Pages/HomePage/HomeMenu.tsx b/src/Pages/HomePage/HomeMenu.tsx
index 4e68f1a..65b8e65 100644
--- a/src/Pages/HomePage/HomeMenu.tsx
+++ b/src/Pages/HomePage/HomeMenu.tsx
@@ -2,13 +2,14 @@ import { useContext, useState } from 'react'
import { useDispatch } from 'react-redux'
import { Menu } from 'antd'
import Sider from 'antd/es/layout/Sider'
+import { Header } from 'antd/es/layout/layout'
import {
clearHomeFilters,
setGenreToHomeFilters,
setRatingToHomeFilters,
} from '../../redux/slices'
-import { ThemeContext, ratings } from '../../shared'
+import { ThemeContext, SizeContext, ratings } from '../../shared'
import { GenresError, GenresLoading } from '../../components'
import { useTypedSelector } from '../../hooks'
@@ -19,9 +20,10 @@ function HomeMenu() {
const isError = useTypedSelector((state) => state.genres.isError)
const genres = useTypedSelector((state) => state.genres.genres)
const isLightTheme = useContext(ThemeContext)
- const [openKeys, setOpenKeys] = useState(['rating'])
- const dispatch = useDispatch()
+ const isNarrowScreen = useContext(SizeContext)
+ const [openKeys, setOpenKeys] = useState(isNarrowScreen ? [] : ['rating'])
+ const dispatch = useDispatch()
const onOpenChange = (keys: string[]) => {
const latestOpenKey = keys.find((key) => openKeys.indexOf(key) === -1)
if (latestOpenKey && rootSubmenuKeys.indexOf(latestOpenKey) === -1) {
@@ -60,27 +62,54 @@ function HomeMenu() {
}
return (
-
-
-
+ <>
+ {!isNarrowScreen && (
+
+
+
+ )}
+ {isNarrowScreen && (
+
+
+
+ )}
+ >
)
}
diff --git a/src/Pages/ListsPage/ListsContent.tsx b/src/Pages/ListsPage/ListsContent.tsx
index 869fde5..91ab7be 100644
--- a/src/Pages/ListsPage/ListsContent.tsx
+++ b/src/Pages/ListsPage/ListsContent.tsx
@@ -1,6 +1,8 @@
import { Content } from 'antd/es/layout/layout'
import { Button, Flex, Input, Modal, Pagination, QRCode } from 'antd'
import { useState, useCallback, useMemo, useLayoutEffect } from 'react'
+import { useDispatch } from 'react-redux'
+import { useParams } from 'react-router'
import {
CaseComponent,
@@ -12,9 +14,7 @@ import {
import { useTypedSelector, usePageResize } from '../../hooks'
import { createListShareUrl, determineCardsAmountByViewport } from '../../utils'
import { requestListAnimeData } from '../../redux/slices'
-import { useDispatch } from 'react-redux'
import { DispatchType } from '../../types'
-import { useParams } from 'react-router'
import { copyLinkToClipboard } from '../../utils/copyLinkToClipboard'
const initialCardsAmount = determineCardsAmountByViewport()
@@ -67,13 +67,7 @@ export function ListsContent() {
usePageResize(onResize)
return (
-
+
}
emptyElement={}
>
-
+
{listAnimes.map((anime) => (
))}
-
+
state.lists.lists)
const [newListName, setNewListName] = useState('')
const [listNames, setListNames] = useState(['add'])
@@ -38,7 +40,7 @@ function ListsMenu() {
setListNames(['add', ...Object.keys(storedLists)])
}, [storedLists])
- useLayoutEffect(() => {
+ useEffect(() => {
const items: { key: string; label: JSX.Element }[] = listNames.map(
(item) => {
const obj = { key: item, label: }
@@ -152,16 +154,91 @@ function ListsMenu() {
setClickedDeleteList(null)
}}
/>
-
-
-
+ {!isNarrowScreen && (
+
+
+
+ )}
+ {isNarrowScreen && (
+
+
+
+ {
+ const { value } = e.target
+ const isValid = /^[a-zA-Z0-9 ]*$/.test(value)
+ if (isValid) {
+ setNewListName(value)
+ setIsNewNameInvalid(false)
+ } else {
+ setIsNewNameInvalid(true)
+ setWarningMessage('a-z A-Z 0-9 symbols only')
+ setTimeout(() => setIsNewNameInvalid(false), 2000)
+ }
+ }}
+ onSearch={() => {
+ const trimmedName = newListName.trim()
+ const verification = verifyNewListName(trimmedName, listNames)
+ if (verification.isValid) {
+ setIsNewNameInvalid(false)
+ setListNames([...listNames].splice(0, 1, 'add', trimmedName))
+ dispatch(postNewList(trimmedName))
+ navigate('/lists/' + trimmedName)
+ } else {
+ setIsNewNameInvalid(true)
+ setWarningMessage(verification.message)
+ }
+ }}
+ />
+
+ {listname && (
+
+ )}
+
+ )}
>
)
}
diff --git a/src/Pages/ListsPage/ListsPage.tsx b/src/Pages/ListsPage/ListsPage.tsx
index 51a9cbb..e29149d 100644
--- a/src/Pages/ListsPage/ListsPage.tsx
+++ b/src/Pages/ListsPage/ListsPage.tsx
@@ -3,15 +3,7 @@ import ListsMenu from './ListsMenu'
export function ListsPage() {
return (
-
+
diff --git a/src/Pages/RandomAnimePage/RandomAnimePage.tsx b/src/Pages/RandomAnimePage/RandomAnimePage.tsx
index 3cc7bb2..0a427fc 100644
--- a/src/Pages/RandomAnimePage/RandomAnimePage.tsx
+++ b/src/Pages/RandomAnimePage/RandomAnimePage.tsx
@@ -11,7 +11,6 @@ import {
} from '../../components'
import { DispatchType } from '../../types'
import { requestRandomPageData } from '../../redux/slices/animePage/thunk'
-//import { fetchAnimePageRequest } from '../../redux/slices'
import { useTypedSelector } from '../../hooks'
export function RandomAnimePage() {
@@ -24,10 +23,6 @@ export function RandomAnimePage() {
useEffect(() => {
dispatch(requestRandomPageData())
-
- // return () => {
- // dispatch(fetchAnimePageRequest())
- // }
}, [dispatch])
return (
diff --git a/src/Pages/SearchPage/SearchContent.tsx b/src/Pages/SearchPage/SearchContent.tsx
index 79f6ada..8cf1dc5 100644
--- a/src/Pages/SearchPage/SearchContent.tsx
+++ b/src/Pages/SearchPage/SearchContent.tsx
@@ -75,7 +75,13 @@ function SearchContent() {
return (
-
+
}
>
{searchedAnimes && (
-
+
{searchedAnimes.map((anime) => (
))}
-
+
)}
state.genres.genres)
const navigate = useNavigate()
+ const [buttonText, setButtonText] = useState('Hide filters')
+ const [isFormOpen, setIsFormOpen] = useState(true)
useEffect(() => {
setFormObj(urlFormData)
}, [urlFormData])
return (
-
+
+
)
}
diff --git a/src/Pages/SearchPage/SearchPage.tsx b/src/Pages/SearchPage/SearchPage.tsx
index 9cd0d4a..6c2d0c8 100644
--- a/src/Pages/SearchPage/SearchPage.tsx
+++ b/src/Pages/SearchPage/SearchPage.tsx
@@ -3,14 +3,7 @@ import SearchContent from './SearchContent'
export function SearchPage() {
return (
-
+
diff --git a/src/api/parsers/parseAnimeResponseItem.ts b/src/api/parsers/parseAnimeResponseItem.ts
index e82b98a..8e8822e 100644
--- a/src/api/parsers/parseAnimeResponseItem.ts
+++ b/src/api/parsers/parseAnimeResponseItem.ts
@@ -9,6 +9,6 @@ export const parseAnimeResponseItem = (
genres: item.genres.map((genre: { name: string; mal_id: number }) => {
return { name: genre.name, id: genre.mal_id }
}),
- img: item.images.jpg.image_url,
+ img: item.images.jpg.large_image_url,
rating: item.rating,
})
diff --git a/src/api/requests/getDupesReplacement.ts b/src/api/requests/getDupesReplacement.ts
index 4fe54cd..6161f90 100644
--- a/src/api/requests/getDupesReplacement.ts
+++ b/src/api/requests/getDupesReplacement.ts
@@ -1,6 +1,5 @@
import { AnimeBaseResponseType } from '../../types'
-import { filterAnimeDupes } from '../../utils'
-import { setPageNumToUrl } from '../../utils/urlCreators/setPageNumToUrl'
+import { filterAnimeDupes, setPageNumToUrl } from '../../utils'
import { getAnimeData } from './getAnimeData'
export async function getDupesReplacement(
diff --git a/src/components/AddToListSelect.tsx b/src/components/AddToListSelect.tsx
index 37176f9..d8637a8 100644
--- a/src/components/AddToListSelect.tsx
+++ b/src/components/AddToListSelect.tsx
@@ -1,9 +1,10 @@
import { PlusOutlined } from '@ant-design/icons'
import { Button, Divider, Input, Select, Space, Tooltip } from 'antd'
import { ChangeEvent, useRef, useState, useEffect } from 'react'
+import { useDispatch } from 'react-redux'
+
import { verifyNewListName } from '../utils'
import { useTypedSelector } from '../hooks'
-import { useDispatch } from 'react-redux'
import { DispatchType } from '../types'
import {
deleteItemFromList,
diff --git a/src/components/AnimeCard.tsx b/src/components/AnimeCard.tsx
index bb41f20..d6c2ae2 100644
--- a/src/components/AnimeCard.tsx
+++ b/src/components/AnimeCard.tsx
@@ -64,7 +64,7 @@ function AnimeCard({ cardData, isDeletable }: Props) {
className="poster"
alt={cardData.titleEnglish}
src={cardData.img}
- style={{ objectFit: 'cover' }}
+ style={{ width: 'inherit' }}
/>
}
diff --git a/src/components/ContentEmpty.tsx b/src/components/ContentEmpty.tsx
index 611be0a..9f1154c 100644
--- a/src/components/ContentEmpty.tsx
+++ b/src/components/ContentEmpty.tsx
@@ -11,7 +11,7 @@ function ContentEmpty({
message = "Sorry, there're no animes with these parametres"
break
case 'byId':
- message = "Sorry, anime with this ID doesn't exist"
+ message = "This page doesn't exist"
break
case 'byList':
message = 'This list is empty'
diff --git a/src/redux/reducer.ts b/src/redux/reducer.ts
index 7299c5b..9a32f11 100644
--- a/src/redux/reducer.ts
+++ b/src/redux/reducer.ts
@@ -1,4 +1,5 @@
import { combineReducers } from 'redux'
+
import {
genresReducer,
listsReducer,
diff --git a/src/redux/slices/lists/thunk/requestListAnimeData.ts b/src/redux/slices/lists/thunk/requestListAnimeData.ts
index f4fc27a..f52caca 100644
--- a/src/redux/slices/lists/thunk/requestListAnimeData.ts
+++ b/src/redux/slices/lists/thunk/requestListAnimeData.ts
@@ -1,4 +1,6 @@
import { Dispatch } from 'redux'
+import { ThunkAction } from 'redux-thunk'
+
import {
fetchListAnimesEmpty,
fetchListAnimesFailure,
@@ -12,7 +14,6 @@ import {
} from '../../../../types'
import { createGetIdAnimeUrl } from '../../../../utils'
import { getAnimePageData, parseAnimeResponseItem } from '../../../../api'
-import { ThunkAction } from 'redux-thunk'
import { ListsActionType } from '../actions/actions'
function requestListAnimeData(
diff --git a/src/redux/slices/searchCards/thunk/requestSearchCardsData.ts b/src/redux/slices/searchCards/thunk/requestSearchCardsData.ts
index a4f70a2..94f027b 100644
--- a/src/redux/slices/searchCards/thunk/requestSearchCardsData.ts
+++ b/src/redux/slices/searchCards/thunk/requestSearchCardsData.ts
@@ -1,4 +1,5 @@
import { ThunkAction } from 'redux-thunk'
+
import { SearchCardsStateType } from '../../../../types'
import { createAdvancedSearchAnimeUrl } from '../../../../utils'
import requestCardsData from '../../../thunk/requestCardsData'
diff --git a/src/shared/SizeContext.ts b/src/shared/SizeContext.ts
new file mode 100644
index 0000000..df9a9aa
--- /dev/null
+++ b/src/shared/SizeContext.ts
@@ -0,0 +1,3 @@
+import { createContext } from 'react'
+
+export const SizeContext = createContext(false)
diff --git a/src/shared/index.ts b/src/shared/index.ts
index 0180ae3..98f7f06 100644
--- a/src/shared/index.ts
+++ b/src/shared/index.ts
@@ -1,3 +1,4 @@
export * from './ratings'
export { ThemeContext } from './ThemeContext'
+export { SizeContext } from './SizeContext'
export { initialSearchFormData } from './initialSearchFormData'
diff --git a/src/utils/createNavItems.tsx b/src/utils/createNavItems.tsx
index c627e0d..70407ec 100644
--- a/src/utils/createNavItems.tsx
+++ b/src/utils/createNavItems.tsx
@@ -1,26 +1,46 @@
+import { MenuOutlined } from '@ant-design/icons'
import { Link } from 'react-router-dom'
-export function createNavItems(onHomePageClick: () => void) {
- return [
- {
- key: '/',
- label: (
-
- Home
-
- ),
- },
- {
- key: '/search',
- label: Search,
- },
- {
- key: '/lists',
- label: My Lists,
- },
- {
- key: '/random',
- label: Random,
- },
- ]
-}
+export const navItems = [
+ {
+ key: '/',
+ label: Home,
+ },
+ {
+ key: '/search',
+ label: Search,
+ },
+ {
+ key: '/lists',
+ label: My Lists,
+ },
+ {
+ key: '/random',
+ label: Random,
+ },
+]
+
+export const burgerNavItems = [
+ {
+ key: 'nav',
+ label: ,
+ children: [
+ {
+ key: '/',
+ label: Home,
+ },
+ {
+ key: '/search',
+ label: Search,
+ },
+ {
+ key: '/lists',
+ label: My Lists,
+ },
+ {
+ key: '/random',
+ label: Random,
+ },
+ ],
+ },
+]
diff --git a/src/utils/determineCardsAmountByViewport.ts b/src/utils/determineCardsAmountByViewport.ts
index fe74017..1b83218 100644
--- a/src/utils/determineCardsAmountByViewport.ts
+++ b/src/utils/determineCardsAmountByViewport.ts
@@ -1,15 +1,13 @@
export function determineCardsAmountByViewport() {
- if (window.matchMedia('(min-width: 1767px)').matches) {
+ if (window.matchMedia('(min-width: 1841px)').matches) {
return 14
- } else if (window.matchMedia('(min-width: 1542px)').matches) {
+ } else if (window.matchMedia('(min-width: 1581px)').matches) {
return 12
- } else if (window.matchMedia('(min-width: 1317px)').matches) {
+ } else if (window.matchMedia('(min-width: 1401px)').matches) {
return 10
- } else if (window.matchMedia('(min-width: 1092px)').matches) {
+ } else if (window.matchMedia('(min-width: 1131px)').matches) {
return 8
- } else if (window.matchMedia('(min-width: 867px)').matches) {
- return 6
} else {
- return 4
+ return 6
}
}
diff --git a/src/utils/index.ts b/src/utils/index.ts
index 20883fe..2308b29 100644
--- a/src/utils/index.ts
+++ b/src/utils/index.ts
@@ -1,7 +1,6 @@
export * from './urlCreators'
export { createItemsObjForAnimePage } from './createItemsObjForAnimePage'
-export { createNavItems } from './createNavItems'
export { determineCardsAmountByViewport } from './determineCardsAmountByViewport'
export { filterAnimeDupes } from './filterAnimeDupes'
export { getStatusForBadge } from './getStatusForBadge'
diff --git a/src/utils/urlCreators/index.ts b/src/utils/urlCreators/index.ts
index 9eac625..9d58074 100644
--- a/src/utils/urlCreators/index.ts
+++ b/src/utils/urlCreators/index.ts
@@ -2,3 +2,4 @@ export { createListShareUrl } from './createListShareUrl'
export { createAdvancedSearchAnimeUrl } from './createAdvancedSearchAnimeUrl'
export { createGetIdAnimeUrl } from './createGetIdAnimeUrl'
export { createGetTopAnimeUrl } from './createGetTopAnimeUrl'
+export { setPageNumToUrl } from './setPageNumToUrl'