mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
Add multiselect component
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
Select as MantineSelect,
|
Select as MantineSelect,
|
||||||
SelectProps as MantineSelectProps,
|
SelectProps as MantineSelectProps,
|
||||||
|
MultiSelect as MantineMultiSelect,
|
||||||
|
MultiSelectProps as MantineMultiSelectProps,
|
||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
|
||||||
@@ -9,6 +11,11 @@ interface SelectProps extends MantineSelectProps {
|
|||||||
width?: number | string;
|
width?: number | string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface MultiSelectProps extends MantineMultiSelectProps {
|
||||||
|
maxWidth?: number | string;
|
||||||
|
width?: number | string;
|
||||||
|
}
|
||||||
|
|
||||||
const StyledSelect = styled(MantineSelect)`
|
const StyledSelect = styled(MantineSelect)`
|
||||||
& [data-selected='true'] {
|
& [data-selected='true'] {
|
||||||
background: var(--input-select-bg);
|
background: var(--input-select-bg);
|
||||||
@@ -68,7 +75,78 @@ export const Select = ({ width, maxWidth, ...props }: SelectProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const StyledMultiSelect = styled(MantineMultiSelect)`
|
||||||
|
& [data-selected='true'] {
|
||||||
|
background: var(--input-select-bg);
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-MultiSelect-disabled {
|
||||||
|
background: var(--input-select-bg);
|
||||||
|
opacity: 0.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .mantine-MultiSelect-itemsWrapper {
|
||||||
|
& .mantine-Select-item {
|
||||||
|
padding: 40px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const MultiSelect = ({
|
||||||
|
width,
|
||||||
|
maxWidth,
|
||||||
|
...props
|
||||||
|
}: MultiSelectProps) => {
|
||||||
|
return (
|
||||||
|
<StyledMultiSelect
|
||||||
|
withinPortal
|
||||||
|
styles={{
|
||||||
|
dropdown: {
|
||||||
|
background: 'var(--dropdown-menu-bg)',
|
||||||
|
filter: 'drop-shadow(0 0 5px rgb(0, 0, 0, 20%))',
|
||||||
|
},
|
||||||
|
input: {
|
||||||
|
background: 'var(--input-bg)',
|
||||||
|
color: 'var(--input-fg)',
|
||||||
|
},
|
||||||
|
item: {
|
||||||
|
'&:hover': {
|
||||||
|
background: 'var(--dropdown-menu-bg-hover)',
|
||||||
|
},
|
||||||
|
'&[data-hovered]': {
|
||||||
|
background: 'var(--dropdown-menu-bg-hover)',
|
||||||
|
},
|
||||||
|
'&[data-selected="true"]': {
|
||||||
|
'&:hover': {
|
||||||
|
background: 'var(--dropdown-menu-bg-hover)',
|
||||||
|
},
|
||||||
|
background: 'none',
|
||||||
|
color: 'var(--primary-color)',
|
||||||
|
},
|
||||||
|
color: 'var(--dropdown-menu-fg)',
|
||||||
|
padding: '.5rem .1rem',
|
||||||
|
},
|
||||||
|
value: {
|
||||||
|
margin: '.2rem',
|
||||||
|
paddingBottom: '1rem',
|
||||||
|
paddingLeft: '1rem',
|
||||||
|
paddingTop: '1rem',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
sx={{ maxWidth, width }}
|
||||||
|
transition="pop"
|
||||||
|
transitionDuration={100}
|
||||||
|
{...props}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
Select.defaultProps = {
|
Select.defaultProps = {
|
||||||
maxWidth: undefined,
|
maxWidth: undefined,
|
||||||
width: undefined,
|
width: undefined,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
MultiSelect.defaultProps = {
|
||||||
|
maxWidth: undefined,
|
||||||
|
width: undefined,
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user