Skip to content

Commit

Permalink
warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nlkluth committed Dec 4, 2023
1 parent e615659 commit aeb9625
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/nextjs/app/migration/components.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function ComponentsPage() {
<h1 className="text-h4">Select</h1>
<div className="mb-8 mt-2">
<Select
id="demo"
label="Label"
placeholder="Placeholder Text"
options={[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const ProductVariantSelector = ({ variants, selectedVariant, onVariantCha
) : (
<Select
options={options}
id="product-variants-select"
placeholder="Select a flavour"
selectedItem={{
title: selectedVariant?.name ?? "",
Expand Down
1 change: 1 addition & 0 deletions packages/shared-ui/components/ProductSort/ProductSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const ProductSort: React.FC<ProductSortProps> = ({
<Select
label=""
placeholder={title}
id="sort-select"
selectedItem={selectedItem}
options={elements}
className={selectClassName}
Expand Down
4 changes: 3 additions & 1 deletion packages/shared-ui/components/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,20 @@ export interface Props {
options: Option[];
label?: string;
placeholder: string;
id: string;
selectedItem?: Option | null;
className?: string;
onChange?: (value?: Option | null) => void;
}

const itemToString = (item: Option | null) => (item ? item.title : "");

export function Select({ label, placeholder, options, className, selectedItem, onChange }: Props) {
export function Select({ label, placeholder, options, className, selectedItem, onChange, id }: Props) {
const { isOpen, getToggleButtonProps, getLabelProps, getMenuProps, highlightedIndex, getItemProps } = useSelect({
items: options,
itemToString,
selectedItem,
id,
onSelectedItemChange({ selectedItem }) {
onChange && onChange(selectedItem);
},
Expand Down

0 comments on commit aeb9625

Please sign in to comment.