Make composer min height conditional and align attachments (#5976)

* Make web composer min height condiitonal

* Fix alignment

* Fix alignment on mobile
This commit is contained in:
dan
2024-10-28 19:12:15 +00:00
committed by GitHub
parent 5bce043e1e
commit dcc5405e8a
4 changed files with 18 additions and 7 deletions
-3
View File
@@ -92,9 +92,6 @@ a[role='link'][data-no-underline='1']:hover {
} }
/* ProseMirror */ /* ProseMirror */
.ProseMirror {
min-height: 140px;
}
.ProseMirror-dark { .ProseMirror-dark {
color: white; color: white;
} }
+6 -2
View File
@@ -565,6 +565,9 @@ function ComposerPost({
const {_} = useLingui() const {_} = useLingui()
const {data: currentProfile} = useProfileQuery({did: currentDid}) const {data: currentProfile} = useProfileQuery({did: currentDid})
const richtext = draft.richtext const richtext = draft.richtext
const isTextOnly =
!draft.embed.link && !draft.embed.quote && !draft.embed.media
const forceMinHeight = isWeb && isTextOnly
const selectTextInputPlaceholder = isReply const selectTextInputPlaceholder = isReply
? _(msg`Write your reply`) ? _(msg`Write your reply`)
: _(msg`What's up?`) : _(msg`What's up?`)
@@ -615,6 +618,7 @@ function ComposerPost({
richtext={richtext} richtext={richtext}
placeholder={selectTextInputPlaceholder} placeholder={selectTextInputPlaceholder}
autoFocus autoFocus
webForceMinHeight={forceMinHeight}
setRichText={rt => { setRichText={rt => {
dispatch({type: 'update_richtext', richtext: rt}) dispatch({type: 'update_richtext', richtext: rt})
}} }}
@@ -757,7 +761,7 @@ function ComposerEmbeds({
)} )}
{embed.media?.type === 'gif' && ( {embed.media?.type === 'gif' && (
<View style={a.relative} key={embed.media.gif.url}> <View style={[a.relative, a.mt_lg]} key={embed.media.gif.url}>
<ExternalEmbedGif <ExternalEmbedGif
gif={embed.media.gif} gif={embed.media.gif}
onRemove={() => dispatch({type: 'embed_remove_gif'})} onRemove={() => dispatch({type: 'embed_remove_gif'})}
@@ -773,7 +777,7 @@ function ComposerEmbeds({
)} )}
{!embed.media && embed.link && ( {!embed.media && embed.link && (
<View style={a.relative} key={embed.link.uri}> <View style={[a.relative, a.mt_lg]} key={embed.link.uri}>
<ExternalEmbedLink <ExternalEmbedLink
uri={embed.link.uri} uri={embed.link.uri}
hasQuote={!!embed.quote} hasQuote={!!embed.quote}
@@ -43,6 +43,7 @@ export interface TextInputRef {
interface TextInputProps extends ComponentProps<typeof RNTextInput> { interface TextInputProps extends ComponentProps<typeof RNTextInput> {
richtext: RichText richtext: RichText
placeholder: string placeholder: string
webForceMinHeight: boolean
setRichText: (v: RichText) => void setRichText: (v: RichText) => void
onPhotoPasted: (uri: string) => void onPhotoPasted: (uri: string) => void
onPressPublish: (richtext: RichText) => void onPressPublish: (richtext: RichText) => void
@@ -230,7 +231,7 @@ export const TextInput = forwardRef(function TextInputImpl(
}, [t, richtext, inputTextStyle]) }, [t, richtext, inputTextStyle])
return ( return (
<View style={[a.flex_1, a.pl_md, a.pb_2xl]}> <View style={[a.flex_1, a.pl_md]}>
<PasteInput <PasteInput
testID="composerTextInput" testID="composerTextInput"
ref={textInput} ref={textInput}
@@ -244,7 +245,7 @@ export const TextInput = forwardRef(function TextInputImpl(
allowFontScaling allowFontScaling
multiline multiline
scrollEnabled={false} scrollEnabled={false}
numberOfLines={4} numberOfLines={2}
style={[ style={[
inputTextStyle, inputTextStyle,
a.w_full, a.w_full,
@@ -41,6 +41,7 @@ interface TextInputProps {
richtext: RichText richtext: RichText
placeholder: string placeholder: string
suggestedLinks: Set<string> suggestedLinks: Set<string>
webForceMinHeight: boolean
setRichText: (v: RichText | ((v: RichText) => RichText)) => void setRichText: (v: RichText | ((v: RichText) => RichText)) => void
onPhotoPasted: (uri: string) => void onPhotoPasted: (uri: string) => void
onPressPublish: (richtext: RichText) => void onPressPublish: (richtext: RichText) => void
@@ -52,6 +53,7 @@ export const TextInput = React.forwardRef(function TextInputImpl(
{ {
richtext, richtext,
placeholder, placeholder,
webForceMinHeight,
setRichText, setRichText,
onPhotoPasted, onPhotoPasted,
onPressPublish, onPressPublish,
@@ -271,6 +273,13 @@ export const TextInput = React.forwardRef(function TextInputImpl(
return style return style
}, [t, fonts]) }, [t, fonts])
React.useLayoutEffect(() => {
let node = editor?.view.dom
if (node) {
node.style.minHeight = webForceMinHeight ? '140px' : ''
}
}, [editor, webForceMinHeight])
return ( return (
<> <>
<View style={styles.container}> <View style={styles.container}>