mirror of
https://github.com/Foundry376/Mailspring.git
synced 2025-10-06 03:14:39 +08:00
feat(thread-list): Create custom icon components via role: ThreadListIcon
This commit is contained in:
parent
7e0b02fc17
commit
74894e91ff
2 changed files with 16 additions and 3 deletions
|
@ -1,7 +1,11 @@
|
||||||
_ = require 'underscore'
|
_ = require 'underscore'
|
||||||
React = require 'react'
|
React = require 'react'
|
||||||
classNames = require 'classnames'
|
classNames = require 'classnames'
|
||||||
{ListTabular, MultiselectList, RetinaImg, MailLabel} = require 'nylas-component-kit'
|
{ListTabular,
|
||||||
|
MultiselectList,
|
||||||
|
RetinaImg,
|
||||||
|
MailLabel,
|
||||||
|
InjectedComponentSet} = require 'nylas-component-kit'
|
||||||
{timestamp, subject} = require './formatting-utils'
|
{timestamp, subject} = require './formatting-utils'
|
||||||
{Actions,
|
{Actions,
|
||||||
Utils,
|
Utils,
|
||||||
|
@ -69,6 +73,11 @@ class ThreadList extends React.Component
|
||||||
<span>
|
<span>
|
||||||
<ThreadListIcon thread={thread} />
|
<ThreadListIcon thread={thread} />
|
||||||
<MailImportantIcon thread={thread} />
|
<MailImportantIcon thread={thread} />
|
||||||
|
<InjectedComponentSet
|
||||||
|
inline={true}
|
||||||
|
containersRequired={false}
|
||||||
|
matching={role: "ThreadListIcon"}
|
||||||
|
exposedProps={thread: thread}/>
|
||||||
</span>
|
</span>
|
||||||
|
|
||||||
c2 = new ListTabular.Column
|
c2 = new ListTabular.Column
|
||||||
|
|
|
@ -45,6 +45,8 @@ class InjectedComponentSet extends React.Component
|
||||||
will always be displayed.
|
will always be displayed.
|
||||||
- `exposedProps` (optional) An {Object} with props that will be passed to each
|
- `exposedProps` (optional) An {Object} with props that will be passed to each
|
||||||
item rendered into the set.
|
item rendered into the set.
|
||||||
|
- `containersRequired` (optional). Pass false to optionally remove the containers
|
||||||
|
placed around injected components to isolate them from the rest of the app.
|
||||||
|
|
||||||
- Any other props you provide, such as `direction`, `data-column`, etc.
|
- Any other props you provide, such as `direction`, `data-column`, etc.
|
||||||
will be applied to the {Flexbox} rendered by the InjectedComponentSet.
|
will be applied to the {Flexbox} rendered by the InjectedComponentSet.
|
||||||
|
@ -54,9 +56,11 @@ class InjectedComponentSet extends React.Component
|
||||||
children: React.PropTypes.array
|
children: React.PropTypes.array
|
||||||
className: React.PropTypes.string
|
className: React.PropTypes.string
|
||||||
exposedProps: React.PropTypes.object
|
exposedProps: React.PropTypes.object
|
||||||
|
containersRequired: React.PropTypes.bool
|
||||||
|
|
||||||
@defaultProps:
|
@defaultProps:
|
||||||
direction: 'row'
|
direction: 'row'
|
||||||
|
containersRequired: true
|
||||||
|
|
||||||
constructor: (@props) ->
|
constructor: (@props) ->
|
||||||
@state = @_getStateFromStores()
|
@state = @_getStateFromStores()
|
||||||
|
@ -77,8 +81,8 @@ class InjectedComponentSet extends React.Component
|
||||||
flexboxClassName = @props.className ? ""
|
flexboxClassName = @props.className ? ""
|
||||||
exposedProps = @props.exposedProps ? {}
|
exposedProps = @props.exposedProps ? {}
|
||||||
|
|
||||||
elements = @state.components.map (component) ->
|
elements = @state.components.map (component) =>
|
||||||
if component.containerRequired is false
|
if @props.containersRequired is false or component.containerRequired is false
|
||||||
<component key={component.displayName} {...exposedProps} />
|
<component key={component.displayName} {...exposedProps} />
|
||||||
else
|
else
|
||||||
<UnsafeComponent component={component} key={component.displayName} {...exposedProps} />
|
<UnsafeComponent component={component} key={component.displayName} {...exposedProps} />
|
||||||
|
|
Loading…
Add table
Reference in a new issue