Skip to content

Commit

Permalink
feat: add bottom arrow
Browse files Browse the repository at this point in the history
  • Loading branch information
1587315093 committed Oct 10, 2023
1 parent 9f71892 commit d5aa698
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/components/popover/popover-menu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ export const PopoverMenu = forwardRef<PopoverRef, PopoverMenuProps>(
{...props}
className={classNames(classPrefix, props.className)}
content={overlay}
bottomArrow={
!!(props?.maxCount && props.actions.length > props?.maxCount)
}
>
{props.children}
</Popover>
Expand Down
13 changes: 13 additions & 0 deletions src/components/popover/popover.less
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,17 @@
.adm-popover-arrow {
color: var(--background);
}

&-bottom-arrow {
position: absolute;
width: 100%;
display: flex;
justify-content: center;
align-items: center;
&::after {
content: ' ';
border: var(--arrow-size) solid transparent;
border-color: #fff transparent transparent transparent;
}
}
}
5 changes: 5 additions & 0 deletions src/components/popover/popover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { useClickAway, useIsomorphicLayoutEffect } from 'ahooks'
import { DeprecatedPlacement, Placement } from './index'
import { normalizePlacement } from './normalize-placement'
import { convertPx } from '../../utils/convert-px'

const classPrefix = `adm-popover`

export type PopoverProps = {
Expand All @@ -49,6 +50,7 @@ export type PopoverProps = {
placement?: Placement | DeprecatedPlacement
stopPropagation?: PropagationEvent[]
content: ReactNode
bottomArrow?: boolean
} & NativeProps<'--z-index' | '--arrow-size'>

export type PopoverRef = {
Expand Down Expand Up @@ -107,6 +109,9 @@ export const Popover = forwardRef<PopoverRef, PopoverProps>((p, ref) => {
<div className={`${classPrefix}-inner`}>
<div className={`${classPrefix}-inner-content`}>{props.content}</div>
</div>
{props.bottomArrow && (
<div className={`${classPrefix}-bottom-arrow`}></div>

Check warning on line 113 in src/components/popover/popover.tsx

View check run for this annotation

Codecov / codecov/patch

src/components/popover/popover.tsx#L113

Added line #L113 was not covered by tests
)}
</div>
)
)
Expand Down

0 comments on commit d5aa698

Please sign in to comment.