mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-13 21:24:58 +08:00
45ef25fc02
Summary: Adds new redesigned preferences with horizontal tab bar and refactored code. Converts Preferences, Plugins, and a few components to ES6. Test Plan: Tested locally. Reviewers: evan, bengotow Reviewed By: bengotow Subscribers: juan Differential Revision: https://phab.nylas.com/D2818
68 lines
1.3 KiB
JavaScript
68 lines
1.3 KiB
JavaScript
import React from 'react';
|
|
import classNames from 'classnames';
|
|
|
|
import Tabs from './tabs';
|
|
import TabsStore from './tabs-store';
|
|
import PluginsActions from './plugins-actions';
|
|
|
|
|
|
class PluginsTabs extends React.Component {
|
|
|
|
static displayName = 'PluginsTabs';
|
|
|
|
static propTypes = {
|
|
'onChange': React.PropTypes.Func,
|
|
};
|
|
|
|
constructor() {
|
|
super();
|
|
this.state = this._getStateFromStores();
|
|
}
|
|
|
|
componentDidMount() {
|
|
this._unsubscribers = [];
|
|
this._unsubscribers.push(TabsStore.listen(this._onChange));
|
|
}
|
|
|
|
componentWillUnmount() {
|
|
this._unsubscribers.forEach(unsubscribe => unsubscribe());
|
|
}
|
|
|
|
static containerRequired = false;
|
|
|
|
static containerStyles = {
|
|
minWidth: 200,
|
|
maxWidth: 290,
|
|
};
|
|
|
|
_getStateFromStores() {
|
|
return {
|
|
tabIndex: TabsStore.tabIndex(),
|
|
};
|
|
}
|
|
|
|
_onChange = () => {
|
|
this.setState(this._getStateFromStores());
|
|
}
|
|
|
|
_renderItems() {
|
|
return Tabs.map(({name, key, icon}, idx) => {
|
|
const classes = classNames({
|
|
'tab': true,
|
|
'active': idx === this.state.tabIndex,
|
|
});
|
|
return (<li key={key} className={classes} onClick={() => PluginsActions.selectTabIndex(idx)}>{name}</li>);
|
|
});
|
|
}
|
|
|
|
render() {
|
|
return (
|
|
<ul className="plugins-view-tabs">
|
|
{this._renderItems()}
|
|
</ul>
|
|
);
|
|
}
|
|
|
|
}
|
|
|
|
export default PluginsTabs;
|