Mailspring/guides/InterfaceConcepts.html

204 lines
13 KiB
HTML
Raw Normal View History

2015-10-02 03:34:16 +08:00
<html>
<head>
<meta charset="utf-8">
<title>N1 — Interface Concepts</title>
<meta property="og:title" content="An extensible mail client built on the modern web | N1">
<meta property="og:type" content="website">
<meta property="og:image" content="https://nylas.github.io/n1/images/meta_share.png">
<link rel="shortcut icon" href="/images/favicon.ico">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="stylesheet" type="text/css" href="/css/main.css"/>
<link rel="stylesheet" type="text/css" href="/css/tomorrow.css">
</head>
<body>
<div id="header">
<div class="container">
<img src="/images/edgehill.png" class="logo" />
<div class="title">N1<div class="small">Developer Preview</div></div>
</div>
</div>
<div class="container">
<div class="page-title">Interface Concepts</div>
<div id="sidebar">
<div class="heading">Getting Started</div>
<ul>
<li><a href="/guides/FirstSteps.html" >First Steps</a></li>
</ul>
<div class="heading">Guides</div>
<ul>
<li><a href="/guides/InterfaceConcepts.html" >Interface Concepts</a></li>
<li><a href="/guides/PackageOverview.html" >Building a Package</a></li>
<li><a href="/guides/React.html" >Interface Components</a></li>
<li><a href="/guides/Architecture.html" >Application Architecture</a></li>
<li><a href="/guides/Debugging.html" >Debugging N1</a></li>
<li><a href="/guides/Database.html" >Accessing the Database</a></li>
<li><a href="/guides/DraftStoreExtensions.html" >Extending the Composer</a></li>
<li><a href="/guides/WritingSpecs.html" >Writing Specs</a></li>
</ul>
<div class="heading">Sample Code</div>
<ul>
<li><a href="https://github.com/nylas/edgehill-plugins/tree/master/translate" target="_blank">Composer Translation</a></li>
<li><a href="https://github.com/nylas/edgehill-plugins/tree/master/sidebar-github-profile" target="_blank">Github Sidebar</a></li>
</ul>
<div class="heading">API Reference</div>
<ul>
<div class="heading">General</div>
<ul>
<li><a href="/docs/Actions.html" >Actions</a></li>
<li><a href="/docs/Atom.html" >Atom</a></li>
<li><a href="/docs/BufferedNodeProcess.html" >BufferedNodeProcess</a></li>
<li><a href="/docs/BufferedProcess.html" >BufferedProcess</a></li>
<li><a href="/docs/ChangeFolderTask.html" >ChangeFolderTask</a></li>
<li><a href="/docs/ChangeLabelsTask.html" >ChangeLabelsTask</a></li>
<li><a href="/docs/Config.html" >Config</a></li>
<li><a href="/docs/DraggableImg.html" >DraggableImg</a></li>
<li><a href="/docs/FocusTrackingRegion.html" >FocusTrackingRegion</a></li>
<li><a href="/docs/Switch.html" >Switch</a></li>
<li><a href="/docs/Task.html" >Task</a></li>
<li><a href="/docs/TaskQueueStatusStore.html" >TaskQueueStatusStore</a></li>
</ul>
<div class="heading">Component Kit</div>
<ul>
<li><a href="/docs/EventedIFrame.html" >EventedIFrame</a></li>
<li><a href="/docs/Flexbox.html" >Flexbox</a></li>
<li><a href="/docs/InjectedComponent.html" >InjectedComponent</a></li>
<li><a href="/docs/InjectedComponentSet.html" >InjectedComponentSet</a></li>
<li><a href="/docs/Menu.html" >Menu</a></li>
<li><a href="/docs/MenuItem.html" >MenuItem</a></li>
<li><a href="/docs/MenuNameEmailItem.html" >MenuNameEmailItem</a></li>
<li><a href="/docs/MultiselectActionBar.html" >MultiselectActionBar</a></li>
<li><a href="/docs/MultiselectList.html" >MultiselectList</a></li>
<li><a href="/docs/Popover.html" >Popover</a></li>
<li><a href="/docs/ResizableRegion.html" >ResizableRegion</a></li>
<li><a href="/docs/RetinaImg.html" >RetinaImg</a></li>
<li><a href="/docs/Spinner.html" >Spinner</a></li>
<li><a href="/docs/TimeoutTransitionGroupChild.html" >TimeoutTransitionGroupChild</a></li>
<li><a href="/docs/UnsafeComponent.html" >UnsafeComponent</a></li>
</ul>
<div class="heading">Models</div>
<ul>
<li><a href="/docs/Account.html" >Account</a></li>
<li><a href="/docs/Calendar.html" >Calendar</a></li>
<li><a href="/docs/Contact.html" >Contact</a></li>
<li><a href="/docs/File.html" >File</a></li>
<li><a href="/docs/Folder.html" >Folder</a></li>
<li><a href="/docs/Label.html" >Label</a></li>
<li><a href="/docs/Message.html" >Message</a></li>
<li><a href="/docs/Model.html" >Model</a></li>
<li><a href="/docs/Thread.html" >Thread</a></li>
</ul>
<div class="heading">Stores</div>
<ul>
<li><a href="/docs/AccountStore.html" >AccountStore</a></li>
<li><a href="/docs/ComponentRegistry.html" >ComponentRegistry</a></li>
<li><a href="/docs/ContactStore.html" >ContactStore</a></li>
<li><a href="/docs/EventStore.html" >EventStore</a></li>
<li><a href="/docs/FocusedContentStore.html" >FocusedContentStore</a></li>
<li><a href="/docs/MessageStoreExtension.html" >MessageStoreExtension</a></li>
<li><a href="/docs/TaskQueue.html" >TaskQueue</a></li>
<li><a href="/docs/WorkspaceStore.html" >WorkspaceStore</a></li>
</ul>
<div class="heading">Database</div>
<ul>
<li><a href="/docs/Attribute.html" >Attribute</a></li>
<li><a href="/docs/AttributeBoolean.html" >AttributeBoolean</a></li>
<li><a href="/docs/AttributeCollection.html" >AttributeCollection</a></li>
<li><a href="/docs/AttributeDateTime.html" >AttributeDateTime</a></li>
<li><a href="/docs/AttributeJoinedData.html" >AttributeJoinedData</a></li>
<li><a href="/docs/AttributeNumber.html" >AttributeNumber</a></li>
<li><a href="/docs/AttributeObject.html" >AttributeObject</a></li>
<li><a href="/docs/AttributeServerId.html" >AttributeServerId</a></li>
<li><a href="/docs/AttributeString.html" >AttributeString</a></li>
<li><a href="/docs/DatabaseStore.html" >DatabaseStore</a></li>
<li><a href="/docs/DatabaseView.html" >DatabaseView</a></li>
<li><a href="/docs/Matcher.html" >Matcher</a></li>
<li><a href="/docs/ModelQuery.html" >ModelQuery</a></li>
<li><a href="/docs/SortOrder.html" >SortOrder</a></li>
</ul>
<div class="heading">Drafts</div>
<ul>
<li><a href="/docs/DraftChangeSet.html" >DraftChangeSet</a></li>
<li><a href="/docs/DraftStore.html" >DraftStore</a></li>
<li><a href="/docs/DraftStoreExtension.html" >DraftStoreExtension</a></li>
<li><a href="/docs/DraftStoreProxy.html" >DraftStoreProxy</a></li>
</ul>
<div class="heading">Atom</div>
<ul>
<li><a href="/docs/Clipboard.html" >Clipboard</a></li>
<li><a href="/docs/Color.html" >Color</a></li>
<li><a href="/docs/CommandRegistry.html" >CommandRegistry</a></li>
<li><a href="/docs/MenuManager.html" >MenuManager</a></li>
<li><a href="/docs/PackageManager.html" >PackageManager</a></li>
<li><a href="/docs/ScopeDescriptor.html" >ScopeDescriptor</a></li>
<li><a href="/docs/StyleManager.html" >StyleManager</a></li>
<li><a href="/docs/ThemeManager.html" >ThemeManager</a></li>
</ul>
</ul>
</div>
<div id="main" class="article">
<p>The N1 user interface is conceptually organized into Sheets. Each Sheet represents a window of content. For example, the <code>Threads</code> sheet lies at the heart of the application. When the user chooses the &quot;Files&quot; tab, a separate <code>Files</code> sheet is displayed in place of <code>Threads</code>. When the user clicks a thread in single-pane mode, a <code>Thread</code> sheet is pushed on to the workspace and appears after a brief transition.</p>
<p><img src="./images/sheets.png"></p>
<p>The <a href='/docs/workspacestore.html'>WorkspaceStore</a> maintains the state of the application&#39;s workspace and the stack of sheets currently being displayed. Your packages can declare &quot;root&quot; sheets which are listed in the app&#39;s main sidebar, or push custom sheets on top of sheets to display data.</p>
<p>The Nylas Workspace supports two display modes: <code>split</code> and <code>list</code>. Each Sheet describes it&#39;s appearance in each of the view modes it supports. For example, the <code>Threads</code> sheet describes a three column <code>split</code> view and a single column <code>list</code> view. Other sheets, like <code>Files</code> register for only one mode, and the user&#39;s mode preference is ignored.</p>
<p>For each mode, Sheets register a set of column names.</p>
<p><img src="./images/columns.png"></p>
<pre><code class="lang-coffee"><span class="hljs-variable">@defineSheet</span> <span class="hljs-string">'Threads'</span>, {<span class="hljs-attribute">root</span>: true},
<span class="hljs-attribute">split</span>: [<span class="hljs-string">'RootSidebar'</span>, <span class="hljs-string">'ThreadList'</span>, <span class="hljs-string">'MessageList'</span>, <span class="hljs-string">'MessageListSidebar'</span>]
<span class="hljs-attribute">list</span>: [<span class="hljs-string">'RootSidebar'</span>, <span class="hljs-string">'ThreadList'</span>]
</code></pre>
<p>Column names are important. Once you&#39;ve registered a sheet, your package (and other packages) register React components that appear in each column.</p>
<p>Sheets also have a <code>Header</code> and <code>Footer</code> region that spans all of their content columns. You can register components to appear in these regions to display notifications, add bars beneath the toolbar, etc.</p>
<pre><code class="lang-coffee">ComponentRegistry<span class="hljs-class">.register</span> AccountSidebar,
location: WorkspaceStore<span class="hljs-class">.Location</span><span class="hljs-class">.RootSidebar</span>
ComponentRegistry<span class="hljs-class">.register</span> NotificationsStickyBar,
location: WorkspaceStore<span class="hljs-class">.Sheet</span><span class="hljs-class">.Threads</span><span class="hljs-class">.Header</span>
</code></pre>
<p>Each column is laid out as a CSS Flexbox, making them extremely flexible. For more about layout using Flexbox, see Working with Flexbox.</p>
<h3 id="toolbars">Toolbars</h3>
<p>Toolbars in N1 are also powered by the <a href='/docs/componentregistry.html'>ComponentRegistry</a>. Though toolbars appear to be a single unit at the top of a sheet, they are divided into columns with the same widths as the columns in the sheet beneath them.</p>
<p><img src="./images/toolbar.png"></p>
<p>Each Toolbar column is laid out using <a href='/docs/flexbox.html'>Flexbox</a>. You can control where toolbar elements appear within the column using the CSS <code>order</code> attribute. To make it easy to position toolbar items on the left, right, or center of a column, we&#39;ve added two &quot;spacer&quot; elements with <code>order:50</code> and <code>order:-50</code> that evenly use up available space. Other CSS attributes allow you to control whether your items shrink or expand as the column&#39;s size changes.</p>
<p><img src="./images/toolbar-column.png"></p>
<p>To add items to a toolbar, you inject them via the <a href='/docs/componentregistry.html'>ComponentRegistry</a>. There are several ways of describing the location of a toolbar component which are useful in different scenarios:</p>
<ul>
<li><p><code>&lt;Location&gt;.Toolbar</code>: This component will always appear in the toolbar above the column named <code>&lt;Location&gt;</code>.</p>
<p> (Example: Compose button which appears above the Left Sidebar column, regardless of what else is there.)</p>
</li>
<li><p><code>&lt;ComponentName&gt;.Toolbar</code>: This component will appear in the toolbar above <code>&lt;ComponentName&gt;</code>.</p>
<p> (Example: Archive button that should always be coupled with the MessageList component, placed anywhere a MessageList component is placed.)</p>
</li>
<li><p><code>Global.Toolbar.Left</code>: This component will always be added to the leftmost column of the toolbar.</p>
<p> (Example: Window Controls)</p>
</li>
</ul>
</div>
</div>
<div id="footer">
<div class="container">
<img src="images/edgehill.png" class="logo" />
<div class="small">N1 Developer Preview<br><em>© 2014-2015 Nylas, Inc.</em></div>
</div>
</div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-60022049-2', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>