Skip to content

Commit

Permalink
feat: [SC-25978] 💄 Improved UI experience in Explore Collections Mini…
Browse files Browse the repository at this point in the history
…-App
  • Loading branch information
FrancoAguzzi committed Dec 20, 2024
1 parent 1b4692f commit fd83509
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 26 deletions.
74 changes: 51 additions & 23 deletions apps/namegraph.dev/app/explore-collections/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export default function ExploreCollectionsPage() {

useEffect(() => {
if (debouncedValue) {
setNameIdeas(null);
setNameIdeasLoading(true);
getCollectionsForQuery(debouncedValue)
.then((res) => setNameIdeas(res))
.finally(() => setNameIdeasLoading(false));
Expand Down Expand Up @@ -161,6 +163,12 @@ export default function ExploreCollectionsPage() {
};
}, []);

useEffect(() => {
if (nameIdeas) {
setActiveQuickJumpPill();
}
}, [nameIdeas]);

useEffect(() => {
if (activeCategoryID) {
clearActiveQuickJumpPills();
Expand All @@ -172,20 +180,6 @@ export default function ExploreCollectionsPage() {
}
}, [activeCategoryID]);

useEffect(() => {
const elm = document.getElementById("scrollable-elm");

console.log(elm);

elm?.addEventListener("scroll", () => {
console.log(elm.scrollTop);
});

return elm?.removeEventListener("scroll", () => {
console.log(elm.scrollTop);
});
}, []);

return (
<div className="mx-auto py-8 w-full">
<div className="flex flex-col gap-8">
Expand All @@ -196,15 +190,48 @@ export default function ExploreCollectionsPage() {
🔎 Search for a name and see name ideas ⬇️
</h1>
</div>
<DebounceInput
id="query"
type="text"
name="query"
autoComplete="off"
debounceTimeout={300}
onChange={(e) => setDebouncedValue(e.target.value)}
className="w-full bg-gray-100 border border-gray-300 rounded-md p-3 px-4"
/>
<div className="flex space-x-2 items-center">
<DebounceInput
id="query"
type="text"
name="query"
autoComplete="off"
debounceTimeout={300}
onChange={(e) => setDebouncedValue(e.target.value)}
className="w-full bg-gray-100 border border-gray-300 rounded-md p-3 px-4"
/>
{nameIdeasLoading ? (
<div role="status">
<svg
aria-hidden="true"
className="w-6 h-6 me-2 text-gray-200 animate-spin dark:text-gray-600 fill-blue-600"
viewBox="0 0 100 101"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
fill="currentColor"
/>
<path
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
fill="currentFill"
/>
</svg>
<span className="sr-only">Loading...</span>
</div>
) : debouncedValue ? (
<svg
className="w-6 h-6 me-2 text-green-500 dark:text-green-400 flex-shrink-0"
aria-hidden="true"
xmlns="http://www.w3.org/2000/svg"
fill="currentColor"
viewBox="0 0 20 20"
>
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5Zm3.707 8.207-4 4a1 1 0 0 1-1.414 0l-2-2a1 1 0 0 1 1.414-1.414L9 10.586l3.293-3.293a1 1 0 0 1 1.414 1.414Z" />
</svg>
) : null}
</div>
<p className="leading-6 text-sm font-semibold text-gray-600 max-w-[760px] mx-auto text-center mt-6">
Use NameGraph SDK to generate multiple name ideas suggestions for
a single search. This works just as typing something like{" "}
Expand Down Expand Up @@ -245,6 +272,7 @@ export default function ExploreCollectionsPage() {
`}
>
<QuickJumpsByCategory
search={debouncedValue}
nameIdeas={nameIdeas}
activeCategoryID={activeCategoryID}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import {
} from "@/lib/utils";

interface QuickJumpsByCategoryProps {
search: string;
activeCategoryID: string;
nameIdeas: null | NameGraphGroupedByCategoryResponse;
}

export const QuickJumpsByCategory = ({
search,
nameIdeas,
activeCategoryID,
}: QuickJumpsByCategoryProps) => {
Expand Down Expand Up @@ -60,12 +62,16 @@ export const QuickJumpsByCategory = ({
}
}, [quickJumpCategories]);

useEffect(() => {
setLoadingQuickJumpPills(true);
}, [search]);

if (nameIdeas?.categories === null) return null;

return (
<div className="w-full px-3 relative bg-white border-b border-gray-300 pt-3 border-t">
<h2 className="text-lg font-regular mb-4 text-center">
📚 Collections and name ideas found ⬇️
📚 Collections and name ideas found for <b>{search}</b> ⬇️
</h2>
{!quickJumpCategories || loadingQuickJumpPills ? (
<div className="mx-3 px-2 mb-3 md:px-7 lg:px-12">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const WritersBlockPill = ({
suggestion: WritersBlockSuggestion | null;
}) => {
return (
<button className="ens-webfont relative min-w-[180px] min-h-[48px] bg-white border py-1.5 px-5 mb-2 whitespace-nowrap text-sm font-medium leading-5 transition rounded-xl focus-visible:outline-black border-gray-200">
<div className="ens-webfont relative min-w-[180px] min-h-[48px] bg-white border py-1.5 px-5 mb-2 whitespace-nowrap text-sm font-medium leading-5 transition rounded-xl focus-visible:outline-black border-gray-200">
<div className="text-gray-500 relative">
{suggestion?.collectionName ? (
<p className="break-all">{suggestion.collectionName}</p>
Expand All @@ -24,6 +24,6 @@ export const WritersBlockPill = ({
<Skeleton className="pb-1.5 w-full min-w-[140px] h-4" />
)}
</div>
</button>
</div>
);
};

0 comments on commit fd83509

Please sign in to comment.