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
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 69eab7e
Implements dark mode conditional styling in QuestionClassifier
chelseatroy a99e583
Adds dark theme to tutorial components for museum mode
chelseatroy 26ace28
Adds dark theme to swipe classifier for museum mode
chelseatroy 3a50c15
Determine at fetch time whether projects should be in museum mode.
chelseatroy 9e82244
Use project museum mode attribute to determine app colors
chelseatroy 57ff426
Adjust props validation for project.in_museum_mode
chelseatroy 3d1696a
Adjust navigation to lock museum users into their approved projects
chelseatroy 8d06908
Change 'hambuger' to 'hamburger' XD
chelseatroy eea18c4
Update snapshots with npm test -- -u
chelseatroy 6e0a465
Adjustments based on hound-ci findings
chelseatroy 9ef6a8a
Remove project-specific contextual information from the navigation ba…
chelseatroy ce7d327
Repair default and preview background colors on navigation bar, as pe…
chelseatroy 5ecb0d5
Unify a duplicate color in the theme file under the name $zooniverseTeal
chelseatroy 9c7498b
Update snapshot tests with npm test -- -u
chelseatroy de1326f
Refrain from showing the "already seen" banner on any subject in muse…
chelseatroy d2a109f
Upgrade to react-native 0.59.9, thanks XCode, how kind of you
chelseatroy 5bfd077
Style initial view for drawing classifier
chelseatroy 0525081
Style the help modal to appear dark in museum mode
chelseatroy 1ad4216
Extend dark mode to include tutorials, help modals, and classificatio…
chelseatroy a5500f5
Make the help text on the drawing classifier appear lighter in dark mode
chelseatroy 16c88b6
Redo question and tutorial tabs on workflows
chelseatroy 3bcc1a4
Remove unnecessary extra attributes
chelseatroy e47a1c6
Rip out the now-unused extra property in ClassifierButton
chelseatroy 08fcdda
Prepare to switch button selection colors to dark mode
chelseatroy 8506a2c
Make single answer and multi answer button styles operational in both…
chelseatroy 2752134
Label workflow styles and classes in a discoverable way
chelseatroy facb7db
Differentiate different types of workflow buttons
chelseatroy 0f3175f
Remove unused type attribute from workflow buttons.
chelseatroy 7867644
Implement some stylistic changes to museum mode:
chelseatroy 8f6fcbe
The Field Guide in Drawing Workflows cannot have ever worked. This fi…
chelseatroy db6d719
Include dark mode styling for field guide button
chelseatroy 462f8fc
Update snapshots with npm test -- -u
chelseatroy 48958fc
Put Field Guide and Submit buttons next to each other in landscape mo…
chelseatroy ee57bab
Give the field guide a dark mode
chelseatroy 007c1bb
Update snapshots with npm test -- -u
chelseatroy 2a50fb7
Update life cycle management from deprecated React Native methods
chelseatroy 70a5bbc
Fix typo in tutorial button text
chelseatroy 7665e55
Optimize imports in SwipeTabs
chelseatroy f81dcc9
Increment version in Android and iOS to cut a new build for both plat…
chelseatroy File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) { | ||
return withModeStyle | ||
} else { | ||
return withoutModeStyle | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)