diff options
author | David Yip <yipdw@member.fsf.org> | 2018-01-13 21:22:37 -0600 |
---|---|---|
committer | David Yip <yipdw@member.fsf.org> | 2018-01-14 03:06:11 -0600 |
commit | 1dbb6b5e08b6672a77d2f7f4121e7874b750db60 (patch) | |
tree | 158f5bd61cf785bfbb9f81eeead007bc8dbfdfb5 /app/javascript/flavours | |
parent | 1e0b7070185b748e27a301acfc325bfb38be7b31 (diff) |
Set glitchy elephant friend variant in initial state. #294.
Also lay some groundwork needed to interactively change the glitchfriend. The codebase uses "elefriend" because it's shorter and didn't require me to realign the actions in actions/compose.js. Same idea, though.
Diffstat (limited to 'app/javascript/flavours')
-rw-r--r-- | app/javascript/flavours/glitch/actions/compose.js | 7 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/features/drawer/index.js | 11 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/images/mbstobon-ui-0.png | bin | 0 -> 39646 bytes | |||
-rw-r--r-- | app/javascript/flavours/glitch/images/mbstobon-ui-1.png | bin | 39646 -> 43609 bytes | |||
-rw-r--r-- | app/javascript/flavours/glitch/images/mbstobon-ui-2.png | bin | 43609 -> 40376 bytes | |||
-rw-r--r-- | app/javascript/flavours/glitch/images/mbstobon-ui-3.png | bin | 40376 -> 0 bytes | |||
-rw-r--r-- | app/javascript/flavours/glitch/reducers/compose.js | 7 | ||||
-rw-r--r-- | app/javascript/flavours/glitch/styles/components/drawer.scss | 4 |
8 files changed, 22 insertions, 7 deletions
diff --git a/app/javascript/flavours/glitch/actions/compose.js b/app/javascript/flavours/glitch/actions/compose.js index a88dba1b1..c46387104 100644 --- a/app/javascript/flavours/glitch/actions/compose.js +++ b/app/javascript/flavours/glitch/actions/compose.js @@ -12,6 +12,7 @@ import { } from './timelines'; export const COMPOSE_CHANGE = 'COMPOSE_CHANGE'; +export const COMPOSE_CYCLE_ELEFRIEND = 'COMPOSE_CYCLE_ELEFRIEND'; export const COMPOSE_SUBMIT_REQUEST = 'COMPOSE_SUBMIT_REQUEST'; export const COMPOSE_SUBMIT_SUCCESS = 'COMPOSE_SUBMIT_SUCCESS'; export const COMPOSE_SUBMIT_FAIL = 'COMPOSE_SUBMIT_FAIL'; @@ -54,6 +55,12 @@ export function changeCompose(text) { }; }; +export function cycleElefriendCompose() { + return { + type: COMPOSE_CYCLE_ELEFRIEND, + }; +}; + export function replyCompose(status, router) { return (dispatch, getState) => { dispatch({ diff --git a/app/javascript/flavours/glitch/features/drawer/index.js b/app/javascript/flavours/glitch/features/drawer/index.js index ba56f1a30..8f9719096 100644 --- a/app/javascript/flavours/glitch/features/drawer/index.js +++ b/app/javascript/flavours/glitch/features/drawer/index.js @@ -28,6 +28,7 @@ import { wrap } from 'flavours/glitch/util/redux_helpers'; const mapStateToProps = state => ({ account: state.getIn(['accounts', me]), columns: state.getIn(['settings', 'columns']), + elefriend: state.getIn(['compose', 'elefriend']), results: state.getIn(['search', 'results']), searchHidden: state.getIn(['search', 'hidden']), searchValue: state.getIn(['search', 'value']), @@ -56,6 +57,7 @@ class Drawer extends React.Component { const { account, columns, + elefriend, intl, multiColumn, onChange, @@ -69,10 +71,8 @@ class Drawer extends React.Component { submitted, } = this.props; - let choices = ['mbstobon-bg-1', 'mbstobon-bg-2', 'mbstobon-bg-3']; - let glitchyFriendDecision = choices[Math.floor(Math.random() * choices.length)]; - let drawerAttrs = { - className: classNames('contents', glitchyFriendDecision) + let elefriendAttrs = { + className: classNames('mastodon', 'mbstobon-' + elefriend), }; // The result. @@ -98,7 +98,7 @@ class Drawer extends React.Component { <DrawerAccount account={account} /> <div className='drawer__inner'> <Composer /> - {multiColumn && <div className="mastodon mbstobon-bg-1" />} + {multiColumn && <div {...elefriendAttrs} />} </div> <DrawerResults results={results} @@ -120,6 +120,7 @@ Drawer.propTypes = { account: ImmutablePropTypes.map, columns: ImmutablePropTypes.list, results: ImmutablePropTypes.map, + elefriend: PropTypes.number, searchHidden: PropTypes.bool, searchValue: PropTypes.string, submitted: PropTypes.bool, diff --git a/app/javascript/flavours/glitch/images/mbstobon-ui-0.png b/app/javascript/flavours/glitch/images/mbstobon-ui-0.png new file mode 100644 index 000000000..25e1707c9 --- /dev/null +++ b/app/javascript/flavours/glitch/images/mbstobon-ui-0.png Binary files differdiff --git a/app/javascript/flavours/glitch/images/mbstobon-ui-1.png b/app/javascript/flavours/glitch/images/mbstobon-ui-1.png index 25e1707c9..64cf3cbf3 100644 --- a/app/javascript/flavours/glitch/images/mbstobon-ui-1.png +++ b/app/javascript/flavours/glitch/images/mbstobon-ui-1.png Binary files differdiff --git a/app/javascript/flavours/glitch/images/mbstobon-ui-2.png b/app/javascript/flavours/glitch/images/mbstobon-ui-2.png index 64cf3cbf3..b767a9122 100644 --- a/app/javascript/flavours/glitch/images/mbstobon-ui-2.png +++ b/app/javascript/flavours/glitch/images/mbstobon-ui-2.png Binary files differdiff --git a/app/javascript/flavours/glitch/images/mbstobon-ui-3.png b/app/javascript/flavours/glitch/images/mbstobon-ui-3.png deleted file mode 100644 index b767a9122..000000000 --- a/app/javascript/flavours/glitch/images/mbstobon-ui-3.png +++ /dev/null Binary files differdiff --git a/app/javascript/flavours/glitch/reducers/compose.js b/app/javascript/flavours/glitch/reducers/compose.js index f341977b7..dfab38387 100644 --- a/app/javascript/flavours/glitch/reducers/compose.js +++ b/app/javascript/flavours/glitch/reducers/compose.js @@ -2,6 +2,7 @@ import { COMPOSE_MOUNT, COMPOSE_UNMOUNT, COMPOSE_CHANGE, + COMPOSE_CYCLE_ELEFRIEND, COMPOSE_REPLY, COMPOSE_REPLY_CANCEL, COMPOSE_MENTION, @@ -35,6 +36,8 @@ import uuid from 'flavours/glitch/util/uuid'; import { me } from 'flavours/glitch/util/initial_state'; import { overwrite } from 'flavours/glitch/util/js_helpers'; +const totalElefriends = 3; + const initialState = ImmutableMap({ mounted: false, advanced_options: ImmutableMap({ @@ -42,6 +45,7 @@ const initialState = ImmutableMap({ threaded_mode: false, }), sensitive: false, + elefriend: Math.floor(Math.random() * totalElefriends), spoiler: false, spoiler_text: '', privacy: null, @@ -259,6 +263,9 @@ export default function compose(state = initialState, action) { return state .set('text', action.text) .set('idempotencyKey', uuid()); + case COMPOSE_CYCLE_ELEFRIEND: + return state + .set('elefriend', (state.get('elefriend') + 1) % totalElefriends); case COMPOSE_REPLY: return state.withMutations(map => { map.set('in_reply_to', action.status.get('id')); diff --git a/app/javascript/flavours/glitch/styles/components/drawer.scss b/app/javascript/flavours/glitch/styles/components/drawer.scss index 75b5d6b04..8526003bf 100644 --- a/app/javascript/flavours/glitch/styles/components/drawer.scss +++ b/app/javascript/flavours/glitch/styles/components/drawer.scss @@ -66,8 +66,8 @@ .mastodon { flex: 1; - @for $i from 1 through 3 { - &.mbstobon-bg-#{$i} { + @for $i from 0 through 2 { + &.mbstobon-#{$i} { background: url("~flavours/glitch/images/mbstobon-ui-#{$i}.png") no-repeat left bottom / contain; } } |