mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
patch(thread-list): Limit number of injected icons in narrow mode to 1
- Update InjectedComponentSet to take a limit for the amount of matching components to render
This commit is contained in:
parent
3086806446
commit
36cda855f7
|
@ -6,7 +6,6 @@ classNames = require 'classnames'
|
|||
RetinaImg,
|
||||
MailLabelSet,
|
||||
MailImportantIcon,
|
||||
InjectedComponent,
|
||||
InjectedComponentSet} = require 'nylas-component-kit'
|
||||
|
||||
{Thread, FocusedPerspectiveStore, Utils} = require 'nylas-exports'
|
||||
|
@ -114,17 +113,20 @@ cNarrow = new ListTabular.Column
|
|||
if hasDraft
|
||||
pencil = <RetinaImg name="icon-draft-pencil.png" className="draft-icon" mode={RetinaImg.Mode.ContentPreserve} />
|
||||
|
||||
# TODO We are limiting the amount on injected icons in narrow mode to 1
|
||||
# until we revisit the UI to accommodate more icons
|
||||
<div style={display: 'flex', alignItems: 'flex-start'}>
|
||||
<div className="icons-column">
|
||||
<ThreadListIcon thread={thread} />
|
||||
<InjectedComponentSet
|
||||
key="injected-component-set"
|
||||
inline={true}
|
||||
matchLimit={1}
|
||||
direction="column"
|
||||
containersRequired={false}
|
||||
key="injected-component-set"
|
||||
exposedProps={thread: thread}
|
||||
matching={role: "ThreadListIcon"}
|
||||
className="thread-injected-icons"
|
||||
exposedProps={thread: thread}
|
||||
/>
|
||||
<MailImportantIcon
|
||||
thread={thread}
|
||||
|
|
|
@ -40,6 +40,7 @@ class InjectedComponentSet extends React.Component
|
|||
- `matching` Pass an {Object} with ComponentRegistry descriptors
|
||||
This set of descriptors is provided to {ComponentRegistry::findComponentsForDescriptor}
|
||||
to retrieve components for display.
|
||||
- `matchLimit` (optional) A {Number} that indicates the max number of matching elements to render
|
||||
- `className` (optional) A {String} class name for the containing element.
|
||||
- `children` (optional) Any React elements rendered inside the InjectedComponentSet
|
||||
will always be displayed.
|
||||
|
@ -57,6 +58,7 @@ class InjectedComponentSet extends React.Component
|
|||
matching: React.PropTypes.object.isRequired
|
||||
children: React.PropTypes.array
|
||||
className: React.PropTypes.string
|
||||
matchLimit: React.PropTypes.number
|
||||
exposedProps: React.PropTypes.object
|
||||
containersRequired: React.PropTypes.bool
|
||||
onComponentsDidRender: React.PropTypes.func
|
||||
|
@ -121,8 +123,9 @@ class InjectedComponentSet extends React.Component
|
|||
|
||||
_getStateFromStores: (props) =>
|
||||
props ?= @props
|
||||
limit = props.matchLimit
|
||||
|
||||
components: ComponentRegistry.findComponentsMatching(@props.matching)
|
||||
components: ComponentRegistry.findComponentsMatching(@props.matching)[...limit]
|
||||
visible: ComponentRegistry.showComponentRegions()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue