/******************************************************************************** * Copyright (c) 2026 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional * information regarding copyright ownership. * * This program and the accompanying materials are made available under the * terms of the Eclipse Public License 2.0 which is available at * https://www.eclipse.org/legal/epl-2.0 * * SPDX-License-Identifier: EPL-2.0 ********************************************************************************/ import { FunctionComponent } from 'react'; import { Box, Container } from '@mui/material'; import { ExtensionCategory } from '../../extension-registry-types'; import { CATEGORY_ICONS, DefaultCategoryIcon } from '../../components/categories'; import { CategoryPill } from '../../components/category-pill'; import { CategoryCard } from '../../components/category-card'; import { Eyebrow } from '../../components/page-primitives'; import { useSearch } from '../../hooks/use-search'; import { useHomeCategories } from './use-home-data'; export interface BrowseCategoriesProps { /** Categories to offer; defaults to the registry's browsable home list. */ categories?: ExtensionCategory[]; /** Category click handler; defaults to opening the search page filtered to it. */ onSelect?: (category: ExtensionCategory) => void; } /** "Browse by category" section: a horizontal pill row on mobile, a card grid on desktop. */ export const BrowseCategories: FunctionComponent = props => { const homeCategories = useHomeCategories(); const { search } = useSearch(); const categories = props.categories ?? homeCategories; const onSelect = props.onSelect ?? ((category: ExtensionCategory) => search({ query: '', category })); if (categories.length === 0) { return null; } return ( Browse by category {categories.map(cat => ( onSelect(cat)} /> ))} {categories.map(cat => ( onSelect(cat)} /> ))} ); };