Merge pull request #541 from yuya-oc/fix-add-button-align

Fix alignment for 'Add new server' button
This commit is contained in:
Yuya Ochiai 2017-05-31 20:34:23 +09:00 committed by GitHub
commit 446af5ef76
4 changed files with 30 additions and 62 deletions

View file

@ -111,9 +111,6 @@ const MainPage = createReactClass({
} }
}, },
handleSelect(key) { handleSelect(key) {
if (key === 'addServerButton') {
return;
}
const newKey = (this.props.teams.length + key) % this.props.teams.length; const newKey = (this.props.teams.length + key) % this.props.teams.length;
this.setState({ this.setState({
key: newKey key: newKey

View file

@ -1,29 +1,6 @@
const React = require('react'); const React = require('react');
const PropTypes = require('prop-types'); const PropTypes = require('prop-types');
const {Nav, NavItem, Button} = require('react-bootstrap'); const {Glyphicon, Nav, NavItem} = require('react-bootstrap');
function AddServerButton(props) {
return (
<NavItem
className='AddServerButton'
key='addServerButton'
eventKey='addServerButton'
>
<Button
id='tabBarAddNewTeam'
onClick={props.onClick}
className='AddServerButton-button'
title='Add new server'
>
{'+'}
</Button>
</NavItem>
);
}
AddServerButton.propTypes = {
onClick: PropTypes.func
};
function TabBar(props) { function TabBar(props) {
const tabs = props.teams.map((team, index) => { const tabs = props.teams.map((team, index) => {
@ -76,16 +53,32 @@ function TabBar(props) {
{ badgeDiv } { badgeDiv }
</NavItem>); </NavItem>);
}); });
tabs.push(
<NavItem
className='TabBar-addServerButton'
key='addServerButton'
id='addServerButton'
eventKey='addServerButton'
title='Add new server'
>
<Glyphicon glyph='plus'/>
</NavItem>
);
return ( return (
<Nav <Nav
className='TabBar' className='TabBar'
id={props.id} id={props.id}
bsStyle='tabs' bsStyle='tabs'
activeKey={props.activeKey} activeKey={props.activeKey}
onSelect={props.onSelect} onSelect={(eventKey) => {
if (eventKey === 'addServerButton') {
props.onAddServer();
} else {
props.onSelect(eventKey);
}
}}
> >
{ tabs } { tabs }
<AddServerButton onClick={props.onAddServer}/>
</Nav> </Nav>
); );
} }

View file

@ -10,13 +10,18 @@
padding: 0 15px; padding: 0 15px;
} }
.TabBar .AddServerButton>a { .TabBar .TabBar-addServerButton>a {
border: none; border: none;
background: transparent; background: transparent;
margin: 0px; color: #999;
margin-left: 1px; /*Has no border and would be placed above the last item's border due to it's margin-right: -1px */ font-size: 10px;
padding: 0; line-height: 31px;
margin-bottom: 1px; }
.TabBar .TabBar-addServerButton>a:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
} }
.TabBar .TabBar-badge { .TabBar .TabBar-badge {
@ -32,30 +37,3 @@
margin-top: 5px; margin-top: 5px;
border-radius: 50%; border-radius: 50%;
}; };
.TabBar .AddServerButton-button {
background-color: #fff;
border-color: #ccc;
color: #333;
margin-top: 3px;
}
.TabBar .AddServerButton-button {
border: none;
font-size: 20px;
height: 31px;
padding: 2px 0 0 0;
width: 40px;
color: #999;
font-weight: bold;
margin: 0;
border-radius: 2px 2px 0 0;
outline: none;
}
.TabBar .AddServerButton-button:hover {
color: #333;
background-color: #e6e6e6;
border-color: #adadad;
}

View file

@ -185,7 +185,7 @@ describe('browser/index.html', function desc() {
it('should open the new server prompt after clicking the add button', () => { it('should open the new server prompt after clicking the add button', () => {
// See settings_test for specs that cover the actual prompt // See settings_test for specs that cover the actual prompt
return this.app.client.waitUntilWindowLoaded(). return this.app.client.waitUntilWindowLoaded().
click('#tabBarAddNewTeam'). click('#addServerButton').
pause(500). pause(500).
isExisting('#newServerModal').then((existing) => existing.should.be.true); isExisting('#newServerModal').then((existing) => existing.should.be.true);
}); });