ChatPageNew: display disabled ChatComposer and "To:" label

environments/review-chats-g56n7m/deployments/1169
Alex Gleason 2 years ago
parent 4bab81bd7c
commit 19382c3ab9
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7

@ -6,6 +6,7 @@ import AutosuggestAccountInput from 'soapbox/components/autosuggest_account_inpu
import Icon from 'soapbox/components/icon';
import SvgIcon from './ui/icon/svg-icon';
import { InputThemes } from './ui/input/input';
const messages = defineMessages({
placeholder: { id: 'account_search.placeholder', defaultMessage: 'Search for an account' },
@ -22,10 +23,12 @@ interface IAccountSearch {
className?: string,
autoFocus?: boolean,
hidePortal?: boolean,
theme?: InputThemes,
showButtons?: boolean,
}
/** 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 [value, setValue] = useState('');
@ -76,23 +79,25 @@ const AccountSearch: React.FC<IAccountSearch> = ({ onSelected, className, ...res
{...rest}
/>
<div
role='button'
tabIndex={0}
className='absolute inset-y-0 right-0 px-3 flex items-center cursor-pointer'
onClick={handleClear}
>
<SvgIcon
src={require('@tabler/icons/search.svg')}
className={classNames('h-4 w-4 text-gray-400', { hidden: !isEmpty() })}
/>
<SvgIcon
src={require('@tabler/icons/x.svg')}
className={classNames('h-4 w-4 text-gray-400', { hidden: isEmpty() })}
aria-label={intl.formatMessage(messages.placeholder)}
/>
</div>
{showButtons && (
<div
role='button'
tabIndex={0}
className='absolute inset-y-0 right-0 px-3 flex items-center cursor-pointer'
onClick={handleClear}
>
<SvgIcon
src={require('@tabler/icons/search.svg')}
className={classNames('h-4 w-4 text-gray-400', { hidden: !isEmpty() })}
/>
<SvgIcon
src={require('@tabler/icons/x.svg')}
className={classNames('h-4 w-4 text-gray-400', { hidden: isEmpty() })}
aria-label={intl.formatMessage(messages.placeholder)}
/>
</div>
)}
</div>
</div>
);

@ -10,7 +10,7 @@ const messages = defineMessages({
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,
onSubmit: () => void,
hasErrorSubmittingMessage?: boolean,
@ -23,10 +23,11 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement, IChatComposer>(({
value,
onSubmit,
hasErrorSubmittingMessage = false,
disabled = false,
}, ref) => {
const intl = useIntl();
const isSubmitDisabled = value.length === 0;
const isSubmitDisabled = disabled || value.length === 0;
return (
<div className='mt-auto pt-4 px-4 shadow-3xl'>
@ -42,6 +43,7 @@ const ChatComposer = React.forwardRef<HTMLTextAreaElement, IChatComposer>(({
isResizeable={false}
autoGrow
maxRows={5}
disabled={disabled}
/>
</Stack>

@ -1,10 +1,13 @@
import React from 'react';
import { FormattedMessage } from 'react-intl';
import { useHistory } from 'react-router-dom';
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 ChatComposer from '../../chat-composer';
interface IChatPageNew {
}
@ -19,11 +22,31 @@ const ChatPageNew: React.FC<IChatPageNew> = () => {
};
return (
<Stack className='h-full p-6 space-y-8'>
<CardTitle title='New Message' />
<Stack className='h-full'>
<Stack className='flex-grow p-6 space-y-8'>
<CardTitle title='New Message' />
<HStack space={2} alignItems='center'>
<Text>
<FormattedMessage
id='chats.new.to'
defaultMessage='To:'
/>
</Text>
<AccountSearch
onSelected={handleAccountSelected}
theme='transparent'
showButtons={false}
autoFocus
/>
</HStack>
</Stack>
<AccountSearch
onSelected={handleAccountSelected}
<ChatComposer
value=''
onSubmit={() => {}}
disabled
/>
</Stack>
);

Loading…
Cancel
Save