mirror of
https://github.com/glitch-soc/mastodon.git
synced 2025-12-13 15:58:50 +00:00
Compare commits
4 Commits
tootbutton
...
compose-re
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b982058173 | ||
|
|
2c9123660d | ||
|
|
05c63c5c99 | ||
|
|
118fe224ff |
@@ -29,11 +29,6 @@ settings:
|
|||||||
import/ignore:
|
import/ignore:
|
||||||
- node_modules
|
- node_modules
|
||||||
- \\.(css|scss|json)$
|
- \\.(css|scss|json)$
|
||||||
import/resolver:
|
|
||||||
node:
|
|
||||||
moduleDirectory:
|
|
||||||
- node_modules
|
|
||||||
- app/javascript
|
|
||||||
|
|
||||||
rules:
|
rules:
|
||||||
brace-style: warn
|
brace-style: warn
|
||||||
|
|||||||
@@ -112,19 +112,3 @@ exports[`<Button /> renders the props.text instead of children 1`] = `
|
|||||||
foo
|
foo
|
||||||
</button>
|
</button>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`<Button /> renders title if props.title is given 1`] = `
|
|
||||||
<button
|
|
||||||
className="button"
|
|
||||||
disabled={undefined}
|
|
||||||
onClick={[Function]}
|
|
||||||
style={
|
|
||||||
Object {
|
|
||||||
"height": "36px",
|
|
||||||
"lineHeight": "36px",
|
|
||||||
"padding": "0 16px",
|
|
||||||
}
|
|
||||||
}
|
|
||||||
title="foo"
|
|
||||||
/>
|
|
||||||
`;
|
|
||||||
|
|||||||
@@ -72,11 +72,4 @@ describe('<Button />', () => {
|
|||||||
|
|
||||||
expect(tree).toMatchSnapshot();
|
expect(tree).toMatchSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders title if props.title is given', () => {
|
|
||||||
const component = renderer.create(<Button title='foo' />);
|
|
||||||
const tree = component.toJSON();
|
|
||||||
|
|
||||||
expect(tree).toMatchSnapshot();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ export default class Button extends React.PureComponent {
|
|||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
style: PropTypes.object,
|
style: PropTypes.object,
|
||||||
children: PropTypes.node,
|
children: PropTypes.node,
|
||||||
title: PropTypes.string,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
@@ -36,26 +35,26 @@ export default class Button extends React.PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
let attrs = {
|
const style = {
|
||||||
className: classNames('button', this.props.className, {
|
padding: `0 ${this.props.size / 2.25}px`,
|
||||||
'button-secondary': this.props.secondary,
|
height: `${this.props.size}px`,
|
||||||
'button--block': this.props.block,
|
lineHeight: `${this.props.size}px`,
|
||||||
}),
|
...this.props.style,
|
||||||
disabled: this.props.disabled,
|
|
||||||
onClick: this.handleClick,
|
|
||||||
ref: this.setRef,
|
|
||||||
style: {
|
|
||||||
padding: `0 ${this.props.size / 2.25}px`,
|
|
||||||
height: `${this.props.size}px`,
|
|
||||||
lineHeight: `${this.props.size}px`,
|
|
||||||
...this.props.style,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.props.title) attrs.title = this.props.title;
|
const className = classNames('button', this.props.className, {
|
||||||
|
'button-secondary': this.props.secondary,
|
||||||
|
'button--block': this.props.block,
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button {...attrs}>
|
<button
|
||||||
|
className={className}
|
||||||
|
disabled={this.props.disabled}
|
||||||
|
onClick={this.handleClick}
|
||||||
|
ref={this.setRef}
|
||||||
|
style={style}
|
||||||
|
>
|
||||||
{this.props.text || this.props.children}
|
{this.props.text || this.props.children}
|
||||||
</button>
|
</button>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -164,8 +164,6 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
|
|
||||||
let publishText = '';
|
let publishText = '';
|
||||||
let publishText2 = '';
|
let publishText2 = '';
|
||||||
let title = '';
|
|
||||||
let title2 = '';
|
|
||||||
|
|
||||||
const privacyIcons = {
|
const privacyIcons = {
|
||||||
none: '',
|
none: '',
|
||||||
@@ -175,10 +173,7 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
direct: 'envelope',
|
direct: 'envelope',
|
||||||
};
|
};
|
||||||
|
|
||||||
title = `${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${this.props.privacy}.short` })}`;
|
|
||||||
|
|
||||||
if (showSideArm) {
|
if (showSideArm) {
|
||||||
// Enhanced behavior with dual toot buttons
|
|
||||||
publishText = (
|
publishText = (
|
||||||
<span>
|
<span>
|
||||||
{
|
{
|
||||||
@@ -190,15 +185,13 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
title2 = `${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${secondaryVisibility}.short` })}`;
|
|
||||||
publishText2 = (
|
publishText2 = (
|
||||||
<i
|
<i
|
||||||
className={`fa fa-${privacyIcons[secondaryVisibility]}`}
|
className={`fa fa-${privacyIcons[secondaryVisibility]}`}
|
||||||
aria-label={title2}
|
aria-label={`${intl.formatMessage(messages.publish)}: ${intl.formatMessage({ id: `privacy.${secondaryVisibility}.short` })}`}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
// Original vanilla behavior - no icon if public or unlisted
|
|
||||||
if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
|
if (this.props.privacy === 'private' || this.props.privacy === 'direct') {
|
||||||
publishText = <span className='compose-form__publish-private'><i className='fa fa-lock' /> {intl.formatMessage(messages.publish)}</span>;
|
publishText = <span className='compose-form__publish-private'><i className='fa fa-lock' /> {intl.formatMessage(messages.publish)}</span>;
|
||||||
} else {
|
} else {
|
||||||
@@ -263,7 +256,6 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
<Button
|
<Button
|
||||||
className='compose-form__publish__side-arm'
|
className='compose-form__publish__side-arm'
|
||||||
text={publishText2}
|
text={publishText2}
|
||||||
title={title2}
|
|
||||||
onClick={this.handleSubmit2}
|
onClick={this.handleSubmit2}
|
||||||
disabled={submitDisabled}
|
disabled={submitDisabled}
|
||||||
/> : ''
|
/> : ''
|
||||||
@@ -271,7 +263,6 @@ export default class ComposeForm extends ImmutablePureComponent {
|
|||||||
<Button
|
<Button
|
||||||
className='compose-form__publish__primary'
|
className='compose-form__publish__primary'
|
||||||
text={publishText}
|
text={publishText}
|
||||||
title={title}
|
|
||||||
onClick={this.handleSubmit}
|
onClick={this.handleSubmit}
|
||||||
disabled={submitDisabled}
|
disabled={submitDisabled}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export default class Upload extends ImmutablePureComponent {
|
|||||||
<div className='compose-form__upload' onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
|
<div className='compose-form__upload' onMouseEnter={this.handleMouseEnter} onMouseLeave={this.handleMouseLeave}>
|
||||||
<Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}>
|
<Motion defaultStyle={{ scale: 0.8 }} style={{ scale: spring(1, { stiffness: 180, damping: 12 }) }}>
|
||||||
{({ scale }) => (
|
{({ scale }) => (
|
||||||
<div className='compose-form__upload-thumbnail' style={{ transform: `scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})` }}>
|
<div className='compose-form__upload-thumbnail' style={{ transform: `translateZ(0) scale(${scale})`, backgroundImage: `url(${media.get('preview_url')})` }}>
|
||||||
<IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.handleUndoClick} />
|
<IconButton icon='times' title={intl.formatMessage(messages.undo)} size={36} onClick={this.handleUndoClick} />
|
||||||
|
|
||||||
<div className={classNames('compose-form__upload-description', { active })}>
|
<div className={classNames('compose-form__upload-description', { active })}>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ class SensitiveButton extends React.PureComponent {
|
|||||||
'compose-form__sensitive-button--visible': visible,
|
'compose-form__sensitive-button--visible': visible,
|
||||||
});
|
});
|
||||||
return (
|
return (
|
||||||
<div className={className} style={{ transform: `scale(${scale})` }}>
|
<div className={className} style={{ transform: `translateZ(0) scale(${scale})` }}>
|
||||||
<IconButton
|
<IconButton
|
||||||
className='compose-form__sensitive-button__icon'
|
className='compose-form__sensitive-button__icon'
|
||||||
title={intl.formatMessage(messages.title)}
|
title={intl.formatMessage(messages.title)}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ export default class UploadArea extends React.PureComponent {
|
|||||||
{({ backgroundOpacity, backgroundScale }) =>
|
{({ backgroundOpacity, backgroundScale }) =>
|
||||||
<div className='upload-area' style={{ visibility: active ? 'visible' : 'hidden', opacity: backgroundOpacity }}>
|
<div className='upload-area' style={{ visibility: active ? 'visible' : 'hidden', opacity: backgroundOpacity }}>
|
||||||
<div className='upload-area__drop'>
|
<div className='upload-area__drop'>
|
||||||
<div className='upload-area__background' style={{ transform: `scale(${backgroundScale})` }} />
|
<div className='upload-area__background' style={{ transform: `translateZ(0) scale(${backgroundScale})` }} />
|
||||||
<div className='upload-area__content'><FormattedMessage id='upload_area.title' defaultMessage='Drag & drop to upload' /></div>
|
<div className='upload-area__content'><FormattedMessage id='upload_area.title' defaultMessage='Drag & drop to upload' /></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -159,11 +159,11 @@
|
|||||||
"privacy.public.short": "Publiczny",
|
"privacy.public.short": "Publiczny",
|
||||||
"privacy.unlisted.long": "Niewidoczny na publicznych osiach czasu",
|
"privacy.unlisted.long": "Niewidoczny na publicznych osiach czasu",
|
||||||
"privacy.unlisted.short": "Niewidoczny",
|
"privacy.unlisted.short": "Niewidoczny",
|
||||||
"relative_time.days": "{number} dni",
|
"relative_time.days": "{number}d",
|
||||||
"relative_time.hours": "{number} godz.",
|
"relative_time.hours": "{number}h",
|
||||||
"relative_time.just_now": "teraz",
|
"relative_time.just_now": "now",
|
||||||
"relative_time.minutes": "{number} min.",
|
"relative_time.minutes": "{number}m",
|
||||||
"relative_time.seconds": "{number} s.",
|
"relative_time.seconds": "{number}s",
|
||||||
"reply_indicator.cancel": "Anuluj",
|
"reply_indicator.cancel": "Anuluj",
|
||||||
"report.placeholder": "Dodatkowe komentarze",
|
"report.placeholder": "Dodatkowe komentarze",
|
||||||
"report.submit": "Wyślij",
|
"report.submit": "Wyślij",
|
||||||
|
|||||||
@@ -3402,21 +3402,21 @@ button.icon-button.active i.fa-retweet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.fa-search {
|
.fa-search {
|
||||||
transform: rotate(90deg);
|
transform: translateZ(0) rotate(90deg);
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
transform: rotate(0deg);
|
transform: translateZ(0) rotate(0deg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.fa-times-circle {
|
.fa-times-circle {
|
||||||
top: 11px;
|
top: 11px;
|
||||||
transform: rotate(0deg);
|
transform: translateZ(0) rotate(0deg);
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|
||||||
&.active {
|
&.active {
|
||||||
transform: rotate(90deg);
|
transform: translateZ(0) rotate(90deg);
|
||||||
}
|
}
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
|
|||||||
17
package.json
17
package.json
@@ -135,5 +135,22 @@
|
|||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"fsevents": "*"
|
"fsevents": "*"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"projects": [
|
||||||
|
"<rootDir>/app/javascript/mastodon"
|
||||||
|
],
|
||||||
|
"testPathIgnorePatterns": [
|
||||||
|
"<rootDir>/node_modules/",
|
||||||
|
"<rootDir>/vendor/",
|
||||||
|
"<rootDir>/config/",
|
||||||
|
"<rootDir>/log/",
|
||||||
|
"<rootDir>/public/",
|
||||||
|
"<rootDir>/tmp/"
|
||||||
|
],
|
||||||
|
"setupFiles": [
|
||||||
|
"raf/polyfill"
|
||||||
|
],
|
||||||
|
"setupTestFrameworkScriptFile": "<rootDir>/app/javascript/mastodon/test_setup.js"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user