From ef859e16e88004a215b725878449683e455ad8ee Mon Sep 17 00:00:00 2001 From: chr Date: Mon, 12 Nov 2018 21:48:32 -0800 Subject: [PATCH] Doodlebox MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A modification to the Mastodon interface that allows you to select a doodle icon in addition to uploading a media file from your computer. The doodle interface allows you to draw using your mouse, finger, or pointing device in several colors. It was originally developed by Ondřej Hruška for use on the GlitchSoc fork. --- app/javascript/mastodon/actions/compose.js | 9 + .../mastodon/components/icon_button.js | 12 +- .../compose/components/attach_options.js | 133 ++++ .../compose/components/compose_dropdown.js | 76 +++ .../compose/components/compose_form.js | 7 +- .../features/ui/components/doodle_modal.js | 614 ++++++++++++++++++ .../features/ui/components/modal_root.js | 14 +- app/javascript/mastodon/reducers/compose.js | 14 + app/javascript/styles/doodle.scss | 96 +++ .../styles/mastodon/components.scss | 74 ++- package.json | 1 + yarn.lock | 4 + 12 files changed, 1046 insertions(+), 8 deletions(-) create mode 100644 app/javascript/mastodon/features/compose/components/attach_options.js create mode 100644 app/javascript/mastodon/features/compose/components/compose_dropdown.js create mode 100644 app/javascript/mastodon/features/ui/components/doodle_modal.js create mode 100644 app/javascript/styles/doodle.scss diff --git a/app/javascript/mastodon/actions/compose.js b/app/javascript/mastodon/actions/compose.js index a4352faab..7dcc2d8e2 100644 --- a/app/javascript/mastodon/actions/compose.js +++ b/app/javascript/mastodon/actions/compose.js @@ -49,6 +49,8 @@ export const COMPOSE_UPLOAD_CHANGE_REQUEST = 'COMPOSE_UPLOAD_UPDATE_REQUEST' export const COMPOSE_UPLOAD_CHANGE_SUCCESS = 'COMPOSE_UPLOAD_UPDATE_SUCCESS'; export const COMPOSE_UPLOAD_CHANGE_FAIL = 'COMPOSE_UPLOAD_UPDATE_FAIL'; +export const COMPOSE_DOODLE_SET = 'COMPOSE_DOODLE_SET'; + export function changeCompose(text) { return { type: COMPOSE_CHANGE, @@ -182,6 +184,13 @@ export function submitComposeFail(error) { }; }; +export function doodleSet(options) { + return { + type: COMPOSE_DOODLE_SET, + options: options, + }; +}; + export function uploadCompose(files) { return function (dispatch, getState) { if (getState().getIn(['compose', 'media_attachments']).size > 3) { diff --git a/app/javascript/mastodon/components/icon_button.js b/app/javascript/mastodon/components/icon_button.js index b96e48fd0..94e0dd86a 100644 --- a/app/javascript/mastodon/components/icon_button.js +++ b/app/javascript/mastodon/components/icon_button.js @@ -22,6 +22,7 @@ export default class IconButton extends React.PureComponent { animate: PropTypes.bool, overlay: PropTypes.bool, tabIndex: PropTypes.string, + label: PropTypes.string, }; static defaultProps = { @@ -42,14 +43,18 @@ export default class IconButton extends React.PureComponent { } render () { - const style = { + let style = { fontSize: `${this.props.size}px`, - width: `${this.props.size * 1.28571429}px`, height: `${this.props.size * 1.28571429}px`, lineHeight: `${this.props.size}px`, ...this.props.style, ...(this.props.active ? this.props.activeStyle : {}), }; + if (!this.props.label) { + style.width = `${this.props.size * 1.28571429}px`; + } else { + style.textAlign = 'left'; + } const { active, @@ -104,7 +109,8 @@ export default class IconButton extends React.PureComponent { style={style} tabIndex={tabIndex} > -