Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to dark mode for the Museum Experience! #280

Merged
merged 40 commits into from Nov 11, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
74287e3
Switch between dark mode and light mode with a set of theme functions
chelseatroy Aug 6, 2019
69eab7e
Implements dark mode conditional styling in QuestionClassifier
chelseatroy Aug 7, 2019
a99e583
Adds dark theme to tutorial components for museum mode
chelseatroy Aug 12, 2019
26ace28
Adds dark theme to swipe classifier for museum mode
chelseatroy Aug 20, 2019
3a50c15
Determine at fetch time whether projects should be in museum mode.
chelseatroy Aug 27, 2019
9e82244
Use project museum mode attribute to determine app colors
chelseatroy Aug 27, 2019
57ff426
Adjust props validation for project.in_museum_mode
chelseatroy Aug 27, 2019
3d1696a
Adjust navigation to lock museum users into their approved projects
chelseatroy Sep 16, 2019
8d06908
Change 'hambuger' to 'hamburger' XD
chelseatroy Sep 16, 2019
eea18c4
Update snapshots with npm test -- -u
chelseatroy Sep 16, 2019
6e0a465
Adjustments based on hound-ci findings
chelseatroy Sep 16, 2019
9ef6a8a
Remove project-specific contextual information from the navigation ba…
chelseatroy Sep 18, 2019
ce7d327
Repair default and preview background colors on navigation bar, as pe…
chelseatroy Sep 23, 2019
5ecb0d5
Unify a duplicate color in the theme file under the name $zooniverseTeal
chelseatroy Sep 23, 2019
9c7498b
Update snapshot tests with npm test -- -u
chelseatroy Sep 23, 2019
de1326f
Refrain from showing the "already seen" banner on any subject in muse…
chelseatroy Sep 24, 2019
d2a109f
Upgrade to react-native 0.59.9, thanks XCode, how kind of you
chelseatroy Sep 25, 2019
5bfd077
Style initial view for drawing classifier
chelseatroy Sep 26, 2019
0525081
Style the help modal to appear dark in museum mode
chelseatroy Sep 26, 2019
1ad4216
Extend dark mode to include tutorials, help modals, and classificatio…
chelseatroy Oct 1, 2019
a5500f5
Make the help text on the drawing classifier appear lighter in dark mode
chelseatroy Oct 1, 2019
16c88b6
Redo question and tutorial tabs on workflows
chelseatroy Oct 19, 2019
3bcc1a4
Remove unnecessary extra attributes
chelseatroy Oct 20, 2019
e47a1c6
Rip out the now-unused extra property in ClassifierButton
chelseatroy Oct 20, 2019
08fcdda
Prepare to switch button selection colors to dark mode
chelseatroy Oct 21, 2019
8506a2c
Make single answer and multi answer button styles operational in both…
chelseatroy Oct 21, 2019
2752134
Label workflow styles and classes in a discoverable way
chelseatroy Oct 22, 2019
facb7db
Differentiate different types of workflow buttons
chelseatroy Oct 22, 2019
0f3175f
Remove unused type attribute from workflow buttons.
chelseatroy Oct 23, 2019
7867644
Implement some stylistic changes to museum mode:
chelseatroy Oct 27, 2019
8f6fcbe
The Field Guide in Drawing Workflows cannot have ever worked. This fi…
chelseatroy Oct 27, 2019
db6d719
Include dark mode styling for field guide button
chelseatroy Oct 27, 2019
462f8fc
Update snapshots with npm test -- -u
chelseatroy Oct 27, 2019
48958fc
Put Field Guide and Submit buttons next to each other in landscape mo…
chelseatroy Nov 6, 2019
ee57bab
Give the field guide a dark mode
chelseatroy Nov 6, 2019
007c1bb
Update snapshots with npm test -- -u
chelseatroy Nov 6, 2019
2a50fb7
Update life cycle management from deprecated React Native methods
chelseatroy Nov 7, 2019
70a5bbc
Fix typo in tutorial button text
chelseatroy Nov 7, 2019
7665e55
Optimize imports in SwipeTabs
chelseatroy Nov 11, 2019
f81dcc9
Increment version in Android and iOS to cut a new build for both plat…
chelseatroy Nov 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/actions/colorModes.js
@@ -0,0 +1,47 @@
export function framingBackgroundColorFor(museumMode) {
return switchOn(
museumMode,
{backgroundColor: '#2D2D2D'},
{backgroundColor: '#ff4500'}
)
}

export function contentBackgroundColorFor(museumMode) {
return switchOn(
museumMode,
{backgroundColor: '#333333'},
{backgroundColor: 'white'}
)
}

export function separatorColorFor(museumMode) {
return switchOn(
museumMode,
{borderBottomColor: 'black'},
{borderBottomColor: '$borderGrey'}
)
}

export function helpTextColorFor(museumMode) {
return switchOn(
museumMode,
{color: '#addde0'},
{color: 'rgba(0,93,105,1)'}
)
}

export function textColorFor(museumMode) {
return switchOn(
museumMode,
'#addde0',
'black'
)
}

function switchOn(mode, withModeStyle, withoutModeStyle) {
if (mode) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can probably be a one-line ternary return mode ? withModeStyle : withoutModeStyle

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could indeed! And that's a common way to condense control flow, for sure.

The tradeoff with a ternary is that its brevity (and, in the case of JavaScript, its functionality) depends on executing a single operation—the return of the value—from each branch. So if I wanted to perform logging, printing, or debugging with a ternary conditional, I would first be forced to remove it from the ternary into a multi-line conditional like the one shown here. This function's relatively broad usage footprint (it gets executed in a lot of different places) makes it a likely place for a developer to want to debug if they have questions about how our conditional styling works, or want to understand whether or not a method that uses this method has the appropriate inputs if it's functioning in a way other than the developer expects. This already happened to me a few times because I passed my dark mode and light mode arguments to client functions in the wrong order :).

