Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix reset icon when files dropped #66

Merged
merged 2 commits into from
Nov 23, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 41 additions & 9 deletions renderer/components/FilePath.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,33 @@ const folderIcon = (
</svg>
);

const FilePath = ({ dropFilePath, dropFilePathClean }) => (
<div onClick={() => shell.showItemInFolder(dropFilePath)}>
<span className="icon">{folderIcon}</span>
<span className="location">{dropFilePathClean}</span>
const FilePath = ({ dropFilePath, dropFilePathClean, onReset }) => (
<div>
<span className="folder">{folderIcon}</span>
<span
className="location"
onClick={() => shell.showItemInFolder(dropFilePath)}
>
{dropFilePathClean}
</span>
<span className="reset" onClick={onReset}>
{" "}
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="14"
viewBox="0 0 14 14"
>
<g fill="none" fillRule="evenodd">
<circle cx="7" cy="7" r="7" fill="#C8C8C8" />
<path
fill="#FFF"
fillRule="nonzero"
d="M8.06066017,7 L10.0303301,5.03033009 C10.3232233,4.73743687 10.3232233,4.26256313 10.0303301,3.96966991 C9.73743687,3.6767767 9.26256313,3.6767767 8.96966991,3.96966991 L7,5.93933983 L5.03033009,3.96966991 C4.3232233,3.26256313 3.26256313,4.3232233 3.96966991,5.03033009 L5.93933983,7 L3.96966991,8.96966991 C3.6767767,9.26256313 3.6767767,9.73743687 3.96966991,10.0303301 C4.26256313,10.3232233 4.73743687,10.3232233 5.03033009,10.0303301 L7,8.06066017 L8.96966991,10.0303301 C9.6767767,10.7374369 10.7374369,9.6767767 10.0303301,8.96966991 L8.06066017,7 Z"
/>
</g>
</svg>
</span>

<style jsx>
{`
Expand All @@ -33,26 +56,35 @@ const FilePath = ({ dropFilePath, dropFilePathClean }) => (
align-items: center;
}

.icon {
.folder {
width: 20px;
vertical-align: center;
margin-right: 8px;
}

svg {
width: 100%;
}

.location {
font-size: 21px;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
flex: 1;
}

.location:hover {
color: rgba(0, 0, 0, 0.5);
}

.reset {
margin-left: 12px;
}

.reset:hover circle {
fill: #949494;
}

svg {
width: 100%;
}
`}
</style>
</div>
Expand Down
2 changes: 2 additions & 0 deletions renderer/components/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Search extends React.Component {
placeholder,
dropFilePath,
dropFilePathClean,
onReset,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing PropType validation.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

onSubmit,
onChange,
onFocus,
Expand All @@ -22,6 +23,7 @@ class Search extends React.Component {
<FilePath
dropFilePath={dropFilePath}
dropFilePathClean={dropFilePathClean}
onReset={onReset}
/>
)}

Expand Down
3 changes: 2 additions & 1 deletion renderer/containers/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { connect } from "react-redux";

import Search from "./../components/Search";

import { updateSearchQuery } from "./../actions";
import { updateSearchQuery, resetSearch } from "./../actions";

const mapStateToProps = ({ search }) => ({
value: search.searchQuery || search.dropFilePath,
Expand All @@ -16,6 +16,7 @@ const mapDispatchToProps = {
const searchQuery = event.target.value;
dispatch(updateSearchQuery(searchQuery));
},
onReset: resetSearch,
};

export default connect(mapStateToProps, mapDispatchToProps, null, {
Expand Down