Skip to content

Commit

Permalink
tsdoc commented
Browse files Browse the repository at this point in the history
  • Loading branch information
gautam-divyanshu committed Jan 9, 2025
1 parent 38ef3ef commit b454185
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions src/subComponents/SortingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,40 @@ import PropTypes from 'prop-types';
import styles from '../style/app.module.css';

interface InterfaceSortingOption {
/** The label to display for the sorting option */
label: string;
/** The value associated with the sorting option */
value: string;
}

interface InterfaceSortingButtonProps {
/** The title attribute for the Dropdown */
title?: string;
/** The list of sorting options to display in the Dropdown */
sortingOptions: InterfaceSortingOption[];
/** The currently selected sorting option */
selectedOption?: string;
/** Callback function to handle sorting option change */
onSortChange: (value: string) => void;
/** The prefix for data-testid attributes for testing */
dataTestIdPrefix: string;
/** The data-testid attribute for the Dropdown */
dropdownTestId?: string;
/** Custom class name for the Dropdown */
className?: string;
buttonLabel?: string; // Optional prop for custom button label
type?: 'sort' | 'filter'; // Type to determine the icon
/** Optional prop for custom button label */
buttonLabel?: string;
/** Type to determine the icon to display: 'sort' or 'filter' */
type?: 'sort' | 'filter';
}

/**
* SortingButton component renders a Dropdown with sorting options.
* It allows users to select a sorting option and triggers a callback on selection.
*
* @param props - The properties for the SortingButton component.
* @returns The rendered SortingButton component.
*/
const SortingButton: React.FC<InterfaceSortingButtonProps> = ({
title,
sortingOptions,
Expand All @@ -30,8 +48,8 @@ const SortingButton: React.FC<InterfaceSortingButtonProps> = ({
dataTestIdPrefix,
dropdownTestId,
className = styles.dropdown,
buttonLabel, // Destructure the optional buttonLabel prop
type = 'sort', // Default to 'sort'
buttonLabel,
type = 'sort',
}) => {
// Determine the icon based on the type
const IconComponent = type === 'filter' ? FilterAltOutlined : SortIcon;
Expand Down

0 comments on commit b454185

Please sign in to comment.