Skip to content

Commit

Permalink
activate quick add menu
Browse files Browse the repository at this point in the history
  • Loading branch information
erquhart committed Dec 5, 2017
1 parent 7485ce0 commit c80ddb9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 31 deletions.
6 changes: 5 additions & 1 deletion src/components/App/Header.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
font-size: 12px;
font-weight: 600;
background-color: #7d8190;
padding: 6px 12px;
padding: 4px 24px 4px 14px;
margin-right: 8px;
color: #fff;

Expand All @@ -70,6 +70,10 @@
&:focus {
color: #fff;
}

&:after {
top: 11px;
}
}

.nc-appHeader-avatar {
Expand Down
50 changes: 23 additions & 27 deletions src/components/App/Header.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { Icon, Dropdown, DropdownItem } from 'UI';
import { stripProtocol } from 'Lib/urlHelper';

export default class Header extends React.Component {

static propTypes = {
user: ImmutablePropTypes.map.isRequired,
collections: ImmutablePropTypes.orderedMap.isRequired,
Expand All @@ -15,6 +14,13 @@ export default class Header extends React.Component {
displayUrl: PropTypes.string,
};

handleCreatePostClick = (collectionName) => {
const { onCreateEntryClick } = this.props;
if (onCreateEntryClick) {
onCreateEntryClick(collectionName);
}
};

render() {
const {
user,
Expand All @@ -26,29 +32,6 @@ export default class Header extends React.Component {
displayUrl,
} = this.props;

/**
* preserve the Quick New dropdown code
{
collections.filter(collection => collection.get('create')).toList().map(collection =>
<MenuItem
key={collection.get("name")}
value={collection.get("name")}
onClick={this.handleCreatePostClick.bind(this, collection.get('name'))} // eslint-disable-line
caption={collection.get("label")}
/>
)
}
<MenuItem onClick={onLogoutClick} value="log out" caption="Log Out" />
handleCreatePostClick = (collectionName) => {
const { onCreateEntryClick } = this.props;
if (onCreateEntryClick) {
onCreateEntryClick(collectionName);
}
};
*/
const avatarUrl = user.get('avatar_url');

return (
Expand Down Expand Up @@ -79,9 +62,22 @@ export default class Header extends React.Component {
</button>
</nav>
<div className="nc-appHeader-actions">
<button className="nc-appHeader-button nc-appHeader-quickNew">
Quick new
</button>
<Dropdown
classNameButton="nc-appHeader-button nc-appHeader-quickNew"
label="Quick add"
dropdownWidth="160px"
dropdownPosition="right"
>
{
collections.filter(collection => collection.get('create')).toList().map(collection =>
<DropdownItem
key={collection.get("name")}
label={collection.get("label")}
onClick={() => this.handleCreatePostClick(collection.get('name'))}
/>
)
}
</Dropdown>
{
displayUrl
? <a
Expand Down
4 changes: 3 additions & 1 deletion src/components/UI/Dropdown/Dropdown.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import React from 'react';
import PropTypes from 'prop-types';
import c from 'classnames';
import { Wrapper, Button, Menu, MenuItem } from 'react-aria-menubutton';
import { Icon } from 'UI';

const Dropdown = ({
label,
button,
classNameButton = '',
dropdownWidth = 'auto',
dropdownPosition = 'left',
children
Expand All @@ -20,7 +22,7 @@ const Dropdown = ({
{
button
? <Button>{button}</Button>
: <Button className="nc-dropdownButton">{label}</Button>
: <Button className={c('nc-dropdownButton', classNameButton)}>{label}</Button>
}
<Menu>
<ul className="nc-dropdownList" style={style}>
Expand Down
1 change: 1 addition & 0 deletions src/components/UI/UI.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "./Icon/Icon.css";
@import "./Loader/Loader.css";
@import "./Toast/Toast.css";
@import "./Modal/Modal.css";
Expand Down
3 changes: 1 addition & 2 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
*/
@import "reboot.css/dist/reboot.css";
@import "./components/UI/base.css";
@import "./components/UI/Icon/Icon.css";

/**
* Components
*/
@import "./components/UI/UI.css";
@import "./components/App/App.css";
@import "./components/Collection/Collection.css";
@import "./components/Workflow/Workflow.css";
@import "./components/Editor/Editor.css";
@import "./components/UI/UI.css";
@import "./components/MediaLibrary/MediaLibrary.css";
@import "./components/EditorWidgets/EditorWidgets.css";

Expand Down

0 comments on commit c80ddb9

Please sign in to comment.