diff --git a/src/components/Views/Edit.module.scss b/src/components/Views/Edit.module.scss index 5b5a5f5e..6644d763 100644 --- a/src/components/Views/Edit.module.scss +++ b/src/components/Views/Edit.module.scss @@ -77,10 +77,9 @@ .titleInput, .subtitleInput { - border: 0; - outline: 0; - padding: 0; font-size: 36px; + line-height: 1.1; + margin-bottom: 1.2rem; &::placeholder { opacity: 0.3; @@ -93,6 +92,8 @@ } } +//Grow input + .editSettings, .edit { display: none; diff --git a/src/components/Views/Edit.tsx b/src/components/Views/Edit.tsx index c3edfd24..5c273aa0 100644 --- a/src/components/Views/Edit.tsx +++ b/src/components/Views/Edit.tsx @@ -14,6 +14,7 @@ import { useSession } from '../../context/session' import { Modal } from '../Nav/Modal' import { hideModal, showModal } from '../../stores/ui' import { imageProxy } from '../../utils/imageProxy' +import { GrowingTextarea } from '../_shared/GrowingTextarea' type EditViewProps = { shout: Shout @@ -73,11 +74,10 @@ export const EditView = (props: EditViewProps) => { }) }) - const handleTitleInputChange = (e) => { - const title = e.currentTarget.value - setForm('title', title) + const handleTitleInputChange = (value) => { + setForm('title', value) - if (title) { + if (value) { setFormErrors('title', '') } } @@ -139,30 +139,21 @@ export const EditView = (props: EditViewProps) => { })} >
- handleTitleInputChange(value)} class={styles.titleInput} - type="text" - name="title" - id="title" placeholder={t('Header')} - autocomplete="off" - value={form.title} - onInput={handleTitleInputChange} + initialValue={form.title} />
{formErrors.title}
- - setForm('subtitle', value)} class={styles.subtitleInput} - type="text" - name="subtitle" - id="subtitle" - autocomplete="off" placeholder={t('Subheader')} - value={form.subtitle} - onChange={(e) => setForm('subtitle', e.currentTarget.value)} + initialValue={form.subtitle} /> void +} + +export const GrowingTextarea = (props: Props) => { + const [value, setValue] = createSignal('') + const handleChangeValue = (event) => { + setValue(event.target.value) + props.value(event.target.value) + } + + const handleKeyDown = async (event) => { + if (event.key === 'Enter' && event.shiftKey) { + return + } + + if (event.key === 'Enter' && !event.shiftKey && value()?.trim().length > 0) { + event.preventDefault() + } + } + + return ( +
+
+