-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Product Directory Refresh #18133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Product Directory Refresh #18133
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
acfe24e
Update Products directory
hturan 457ec03
Fix changes to 1.1.1.1 icon
hturan b7d0add
Fixed client-side node imports
hturan 00a9e58
Added dark colors
hturan 2e00925
Design tweaks for truncated product names
hturan 0dfacf2
Fix types, add category deep-links
hturan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,137 @@ | ||
| import { useState, type ChangeEvent } from "react"; | ||
| import type { CollectionEntry } from "astro:content"; | ||
| import type { IconifyIconBuildResult } from "@iconify/utils"; | ||
|
|
||
| const ProductCatalog = ({ | ||
| products, | ||
| }: { | ||
| products: (CollectionEntry<"products"> & { | ||
| icon: IconifyIconBuildResult; | ||
| groups: string[]; | ||
| })[]; | ||
| }) => { | ||
| const [filters, setFilters] = useState<{ | ||
| search: string; | ||
| groups: string[]; | ||
| }>({ | ||
| search: "", | ||
| groups: [], | ||
| }); | ||
|
|
||
| const groups = [...new Set(products.map((product) => product.groups).flat())]; | ||
|
|
||
| const productList = products.filter((product) => { | ||
| if (filters.groups.length > 0) { | ||
| if ( | ||
| filters.groups.filter((val) => product.groups.includes(val)).length === | ||
| 0 | ||
| ) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| if (filters.search) { | ||
| if ( | ||
| !product.data.name.toLowerCase().includes(filters.search.toLowerCase()) | ||
| ) { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| return true; | ||
| }); | ||
|
|
||
| return ( | ||
| <div className="md:flex"> | ||
| <div className="md:w-1/4 w-full mr-8"> | ||
| <input | ||
| type="text" | ||
| className="w-full mb-8 rounded-md bg-white dark:bg-black border-2 border-gray-200 dark:border-gray-700 px-2 py-2" | ||
| placeholder="Search products" | ||
| value={filters.search} | ||
| onChange={(e) => setFilters({ ...filters, search: e.target.value })} | ||
| /> | ||
|
|
||
| <div className="!mb-8 md:block hidden"> | ||
| <span className="uppercase text-gray-600 dark:text-gray-200 text-sm font-bold"> | ||
| Groups | ||
| </span> | ||
|
|
||
| {groups.map((group) => ( | ||
| <label key={group} className="block !my-2"> | ||
| <input | ||
| type="checkbox" | ||
| className="mr-2" | ||
| value={group} | ||
| onChange={(e: ChangeEvent<HTMLInputElement>) => { | ||
| if (e.target.checked) { | ||
| setFilters({ | ||
| ...filters, | ||
| groups: [...filters.groups, e.target.value], | ||
| }); | ||
| } else { | ||
| setFilters({ | ||
| ...filters, | ||
| groups: filters.groups.filter( | ||
| (f) => f !== e.target.value, | ||
| ), | ||
| }); | ||
| } | ||
| }} | ||
| />{" "} | ||
| {group} | ||
| </label> | ||
| ))} | ||
| </div> | ||
| </div> | ||
|
|
||
| <div className="grid lg:grid-cols-3 md:grid-cols-2 grid-cols-1 gap-2 lg:gap-4 lg:w-3/4 w-full items-stretch self-start !mt-0"> | ||
| {productList.length === 0 && ( | ||
| <div className="border lg:col-span-3 md:col-span-2 bg-gray-50 dark:bg-gray-800 dark:border-gray-500 rounded-md w-full flex-col flex align-middle justify-center text-center py-6"> | ||
| <span className="text-lg !font-bold">No products found</span> | ||
| <p> | ||
| Try a different search term, or broaden your search by removing | ||
| filters. | ||
| </p> | ||
| </div> | ||
| )} | ||
| {productList.map((product) => { | ||
| return ( | ||
| <a | ||
| href={product.data.product.url} | ||
| className="self-stretch p-3 border-gray-200 dark:border-gray-700 border-solid border rounded-md block !text-inherit no-underline hover:bg-gray-50 dark:hover:bg-black" | ||
| > | ||
| <div className="flex items-center"> | ||
| {product.icon && ( | ||
| <div className="rounded-full p-2 bg-orange-50 mr-2 text-orange-500 dark:bg-orange-950"> | ||
| <svg | ||
| {...product.icon.attributes} | ||
| width={28} | ||
| height={28} | ||
| dangerouslySetInnerHTML={{ __html: product.icon.body }} | ||
| /> | ||
| </div> | ||
| )} | ||
| {!product.icon && ( | ||
| <div className="flex items-center justify-center leading-none rounded-full p-2 bg-orange-50 dark:bg-orange-950 mr-2 text-[color:var(--orange-accent-200)] text-xl font-bold w-11 h-11"> | ||
| {product.data.name.substr(0, 1)} | ||
| </div> | ||
| )} | ||
| <span className="font-semibold text-lg text-ellipsis overflow-hidden whitespace-nowrap"> | ||
| {product.data.name} | ||
| </span> | ||
| </div> | ||
| {product.data.meta && ( | ||
| <p className="!mt-2 line-clamp-2 text-sm leading-6"> | ||
| {product.data.meta.description} | ||
| </p> | ||
| )} | ||
| </a> | ||
| ); | ||
| })} | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default ProductCatalog; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of room for us to de-dupe this and
ModelCatalogin the future. Left it be for now until we tackle a third instance of this pattern.