more nav restyling

This commit is contained in:
Cassie Tarakajian 2017-07-19 17:35:25 -04:00
parent fd26279fed
commit 394772c32c
2 changed files with 61 additions and 138 deletions

View file

@ -6,6 +6,10 @@ const triangleUrl = require('../images/down-filled-triangle.svg');
const logoUrl = require('../images/p5js-logo-small.svg');
class Nav extends React.PureComponent {
isUserOwner() {
return this.props.project.owner && this.props.project.owner.id === this.props.user.id;
}
render() {
return (
<nav className="nav" role="navigation" title="main-navigation">
@ -19,7 +23,7 @@ class Nav extends React.PureComponent {
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li>
<li className="nav__dropdown-item">
<button
onClick={() => {
if (!this.props.unsavedChanges) {
@ -32,97 +36,9 @@ class Nav extends React.PureComponent {
New
</button>
</li>
<li>
<button>
Save
</button>
</li>
<li>
<button>
Duplicate
</button>
</li>
<li>
<button>
Open
</button>
</li>
<li>
<button>
Download
</button>
</li>
</ul>
</li>
<li className="nav__item">
<button>
Edit
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li>
Tidy Code
</li>
<li>
Find
</li>
</ul>
</li>
<li className="nav__item">
<button>
Sketch
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li>
Run
</li>
<li>
Stop
</li>
</ul>
</li>
<li className="nav__item">
<button>
Help
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li>
Keyboard Shortcuts
</li>
<li>
Reference
</li>
<li>
About
</li>
</ul>
</li>
<li className="nav__item">
{ (!this.props.project.owner || this.isUserOwner()) &&
<li className="nav__dropdown-item">
<button
className="nav__new"
onClick={() => {
if (!this.props.unsavedChanges) {
this.props.newProject();
} else if (this.props.warnIfUnsavedChanges()) {
this.props.newProject();
}
}}
>
New
</button>
</li>
{(() => { // eslint-disable-line
if (
!this.props.project.owner ||
(this.props.project.owner && this.props.project.owner.id === this.props.user.id)
) {
return (
<li className="nav__item">
<button
className="nav__save"
onClick={() => {
if (this.props.user.authenticated) {
this.props.saveProject();
@ -133,82 +49,90 @@ class Nav extends React.PureComponent {
>
Save
</button>
</li>
);
}
})()}
{(() => { // eslint-disable-line
if (this.props.project.id && this.props.user.authenticated) {
return (
<li className="nav__item">
<button className="nav__clone" onClick={this.props.cloneProject}>
</li> }
{ this.props.project.id && this.props.user.authenticated &&
<li className="nav__dropdown-item">
<button onClick={this.props.cloneProject}>
Duplicate
</button>
</li>
);
}
})()}
{(() => { // eslint-disable-line
if (this.props.project.id) {
return (
<li className="nav__item">
<button className="nav__export" onClick={() => this.props.exportProjectAsZip(this.props.project.id)}>
Download
</button>
</li>
);
}
})()}
{(() => { // eslint-disable-line
if (this.props.project.id) {
return (
<li className="nav__item">
</li> }
{ this.props.project.id &&
<li className="nav__dropdown-item">
<button onClick={this.props.showShareModal}>
Share
</button>
</li>
);
}
})()}
{(() => { // eslint-disable-line
if (this.props.user.authenticated) {
return (
<li className="nav__item">
<p className="nav__open">
<Link
to={`/${this.props.user.username}/sketches`}
>
</li> }
{ this.props.project.id &&
<li className="nav__dropdown-item">
<button onClick={() => this.props.exportProjectAsZip(this.props.project.id)}>
Download
</button>
</li> }
{ this.props.user.authenticated &&
<li className="nav__dropdown-item">
<Link to={`/${this.props.user.username}/sketches`}>
Open
</Link>
</p>
</li>
);
}
})()}
<li className="nav__item">
<p className="nav__open">
</li> }
<li className="nav__dropdown-item">
<Link
to="/p5/sketches"
>
Examples
</Link>
</p>
</li>
</ul>
</li>
<li className="nav__item">
<p className="nav__reference">
<button>
Edit
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li className="nav__dropdown-item">
Tidy Code
</li>
<li cclassName="nav__dropdown-item">
Find
</li>
</ul>
</li>
<li className="nav__item">
<button>
Sketch
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li className="nav__dropdown-item">
Run
</li>
<li className="nav__dropdown-item">
Stop
</li>
</ul>
</li>
<li className="nav__item">
<button>
Help
<InlineSVG src={triangleUrl} />
</button>
<ul className="nav__dropdown">
<li className="nav__dropdown-item">
Keyboard Shortcuts
</li>
<li className="nav__dropdown-item">
<a
href="https://p5js.org/reference/"
target="_blank"
rel="noopener noreferrer"
>Reference</a>
</p>
</li>
<li className="nav__item">
<p className="nav__about">
<li className="nav__dropdown-item">
<Link to="/about">
About
</Link>
</p>
</li>
</ul>
</li>
</ul>
<ul className="nav__items-right" title="user-menu">

View file

@ -28,7 +28,6 @@
.nav__item {
position: relative;
padding: 0 #{24 / $base-font-size}rem;
text-align: center;
display: flex;
align-items: center;
justify-content: center;
@ -49,15 +48,15 @@
border: 1px solid map-get($theme-map, 'modal-border-color');
box-shadow: 0 0 18px getThemifyVariable('shadow-color');
}
@extend %hidden-element;
display: none;
text-align: left;
width: #{140 / $base-font-size}rem;
.nav__item:hover & {
.nav__item:hover &, .nav__item--open & {
display: flex;
position: absolute;
flex-direction: column;
top: #{-8 / $base-font-size}rem;;
left: #{-11 / $base-font-size}rem;
top: 50%;
left: 0;
height: auto;
}
padding-bottom: #{8 / $base-font-size}rem;