simplify optional text on link

This commit is contained in:
keyan 2023-10-22 11:54:27 -05:00
parent 40f63baa05
commit b853cacfa7
2 changed files with 14 additions and 25 deletions

View File

@ -1,5 +1,5 @@
import AccordianItem from './accordian-item'
import { MarkdownInput, Input, InputUserSuggest, VariableInput, Checkbox } from './form'
import { Input, InputUserSuggest, VariableInput, Checkbox } from './form'
import InputGroup from 'react-bootstrap/InputGroup'
import { BOOST_MIN, BOOST_MULT, MAX_FORWARDS } from '../lib/constants'
import { DEFAULT_CROSSPOSTING_RELAYS } from '../lib/nostr'
@ -11,15 +11,14 @@ import { useRouter } from 'next/router'
const EMPTY_FORWARD = { nym: '', pct: '' }
export function AdvPostInitial ({ text, forward, boost }) {
export function AdvPostInitial ({ forward, boost }) {
return {
text: text || '',
boost: boost || '',
forward: forward?.length ? forward : [EMPTY_FORWARD]
}
}
export default function AdvPostForm ({ isLink }) {
export default function AdvPostForm ({ children }) {
const me = useMe()
const router = useRouter()
@ -28,24 +27,7 @@ export default function AdvPostForm ({ isLink }) {
header={<div style={{ fontWeight: 'bold', fontSize: '92%' }}>options</div>}
body={
<>
{isLink &&
<MarkdownInput
label={
<div className='d-flex align-items-center'>text
<Info>
<span className='fw-bold'>You can use this text to ...</span>
<ul>
<li>provide context</li>
<li>summarize the link</li>
<li>spur great conversation!</li>
<li>or for anything else that comes to your mind</li>
</ul>
</Info>
</div>
}
name='text'
minRows={6}
/>}
{children}
<Input
label={
<div className='d-flex align-items-center'>boost

View File

@ -1,5 +1,5 @@
import { useState, useEffect, useCallback } from 'react'
import { Form, Input, SubmitButton } from '../components/form'
import { Form, Input, MarkdownInput, SubmitButton } from '../components/form'
import { useRouter } from 'next/router'
import { gql, useApolloClient, useLazyQuery, useMutation } from '@apollo/client'
import Countdown from './countdown'
@ -123,7 +123,8 @@ export function LinkForm ({ item, sub, editThreshold, children }) {
initial={{
title: item?.title || shareTitle || '',
url: item?.url || shareUrl || '',
...AdvPostInitial({ text: item?.text, forward: normalizeForwards(item?.forwards), boost: item?.boost }),
text: item?.text || '',
...AdvPostInitial({ forward: normalizeForwards(item?.forwards), boost: item?.boost }),
...SubSelectInitial({ sub: item?.subName || sub?.name })
}}
schema={schema}
@ -185,7 +186,13 @@ export function LinkForm ({ item, sub, editThreshold, children }) {
}
}}
/>
<AdvPostForm edit={!!item} isLink />
<AdvPostForm edit={!!item}>
<MarkdownInput
label='context'
name='text'
minRows={2}
/>
</AdvPostForm>
<div className='mt-3'>
{item
? (