Make filteredQueryResultsSelector async :)

This commit is contained in:
rektdeckard
2020-07-24 14:38:53 -04:00
parent f14ff1ea4f
commit 8ae4cb2b81
3 changed files with 53 additions and 24 deletions

View File

@@ -1,9 +1,14 @@
html {
background-color: #FAFAFA;
}
body { body {
margin: 0px; margin: 0px;
font-family: monospace; font-family: monospace;
} }
button, select { button,
select {
margin: 4px; margin: 4px;
padding: 8px; padding: 8px;
border: 1px solid black; border: 1px solid black;
@@ -11,41 +16,63 @@ button, select {
background-color: white; background-color: white;
} }
button:focus, select:focus { button > * {
vertical-align: middle;
}
button:focus,
select:focus {
outline: none; outline: none;
border: 1px solid violet; border: 1px solid violet;
border-radius: 24px; border-radius: 24px;
} }
button:hover {
color: white;
background-color: black;
}
button:active { button:active {
background-color: lightblue; background-color: darkmagenta;
} }
input[type="color"] { input[type="color"] {
border: 1px solid black; border: 1px solid black;
border-radius: 24px; border-radius: 50%;
background-color: white;
} }
input[type="color" i] { input[type="color" i] {
-webkit-appearance: square-button; -webkit-appearance: square-button;
width: 32px; padding: 4px;
height: 32px; width: 25px;
height: 25px;
} }
#color-picker { input[type="color"]:focus {
outline: none;
border: 1px solid violet;
}
pre {
padding: 4px;
background-color: gainsboro;
}
/* .color-picker {
padding: 0px; padding: 0px;
border-radius: 100%; background-color: white;
height: 32px; height: 32px;
width: 32px; width: 32px;
border: none; border: none;
outline: none; outline: none;
-webkit-appearance: none; -webkit-appearance: none;
} }
#color-picker::-webkit-color-swatch { .color-picker::-webkit-color-swatch {
border: none; border: none;
border-radius: 50%; border-radius: 50%;
} margin: 4px;
} */
/* input { /* input {
margin: 4px; margin: 4px;

View File

@@ -1,7 +1,8 @@
import React from "react"; import React, { Suspense } from "react";
import { Header, Toolbar, IconGrid, Footer } from "../"; import { Header, Toolbar, Footer } from "../";
import "./App.css"; import "./App.css";
import IconGrid from "../IconGrid/IconGrid";
const App: React.FC<any> = () => { const App: React.FC<any> = () => {
return ( return (
@@ -9,7 +10,9 @@ const App: React.FC<any> = () => {
<Header /> <Header />
<main> <main>
<Toolbar /> <Toolbar />
<IconGrid /> <Suspense fallback={<div>Loading...</div>}>
<IconGrid />
</Suspense>
</main> </main>
<Footer /> <Footer />
</> </>

View File

@@ -21,16 +21,15 @@ const isQueryMatch = (icon: IconEntry, query: string): boolean => {
export const filteredQueryResultsSelector = selector<Readonly<IconEntry[]>>({ export const filteredQueryResultsSelector = selector<Readonly<IconEntry[]>>({
key: "filteredQueryResultsSelector", key: "filteredQueryResultsSelector",
get: ({ get }) => { get: async ({ get }) => {
const query = get(searchQueryAtom).trim().toLowerCase(); const query = get(searchQueryAtom).trim().toLowerCase();
const style = get(styleQueryAtom); const style = get(styleQueryAtom);
if (!query && !style) return icons; if (!query && !style) return icons;
return icons.filter((icon) => { return await new Promise((resolve) =>
return isQueryMatch(icon, query); resolve(icons.filter((icon) => isQueryMatch(icon, query)))
}); );
// .sort(() => Math.floor(Math.random() - 0.5));
}, },
}); });