-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #421 from deltaDAO/feat/update-filters
feat: update filters
- Loading branch information
Showing
27 changed files
with
922 additions
and
568 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
module.exports = { | ||
filters: [ | ||
{ | ||
id: 'filterSet', | ||
label: 'Categories', | ||
type: 'filterList', | ||
options: [ | ||
{ | ||
label: 'automotive', | ||
value: 'automotive' | ||
}, | ||
{ | ||
label: 'manufacturing', | ||
value: 'manufacturing' | ||
}, | ||
{ | ||
label: 'text analysis', | ||
value: 'textAnalysis' | ||
}, | ||
{ | ||
label: 'finance', | ||
value: 'finance' | ||
} | ||
] | ||
} | ||
], | ||
filterSets: { | ||
automotive: [ | ||
'charging', | ||
'ev', | ||
'gx4m', | ||
'mobility', | ||
'moveid', | ||
'parking', | ||
'traffic' | ||
], | ||
manufacturing: [ | ||
'euprogigant', | ||
'industry40', | ||
'manufacturing', | ||
'predictive-maintenance' | ||
], | ||
textAnalysis: ['library', 'ocr', 'text-analysis'], | ||
finance: ['graphql'] | ||
} | ||
} |
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,66 @@ | ||
import React, { | ||
createContext, | ||
useContext, | ||
ReactElement, | ||
ReactNode, | ||
useState | ||
} from 'react' | ||
import { | ||
SortDirectionOptions, | ||
SortTermOptions | ||
} from '../../src/@types/aquarius/SearchQuery' | ||
|
||
export interface Filters { | ||
[key: string]: string[] | ||
} | ||
|
||
export interface Sort { | ||
sort: SortTermOptions | ||
sortOrder: SortDirectionOptions | ||
} | ||
|
||
interface FilterValue { | ||
filters: Filters | ||
setFilters: (filters: Filters) => void | ||
ignorePurgatory: boolean | ||
setIgnorePurgatory: (value: boolean) => void | ||
sort: Sort | ||
setSort: (sort: Sort) => void | ||
} | ||
|
||
const FilterContext = createContext({} as FilterValue) | ||
|
||
function FilterProvider({ children }: { children: ReactNode }): ReactElement { | ||
const [filters, setFilters] = useState<Filters>({ | ||
accessType: [], | ||
serviceType: [], | ||
filterSet: [] | ||
}) | ||
const [ignorePurgatory, setIgnorePurgatory] = useState<boolean>(true) | ||
const [sort, setSort] = useState<Sort>({ | ||
sort: SortTermOptions.Created, | ||
sortOrder: SortDirectionOptions.Descending | ||
}) | ||
|
||
return ( | ||
<FilterContext.Provider | ||
value={ | ||
{ | ||
filters, | ||
setFilters, | ||
ignorePurgatory, | ||
setIgnorePurgatory, | ||
sort, | ||
setSort | ||
} as FilterValue | ||
} | ||
> | ||
{children} | ||
</FilterContext.Provider> | ||
) | ||
} | ||
|
||
// Helper hook to access the provider values | ||
const useFilter = (): FilterValue => useContext(FilterContext) | ||
|
||
export { FilterProvider, useFilter } |
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,12 @@ | ||
import { useEffect, useCallback } from 'react' | ||
|
||
const useDebounce = (effect, dependencies: any[], delay: number) => { | ||
const callback = useCallback(effect, dependencies) | ||
|
||
useEffect(() => { | ||
const timeout = setTimeout(callback, delay) | ||
return () => clearTimeout(timeout) | ||
}, [callback, delay]) | ||
} | ||
|
||
export default useDebounce |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.title, | ||
.compactTitle { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
cursor: pointer; | ||
margin-bottom: 0; | ||
color: var(--font-color-title); | ||
} | ||
|
||
.title > span:first-child, | ||
.compactTitle > span:first-child { | ||
margin-right: calc(var(--spacer) / 4); | ||
} | ||
|
||
.compactTitle { | ||
font-size: var(--font-size-h5); | ||
} | ||
|
||
.badge { | ||
margin: 0; | ||
background-color: var(--menu-border-color); | ||
color: var(--menu-network-badge-font-color); | ||
font-size: var(--font-size-base); | ||
vertical-align: middle; | ||
} | ||
|
||
.toggle { | ||
margin-left: calc(var(--spacer) / 4); | ||
transform: none !important; | ||
} | ||
|
||
.toggle svg { | ||
display: inline-block; | ||
width: var(--font-size-base); | ||
height: var(--font-size-base); | ||
fill: var(--font-color-title); | ||
vertical-align: middle; | ||
transition: 0.2s ease-out; | ||
} | ||
|
||
.open .toggle svg { | ||
transform: rotate(180deg); | ||
} | ||
|
||
.actions .content { | ||
max-height: 0; | ||
visibility: hidden; | ||
overflow: hidden; | ||
transition: 0.3s; | ||
} | ||
|
||
.open .content { | ||
max-height: 35rem; | ||
visibility: visible; | ||
overflow-y: scroll; | ||
transition: 0.3s max-height; | ||
} | ||
|
||
.open .compactContent { | ||
max-height: 15rem; | ||
} |
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,56 @@ | ||
import React, { ReactElement, ReactNode, useState } from 'react' | ||
import Button from '@shared/atoms/Button' | ||
import styles from './index.module.css' | ||
import Caret from '@images/caret.svg' | ||
import classNames from 'classnames/bind' | ||
import Badge from '@shared/atoms/Badge' | ||
|
||
const cx = classNames.bind(styles) | ||
|
||
export default function Accordion({ | ||
title, | ||
defaultExpanded = false, | ||
badgeNumber, | ||
compact, | ||
action, | ||
children | ||
}: { | ||
title: string | ||
defaultExpanded?: boolean | ||
badgeNumber?: number | ||
compact?: boolean | ||
action?: ReactNode | ||
children: ReactNode | ||
}): ReactElement { | ||
const [open, setOpen] = useState(!!defaultExpanded) | ||
|
||
async function handleClick() { | ||
setOpen(!open) | ||
} | ||
|
||
return ( | ||
<div className={cx({ actions: true, open })}> | ||
<h3 | ||
className={compact ? styles.compactTitle : styles.title} | ||
onClick={handleClick} | ||
> | ||
<span>{title}</span> | ||
{badgeNumber > 0 && ( | ||
<Badge label={badgeNumber} className={styles.badge} /> | ||
)} | ||
<Button | ||
style="text" | ||
size="small" | ||
onClick={handleClick} | ||
className={styles.toggle} | ||
> | ||
<Caret /> | ||
</Button> | ||
</h3> | ||
{action} | ||
<div className={cx({ content: true, compactContent: compact })}> | ||
{children} | ||
</div> | ||
</div> | ||
) | ||
} |
Oops, something went wrong.