Skip to content

Commit

Permalink
feat: persist catalog layout globally
Browse files Browse the repository at this point in the history
  • Loading branch information
tplevko authored and lordrip committed Oct 17, 2023
1 parent a1c5ca6 commit 279bcc8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/ui/src/components/Catalog/Catalog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { FunctionComponent, PropsWithChildren, useCallback, useEffect, useState } from 'react';
import { useLocalStorage } from '../../hooks';
import { LocalStorageKeys } from '../../models';
import { BaseCatalog } from './BaseCatalog';
import { CatalogLayout, ITile } from './Catalog.models';
import './Catalog.scss';
Expand All @@ -15,7 +17,7 @@ export const Catalog: FunctionComponent<PropsWithChildren<CatalogProps>> = (prop
const [searchTerm, setSearchTerm] = useState('');
const [groups, setGroups] = useState<string[]>([]);
const [activeGroup, setActiveGroup] = useState<string>(getFirstActiveGroup(props.tiles));
const [activeLayout, setActiveLayout] = useState(CatalogLayout.Gallery);
const [activeLayout, setActiveLayout] = useLocalStorage(LocalStorageKeys.CatalogLayout, CatalogLayout.Gallery);
const [filteredTiles, setFilteredTiles] = useState<ITile[]>([]);
const [filterTags, setFilterTags] = useState<string[]>([]);

Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/models/local-storage-keys.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const enum LocalStorageKeys {
SourceCode = 'sourceCode',
CatalogLayout = 'catalogLayout',
}

0 comments on commit 279bcc8

Please sign in to comment.