2022-08-26 09:34:15 +02:00
|
|
|
import { CancelIcon, FiltersIcon, PlusIcon, RefreshIcon } from '@/icons'
|
|
|
|
|
import { useState } from 'preact/hooks'
|
|
|
|
|
import { useDashboardContext } from '../../contexts/DashboardContext'
|
|
|
|
|
import { DashboardFilters } from './components/DashboardFilters'
|
2022-09-01 08:12:46 +02:00
|
|
|
import { DashboardSwitch } from './components/DashboardSwitch'
|
2022-08-26 09:34:15 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
|
onNewBox: () => void
|
|
|
|
|
onRefresh: () => void
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const DashboardHeader = ({ onNewBox, onRefresh }: Props) => {
|
|
|
|
|
const { verticalMode } = useDashboardContext()
|
|
|
|
|
const [filtersShown, setFiltersShown] = useState(false)
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="dashboard-head">
|
|
|
|
|
{verticalMode && (
|
|
|
|
|
<>
|
2022-08-28 12:30:37 +02:00
|
|
|
<button className="icon" onClick={onNewBox}>
|
2022-08-26 09:34:15 +02:00
|
|
|
<PlusIcon />
|
|
|
|
|
</button>
|
2022-08-28 12:30:37 +02:00
|
|
|
<button className="icon" onClick={onRefresh}>
|
2022-08-26 09:34:15 +02:00
|
|
|
<RefreshIcon />
|
|
|
|
|
</button>
|
|
|
|
|
<div className="filter-button" onClick={() => setFiltersShown(true)}>
|
|
|
|
|
<FiltersIcon />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{filtersShown && (
|
|
|
|
|
<div className="filters-panel">
|
|
|
|
|
<div className="shadow" />
|
|
|
|
|
<div className="inner">
|
|
|
|
|
<div
|
|
|
|
|
className="filter-close"
|
|
|
|
|
onClick={() => setFiltersShown(false)}
|
|
|
|
|
>
|
|
|
|
|
<CancelIcon />
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<DashboardFilters />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
{!verticalMode && (
|
|
|
|
|
<>
|
2022-09-01 08:12:46 +02:00
|
|
|
<DashboardSwitch />
|
2022-08-26 09:34:15 +02:00
|
|
|
<button onClick={onNewBox}>Add box</button>
|
|
|
|
|
<div className="spacer" />
|
|
|
|
|
<DashboardFilters />
|
|
|
|
|
<div className="spacer" />
|
|
|
|
|
<button onClick={onRefresh}>
|
|
|
|
|
<RefreshIcon /> Refresh all
|
|
|
|
|
</button>
|
|
|
|
|
</>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|