This commit is contained in:
Cassie Tarakajian 2017-07-24 11:12:11 -04:00
parent e987e8f483
commit 983248ccb7
3 changed files with 53 additions and 45 deletions

View file

@ -20,49 +20,53 @@ class SketchList extends React.Component {
const username = this.props.username !== undefined ? this.props.username : this.props.user.username; const username = this.props.username !== undefined ? this.props.username : this.props.user.username;
return ( return (
<div className="sketches-table-container"> <div className="sketches-table-container">
<table className="sketches-table" summary="table containing all saved projects"> { this.props.sketches.length === 0 &&
<thead> <p className="sketches-table__empty">No sketches.</p>
<tr> }
<th className="sketch-list__trash-column" scope="col"></th> { this.props.sketches.length > 0 &&
<th scope="col">Sketch</th> <table className="sketches-table" summary="table containing all saved projects">
<th scope="col">Date created</th> <thead>
<th scope="col">Date updated</th> <tr>
</tr> <th className="sketch-list__trash-column" scope="col"></th>
</thead> <th scope="col">Sketch</th>
<tbody> <th scope="col">Date created</th>
{this.props.sketches.map(sketch => <th scope="col">Date updated</th>
// eslint-disable-next-line
<tr
className="sketches-table__row visibility-toggle"
key={sketch.id}
onClick={() => browserHistory.push(`/${username}/sketches/${sketch.id}`)}
>
<td className="sketch-list__trash-column">
{(() => { // eslint-disable-line
if (this.props.username === this.props.user.username || this.props.username === undefined) {
return (
<button
className="sketch-list__trash-button"
onClick={(e) => {
e.stopPropagation();
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
this.props.deleteProject(sketch.id);
}
}}
>
<InlineSVG src={trashCan} alt="Delete Project" />
</button>
);
}
})()}
</td>
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
</tr> </tr>
)} </thead>
</tbody> <tbody>
</table> {this.props.sketches.map(sketch =>
// eslint-disable-next-line
<tr
className="sketches-table__row visibility-toggle"
key={sketch.id}
onClick={() => browserHistory.push(`/${username}/sketches/${sketch.id}`)}
>
<td className="sketch-list__trash-column">
{(() => { // eslint-disable-line
if (this.props.username === this.props.user.username || this.props.username === undefined) {
return (
<button
className="sketch-list__trash-button"
onClick={(e) => {
e.stopPropagation();
if (window.confirm(`Are you sure you want to delete "${sketch.name}"?`)) {
this.props.deleteProject(sketch.id);
}
}}
>
<InlineSVG src={trashCan} alt="Delete Project" />
</button>
);
}
})()}
</td>
<th scope="row"><Link to={`/${username}/sketches/${sketch.id}`}>{sketch.name}</Link></th>
<td>{moment(sketch.createdAt).format('MMM D, YYYY h:mm A')}</td>
<td>{moment(sketch.updatedAt).format('MMM D, YYYY h:mm A')}</td>
</tr>
)}
</tbody>
</table>}
</div> </div>
); );
} }

View file

@ -1,5 +1,5 @@
.asset-table-container { .asset-table-container {
flex: 1 1 0%; // flex: 1 1 0%;
overflow-y: scroll; overflow-y: scroll;
max-width: 100%; max-width: 100%;
width: #{1000 / $base-font-size}rem; width: #{1000 / $base-font-size}rem;

View file

@ -1,9 +1,8 @@
.sketches-table-container { .sketches-table-container {
flex: 1 1 0%;
overflow-y: scroll; overflow-y: scroll;
max-width: 100%; max-width: 100%;
width: #{1000 / $base-font-size}rem; width: #{1000 / $base-font-size}rem;
min-height: #{400 / $base-font-size}rem;
} }
.sketches-table { .sketches-table {
@ -72,3 +71,8 @@
} }
} }
} }
.sketches-table__empty {
text-align: center;
font-size: #{16 / $base-font-size}rem;
}