ComposeForm: convert buttons to ComposeFormButton component
This commit is contained in:
parent
c9a4087108
commit
890299ead0
6 changed files with 66 additions and 43 deletions
|
@ -0,0 +1,34 @@
|
|||
import classNames from 'classnames';
|
||||
import React from 'react';
|
||||
|
||||
import { IconButton } from 'soapbox/components/ui';
|
||||
|
||||
interface IComposeFormButton {
|
||||
icon: string,
|
||||
title?: string,
|
||||
active?: boolean,
|
||||
disabled?: boolean,
|
||||
onClick: () => void,
|
||||
}
|
||||
|
||||
const ComposeFormButton: React.FC<IComposeFormButton> = ({
|
||||
icon,
|
||||
title,
|
||||
active,
|
||||
disabled,
|
||||
onClick,
|
||||
}) => {
|
||||
return (
|
||||
<div>
|
||||
<IconButton
|
||||
className={classNames('text-gray-400 hover:text-gray-600', { 'text-gray-600': active })}
|
||||
src={icon}
|
||||
title={title}
|
||||
disabled={disabled}
|
||||
onClick={onClick}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default ComposeFormButton;
|
|
@ -1,9 +1,8 @@
|
|||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import ComposeFormButton from './compose_form_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
marked: { id: 'compose_form.markdown.marked', defaultMessage: 'Post markdown enabled' },
|
||||
|
@ -27,14 +26,12 @@ class MarkdownButton extends React.PureComponent {
|
|||
const { intl, active } = this.props;
|
||||
|
||||
return (
|
||||
<div className='compose-form__markdown-button'>
|
||||
<IconButton
|
||||
className={classNames('compose-form__markdown-button-icon', { active })}
|
||||
src={require('@tabler/icons/icons/markdown.svg')}
|
||||
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</div>
|
||||
<ComposeFormButton
|
||||
icon={require('@tabler/icons/icons/markdown.svg')}
|
||||
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
||||
active={active}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|||
import React from 'react';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import ComposeFormButton from './compose_form_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
add_poll: { id: 'poll_button.add_poll', defaultMessage: 'Add a poll' },
|
||||
|
@ -33,15 +33,13 @@ class PollButton extends React.PureComponent {
|
|||
}
|
||||
|
||||
return (
|
||||
<div className='compose-form__poll-button'>
|
||||
<IconButton
|
||||
className={`compose-form__poll-button-icon ${active ? 'active' : ''}`}
|
||||
src={require('@tabler/icons/icons/chart-bar.svg')}
|
||||
title={intl.formatMessage(active ? messages.remove_poll : messages.add_poll)}
|
||||
disabled={disabled}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</div>
|
||||
<ComposeFormButton
|
||||
icon={require('@tabler/icons/icons/chart-bar.svg')}
|
||||
title={intl.formatMessage(active ? messages.remove_poll : messages.add_poll)}
|
||||
active={active}
|
||||
disabled={disabled}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ import Overlay from 'react-overlays/lib/Overlay';
|
|||
|
||||
import Icon from 'soapbox/components/icon';
|
||||
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import { IconButton } from '../../../components/ui';
|
||||
import Motion from '../../ui/util/optional_motion';
|
||||
|
||||
const messages = defineMessages({
|
||||
|
@ -253,7 +253,7 @@ class PrivacyDropdown extends React.PureComponent {
|
|||
<div className={classNames('privacy-dropdown', placement, { active: open })} onKeyDown={this.handleKeyDown}>
|
||||
<div className={classNames('privacy-dropdown__value', { active: this.options.indexOf(valueOption) === 0 })}>
|
||||
<IconButton
|
||||
className='privacy-dropdown__value-icon'
|
||||
className='text-gray-400 hover:text-gray-600'
|
||||
src={valueOption.icon}
|
||||
title={intl.formatMessage(messages.change_privacy)}
|
||||
expanded={open}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import ComposeFormButton from './compose_form_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
add_schedule: { id: 'schedule_button.add_schedule', defaultMessage: 'Schedule post for later' },
|
||||
|
@ -29,15 +28,13 @@ class ScheduleButton extends React.PureComponent {
|
|||
const { intl, active, disabled } = this.props;
|
||||
|
||||
return (
|
||||
<div className='compose-form__schedule-button'>
|
||||
<IconButton
|
||||
className={classNames('compose-form__schedule-button-icon', { active })}
|
||||
src={require('@tabler/icons/icons/calendar-stats.svg')}
|
||||
title={intl.formatMessage(active ? messages.remove_schedule : messages.add_schedule)}
|
||||
disabled={disabled}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</div>
|
||||
<ComposeFormButton
|
||||
icon={require('@tabler/icons/icons/calendar-stats.svg')}
|
||||
title={intl.formatMessage(active ? messages.remove_schedule : messages.add_schedule)}
|
||||
active={active}
|
||||
disabled={disabled}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import classNames from 'classnames';
|
||||
import PropTypes from 'prop-types';
|
||||
import React from 'react';
|
||||
import { defineMessages, injectIntl } from 'react-intl';
|
||||
|
||||
import IconButton from '../../../components/icon_button';
|
||||
import ComposeFormButton from './compose_form_button';
|
||||
|
||||
const messages = defineMessages({
|
||||
marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
|
||||
|
@ -27,14 +26,12 @@ class SpoilerButton extends React.PureComponent {
|
|||
const { intl, active } = this.props;
|
||||
|
||||
return (
|
||||
<div className='compose-form__spoiler-button'>
|
||||
<IconButton
|
||||
className={classNames('compose-form__spoiler-button-icon', { active })}
|
||||
src={require('@tabler/icons/icons/alert-triangle.svg')}
|
||||
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
</div>
|
||||
<ComposeFormButton
|
||||
icon={require('@tabler/icons/icons/alert-triangle.svg')}
|
||||
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
|
||||
active={active}
|
||||
onClick={this.handleClick}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue