Added pagination to tags table

This commit is contained in:
Alejandro Celaya
2021-09-25 09:34:38 +02:00
parent 1da7119c5c
commit 12f6a132bd
7 changed files with 77 additions and 33 deletions

View File

@@ -0,0 +1,7 @@
.sticky-card-paginator {
position: sticky;
bottom: 0;
background-color: var(--primary-color-alfa);
padding: .75rem 0;
border-top: 1px solid var(--border-color);
}

View File

@@ -1,5 +1,6 @@
import { useState, useRef } from 'react';
import { useSwipeable as useReactSwipeable } from 'react-swipeable';
import { parseQuery, stringifyQuery } from './query';
const DEFAULT_DELAY = 2000;
@@ -51,3 +52,17 @@ export const useSwipeable = (showSidebar: () => void, hideSidebar: () => void) =
onSwipedRight: swipeMenuIfNoModalExists(showSidebar),
});
};
export const useQueryState = <T>(paramName: string, initialState: T): [ T, (newValue: T) => void ] => {
const [ value, setValue ] = useState(initialState);
const setValueWithLocation = (value: T) => {
const { location, history } = window;
const query = parseQuery<any>(location.search);
query[paramName] = value;
history.pushState(null, '', `${location.pathname}?${stringifyQuery(query)}`);
setValue(value);
};
return [ value, setValueWithLocation ];
};