Skip to content

Commit

Permalink
misc: migrate multiple combobox to tailwind (#1947)
Browse files Browse the repository at this point in the history
  • Loading branch information
ansmonjol authored Dec 30, 2024
1 parent ffffacd commit e94ad90
Show file tree
Hide file tree
Showing 9 changed files with 226 additions and 335 deletions.
6 changes: 1 addition & 5 deletions src/components/form/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,7 @@ export const ComboBox = ({
// @ts-ignore
{ value, renderGroupHeader, virtualized }
}
PopperComponent={ComboBoxPopperFactory({
...PopperProps,
grouped: !!(data || [])[0]?.group,
virtualized,
})}
PopperComponent={ComboBoxPopperFactory(PopperProps)}
getOptionDisabled={(option) => !!option?.disabled}
getOptionLabel={(option) => {
const optionForString =
Expand Down
17 changes: 3 additions & 14 deletions src/components/form/ComboBox/ComboBoxPopperFactory.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import { Popper, PopperProps } from '@mui/material'
import { cx } from 'class-variance-authority'
import { ReactNode } from 'react'

import { theme } from '~/styles'

import { ComboBoxProps } from './types'

type ComboBoxPopperFactoryArgs = Required<Pick<ComboBoxProps, 'PopperProps'>>['PopperProps'] & {
grouped?: boolean
virtualized?: boolean
}
type ComboBoxPopperFactoryArgs = Required<Pick<ComboBoxProps, 'PopperProps'>>['PopperProps']

// return a configured <Popper> component with custom styles
export const ComboBoxPopperFactory =
({ placement, displayInDialog, grouped, virtualized }: ComboBoxPopperFactoryArgs = {}) =>
({ placement, displayInDialog }: ComboBoxPopperFactoryArgs = {}) =>
// eslint-disable-next-line react/display-name
(props: PopperProps) => (
<Popper
Expand All @@ -35,13 +31,6 @@ export const ComboBoxPopperFactory =
]}
{...props}
>
<div
className={cx({
'combobox-popper--virtualized': virtualized,
'combobox-popper--grouped': grouped,
})}
>
{props?.children as ReactNode}
</div>
<>{props?.children as ReactNode}</>
</Popper>
)
2 changes: 1 addition & 1 deletion src/components/form/ComboBox/ComboboxList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface ComboBoxVirtualizedListProps
children: ReactNode
}

const ComboboxListItem = ({
export const ComboboxListItem = ({
children,
virtualized,
className,
Expand Down
Loading

0 comments on commit e94ad90

Please sign in to comment.