ChatPageNew: display disabled ChatComposer and "To:" label
This commit is contained in:
parent
4bab81bd7c
commit
19382c3ab9
3 changed files with 54 additions and 24 deletions
|
@ -6,6 +6,7 @@ import AutosuggestAccountInput from 'soapbox/components/autosuggest_account_inpu
|
||||||
import Icon from 'soapbox/components/icon';
|
import Icon from 'soapbox/components/icon';
|
||||||
|
|
||||||
import SvgIcon from './ui/icon/svg-icon';
|
import SvgIcon from './ui/icon/svg-icon';
|
||||||
|
import { InputThemes } from './ui/input/input';
|
||||||
|
|
||||||
const messages = defineMessages({
|
const messages = defineMessages({
|
||||||
placeholder: { id: 'account_search.placeholder', defaultMessage: 'Search for an account' },
|
placeholder: { id: 'account_search.placeholder', defaultMessage: 'Search for an account' },
|
||||||
|
@ -22,10 +23,12 @@ interface IAccountSearch {
|
||||||
className?: string,
|
className?: string,
|
||||||
autoFocus?: boolean,
|
autoFocus?: boolean,
|
||||||
hidePortal?: boolean,
|
hidePortal?: boolean,
|
||||||
|
theme?: InputThemes,
|
||||||
|
showButtons?: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Input to search for accounts. */
|
/** Input to search for accounts. */
|
||||||
const AccountSearch: React.FC<IAccountSearch> = ({ onSelected, className, ...rest }) => {
|
const AccountSearch: React.FC<IAccountSearch> = ({ onSelected, className, showButtons = true, ...rest }) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const [value, setValue] = useState('');
|
const [value, setValue] = useState('');
|
||||||
|
@ -76,6 +79,7 @@ const AccountSearch: React.FC<IAccountSearch> = ({ onSelected, className, ...res
|
||||||
{...rest}
|
{...rest}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{showButtons && (
|
||||||
<div
|
<div
|
||||||
role='button'
|
role='button'
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
|
@ -93,6 +97,7 @@ const AccountSearch: React.FC<IAccountSearch> = ({ onSelected, className, ...res
|
||||||
aria-label={intl.formatMessage(messages.placeholder)}
|
aria-label={intl.formatMessage(messages.placeholder)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -10,7 +10,7 @@ const messages = defineMessages({
|
||||||
retry: { id: 'chat.retry', defaultMessage: 'Retry?' },
|
retry: { id: 'chat.retry', defaultMessage: 'Retry?' },
|
||||||
});
|
});
|
||||||
|
|
||||||
interface IChatComposer extends Pick<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onKeyDown' | 'onChange'> {
|
interface IChatComposer extends Pick<React.TextareaHTMLAttributes<HTMLTextAreaElement>, 'onKeyDown' | 'onChange' | 'disabled'> {
|
||||||
value: string,
|
value: string,
|
||||||
onSubmit: () => void,
|
onSubmit: () => void,
|
||||||
hasErrorSubmittingMessage?: boolean,
|
hasErrorSubmittingMessage?: boolean,
|
||||||
|
@ -23,10 +23,11 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement, IChatComposer>(({
|
||||||
value,
|
value,
|
||||||
onSubmit,
|
onSubmit,
|
||||||
hasErrorSubmittingMessage = false,
|
hasErrorSubmittingMessage = false,
|
||||||
|
disabled = false,
|
||||||
}, ref) => {
|
}, ref) => {
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
|
|
||||||
const isSubmitDisabled = value.length === 0;
|
const isSubmitDisabled = disabled || value.length === 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className='mt-auto pt-4 px-4 shadow-3xl'>
|
<div className='mt-auto pt-4 px-4 shadow-3xl'>
|
||||||
|
@ -42,6 +43,7 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement, IChatComposer>(({
|
||||||
isResizeable={false}
|
isResizeable={false}
|
||||||
autoGrow
|
autoGrow
|
||||||
maxRows={5}
|
maxRows={5}
|
||||||
|
disabled={disabled}
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,13 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { useHistory } from 'react-router-dom';
|
import { useHistory } from 'react-router-dom';
|
||||||
|
|
||||||
import AccountSearch from 'soapbox/components/account_search';
|
import AccountSearch from 'soapbox/components/account_search';
|
||||||
import { CardTitle, Stack } from 'soapbox/components/ui';
|
import { CardTitle, HStack, Stack, Text } from 'soapbox/components/ui';
|
||||||
import { useChats } from 'soapbox/queries/chats';
|
import { useChats } from 'soapbox/queries/chats';
|
||||||
|
|
||||||
|
import ChatComposer from '../../chat-composer';
|
||||||
|
|
||||||
interface IChatPageNew {
|
interface IChatPageNew {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +22,31 @@ const ChatPageNew: React.FC<IChatPageNew> = () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Stack className='h-full p-6 space-y-8'>
|
<Stack className='h-full'>
|
||||||
|
<Stack className='flex-grow p-6 space-y-8'>
|
||||||
<CardTitle title='New Message' />
|
<CardTitle title='New Message' />
|
||||||
|
|
||||||
|
<HStack space={2} alignItems='center'>
|
||||||
|
<Text>
|
||||||
|
<FormattedMessage
|
||||||
|
id='chats.new.to'
|
||||||
|
defaultMessage='To:'
|
||||||
|
/>
|
||||||
|
</Text>
|
||||||
|
|
||||||
<AccountSearch
|
<AccountSearch
|
||||||
onSelected={handleAccountSelected}
|
onSelected={handleAccountSelected}
|
||||||
|
theme='transparent'
|
||||||
|
showButtons={false}
|
||||||
|
autoFocus
|
||||||
|
/>
|
||||||
|
</HStack>
|
||||||
|
</Stack>
|
||||||
|
|
||||||
|
<ChatComposer
|
||||||
|
value=''
|
||||||
|
onSubmit={() => {}}
|
||||||
|
disabled
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue