From 924ffe81d477a8cf890c8117efb94b908760bccc Mon Sep 17 00:00:00 2001 From: kibigo! Date: Sat, 23 Dec 2017 22:16:45 -0800 Subject: WIPgit status Refactor; ed. --- .../glitch/features/composer/options/index.js | 321 +++++++++++++++++++++ 1 file changed, 321 insertions(+) create mode 100644 app/javascript/flavours/glitch/features/composer/options/index.js (limited to 'app/javascript/flavours/glitch/features/composer/options/index.js') diff --git a/app/javascript/flavours/glitch/features/composer/options/index.js b/app/javascript/flavours/glitch/features/composer/options/index.js new file mode 100644 index 000000000..ee633e865 --- /dev/null +++ b/app/javascript/flavours/glitch/features/composer/options/index.js @@ -0,0 +1,321 @@ +// Package imports. +import PropTypes from 'prop-types'; +import React from 'react'; +import { + FormattedMessage, + defineMessages, +} from 'react-intl'; +import spring from 'react-motion/lib/spring'; + +// Components. +import IconButton from 'flavours/glitch/components/icon_button'; +import TextIconButton from 'flavours/glitch/components/text_icon_button'; +import Dropdown from './dropdown'; + +// Utils. +import Motion from 'flavours/glitch/util/optional_motion'; +import { + assignHandlers, + hiddenComponent, +} from 'flavours/glitch/util/react_helpers'; + +// Messages. +const messages = defineMessages({ + advanced_options_icon_title: { + defaultMessage: 'Advanced options', + id: 'advanced_options.icon_title', + }, + attach: { + defaultMessage: 'Attach...', + id: 'compose.attach', + }, + change_privacy: { + defaultMessage: 'Adjust status privacy', + id: 'privacy.change', + }, + direct_long: { + defaultMessage: 'Post to mentioned users only', + id: 'privacy.direct.long', + }, + direct_short: { + defaultMessage: 'Direct', + id: 'privacy.direct.short', + }, + doodle: { + defaultMessage: 'Draw something', + id: 'compose.attach.doodle', + }, + local_only_long: { + defaultMessage: 'Do not post to other instances', + id: 'advanced-options.local-only.long', + }, + local_only_short: { + defaultMessage: 'Local-only', + id: 'advanced-options.local-only.short', + }, + private_long: { + defaultMessage: 'Post to followers only', + id: 'privacy.private.long', + }, + private_short: { + defaultMessage: 'Followers-only', + id: 'privacy.private.short', + }, + public_long: { + defaultMessage: 'Post to public timelines', + id: 'privacy.public.long', + }, + public_short: { + defaultMessage: 'Public', + id: 'privacy.public.short', + }, + sensitive: { + defaultMessage: 'Mark media as sensitive', + id: 'compose_form.sensitive', + }, + spoiler: { + defaultMessage: 'Hide text behind warning', + id: 'compose_form.spoiler', + }, + unlisted_long: { + defaultMessage: 'Do not show in public timelines', + id: 'privacy.unlisted.long', + }, + unlisted_short: { + defaultMessage: 'Unlisted', + id: 'privacy.unlisted.short', + }, + upload: { + defaultMessage: 'Upload a file', + id: 'compose.attach.upload', + }, +}); + +// Handlers. +const handlers = { + + // Handles file selection. + changeFiles ({ target: { files } }) { + const { onUpload } = this.props; + if (files.length && onUpload) { + onUpload(files); + } + }, + + // Handles attachment clicks. + clickAttach (name) { + const { fileElement } = this; + const { onDoodleOpen } = this.props; + + // We switch over the name of the option. + switch (name) { + case 'upload': + if (fileElement) { + fileElement.click(); + } + return; + case 'doodle': + if (onDoodleOpen) { + onDoodleOpen(); + } + return; + } + }, + + // Handles a ref to the file input. + refFileElement (fileElement) { + this.fileElement = fileElement; + }, +}; + +// The component. +export default class ComposerOptions extends React.PureComponent { + + // Constructor. + constructor (props) { + super(props); + assignHandlers(this, handlers); + + // Instance variables. + this.fileElement = null; + } + + // Rendering. + render () { + const { + changeFiles, + clickAttach, + refFileElement, + } = this.handlers; + const { + acceptContentTypes, + disabled, + doNotFederate, + full, + hasMedia, + intl, + onChangeSensitivity, + onChangeVisibility, + onModalClose, + onModalOpen, + onToggleAdvancedOption, + privacy, + resetFileKey, + sensitive, + spoiler, + } = this.props; + + // We predefine our privacy items so that we can easily pick the + // dropdown icon later. + const privacyItems = { + direct: { + icon: 'envelope', + meta: , + name: 'direct', + text: , + }, + private: { + icon: 'lock', + meta: , + name: 'private', + text: , + }, + public: { + icon: 'globe', + meta: , + name: 'public', + text: , + }, + unlisted: { + icon: 'unlock-alt', + meta: , + name: 'unlisted', + text: , + }, + }; + + // The result. + return ( +
+ + , + }, + { + icon: 'paint-brush', + name: 'doodle', + text: , + }, + ]} + onChange={clickAttach} + onModalClose={onModalClose} + onModalOpen={onModalOpen} + title={messages.attach} + /> + + {({ scale }) => ( +
+ +
+ )} +
+
+ + + , + name: 'do_not_federate', + on: doNotFederate, + text: , + }, + ]} + onChange={onToggleAdvancedOption} + onModalClose={onModalClose} + onModalOpen={onModalOpen} + title={intl.formatMessage(messages.advanced_options_icon_title)} + /> +
+ ); + } + +} + +// Props. +ComposerOptions.propTypes = { + acceptContentTypes: PropTypes.string, + disabled: PropTypes.bool, + doNotFederate: PropTypes.bool, + full: PropTypes.bool, + hasMedia: PropTypes.bool, + intl: PropTypes.object.isRequired, + onChangeSensitivity: PropTypes.func, + onChangeVisibility: PropTypes.func, + onDoodleOpen: PropTypes.func, + onModalClose: PropTypes.func, + onModalOpen: PropTypes.func, + onToggleAdvancedOption: PropTypes.func, + onUpload: PropTypes.func, + privacy: PropTypes.string, + resetFileKey: PropTypes.string, + sensitive: PropTypes.bool, + spoiler: PropTypes.bool, +}; -- cgit From 083170bec755920b80c64f9cca2cc419831f66c8 Mon Sep 17 00:00:00 2001 From: kibigo! Date: Fri, 29 Dec 2017 14:55:06 -0800 Subject: WIP Refactor; SCSS ed. --- app/javascript/flavours/glitch/actions/compose.js | 8 - .../flavours/glitch/components/avatar.js | 18 +- .../flavours/glitch/components/display_name.js | 12 +- .../glitch/features/composer/options/index.js | 7 +- .../glitch/features/composer/publisher/index.js | 3 +- .../glitch/features/composer/reply/index.js | 9 +- .../glitch/features/composer/textarea/index.js | 3 +- .../composer/textarea/suggestions/index.js | 8 +- .../composer/textarea/suggestions/item/index.js | 4 +- .../features/composer/upload_form/item/index.js | 1 + .../glitch/features/drawer/account/index.js | 70 +++ .../flavours/glitch/features/drawer/index.js | 33 +- .../glitch/features/drawer/pager/account/index.js | 70 --- .../flavours/glitch/features/drawer/pager/index.js | 43 -- .../features/ui/components/onboarding_modal.js | 8 +- app/javascript/flavours/glitch/reducers/compose.js | 3 - .../flavours/glitch/styles/components/compose.scss | 0 .../glitch/styles/components/composer.scss | 315 ++++++++++ .../flavours/glitch/styles/components/drawer.scss | 234 +++++++ .../flavours/glitch/styles/components/index.scss | 695 +-------------------- 20 files changed, 694 insertions(+), 850 deletions(-) create mode 100644 app/javascript/flavours/glitch/features/drawer/account/index.js delete mode 100644 app/javascript/flavours/glitch/features/drawer/pager/account/index.js delete mode 100644 app/javascript/flavours/glitch/features/drawer/pager/index.js delete mode 100644 app/javascript/flavours/glitch/styles/components/compose.scss create mode 100644 app/javascript/flavours/glitch/styles/components/composer.scss (limited to 'app/javascript/flavours/glitch/features/composer/options/index.js') diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index d87786008..31866d223 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -38,7 +38,6 @@ export const COMPOSE_SPOILERNESS_CHANGE = 'COMPOSE_SPOILERNESS_CHANGE'; export const COMPOSE_SPOILER_TEXT_CHANGE = 'COMPOSE_SPOILER_TEXT_CHANGE'; export const COMPOSE_VISIBILITY_CHANGE = 'COMPOSE_VISIBILITY_CHANGE'; export const COMPOSE_LISTABILITY_CHANGE = 'COMPOSE_LISTABILITY_CHANGE'; -export const COMPOSE_COMPOSING_CHANGE = 'COMPOSE_COMPOSING_CHANGE'; export const COMPOSE_EMOJI_INSERT = 'COMPOSE_EMOJI_INSERT'; @@ -382,10 +381,3 @@ export function insertEmojiCompose(position, emoji) { emoji, }; }; - -export function changeComposing(value) { - return { - type: COMPOSE_COMPOSING_CHANGE, - value, - }; -} diff --git a/app/javascript/flavours/glitch/components/avatar.js b/app/javascript/flavours/glitch/components/avatar.js index 82ab0f45a..c5e9072c4 100644 --- a/app/javascript/flavours/glitch/components/avatar.js +++ b/app/javascript/flavours/glitch/components/avatar.js @@ -1,3 +1,4 @@ +import classNames from 'classnames'; import React from 'react'; import PropTypes from 'prop-types'; import ImmutablePropTypes from 'react-immutable-proptypes'; @@ -7,6 +8,7 @@ export default class Avatar extends React.PureComponent { static propTypes = { account: ImmutablePropTypes.map.isRequired, + className: PropTypes.string, size: PropTypes.number.isRequired, style: PropTypes.object, inline: PropTypes.bool, @@ -34,17 +36,19 @@ export default class Avatar extends React.PureComponent { } render () { - const { account, size, animate, inline } = this.props; + const { + account, + animate, + className, + inline, + size, + } = this.props; const { hovering } = this.state; const src = account.get('avatar'); const staticSrc = account.get('avatar_static'); - let className = 'account__avatar'; - - if (inline) { - className = className + ' account__avatar-inline'; - } + const computedClass = classNames('account__avatar', { 'account__avatar-inline': inline }, className); const style = { ...this.props.style, @@ -61,7 +65,7 @@ export default class Avatar extends React.PureComponent { return (
+ @{this.props.account.get('acct')} ); diff --git a/app/javascript/flavours/glitch/features/composer/options/index.js b/app/javascript/flavours/glitch/features/composer/options/index.js index ee633e865..ea998a421 100644 --- a/app/javascript/flavours/glitch/features/composer/options/index.js +++ b/app/javascript/flavours/glitch/features/composer/options/index.js @@ -236,7 +236,12 @@ export default class ComposerOptions extends React.PureComponent { }} > {({ scale }) => ( -
+
{diff} {sideArm && sideArm !== 'none' ? (