diff --git a/site/gatsby-site/src/components/discover/Discover.js b/site/gatsby-site/src/components/discover/Discover.js
index 41cb910f06..775c008c08 100644
--- a/site/gatsby-site/src/components/discover/Discover.js
+++ b/site/gatsby-site/src/components/discover/Discover.js
@@ -1,4 +1,4 @@
-import React, { useState } from 'react';
+import React, { useEffect, useRef, useState } from 'react';
import Col from 'elements/Col';
import Row from 'elements/Row';
import Container from 'elements/Container';
@@ -16,6 +16,7 @@ import parseURL from './parseURL';
import { queryConfig } from './queryParams';
import { history } from 'instantsearch.js/es/lib/routers';
import Pagination from './Pagination';
+import debounce from 'lodash/debounce';
const searchClient = algoliasearch(
config.header.search.algoliaAppId,
@@ -34,6 +35,28 @@ export default function Discover() {
const [indexName] = useState(`instant_search-${locale}-featured`);
+ const [width, setWidth] = useState(0);
+
+ const handleWindowSizeChange = useRef(
+ debounce(() => {
+ setWidth(window.innerWidth);
+ }, 1000)
+ ).current;
+
+ useEffect(() => {
+ window.addEventListener('resize', handleWindowSizeChange);
+
+ handleWindowSizeChange();
+
+ return () => {
+ window.removeEventListener('resize', handleWindowSizeChange);
+ };
+ }, []);
+
+ if (width == 0) {
+ return null;
+ }
+
return (
-
-
-
+ {width > 767 ? : }
diff --git a/site/gatsby-site/src/components/discover/OptionsModal.js b/site/gatsby-site/src/components/discover/OptionsModal.js
index 7ce454b136..94e984f282 100644
--- a/site/gatsby-site/src/components/discover/OptionsModal.js
+++ b/site/gatsby-site/src/components/discover/OptionsModal.js
@@ -1,4 +1,4 @@
-import React, { useEffect, useState } from 'react';
+import React, { useState } from 'react';
import REFINEMENT_LISTS from 'components/discover/REFINEMENT_LISTS';
import { AccordionFilter } from './Filter';
import Stats from './Stats';
@@ -8,16 +8,42 @@ import DisplayModeSwitch from './DisplayModeSwitch';
import Button from 'elements/Button';
import DisplayOptions from './DisplayOptions';
import { Accordion, Modal } from 'flowbite-react';
+import { useRange, useRefinementList } from 'react-instantsearch';
+
+const VirtualRefinementList = ({ attribute }) => {
+ useRefinementList({ attribute });
+
+ return null;
+};
+
+const VirtualRange = ({ attribute }) => {
+ useRange({ attribute });
+
+ return null;
+};
+
+const componentsMap = {
+ refinement: VirtualRefinementList,
+ range: VirtualRange,
+};
+
+function VirtualFilters() {
+ return (
+ <>
+ {REFINEMENT_LISTS.map((list) => {
+ const Component = componentsMap[list.type];
+
+ return ;
+ })}
+ >
+ );
+}
function OptionsModal() {
const [showModal, setShowModal] = useState(false);
const handleClose = () => setShowModal(false);
- const [mounted, setMounted] = useState(false);
-
- useEffect(() => setMounted(true), []);
-
return (
@@ -33,31 +59,32 @@ function OptionsModal() {
- {mounted && (
-
-
- Search Options
-
-
-
-
-
-
-
-
- {REFINEMENT_LISTS.map((list) => (
-
- ))}
-
+
+
+
+
+
+ Search Options
+
+
+
+
+
+
-
-
-
-
-
- )}
+
+ {REFINEMENT_LISTS.map((list) => (
+
+ ))}
+
+
+
+
+
+
+
);
}