Skip to content

Storybook: Adds story and doc for url-input#68286

Open
singhakanshu00 wants to merge 3 commits intoWordPress:trunkfrom
singhakanshu00:feature/storybook
Open

Storybook: Adds story and doc for url-input#68286
singhakanshu00 wants to merge 3 commits intoWordPress:trunkfrom
singhakanshu00:feature/storybook

Conversation

@singhakanshu00
Copy link
Contributor

@singhakanshu00 singhakanshu00 commented Dec 25, 2024

What?

This PR adds story for url-input component.
Also it adds the JSDoc for the same

Why?

Part of: #67165
Part of: #22891

Testing Instructions

  • Start Storybook by running npm run storybook:dev
  • Open Storybook at http://localhost:50240/
  • Test the story for URLInput

Screenshots or screencast

Screen.Recording.2024-12-26.at.1.31.12.PM.mov

@github-actions github-actions bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Dec 25, 2024
@github-actions
Copy link

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @singhakanshu00! In case you missed it, we'd love to have you join us in our Slack community.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

@singhakanshu00 singhakanshu00 changed the title Storybook: Adds story and doc for media-placeholder Storybook: Adds story and doc for url-input Dec 25, 2024
@singhakanshu00 singhakanshu00 changed the title Storybook: Adds story and doc for url-input Storybook: Adds story and doc for media-placeholder Dec 25, 2024
@singhakanshu00 singhakanshu00 changed the title Storybook: Adds story and doc for media-placeholder Storybook: Adds story and doc for url-input Dec 25, 2024
@singhakanshu00 singhakanshu00 changed the title Storybook: Adds story and doc for url-input Storybook: Adds story and doc for url-input (URLInput and URLInputButton) Dec 26, 2024
@singhakanshu00 singhakanshu00 changed the title Storybook: Adds story and doc for url-input (URLInput and URLInputButton) Storybook: Adds story and doc for url-input Dec 26, 2024
@singhakanshu00 singhakanshu00 marked this pull request as ready for review December 26, 2024 08:25
@github-actions
Copy link

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: singhakanshu00 <akanshusingh@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late reply.

I`ve left some feedback, so I'd appreciate it if you could check it.

Comment on lines +94 to +105
const Template = ( args ) => {
const [ value, setValue ] = useState( args.value || '' );

return (
<URLInput
className={ args.className }
value={ value }
onChange={ ( newValue ) => setValue( newValue ) }
{ ...args }
/>
);
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be better to hard-code like this:

export const Default = {
	render: function Template( { onChange, ...args } ) {
		const [ value, setValue ] = useState();

		return (
			<URLInput
				{ ...args }
				value={ value }
				onChange={ ( ...changeArgs ) => {
					setValue( ...changeArgs );
					onChange( ...changeArgs );
				} }
			/>
		);
	},
};

Comment on lines +109 to +115
args: {
label: 'URL',
value: '',
placeholder: 'Enter URL...!!!',
className: 'url-input',
disableSuggestions: false,
},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unless you have a specific reason, we may not need these custom values.

Comment on lines +56 to +71
* @param {Object} props The component props.
* @param {Function} props.onChange Callback to handle input changes.
* @param {Function} props.onSubmit Callback to handle form submission.
* @param {Function} props.__experimentalFetchLinkSuggestions Function to fetch link suggestions.
* @param {Function} props.__experimentalHandleURLSuggestions Function to handle URL-specific suggestions.
* @param {boolean} props.disableSuggestions Whether to disable suggestions.
* @param {boolean} props.__experimentalShowInitialSuggestions Whether to show suggestions initially.
* @param {string} props.value The current input value.
* @param {string} props.placeholder Placeholder for the input field.
* @param {Function} props.debouncedSpeak Function for accessibility messages.
* @param {Function} props.speak Function for accessibility announcements.
* @param {Function} props.__experimentalRenderControl Custom render function for the control.
* @param {Function} props.__experimentalRenderSuggestions Custom render function for suggestions.
* @param {Function} props.autocompleteRef Reference for the autocomplete input.
* @param {Function} props.onKeyDown Optional handler for custom keydown logic.
* @param {Function} props.suffix Optional content to render as a suffix in the input field.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think some type definitions are incorrect:

  • __experimentalHandleURLSuggestions: boolean
  • autocompleteRef: object

Also, the following props are missing:

  • label
  • className
  • isFullWidth
  • hideLabelFromVison
  • instanceId

* A React component for handling URL input with suggestions, autocomplete, and keyboard navigation.
* It provides functionality for fetching and displaying link suggestions based on user input.
*
* @augments {Component}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@augments is non-standard and not used in the Gutenberg project. We can simply remove it.

Furthermore, when @param is on a constructor, I assume it means a description of the method itself.

A simple solution would be to do this:

/**
 * URLInput Component
 *
 * Component description.
 *
 * @param {PropType} props.prop description
 * @param {PropType} props.prop description
 */
class URLInput extends Component {
}

@t-hamano t-hamano added [Type] Developer Documentation Documentation for developers [Package] Block editor /packages/block-editor Storybook Storybook and its stories for components labels Jun 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Package] Block editor /packages/block-editor Storybook Storybook and its stories for components [Type] Developer Documentation Documentation for developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants