From 8caa12b48c5e9e59d322c55808edf8386a69ac4c Mon Sep 17 00:00:00 2001 From: Dhruvik Malaviya Date: Wed, 1 Jan 2025 17:00:36 +0530 Subject: [PATCH] feat: Adds story for url popver component --- .../url-popover/stories/index.story.js | 144 +++++++++++++----- 1 file changed, 103 insertions(+), 41 deletions(-) diff --git a/packages/block-editor/src/components/url-popover/stories/index.story.js b/packages/block-editor/src/components/url-popover/stories/index.story.js index ceed23eed6b84..a66a369e0e260 100644 --- a/packages/block-editor/src/components/url-popover/stories/index.story.js +++ b/packages/block-editor/src/components/url-popover/stories/index.story.js @@ -11,49 +11,111 @@ import { keyboardReturn } from '@wordpress/icons'; */ import URLPopover from '../'; -export default { title: 'BlockEditor/URLPopover' }; +const meta = { + title: 'BlockEditor/URLPopover', + component: URLPopover, + parameters: { + docs: { + canvas: { sourceState: 'shown' }, + description: { + component: + 'Popover component used for editing and viewing URLs.', + }, + }, + }, + argTypes: { + onClose: { + action: 'onClose', + description: 'Callback when the popover is closed.', + table: { + type: { summary: 'function' }, + }, + }, + renderSettings: { + description: 'Callback to render settings inside the popover.', + table: { + type: { summary: 'function' }, + }, + control: false, + }, + placement: { + control: { type: 'text' }, + description: 'Placement of the popover relative to its parent.', + defaultValue: 'bottom', + table: { + type: { summary: 'string' }, + }, + }, + focusOnMount: { + control: { type: 'boolean' }, + description: + 'Controls which element is focused when the popover mounts.', + defaultValue: true, + table: { + type: { summary: 'boolean' }, + }, + }, + }, + args: { + placement: 'bottom', + focusOnMount: true, + }, +}; -const TestURLPopover = () => { - const [ isVisible, setVisiblility ] = useState( false ); - const [ url, setUrl ] = useState( '' ); +export default meta; - const close = () => setVisiblility( false ); - const setTarget = () => {}; +export const Default = { + render: function Template( { onChange, ...args } ) { + const [ isVisible, setIsVisible ] = useState( false ); + const [ url, setUrl ] = useState( '' ); + const [ isOpenInNewTab, setIsOpenInNewTab ] = useState( false ); - return ( - <> - - { isVisible && ( - ( - - ) } - > -
- -
+ { isVisible && ( + ( + + ) } + > +
{ + e.preventDefault(); + closePopover(); + } } + > + setUrl( e.target.value ) } + /> +