diff --git a/internal_packages/composer/lib/new-compose-button.cjsx b/internal_packages/composer/lib/compose-button.cjsx similarity index 78% rename from internal_packages/composer/lib/new-compose-button.cjsx rename to internal_packages/composer/lib/compose-button.cjsx index 38164e51e..e63d22693 100644 --- a/internal_packages/composer/lib/new-compose-button.cjsx +++ b/internal_packages/composer/lib/compose-button.cjsx @@ -2,8 +2,8 @@ React = require 'react' {Message, Actions, NamespaceStore} = require 'nylas-exports' {RetinaImg} = require 'nylas-component-kit' -class NewComposeButton extends React.Component - @displayName: 'NewComposeButton' +class ComposeButton extends React.Component + @displayName: 'ComposeButton' render: => - - - - -ComponentRegistry.register ToolbarWindowControls, - location: WorkspaceStore.Sheet.Global.Toolbar.Left - -class Toolbar extends React.Component - displayName = 'Toolbar' - - propTypes = - data: React.PropTypes.object - depth: React.PropTypes.number - - constructor: (@props) -> - @state = @_getStateFromStores() - - componentDidMount: => - @unlisteners = [] - @unlisteners.push WorkspaceStore.listen (event) => - @setState(@_getStateFromStores()) - @unlisteners.push ComponentRegistry.listen (event) => - @setState(@_getStateFromStores()) - window.addEventListener("resize", @_onWindowResize) - window.requestAnimationFrame => @recomputeLayout() - - componentWillUnmount: => - window.removeEventListener("resize", @_onWindowResize) - unlistener() for unlistener in @unlisteners - - componentWillReceiveProps: (props) => - @setState(@_getStateFromStores(props)) - - componentDidUpdate: => - # Wait for other components that are dirty (the actual columns in the sheet) - # to update as well. - window.requestAnimationFrame => @recomputeLayout() - - shouldComponentUpdate: (nextProps, nextState) => - # This is very important. Because toolbar uses ReactCSSTransitionGroup, - # repetitive unnecessary updates can break animations and cause performance issues. - not _.isEqual(nextProps, @props) or not _.isEqual(nextState, @state) - - render: => - style = - position:'absolute' - width:'100%' - height:'100%' - zIndex: 1 - - toolbars = @state.columns.map (components, idx) => -
- {@_flexboxForComponents(components)} -
- -
- {toolbars} -
- - _flexboxForComponents: (components) => - elements = components.map (component) => - - - - {elements} - - - - - recomputeLayout: => - # Find our item containers that are tied to specific columns - columnToolbarEls = React.findDOMNode(@).querySelectorAll('[data-column]') - - # Find the top sheet in the stack - sheet = document.querySelectorAll("[name='Sheet']")[@props.depth] - return unless sheet - - # Position item containers so they have the position and width - # as their respective columns in the top sheet - for columnToolbarEl in columnToolbarEls - column = columnToolbarEl.dataset.column - columnEl = sheet.querySelector("[data-column='#{column}']") - continue unless columnEl - - columnToolbarEl.style.display = 'inherit' - columnToolbarEl.style.left = "#{columnEl.offsetLeft}px" - columnToolbarEl.style.width = "#{columnEl.offsetWidth}px" - - _onWindowResize: => - @recomputeLayout() - - _getStateFromStores: (props) => - props ?= @props - state = - mode: WorkspaceStore.layoutMode() - columns: [] - - # Add items registered to Regions in the current sheet - if @props.data?.columns[state.mode]? - for loc in @props.data.columns[state.mode] - entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar, mode: state.mode}) - state.columns.push(entries) - - # Add left items registered to the Sheet instead of to a Region - for loc in [WorkspaceStore.Sheet.Global, @props.data] - entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar.Left, mode: state.mode}) - state.columns[0]?.push(entries...) - state.columns[0]?.push(ToolbarBack) if @props.depth > 0 - - # Add right items registered to the Sheet instead of to a Region - for loc in [WorkspaceStore.Sheet.Global, @props.data] - entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar.Right, mode: state.mode}) - state.columns[state.columns.length - 1]?.push(entries...) - - state - - class SheetContainer extends React.Component displayName = 'SheetContainer' @@ -177,19 +30,13 @@ class SheetContainer extends React.Component totalSheets = @state.stack.length topSheet = @state.stack[totalSheets - 1] - toolbarElements = @_toolbarElements() + return
unless topSheet + sheetElements = @_sheetElements() -
- {toolbarElements[0]} - - {toolbarElements[1..-1]} - -
- + {@_toolbarContainerElement()} +
+ _toolbarContainerElement: => + {toolbar} = atom.getLoadSettings() + return [] unless toolbar + + toolbarElements = @_toolbarElements() +
+ {toolbarElements[0]} + + {toolbarElements[1..-1]} + +
+ _toolbarElements: => @state.stack.map (sheet, index) -> +
+ +class ToolbarBack extends React.Component + @displayName: 'ToolbarBack' + render: => +
+ +
+ + _onClick: => + Actions.popSheet() + +class ToolbarWindowControls extends React.Component + @displayName: 'ToolbarWindowControls' + render: => +
+ + + +
+ +ComponentRegistry.register ToolbarWindowControls, + location: WorkspaceStore.Sheet.Global.Toolbar.Left + +class Toolbar extends React.Component + @displayName: 'Toolbar' + + @propTypes: + data: React.PropTypes.object + depth: React.PropTypes.number + + constructor: (@props) -> + @state = @_getStateFromStores() + + componentDidMount: => + @unlisteners = [] + @unlisteners.push WorkspaceStore.listen (event) => + @setState(@_getStateFromStores()) + @unlisteners.push ComponentRegistry.listen (event) => + @setState(@_getStateFromStores()) + window.addEventListener("resize", @_onWindowResize) + window.requestAnimationFrame => @recomputeLayout() + + componentWillUnmount: => + window.removeEventListener("resize", @_onWindowResize) + unlistener() for unlistener in @unlisteners + + componentWillReceiveProps: (props) => + @setState(@_getStateFromStores(props)) + + componentDidUpdate: => + # Wait for other components that are dirty (the actual columns in the sheet) + # to update as well. + window.requestAnimationFrame => @recomputeLayout() + + shouldComponentUpdate: (nextProps, nextState) => + # This is very important. Because toolbar uses ReactCSSTransitionGroup, + # repetitive unnecessary updates can break animations and cause performance issues. + not _.isEqual(nextProps, @props) or not _.isEqual(nextState, @state) + + render: => + style = + position:'absolute' + width:'100%' + height:'100%' + zIndex: 1 + + toolbars = @state.columns.map (components, idx) => +
+ {@_flexboxForComponents(components)} +
+ +
+ {toolbars} +
+ + _flexboxForComponents: (components) => + elements = components.map (component) => + + + + {elements} + + + + + recomputeLayout: => + # Find our item containers that are tied to specific columns + columnToolbarEls = React.findDOMNode(@).querySelectorAll('[data-column]') + + # Find the top sheet in the stack + sheet = document.querySelectorAll("[name='Sheet']")[@props.depth] + return unless sheet + + # Position item containers so they have the position and width + # as their respective columns in the top sheet + for columnToolbarEl in columnToolbarEls + column = columnToolbarEl.dataset.column + columnEl = sheet.querySelector("[data-column='#{column}']") + continue unless columnEl + + columnToolbarEl.style.display = 'inherit' + columnToolbarEl.style.left = "#{columnEl.offsetLeft}px" + columnToolbarEl.style.width = "#{columnEl.offsetWidth}px" + + _onWindowResize: => + @recomputeLayout() + + _getStateFromStores: (props) => + props ?= @props + state = + mode: WorkspaceStore.layoutMode() + columns: [] + + # Add items registered to Regions in the current sheet + if @props.data?.columns[state.mode]? + for loc in @props.data.columns[state.mode] + entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar, mode: state.mode}) + state.columns.push(entries) + + # Add left items registered to the Sheet instead of to a Region + for loc in [WorkspaceStore.Sheet.Global, @props.data] + entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar.Left, mode: state.mode}) + state.columns[0]?.push(entries...) + state.columns[0]?.push(ToolbarBack) if @props.depth > 0 + + # Add right items registered to the Sheet instead of to a Region + for loc in [WorkspaceStore.Sheet.Global, @props.data] + entries = ComponentRegistry.findComponentsMatching({location: loc.Toolbar.Right, mode: state.mode}) + state.columns[state.columns.length - 1]?.push(entries...) + + state + +module.exports = Toolbar \ No newline at end of file diff --git a/static/images/thread-list/icon-draft-pencil@2x.png b/static/images/thread-list/icon-draft-pencil@2x.png new file mode 100644 index 000000000..6cc2dae79 Binary files /dev/null and b/static/images/thread-list/icon-draft-pencil@2x.png differ diff --git a/static/workspace.less b/static/workspace.less index d28acb636..093f0dfe6 100644 --- a/static/workspace.less +++ b/static/workspace.less @@ -19,8 +19,8 @@ atom-workspace { position: relative; font-family: @font-family; - /* Important: This attribute is used in the theme-manager-specs to check that - themes load and override each other correctly. Do not remove! */ + // Important: This attribute is used in the theme-manager-specs to check that + // themes load and override each other correctly. Do not remove! background-color: @background-primary; atom-workspace-axis.horizontal {