| 1 |
import React from 'react' |
| 2 |
import { __ } from '@wordpress/i18n' |
| 3 |
import { useSnippetForm } from '../../../hooks/useSnippetForm' |
| 4 |
|
| 5 |
export const NameInput: React.FC = () => { |
| 6 |
const { snippet, setSnippet, isReadOnly } = useSnippetForm() |
| 7 |
|
| 8 |
return ( |
| 9 |
<div id="titlediv"> |
| 10 |
<div id="titlewrap"> |
| 11 |
<label htmlFor="title" className="screen-reader-text"> |
| 12 |
{__('Name', 'code-snippets')} |
| 13 |
</label> |
| 14 |
<input |
| 15 |
id="title" |
| 16 |
type="text" |
| 17 |
name="snippet_name" |
| 18 |
autoComplete="off" |
| 19 |
value={snippet.name} |
| 20 |
disabled={isReadOnly} |
| 21 |
placeholder={__('Enter snippet title', 'code-snippets')} |
| 22 |
onChange={event => |
| 23 |
setSnippet(previous => ({ ...previous, name: event.target.value }))} |
| 24 |
/> |
| 25 |
</div> |
| 26 |
</div> |
| 27 |
) |
| 28 |
} |
| 29 |
|