Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
22 lines (20 sloc) 719 Bytes
import { Breakpoint } from "../hooks/useBreakpoint";
// Reduce arrays for display on smaller screens based on the provided breakpoint.
export function reduceDataForScreenSize(
data: any[],
breakpoint: Breakpoint,
smallBreakpointIndices: number[],
mediumBreakpointIndices: number[]
) {
switch (breakpoint) {
case Breakpoint.SMALL:
// Return only data in the smallBreakpointIndices
return data.filter((_, i) => smallBreakpointIndices.indexOf(i) !== -1);
case Breakpoint.MEDIUM:
// Return only data in the mediumBreakpointIndices
return data.filter((_, i) => mediumBreakpointIndices.indexOf(i) !== -1);
default:
// Don't filter the data at all
return data;
}
}
You can’t perform that action at this time.