Mailspring/internal_packages/mode-switch/lib/mode-toggle.cjsx
Ben Gotow 7533c7ae81 feat(tutorial): Overlay bubbles that guide you through initial features
Summary:
Add header to show how many trial days remain

More rendering out of Store, consolidate registry and store and expose via new serviceRegistry

WIP

Merge branch 'master' into hallamoore/feature-walkthrough-tutorial

Switch to using observable instead of AbortablePromise

Update submodule

WIP

WIP

Remove annotations

Remove changes

WIP

Test Plan: No tests

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D3260
2016-09-13 02:29:38 -04:00

52 lines
1.5 KiB
CoffeeScript

{ComponentRegistry,
WorkspaceStore,
Actions} = require "nylas-exports"
{RetinaImg} = require 'nylas-component-kit'
React = require "react"
_ = require "underscore"
class ModeToggle extends React.Component
@displayName: 'ModeToggle'
constructor: (@props) ->
@column = WorkspaceStore.Location.MessageListSidebar
@state = @_getStateFromStores()
componentDidMount: =>
@_unsubscriber = WorkspaceStore.listen(@_onStateChanged)
@_mounted = true
componentWillUnmount: =>
@_mounted = false
@_unsubscriber?()
render: =>
<button
className="btn btn-toolbar mode-toggle mode-#{@state.hidden}"
style={order:500}
title={if @state.hidden then "Show sidebar" else "Hide sidebar"}
onClick={@_onToggleMode}>
<RetinaImg
name="toolbar-person-sidebar.png"
mode={RetinaImg.Mode.ContentIsMask} />
</button>
_onStateChanged: =>
# We need to keep track of this because our parent unmounts us in the same
# event listener cycle that we receive the event in. ie:
#
# for listener in listeners
# # 1. workspaceView remove left column
# # ---- Mode toggle unmounts, listeners array mutated in place
# # 2. ModeToggle update
return unless @_mounted
@setState(@_getStateFromStores())
_getStateFromStores: =>
{hidden: WorkspaceStore.isLocationHidden(@column)}
_onToggleMode: =>
Actions.toggleWorkspaceLocationHidden(@column)
module.exports = ModeToggle