誤字盛ボタン・はるきん焼却ボタンの実装
This commit is contained in:
parent
158f9604ea
commit
cce2fb6b96
67
app/javascript/mastodon/actions/UtilBtns.js
Normal file
67
app/javascript/mastodon/actions/UtilBtns.js
Normal file
@ -0,0 +1,67 @@
|
||||
import { changeCompose } from '../actions/compose';
|
||||
|
||||
export const UTILBTNS_GOJI = 'UTILBTNS_GOJI';
|
||||
export const UTILBTNS_HARUKIN = 'UTILBTNS_HARUKIN';
|
||||
|
||||
export function submitGoji (textarea) {
|
||||
return function (dispatch, getState) {
|
||||
if (!textarea.value) {
|
||||
let text = [
|
||||
"#ゴジモリィィィィイイ",
|
||||
":goji:"
|
||||
].join("\r\n");
|
||||
|
||||
dispatch(submitGojiRequest());
|
||||
dispatch(changeCompose(text));
|
||||
|
||||
textarea.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function submitGojiRequest () {
|
||||
return {
|
||||
type: UTILBTNS_GOJI
|
||||
}
|
||||
}
|
||||
|
||||
export function submitHarukin (textarea) {
|
||||
return function (dispatch, getState) {
|
||||
const HARUKINS = [":harukin: ", ":harukin_old: ", ":harukin_ika: ", ":harukin_tako: "];
|
||||
const MAX = 6;
|
||||
|
||||
if (!textarea.value) {
|
||||
let text = "";
|
||||
|
||||
let quantity = Math.round(Math.random() * MAX + 1);
|
||||
let type = Math.round(Math.random() * (HARUKINS.length - 1));
|
||||
|
||||
let harukin = HARUKINS[type];
|
||||
|
||||
switch (quantity) {
|
||||
default:
|
||||
text = [
|
||||
harukin.repeat(quantity),
|
||||
"🔥 ".repeat(quantity)
|
||||
].join("\r\n");
|
||||
|
||||
break;
|
||||
|
||||
case MAX + 1:
|
||||
text = `${harukin}💕\r\n`.repeat(6);
|
||||
break;
|
||||
}
|
||||
|
||||
dispatch(submitHarukinRequest());
|
||||
dispatch(changeCompose(text));
|
||||
|
||||
textarea.focus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function submitHarukinRequest () {
|
||||
return {
|
||||
type: UTILBTNS_HARUKIN
|
||||
}
|
||||
}
|
@ -29,6 +29,8 @@ const messages = defineMessages({
|
||||
publish: { id: 'compose_form.publish', defaultMessage: 'Publish' },
|
||||
publishLoud: { id: 'compose_form.publish_loud', defaultMessage: '{publish}!' },
|
||||
saveChanges: { id: 'compose_form.save_changes', defaultMessage: 'Save changes' },
|
||||
utilBtns_goji: { id: 'compose_form.utilBtns_goji', defaultMessage: 'Typo!!!' },
|
||||
utilBtns_harukin: { id: 'compose_form.utilBtns_harukin', defaultMessage: 'Burn Harukin' }
|
||||
});
|
||||
|
||||
export default @injectIntl
|
||||
@ -65,6 +67,8 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
isInReply: PropTypes.bool,
|
||||
singleColumn: PropTypes.bool,
|
||||
lang: PropTypes.string,
|
||||
onGojiSubmit: PropTypes.func.isRequired,
|
||||
onHarukinSubmit: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
@ -206,6 +210,9 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
this.props.onPickEmoji(position, data, needsSpace);
|
||||
};
|
||||
|
||||
handleOnGojiSubmit = () => this.props.onGojiSubmit(this.autosuggestTextarea.textarea);
|
||||
handleOnHarukinSubmit = () => this.props.onHarukinSubmit(this.autosuggestTextarea.textarea);
|
||||
|
||||
render () {
|
||||
const { intl, onPaste, autoFocus } = this.props;
|
||||
const disabled = this.props.isSubmitting;
|
||||
@ -293,6 +300,10 @@ class ComposeForm extends ImmutablePureComponent {
|
||||
block
|
||||
/>
|
||||
</div>
|
||||
<div className="compose-form__utilBtns">
|
||||
<Button className="compose-form__utilBtns-goji" text={intl.formatMessage(messages.utilBtns_goji)} onClick={this.handleOnGojiSubmit} block />
|
||||
<Button className="compose-form__utilBtns-harukin" text={intl.formatMessage(messages.utilBtns_harukin)} onClick={this.handleOnHarukinSubmit} block />
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
);
|
||||
|
@ -10,6 +10,10 @@ import {
|
||||
insertEmojiCompose,
|
||||
uploadCompose,
|
||||
} from '../../../actions/compose';
|
||||
import {
|
||||
submitGoji,
|
||||
submitHarukin
|
||||
} from '../../../actions/UtilBtns';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
text: state.getIn(['compose', 'text']),
|
||||
@ -63,6 +67,18 @@ const mapDispatchToProps = (dispatch) => ({
|
||||
dispatch(insertEmojiCompose(position, data, needsSpace));
|
||||
},
|
||||
|
||||
onRisaSubmit (textarea) {
|
||||
dispatch(submitRisa(textarea));
|
||||
},
|
||||
|
||||
onGojiSubmit (textarea) {
|
||||
dispatch(submitGoji(textarea));
|
||||
},
|
||||
|
||||
onHarukinSubmit (textarea) {
|
||||
dispatch(submitHarukin(textarea));
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
export default connect(mapStateToProps, mapDispatchToProps)(ComposeForm);
|
||||
|
@ -148,6 +148,8 @@
|
||||
"compose_form.spoiler.marked": "本文は警告の後ろに隠されます",
|
||||
"compose_form.spoiler.unmarked": "本文は隠されていません",
|
||||
"compose_form.spoiler_placeholder": "ここに警告を書いてください",
|
||||
"compose_form.utilBtns_goji": "誤字盛!",
|
||||
"compose_form.utilBtns_harukin": "はるきん焼却",
|
||||
"confirmation_modal.cancel": "キャンセル",
|
||||
"confirmations.block.block_and_report": "ブロックし通報",
|
||||
"confirmations.block.confirm": "ブロック",
|
||||
|
@ -736,10 +736,29 @@ body > [data-popper-placement] {
|
||||
justify-content: flex-end;
|
||||
min-width: 0;
|
||||
flex: 0 0 auto;
|
||||
padding-top: 10px;
|
||||
|
||||
.compose-form__publish-button-wrapper {
|
||||
overflow: hidden;
|
||||
padding-top: 15px;
|
||||
button {
|
||||
display: inline-block;
|
||||
width: auto;
|
||||
|
||||
margin-right: 0.5em;
|
||||
}
|
||||
|
||||
button:last-child {
|
||||
margin-right: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.compose-form__utilBtns {
|
||||
padding-top: 10px;
|
||||
|
||||
* {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user