mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-10 04:30:25 +02:00
add new transitions to popover/dropdown
This commit is contained in:
@@ -24,6 +24,26 @@ type MenuDropdownProps = MantineMenuDropdownProps;
|
|||||||
type MenuLabelProps = MantineMenuLabelProps;
|
type MenuLabelProps = MantineMenuLabelProps;
|
||||||
type MenuProps = MantineMenuProps;
|
type MenuProps = MantineMenuProps;
|
||||||
|
|
||||||
|
const getTransition = (position?: string) => {
|
||||||
|
if (position?.includes('top')) {
|
||||||
|
return 'fade-up';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('bottom')) {
|
||||||
|
return 'fade-down';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('left')) {
|
||||||
|
return 'fade-left';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('right')) {
|
||||||
|
return 'fade-right';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'fade';
|
||||||
|
};
|
||||||
|
|
||||||
export const DropdownMenu = ({ children, ...props }: MenuProps) => {
|
export const DropdownMenu = ({ children, ...props }: MenuProps) => {
|
||||||
return (
|
return (
|
||||||
<MantineMenu
|
<MantineMenu
|
||||||
@@ -31,8 +51,9 @@ export const DropdownMenu = ({ children, ...props }: MenuProps) => {
|
|||||||
dropdown: styles['menu-dropdown'],
|
dropdown: styles['menu-dropdown'],
|
||||||
itemSection: styles['menu-item-section'],
|
itemSection: styles['menu-item-section'],
|
||||||
}}
|
}}
|
||||||
|
offset={10}
|
||||||
transitionProps={{
|
transitionProps={{
|
||||||
transition: 'fade',
|
transition: getTransition(props.position),
|
||||||
}}
|
}}
|
||||||
withinPortal
|
withinPortal
|
||||||
{...props}
|
{...props}
|
||||||
|
|||||||
@@ -10,15 +10,35 @@ import styles from './popover.module.css';
|
|||||||
export interface PopoverDropdownProps extends MantinePopoverDropdownProps {}
|
export interface PopoverDropdownProps extends MantinePopoverDropdownProps {}
|
||||||
export interface PopoverProps extends MantinePopoverProps {}
|
export interface PopoverProps extends MantinePopoverProps {}
|
||||||
|
|
||||||
|
const getTransition = (position?: string) => {
|
||||||
|
if (position?.includes('top')) {
|
||||||
|
return 'fade-up';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('bottom')) {
|
||||||
|
return 'fade-down';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('left')) {
|
||||||
|
return 'fade-left';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (position?.includes('right')) {
|
||||||
|
return 'fade-right';
|
||||||
|
}
|
||||||
|
|
||||||
|
return 'fade';
|
||||||
|
};
|
||||||
|
|
||||||
export const Popover = ({ children, ...props }: PopoverProps) => {
|
export const Popover = ({ children, ...props }: PopoverProps) => {
|
||||||
return (
|
return (
|
||||||
<MantinePopover
|
<MantinePopover
|
||||||
arrowSize={10}
|
|
||||||
classNames={{
|
classNames={{
|
||||||
dropdown: styles.dropdown,
|
dropdown: styles.dropdown,
|
||||||
}}
|
}}
|
||||||
transitionProps={{ transition: 'fade' }}
|
offset={10}
|
||||||
withArrow
|
transitionProps={{ transition: getTransition(props.position) }}
|
||||||
|
withArrow={false}
|
||||||
withinPortal
|
withinPortal
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user