From 8e99f2e778460ad4b95149791cf2467f6b8ae323 Mon Sep 17 00:00:00 2001 From: Swastik Dilip <93096031+swdilip@users.noreply.github.com> Date: Thu, 14 Dec 2023 14:41:02 +0000 Subject: [PATCH] Export popover close (#230) * chore: export popover close * chore: added popover close to docs --------- Co-authored-by: Swastik Dilip <93096031+s-dilip@users.noreply.github.com> --- src/components/Popover/index.tsx | 10 +++++- stories/Popover/Docs.mdx | 55 +++++++++++++++++------------ stories/Popover/Popover.example.tsx | 24 ++++++++++++- stories/Popover/Popover.stories.ts | 1 + 4 files changed, 65 insertions(+), 25 deletions(-) diff --git a/src/components/Popover/index.tsx b/src/components/Popover/index.tsx index 8ddf0685..b28e737e 100644 --- a/src/components/Popover/index.tsx +++ b/src/components/Popover/index.tsx @@ -24,6 +24,8 @@ const Popover = PopoverPrimitive.Root const PopoverTrigger = PopoverPrimitive.Trigger +const PopoverClose = PopoverPrimitive.Close + export interface PopoverProps extends React.ComponentPropsWithoutRef, VariantProps {} @@ -84,4 +86,10 @@ const PopoverSeparator = React.forwardRef< )) PopoverSeparator.displayName = SeparatorPrimitive.Root.displayName -export { Popover, PopoverTrigger, PopoverContent, PopoverSeparator } +export { + Popover, + PopoverTrigger, + PopoverContent, + PopoverSeparator, + PopoverClose +} diff --git a/stories/Popover/Docs.mdx b/stories/Popover/Docs.mdx index 492a620f..8f11387b 100644 --- a/stories/Popover/Docs.mdx +++ b/stories/Popover/Docs.mdx @@ -20,6 +20,10 @@ A popover overlay is a temporary, expandable menu that appears on top of the mai +## With Close Button + + + ### \ The root of the component. @@ -56,6 +60,10 @@ The content contained in the popover. Style or className is ignored. Used to visually separate items in the popover. Can be used to create Headers or Footers. +### \ + +The button that closes the popover. + ## Example ```tsx @@ -64,6 +72,7 @@ import { PopoverContent, PopoverTrigger, PopoverSeparator, + PopoverClose, PopoverProps, Button } from '@nearform/quantum' @@ -72,29 +81,29 @@ import { PlusIcon } from '@/assets/build' const ShoppingList = () => ( - - - - -
-
- Shopping List -
- -
  • Bananas
  • -
  • Bread
  • -
  • Butter
  • -
  • Sugar
  • -
  • Icing Sugar
  • -
  • Eggs
  • -
  • Baking Powder
  • - -
    - - Add new item -
    + + + + +
    +
    + Shopping List +
    + +
  • Bananas
  • +
  • Bread
  • +
  • Butter
  • +
  • Sugar
  • +
  • Icing Sugar
  • +
  • Eggs
  • +
  • Baking Powder
  • + +
    + + Add new item
    - - +
    +
    + ) ``` diff --git a/stories/Popover/Popover.example.tsx b/stories/Popover/Popover.example.tsx index 7fb4bce2..4fe319b9 100644 --- a/stories/Popover/Popover.example.tsx +++ b/stories/Popover/Popover.example.tsx @@ -3,6 +3,7 @@ import { PopoverContent, PopoverTrigger, PopoverSeparator, + PopoverClose, PopoverProps } from '@/components/Popover' import { Button, Label, PlusIcon, Radio, RadioGroup } from '@/index' @@ -27,7 +28,7 @@ const PopoverDemoRadio = () => {
    How often would you like to recieve notifications?
    - + { ) } +const PopoverDemoWithCloseButton = () => { + return ( + + + + + +
    +
    + Press the button below to close the popover +
    + + + +
    +
    +
    + ) +} + interface DemoProps extends PopoverProps { example: string } @@ -111,6 +132,7 @@ const PopoverDemo = ({ example }: DemoProps) => { {example === 'list' && } {example === 'radio' && } {example === 'scrollableList' && } + {example === 'popoverClose' && } ) } diff --git a/stories/Popover/Popover.stories.ts b/stories/Popover/Popover.stories.ts index 6925c6ce..304caa19 100644 --- a/stories/Popover/Popover.stories.ts +++ b/stories/Popover/Popover.stories.ts @@ -19,3 +19,4 @@ export const ScrollableList: Story = { args: { example: 'scrollableList' } } export const Radio: Story = { args: { example: 'radio' } } +export const CloseButton: Story = { args: { example: 'popoverClose' } }