Skip to content

Commit

Permalink
feat: Add a "Select all" for the filters
Browse files Browse the repository at this point in the history
  • Loading branch information
karelianpie committed Aug 7, 2023
1 parent 1a1ca47 commit 9d6539b
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 0 deletions.
37 changes: 37 additions & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import StrategyEntity from 'components/StrategyEntity';
import PartnerEntity from 'components/PartnerEntity';

const defaultSettings: TSettings = {
shouldShowAllFilters: true,
shouldShowOnlyAnomalies: true,
shouldShowOnlyEndorsed: true,
shouldShowVersion: 'v4',
Expand Down Expand Up @@ -63,6 +64,41 @@ const AnomaliesCheckbox = ({appSettings, set_appSettings}: {
</label>;
};

const SelectAllCheckbox = ({appSettings, set_appSettings}: {
appSettings: TSettings,
set_appSettings: (s: TSettings) => void
}): ReactElement | null => {
return <label
htmlFor={'checkbox-anomalies'}
className={'flex w-fit cursor-pointer flex-row items-center rounded-lg bg-neutral-200/60 p-2 font-mono text-sm text-neutral-500 transition-colors hover:bg-neutral-200'}>
<p className={'pr-4'}>{'Select All Filters'}</p>
<input
type={'checkbox'}
id={'checkbox-select-all'}
className={'ml-2 rounded-lg'}
checked={appSettings.shouldShowAllFilters}
onChange={(): void => {
const isSelectAllChecked = !appSettings.shouldShowAllFilters;
set_appSettings({
...appSettings,
shouldShowAllFilters: isSelectAllChecked,
shouldShowMissingTranslations: isSelectAllChecked,
shouldShowIcons: isSelectAllChecked,
shouldShowPrice: isSelectAllChecked,
shouldShowRetirement: isSelectAllChecked,
shouldShowYearnMetaFile: isSelectAllChecked,
shouldShowLedgerLive: isSelectAllChecked,
shouldShowStrategies: isSelectAllChecked,
shouldShowRisk: isSelectAllChecked,
shouldShowRiskScore: isSelectAllChecked,
shouldShowDescriptions: isSelectAllChecked,
shouldShowAPY: isSelectAllChecked,
shouldShowWantTokenDescription: isSelectAllChecked
});
}} />
</label>;
};

function convertToKebabCase(str: string): string {
return str
.trim()
Expand Down Expand Up @@ -277,6 +313,7 @@ function Index(): ReactNode {
/>
</span>
{shouldShowAnomaliesCheckbox ? <AnomaliesCheckbox appSettings={appSettings} set_appSettings={set_appSettings} /> : null}
<SelectAllCheckbox appSettings={appSettings} set_appSettings={set_appSettings} />
</div>
</div>
<div className={'flex flex-wrap pb-6'}>
Expand Down
1 change: 1 addition & 0 deletions types/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {TProtocolsData, TStrategiesData, TTokensData, TVaultsData} from './entit
export type TEntity = 'vaults' | 'tokens' | 'protocols' | 'strategies' | 'partners';
export type TVersions = 'all' | 'v2' | 'v3' | 'v4';
export type TSettings = {
shouldShowAllFilters: boolean,
shouldShowOnlyAnomalies: boolean,
shouldShowOnlyEndorsed: boolean,
shouldShowMissingTranslations: boolean,
Expand Down

0 comments on commit 9d6539b

Please sign in to comment.