/******************************************************************************** * 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, IconButton, Select, MenuItem, Typography, SelectChangeEvent } from '@mui/material'; import { SortBy, SortOrder } from '../../extension-registry-types'; import { ExtensionCategory } from '../../extension-registry-types'; import { Theme } from '@mui/material/styles'; import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'; import ArrowDownwardIcon from '@mui/icons-material/ArrowDownward'; // Distance from the content column's right edge to the viewport edge: the centered // PageContainer's outer gap (its cap is the xl breakpoint) plus its 1.5rem gutter (sm and up). const edgeBleed = (theme: Theme) => `calc((100vw - min(100vw, ${theme.breakpoints.values.xl}px)) / 2 + 1.5rem)`; export const SearchHeader: FunctionComponent = props => { const { sortBy, sortOrder, onSortByChanged, onSortOrderChanged } = props; const handleSortByChange = (event: SelectChangeEvent) => { onSortByChanged(event.target.value as SortBy); }; const toggleSortOrder = () => { onSortOrderChanged(sortOrder === 'asc' ? 'desc' : 'asc'); }; const title = props.searchQuery ? `"${props.searchQuery}"` : props.category || 'All extensions'; return ( ({ pt: '1.75rem', pb: '0.875rem', mb: '1rem', ml: { md: '-1.25rem' }, pl: { md: '1.25rem' }, mr: { xs: '-1rem', sm: `calc(${edgeBleed(theme)} * -1)` }, pr: { xs: '1rem', sm: edgeBleed(theme) }, borderBottom: '1px solid', borderColor: 'border2', display: 'flex', alignItems: 'flex-start', justifyContent: 'space-between', gap: '1rem' })}> {title} {props.resultNumber.toLocaleString()} extensions found Sort by {sortOrder === 'asc' ? ( ) : ( )} ); }; export interface SearchHeaderProps { onSortByChanged: (sb: SortBy) => void; onSortOrderChanged: (so: SortOrder) => void; sortBy: SortBy; sortOrder: SortOrder; resultNumber: number; searchQuery?: string; category?: ExtensionCategory | ''; }