categories,18popup,clear.TextEditorSwap,GameCardHover #177
3
src/components/Filters/CategoryFilterPopup.tsx
Normal file
3
src/components/Filters/CategoryFilterPopup.tsx
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
export const CategoryFilterPopup = () => {
|
||||||
|
return <>Popup</>
|
||||||
|
}
|
@ -1,5 +1,5 @@
|
|||||||
import { useAppSelector, useLocalStorage } from 'hooks'
|
import { useAppSelector, useLocalStorage } from 'hooks'
|
||||||
import React from 'react'
|
import React, { PropsWithChildren } from 'react'
|
||||||
import {
|
import {
|
||||||
FilterOptions,
|
FilterOptions,
|
||||||
SortBy,
|
SortBy,
|
||||||
@ -19,7 +19,7 @@ type Props = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ModFilter = React.memo(
|
export const ModFilter = React.memo(
|
||||||
({ author, filterKey = 'filter' }: Props) => {
|
({ author, filterKey = 'filter', children }: PropsWithChildren<Props>) => {
|
||||||
const userState = useAppSelector((state) => state.user)
|
const userState = useAppSelector((state) => state.user)
|
||||||
const [filterOptions, setFilterOptions] = useLocalStorage<FilterOptions>(
|
const [filterOptions, setFilterOptions] = useLocalStorage<FilterOptions>(
|
||||||
filterKey,
|
filterKey,
|
||||||
@ -176,6 +176,8 @@ export const ModFilter = React.memo(
|
|||||||
Show All
|
Show All
|
||||||
</Option>
|
</Option>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
|
|
||||||
|
{children}
|
||||||
</Filter>
|
</Filter>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1152,7 @@ export const CategoryAutocomplete = ({
|
|||||||
key={`category-${i}`}
|
key={`category-${i}`}
|
||||||
to={{
|
to={{
|
||||||
pathname: getGamePageRoute(game),
|
pathname: getGamePageRoute(game),
|
||||||
search: `c=${c}`
|
search: `l=${c}`
|
||||||
}}
|
}}
|
||||||
className='IBMSMSMBSSCategoriesBoxItem'
|
className='IBMSMSMBSSCategoriesBoxItem'
|
||||||
>
|
>
|
||||||
|
@ -27,6 +27,7 @@ import {
|
|||||||
scrollIntoView
|
scrollIntoView
|
||||||
} from 'utils'
|
} from 'utils'
|
||||||
import { useCuratedSet } from 'hooks/useCuratedSet'
|
import { useCuratedSet } from 'hooks/useCuratedSet'
|
||||||
|
import { CategoryFilterPopup } from 'components/Filters/CategoryFilterPopup'
|
||||||
|
|
||||||
export const GamePage = () => {
|
export const GamePage = () => {
|
||||||
const scrollTargetRef = useRef<HTMLDivElement>(null)
|
const scrollTargetRef = useRef<HTMLDivElement>(null)
|
||||||
@ -52,6 +53,13 @@ export const GamePage = () => {
|
|||||||
const [searchParams, setSearchParams] = useSearchParams()
|
const [searchParams, setSearchParams] = useSearchParams()
|
||||||
const [searchTerm, setSearchTerm] = useState(searchParams.get('q') || '')
|
const [searchTerm, setSearchTerm] = useState(searchParams.get('q') || '')
|
||||||
|
|
||||||
|
// Categories filter
|
||||||
|
const [categories, setCategories] = useState(searchParams.getAll('l') || [])
|
||||||
|
const [heirarchies, setFullHeirarchies] = useState(
|
||||||
|
searchParams.getAll('h') || []
|
||||||
|
)
|
||||||
|
const [showCategoryPopup, setShowCategoryPopup] = useState(false)
|
||||||
|
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
const value = searchTermRef.current?.value || '' // Access the input value from the ref
|
const value = searchTermRef.current?.value || '' // Access the input value from the ref
|
||||||
setSearchTerm(value)
|
setSearchTerm(value)
|
||||||
@ -128,6 +136,14 @@ export const GamePage = () => {
|
|||||||
'#t': [T_TAG_VALUE]
|
'#t': [T_TAG_VALUE]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (categories.length) {
|
||||||
|
filter['#l'] = categories.map((l) => `com.degmods:${l}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (heirarchies.length) {
|
||||||
|
filter['#L'] = heirarchies.map((L) => `com.degmods:${L}`)
|
||||||
|
}
|
||||||
|
|
||||||
const subscription = ndk.subscribe(filter, {
|
const subscription = ndk.subscribe(filter, {
|
||||||
cacheUsage: NDKSubscriptionCacheUsage.PARALLEL,
|
cacheUsage: NDKSubscriptionCacheUsage.PARALLEL,
|
||||||
closeOnEose: true
|
closeOnEose: true
|
||||||
@ -151,7 +167,7 @@ export const GamePage = () => {
|
|||||||
return () => {
|
return () => {
|
||||||
subscription.stop()
|
subscription.stop()
|
||||||
}
|
}
|
||||||
}, [gameName, ndk])
|
}, [gameName, ndk, categories, heirarchies])
|
||||||
|
|
||||||
if (!gameName) return null
|
if (!gameName) return null
|
||||||
|
|
||||||
@ -188,7 +204,29 @@ export const GamePage = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ModFilter />
|
<ModFilter>
|
||||||
|
<div className='FiltersMainElement'>
|
||||||
|
<button
|
||||||
|
className='btn btnMain btnMainDropdown'
|
||||||
|
type='button'
|
||||||
|
onClick={() => {
|
||||||
|
setShowCategoryPopup(true)
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Categories
|
||||||
|
<svg
|
||||||
|
xmlns='http://www.w3.org/2000/svg'
|
||||||
|
viewBox='0 0 512 512'
|
||||||
|
width='1em'
|
||||||
|
height='1em'
|
||||||
|
fill='currentColor'
|
||||||
|
>
|
||||||
|
<path d='M3.9 54.9C10.5 40.9 24.5 32 40 32l432 0c15.5 0 29.5 8.9 36.1 22.9s4.6 30.5-5.2 42.5L320 320.9 320 448c0 12.1-6.8 23.2-17.7 28.6s-23.8 4.3-33.5-3l-64-48c-8.1-6-12.8-15.5-12.8-25.6l0-79.1L9 97.3C-.7 85.4-2.8 68.8 3.9 54.9z' />
|
||||||
|
</svg>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</ModFilter>
|
||||||
|
|
||||||
<div className='IBMSecMain IBMSMListWrapper'>
|
<div className='IBMSecMain IBMSMListWrapper'>
|
||||||
<div className='IBMSMList'>
|
<div className='IBMSMList'>
|
||||||
{currentMods.map((mod) => (
|
{currentMods.map((mod) => (
|
||||||
@ -204,6 +242,7 @@ export const GamePage = () => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{showCategoryPopup && <CategoryFilterPopup />}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -550,7 +550,7 @@ const Body = ({
|
|||||||
className='IBMSMSMBSSCategoriesBoxItem'
|
className='IBMSMSMBSSCategoriesBoxItem'
|
||||||
to={{
|
to={{
|
||||||
pathname: getGamePageRoute(game),
|
pathname: getGamePageRoute(game),
|
||||||
search: `c=${c}`
|
search: `l=${c}`
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<p>{capitalizeEachWord(c)}</p>
|
<p>{capitalizeEachWord(c)}</p>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user