Skip to content

armgit / meet

Public Imported from GitHub
0

Open source video conferencing app powered by LiveKit. Built with Django and React.

✨(frontend) add icon support to select primitive component

lebaudantoine872ce1ecc652
diff --git a/src/frontend/src/primitives/Select.tsx b/src/frontend/src/primitives/Select.tsx
index e701e746..4c5c5b06 100644
--- a/src/frontend/src/primitives/Select.tsx
+++ b/src/frontend/src/primitives/Select.tsx
@@ -1,6 +1,6 @@
import { type ReactNode } from 'react'
import { styled } from '@/styled-system/jsx'
-import { RiArrowDropDownLine } from '@remixicon/react'
+import { RemixiconComponentType, RiArrowDropDownLine } from '@remixicon/react'
import {
Button,
ListBox,
@@ -12,12 +12,14 @@ import {
import { Box } from './Box'
import { StyledPopover } from './Popover'
import { menuRecipe } from '@/primitives/menuRecipe.ts'
+import { css } from '@/styled-system/css'
const StyledButton = styled(Button, {
base: {
width: 'full',
display: 'flex',
justifyContent: 'space-between',
+ alignItems: 'center',
paddingY: 0.125,
paddingX: 0.25,
border: '1px solid',
@@ -53,22 +55,40 @@ const StyledSelectValue = styled(SelectValue, {
},
})
+const StyledIcon = styled('div', {
+ base: {
+ marginRight: '0.35rem',
+ flexShrink: 0,
+ },
+})
+
export const Select = <T extends string | number>({
label,
+ iconComponent,
items,
errors,
...props
}: Omit<SelectProps<object>, 'items' | 'label' | 'errors'> & {
+ iconComponent?: RemixiconComponentType
label: ReactNode
items: Array<{ value: T; label: ReactNode }>
errors?: ReactNode
}) => {
+ const IconComponent = iconComponent
return (
<RACSelect {...props}>
{label}
<StyledButton>
+ {!!IconComponent && (
+ <StyledIcon>
+ <IconComponent size={18} />
+ </StyledIcon>
+ )}
<StyledSelectValue />
- <RiArrowDropDownLine aria-hidden="true" />
+ <RiArrowDropDownLine
+ aria-hidden="true"
+ className={css({ flexShrink: 0 })}
+ />
</StyledButton>
<StyledPopover>
<Box size="sm" type="popover" variant="control">