Sticky publish footer (#179)

This commit is contained in:
Ilya Y 2023-08-15 13:24:08 +03:00 committed by GitHub
parent 3b0c3789df
commit caac88deb7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 163 additions and 135 deletions

View File

@ -1,5 +1,7 @@
.TopicSelect .solid-select-list {
background: #fff;
position: relative;
z-index: 13;
}
.TopicSelect .solid-select-option[data-disabled='true'] {

View File

@ -347,9 +347,6 @@ export const EditView = (props: Props) => {
</Show>
</>
</Show>
<Show when={page().route === 'editSettings'}>
<PublishSettings shoutId={props.shout.id} form={form} />
</Show>
</div>
</div>
<Show when={page().route === 'edit'}>
@ -362,7 +359,9 @@ export const EditView = (props: Props) => {
</div>
</form>
</div>
<Show when={page().route === 'editSettings'}>
<PublishSettings shoutId={props.shout.id} form={form} />
</Show>
<Panel shoutId={props.shout.id} />
</>
)

View File

@ -138,15 +138,22 @@
}
.formActions {
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
padding: 1rem 0;
gap: 1rem;
margin-top: 80px;
background: var(--background-color);
position: sticky;
z-index: 12;
bottom: 0;
border-top: 2px solid var(--black-100);
margin-top: 80px;
margin-bottom: -40px;
.content {
display: flex;
align-items: center;
justify-content: flex-end;
flex-direction: row;
padding: 1rem 0;
gap: 1rem;
}
.cancel {
margin-right: auto;
}

View File

@ -110,139 +110,159 @@ export const PublishSettings = (props: Props) => {
}
return (
<div class={styles.PublishSettings}>
<div>
<button type="button" class={styles.goBack} onClick={handleBackClick}>
<Icon name="arrow-left" class={stylesBeside.icon} />
{t('Back to editor')}
</button>
</div>
<h1>{t('Publish Settings')}</h1>
<h4>{t('Material card')}</h4>
<div class={styles.articlePreview}>
<div class={styles.actions}>
<Button
variant="primary"
onClick={() => showModal('uploadCoverImage')}
value={settingsForm.coverImageUrl ? t('Add another image') : t('Add image')}
/>
<Show when={settingsForm.coverImageUrl}>
<Button variant="secondary" onClick={handleDeleteCoverImage} value={t('Delete cover')} />
</Show>
</div>
<div
class={clsx(styles.shoutCardCoverContainer, { [styles.hasImage]: settingsForm.coverImageUrl })}
>
<Show when={settingsForm.coverImageUrl ?? initialData.coverImageUrl}>
<div class={styles.shoutCardCover}>
<img src={imageProxy(settingsForm.coverImageUrl)} alt={initialData.title} loading="lazy" />
<form class={clsx(styles.PublishSettings, 'inputs-wrapper')}>
<div class="wide-container">
<div class="row">
<div class="col-md-19 col-lg-18 col-xl-16 offset-md-5">
<div>
<button type="button" class={styles.goBack} onClick={handleBackClick}>
<Icon name="arrow-left" class={stylesBeside.icon} />
{t('Back to editor')}
</button>
</div>
</Show>
<div class={styles.text}>
<Show when={settingsForm.mainTopic}>
<div class={styles.mainTopic}>{settingsForm.mainTopic.title}</div>
</Show>
<div class={styles.shoutCardTitle}>{settingsForm.title}</div>
<div class={styles.shoutCardSubtitle}>{settingsForm.subtitle}</div>
<div class={styles.shoutAuthor}>{user().name}</div>
<h1>{t('Publish Settings')}</h1>
<h4>{t('Material card')}</h4>
<div class={styles.articlePreview}>
<div class={styles.actions}>
<Button
variant="primary"
onClick={() => showModal('uploadCoverImage')}
value={settingsForm.coverImageUrl ? t('Add another image') : t('Add image')}
/>
<Show when={settingsForm.coverImageUrl}>
<Button variant="secondary" onClick={handleDeleteCoverImage} value={t('Delete cover')} />
</Show>
</div>
<div
class={clsx(styles.shoutCardCoverContainer, {
[styles.hasImage]: settingsForm.coverImageUrl
})}
>
<Show when={settingsForm.coverImageUrl ?? initialData.coverImageUrl}>
<div class={styles.shoutCardCover}>
<img
src={imageProxy(settingsForm.coverImageUrl)}
alt={initialData.title}
loading="lazy"
/>
</div>
</Show>
<div class={styles.text}>
<Show when={settingsForm.mainTopic}>
<div class={styles.mainTopic}>{settingsForm.mainTopic.title}</div>
</Show>
<div class={styles.shoutCardTitle}>{settingsForm.title}</div>
<div class={styles.shoutCardSubtitle}>{settingsForm.subtitle}</div>
<div class={styles.shoutAuthor}>{user().name}</div>
</div>
</div>
</div>
<p class="description">
{t(
'Choose a title image for the article. You can immediately see how the publication card will look like.'
)}
</p>
<div class={styles.commonSettings}>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Come up with a title for your story')}
initialValue={settingsForm.title}
value={(value) => setSettingsForm('title', value)}
allowEnterKey={false}
maxLength={100}
/>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Come up with a subtitle for your story')}
initialValue={settingsForm.subtitle}
value={(value) => setSettingsForm('subtitle', value)}
allowEnterKey={false}
maxLength={100}
/>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Write a short introduction')}
initialValue={`${settingsForm.lead}`}
value={(value) => setSettingsForm('lead', value)}
allowEnterKey={false}
maxLength={MAX_LEAD_LIMIT}
/>
</div>
<h4>{t('Slug')}</h4>
<div class="pretty-form__item">
<input type="text" name="slug" id="slug" value={settingsForm.slug} />
<label for="slug">{t('Slug')}</label>
</div>
<h4>{t('Topics')}</h4>
<p class="description">
{t(
'Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title'
)}
</p>
<div class={styles.inputContainer}>
<div class={clsx('pretty-form__item', styles.topicSelectContainer)}>
<Show when={topics()}>
<TopicSelect
topics={topics()}
onChange={handleTopicSelectChange}
selectedTopics={props.form.selectedTopics}
onMainTopicChange={(mainTopic) => setForm('mainTopic', mainTopic)}
mainTopic={props.form.mainTopic}
/>
</Show>
</div>
<Show when={formErrors.selectedTopics}>
<div class={styles.validationError}>{formErrors.selectedTopics}</div>
</Show>
</div>
{/*<h4>Соавторы</h4>*/}
{/*<p class="description">У каждого соавтора можно добавить роль</p>*/}
{/*<div class="pretty-form__item--with-button">*/}
{/* <div class="pretty-form__item">*/}
{/* <input type="text" name="authors" id="authors" placeholder="Введите имя или e-mail" />*/}
{/* <label for="authors">Введите имя или e-mail</label>*/}
{/* </div>*/}
{/* <button class="button button--submit">Добавить</button>*/}
{/*</div>*/}
{/*<div class="row">*/}
{/* <div class="col-md-6">Михаил Драбкин</div>*/}
{/* <div class="col-md-6">*/}
{/* <input type="text" name="coauthor" id="coauthor1" class="nolabel" />*/}
{/* </div>*/}
{/*</div>*/}
</div>
</div>
</div>
<p class="description">
{t(
'Choose a title image for the article. You can immediately see how the publication card will look like.'
)}
</p>
<div class={styles.commonSettings}>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Come up with a title for your story')}
initialValue={settingsForm.title}
value={(value) => setSettingsForm('title', value)}
allowEnterKey={false}
maxLength={100}
/>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Come up with a subtitle for your story')}
initialValue={settingsForm.subtitle}
value={(value) => setSettingsForm('subtitle', value)}
allowEnterKey={false}
maxLength={100}
/>
<GrowingTextarea
class={styles.settingInput}
variant="bordered"
placeholder={t('Write a short introduction')}
initialValue={`${settingsForm.lead}`}
value={(value) => setSettingsForm('lead', value)}
allowEnterKey={false}
maxLength={MAX_LEAD_LIMIT}
/>
</div>
<h4>{t('Slug')}</h4>
<div class="pretty-form__item">
<input type="text" name="slug" id="slug" value={settingsForm.slug} />
<label for="slug">{t('Slug')}</label>
</div>
<h4>{t('Topics')}</h4>
<p class="description">
{t(
'Add a few topics so that the reader knows what your content is about and can find it on pages of topics that interest them. Topics can be swapped, the first topic becomes the title'
)}
</p>
<div class={styles.inputContainer}>
<div class={clsx('pretty-form__item', styles.topicSelectContainer)}>
<Show when={topics()}>
<TopicSelect
topics={topics()}
onChange={handleTopicSelectChange}
selectedTopics={props.form.selectedTopics}
onMainTopicChange={(mainTopic) => setForm('mainTopic', mainTopic)}
mainTopic={props.form.mainTopic}
/>
</Show>
</div>
<Show when={formErrors.selectedTopics}>
<div class={styles.validationError}>{formErrors.selectedTopics}</div>
</Show>
</div>
{/*<h4>Соавторы</h4>*/}
{/*<p class="description">У каждого соавтора можно добавить роль</p>*/}
{/*<div class="pretty-form__item--with-button">*/}
{/* <div class="pretty-form__item">*/}
{/* <input type="text" name="authors" id="authors" placeholder="Введите имя или e-mail" />*/}
{/* <label for="authors">Введите имя или e-mail</label>*/}
{/* </div>*/}
{/* <button class="button button--submit">Добавить</button>*/}
{/*</div>*/}
{/*<div class="row">*/}
{/* <div class="col-md-6">Михаил Драбкин</div>*/}
{/* <div class="col-md-6">*/}
{/* <input type="text" name="coauthor" id="coauthor1" class="nolabel" />*/}
{/* </div>*/}
{/*</div>*/}
<div class={styles.formActions}>
<Button
variant="light"
value={t('Cancel changes')}
class={styles.cancel}
onClick={handleCancelClick}
/>
<Button variant="secondary" onClick={handleSaveDraft} value={t('Save draft')} />
<Button onClick={handlePublishSubmit} variant="primary" value={t('Publish')} />
<div class="wide-container">
<div class="row">
<div class="col-md-19 col-lg-18 col-xl-16 offset-md-5">
<div class={styles.content}>
<Button
variant="light"
value={t('Cancel changes')}
class={styles.cancel}
onClick={handleCancelClick}
/>
<Button variant="secondary" onClick={handleSaveDraft} value={t('Save draft')} />
<Button onClick={handlePublishSubmit} variant="primary" value={t('Publish')} />
</div>
</div>
</div>
</div>
</div>
<Modal variant="narrow" name="uploadCoverImage">
<UploadModalContent onClose={(value) => handleUploadModalContentCloseSetCover(value)} />
</Modal>
</div>
</form>
)
}