Because that's likely to happen a lot to this piece of code relative to others, it's important that I make this piece of code as easy to modify for debugging as possible. Leaving it as a multiline conditional facilitates that.

In fact, for me, the heuristic described above simplifies to the following rule of thumb: leave it multiline, rather than ternary, unless a multiline statement obfuscates additional information that a developer would otherwise be able to collect from the shape of the code they're looking at. So I'll use a ternary, say, in a variable assignment while writing JSX, because the shape of the JSX conveys a lot of meaning, and I want to keep my property assignments one-line if possible to convey that meaning successfully.

Sorry for noveling :)

return withModeStyle
} else {
return withoutModeStyle
}
}
3 changes: 3 additions & 0 deletions src/actions/projects.js
Expand Up @@ -5,6 +5,9 @@ import * as R from 'ramda'
import * as ActionConstants from '../constants/actions'
import {isValidMobileWorkflow} from '../utils/workflow-utils'

import * as theme from '../theme'
chelseatroy marked this conversation as resolved.
Show resolved Hide resolved
import * as colorModes from './colorModes';
chelseatroy marked this conversation as resolved.
Show resolved Hide resolved

const productionParams = {
mobile_friendly: true,
launch_approved: true,
Expand Down
70 changes: 35 additions & 35 deletions src/components/SideDrawer.js
@@ -1,51 +1,51 @@
import React, { Component } from 'react'
import React, {Component} from 'react'
import Drawer from 'react-native-drawer'
import SideDrawerContent from './SideDrawerContent'
import {Actions, DefaultRenderer} from 'react-native-router-flux'
import PropTypes from 'prop-types';

class SideDrawer extends Component {
render () {
const state = this.props.navigationState
const children = state.children
render() {
const state = this.props.navigationState
const children = state.children

return (
<Drawer
ref="drawer"
open={state.open}
onOpen={()=>Actions.refresh({key:state.key, open: true})}
onClose={()=>Actions.refresh({key:state.key, open: false})}
type="overlay"
side="right"
content={<SideDrawerContent />}
tapToClose={true}
openDrawerOffset={0.3}
panCloseMask={0.2}
closedDrawerOffset={-3}
styles={drawerStyles}
tweenHandler={(ratio) => ({
main: { opacity:(2-ratio)/2 }
})}
>
<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate} />
</Drawer>
)
}
return (
<Drawer
ref="drawer"
chelseatroy marked this conversation as resolved.
Show resolved Hide resolved
open={state.open}
onOpen={() => Actions.refresh({key: state.key, open: true})}
onClose={() => Actions.refresh({key: state.key, open: false})}
type="overlay"
side="right"
content={<SideDrawerContent/>}
tapToClose={true}
openDrawerOffset={0.3}
panCloseMask={0.2}
closedDrawerOffset={-3}
styles={drawerStyles}
tweenHandler={(ratio) => ({
main: {opacity: (2 - ratio) / 2}
})}
>
<DefaultRenderer navigationState={children[0]} onNavigate={this.props.onNavigate}/>
</Drawer>
)
}
}

const drawerStyles = {
drawer: {
backgroundColor: 'white',
shadowColor: 'black',
shadowOpacity: 0.8,
shadowRadius: 3,
elevation: 3,
}
drawer: {
backgroundColor: 'white',
shadowColor: 'black',
shadowOpacity: 0.8,
shadowRadius: 3,
elevation: 3,
}
}

SideDrawer.propTypes = {
onNavigate: PropTypes.func,
navigationState: PropTypes.object,
onNavigate: PropTypes.func,
navigationState: PropTypes.object,
}

export default SideDrawer
5 changes: 4 additions & 1 deletion src/components/SideDrawerContent.js
Expand Up @@ -87,7 +87,10 @@ export class SideDrawerContent extends Component {
</TouchableOpacity>
</View>

<Separator color="white" style={styles.separatorPadding} />
<Separator
color="white"
style={styles.separatorPadding}
/>

<MenuButton
onPress={this.goHome}
Expand Down
8 changes: 5 additions & 3 deletions src/components/classifier/ClassificationPanel.js
Expand Up @@ -5,9 +5,11 @@ import {
} from 'react-native';
import DeviceInfo from 'react-native-device-info'
import EStyleSheet from 'react-native-extended-stylesheet'
import FontedText from '../common/FontedText'
import PropTypes from 'prop-types';

import FontedText from '../common/FontedText'
import * as colorModes from '../../actions/colorModes'

class ClassificationPanel extends Component {
render() {
const tabs =
Expand All @@ -29,7 +31,7 @@ class ClassificationPanel extends Component {
</View>

return (
<View style={[styles.panelContainer, this.props.containerStyle]}>
<View style={[styles.panelContainer, this.props.containerStyle, colorModes.contentBackgroundColorFor(this.props.inMuseumMode)]}>
{ this.props.hasTutorial ? tabs : null }
{ this.props.children }
</View>
Expand All @@ -39,7 +41,6 @@ class ClassificationPanel extends Component {

const styles = EStyleSheet.create({
panelContainer: {
backgroundColor: 'white',
marginTop: 15,
marginBottom: 0,
marginHorizontal: 25
Expand Down Expand Up @@ -71,5 +72,6 @@ ClassificationPanel.propTypes = {
children: PropTypes.node,
isQuestionVisible: PropTypes.bool,
setQuestionVisibility: PropTypes.func,
inMuseumMode: PropTypes.bool,
}
export default ClassificationPanel