Skip to content

Commit

Permalink
fix: Remove the Trigger and Close from the Popover because of gesture…
Browse files Browse the repository at this point in the history
… conflict
  • Loading branch information
hellohublot committed Oct 20, 2023
1 parent 8e48a86 commit 18fc89d
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 37 deletions.
22 changes: 14 additions & 8 deletions packages/components/src/Popover/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export function Popover({
renderContent,
floatingPanelProps,
sheetProps,
onOpenChange,
...props
}: PopoverProps) {
const { bottom } = useSafeAreaInsets();
Expand Down Expand Up @@ -67,7 +68,13 @@ export function Popover({
}

return (
<TMPopover offset={8} allowFlip placement="bottom-end" {...props}>
<TMPopover
offset={8}
allowFlip
placement="bottom-end"
onOpenChange={onOpenChange}
{...props}
>
<TMPopover.Trigger asChild>{renderTrigger}</TMPopover.Trigger>

{/* floating panel */}
Expand Down Expand Up @@ -131,13 +138,12 @@ export function Popover({
<Text variant="$headingXl" color="$text">
{title}
</Text>
<TMPopover.Close asChild>
<IconButton
icon="CrossedSmallOutline"
size="small"
$platform-native={{ hitSlop: 8 }}
/>
</TMPopover.Close>
<IconButton
icon="CrossedSmallOutline"
size="small"
$platform-native={{ hitSlop: 8 }}
onPress={() => onOpenChange(false)}
/>
</XStack>

{/* divider */}
Expand Down
68 changes: 39 additions & 29 deletions packages/kit/src/views/Components/stories/Popover.tsx
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
import { useState } from 'react';

import { Button, Popover, Stack, Text } from '@onekeyhq/components';

import { Layout } from './utils/Layout';

const PopoverGallery = () => (
<Layout
description=".."
suggestions={['...']}
boundaryConditions={['...']}
elements={[
{
title: 'Default',
element: (
<Popover
title="Popover Demo"
renderTrigger={<Button>Open</Button>}
renderContent={
<Stack space="$4" p="$5">
<Text>
Non exercitation ea laborum cupidatat sunt amet aute
exercitation occaecat minim incididunt non est est voluptate.
</Text>
<Popover.Close>
<Button variant="primary">Button</Button>
</Popover.Close>
</Stack>
}
/>
),
},
]}
/>
);
const PopoverGallery = () => {
const [isOpen, setIsOpen] = useState(false);
return (
<Layout
description=".."
suggestions={['...']}
boundaryConditions={['...']}
elements={[
{
title: 'Default',
element: (
<Popover
title="Popover Demo"
open={isOpen}
onOpenChange={setIsOpen}
renderTrigger={
<Button onPress={() => setIsOpen(true)}>Open</Button>
}
renderContent={
<Stack space="$4" p="$5">
<Text>
Non exercitation ea laborum cupidatat sunt amet aute
exercitation occaecat minim incididunt non est est
voluptate.
</Text>
<Button variant="primary" onPress={() => setIsOpen(false)}>
Button
</Button>
</Stack>
}
/>
),
},
]}
/>
);
};

export default PopoverGallery;

0 comments on commit 18fc89d

Please sign in to comment.