SensitiveButton: use UI components

chats-fixes
Alex Gleason 2022-06-07 13:55:34 -05:00
rodzic 08daa19f2c
commit edffe9a837
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 13 dodań i 11 usunięć

Wyświetl plik

@ -8,6 +8,8 @@ import Stack from '../stack/stack';
interface IFormGroup {
/** Input label message. */
labelText?: React.ReactNode,
/** Input label tooltip message. */
labelTitle?: string,
/** Input hint message. */
hintText?: React.ReactNode,
/** Input errors. */
@ -16,7 +18,7 @@ interface IFormGroup {
/** Input container with label. Renders the child. */
const FormGroup: React.FC<IFormGroup> = (props) => {
const { children, errors = [], labelText, hintText } = props;
const { children, errors = [], labelText, labelTitle, hintText } = props;
const formFieldId: string = useMemo(() => `field-${uuidv4()}`, []);
const inputChildren = React.Children.toArray(children);
const hasError = errors?.length > 0;
@ -41,6 +43,7 @@ const FormGroup: React.FC<IFormGroup> = (props) => {
htmlFor={formFieldId}
data-testid='form-group-label'
className='-mt-0.5 block text-sm font-medium text-gray-700 dark:text-gray-400'
title={labelTitle}
>
{labelText}
</label>
@ -74,6 +77,7 @@ const FormGroup: React.FC<IFormGroup> = (props) => {
htmlFor={formFieldId}
data-testid='form-group-label'
className='block text-sm font-medium text-gray-700 dark:text-gray-400'
title={labelTitle}
>
{labelText}
</label>

Wyświetl plik

@ -1,8 +1,8 @@
import classNames from 'classnames';
import React from 'react';
import { useIntl, defineMessages, FormattedMessage } from 'react-intl';
import { changeComposeSensitivity } from 'soapbox/actions/compose';
import { FormGroup, Checkbox } from 'soapbox/components/ui';
import { useAppSelector, useAppDispatch } from 'soapbox/hooks';
const messages = defineMessages({
@ -23,20 +23,18 @@ const SensitiveButton: React.FC = () => {
};
return (
<div className='compose-form__sensitive-button'>
<label className={classNames('icon-button', { active })} title={intl.formatMessage(active ? messages.marked : messages.unmarked)}>
<input
<div className='px-2.5 py-1'>
<FormGroup
labelText={<FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />}
labelTitle={intl.formatMessage(active ? messages.marked : messages.unmarked)}
>
<Checkbox
name='mark-sensitive'
type='checkbox'
checked={active}
onChange={onClick}
disabled={disabled}
/>
<span className={classNames('checkbox', { active })} />
<FormattedMessage id='compose_form.sensitive.hide' defaultMessage='Mark media as sensitive' />
</label>
</FormGroup>
</div>
);
};