💄(frontend) add dark variant prop to Popover primitive
Add dark variant following same approach as Menu component. Not ideal as light/dark pattern differs from primary/primaryDark variants used elsewhere. Quick implementation that will be refactored during UI v2 migration for better consistency across component variants.
This commit is contained in:
committed by
aleb_the_flash
parent
ac88c046dc
commit
8f28a46a5f
@@ -46,6 +46,18 @@ const StyledOverlayArrow = styled(OverlayArrow, {
|
||||
transform: 'rotate(180deg) translateY(-1px)',
|
||||
},
|
||||
},
|
||||
variants: {
|
||||
variant: {
|
||||
light: {},
|
||||
dark: {
|
||||
fill: 'primaryDark.50',
|
||||
stroke: 'primaryDark.50',
|
||||
},
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'light',
|
||||
},
|
||||
})
|
||||
|
||||
/**
|
||||
@@ -56,6 +68,7 @@ const StyledOverlayArrow = styled(OverlayArrow, {
|
||||
*/
|
||||
export const Popover = ({
|
||||
children,
|
||||
variant = 'light',
|
||||
...dialogProps
|
||||
}: {
|
||||
children: [
|
||||
@@ -64,20 +77,21 @@ export const Popover = ({
|
||||
| (({ close }: { close: () => void }) => ReactNode)
|
||||
| ReactNode,
|
||||
]
|
||||
variant?: 'dark' | 'light'
|
||||
} & DialogProps) => {
|
||||
const [trigger, popoverContent] = children
|
||||
return (
|
||||
<DialogTrigger>
|
||||
{trigger}
|
||||
<StyledPopover>
|
||||
<StyledOverlayArrow>
|
||||
<StyledOverlayArrow variant={variant}>
|
||||
<svg width={12} height={12} viewBox="0 0 12 12">
|
||||
<path d="M0 0 L6 6 L12 0" />
|
||||
</svg>
|
||||
</StyledOverlayArrow>
|
||||
<Dialog {...dialogProps}>
|
||||
{({ close }) => (
|
||||
<Box size="sm" type="popover">
|
||||
<Box size="sm" type="popover" variant={variant}>
|
||||
{typeof popoverContent === 'function'
|
||||
? popoverContent({ close })
|
||||
: popoverContent}
|
||||
|
||||
Reference in New Issue
Block a user