Skip to content

Applied fixes for disappearing icons. #947

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

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const handleClick = func => e => {

function EditIcons({
className,
hovering,
onDelete,
onEdit,
onCreateFile,
Expand All @@ -35,46 +34,44 @@ function EditIcons({
}

return (
<div className={className}>
{(hovering || (window.__isTouch && active) || forceShow) && (
<Container>
{onEdit && (
<Tooltip title="Rename">
<Icon onClick={handleClick(onEdit)}>
<EditIcon />
</Icon>
</Tooltip>
)}
{onUploadFile && (
<Tooltip title="Upload Files">
<Icon onClick={handleClick(onUploadFile)}>
<UploadFileIcon />
</Icon>
</Tooltip>
)}
{onCreateFile && (
<Tooltip title="New File">
<Icon onClick={handleClick(onCreateFile)}>
<AddFileIcon />
</Icon>
</Tooltip>
)}
{onCreateDirectory && (
<Tooltip title="New Directory">
<Icon onClick={handleClick(onCreateDirectory)}>
<AddDirectoryIcon />
</Icon>
</Tooltip>
)}
{onDelete && (
<Tooltip title="Delete">
<Icon onClick={handleClick(onDelete)}>
<CrossIcon />
</Icon>
</Tooltip>
)}
</Container>
)}
<div className={className} style={{ pointerEvents: 'none' }}>
<Container>
{onEdit && (
<Tooltip title="Rename">
<Icon onClick={handleClick(onEdit)}>
<EditIcon style={{ pointerEvents: 'auto' }} />
</Icon>
</Tooltip>
)}
{onUploadFile && (
<Tooltip title="Upload Files">
<Icon onClick={handleClick(onUploadFile)}>
<UploadFileIcon style={{ pointerEvents: 'auto' }} />
</Icon>
</Tooltip>
)}
{onCreateFile && (
<Tooltip title="New File">
<Icon onClick={handleClick(onCreateFile)}>
<AddFileIcon style={{ pointerEvents: 'auto' }} />
</Icon>
</Tooltip>
)}
{onCreateDirectory && (
<Tooltip title="New Directory">
<Icon onClick={handleClick(onCreateDirectory)}>
<AddDirectoryIcon style={{ pointerEvents: 'auto' }} />
</Icon>
</Tooltip>
)}
{onDelete && (
<Tooltip title="Delete">
<Icon onClick={handleClick(onDelete)}>
<CrossIcon style={{ pointerEvents: 'auto' }} />
</Icon>
</Tooltip>
)}
</Container>
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class Entry extends React.PureComponent {
state: props.state || '',
error: false,
selected: false,
hovering: false,
};
}

Expand Down Expand Up @@ -76,9 +75,6 @@ class Entry extends React.PureComponent {

setCurrentModule = () => this.props.setCurrentModule(this.props.id);

onMouseEnter = () => this.setState({ hovering: true });
onMouseLeave = () => this.setState({ hovering: false });

render() {
const {
title,
Expand All @@ -102,7 +98,7 @@ class Entry extends React.PureComponent {
root,
rightColors,
} = this.props;
const { state, error, selected, hovering } = this.state;
const { state, error, selected } = this.state;

const items = [
[
Expand Down Expand Up @@ -151,8 +147,6 @@ class Entry extends React.PureComponent {
nameValidationError={error}
active={active}
editing={state === 'editing' || selected}
onMouseEnter={this.onMouseEnter}
onMouseLeave={this.onMouseLeave}
alternative={isMainModule}
rightColors={rightColors}
noTransition
Expand All @@ -179,10 +173,10 @@ class Entry extends React.PureComponent {
{state === '' && (
<Right>
{isMainModule ? (
<span style={{ opacity: hovering ? 1 : 0 }}>main</span>
<span className="mainIndicator">main</span>
Copy link
Author

Choose a reason for hiding this comment

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

Always rendered, but only visible (via CSS) on :hover of EntryContainer.

) : (
<EditIcons
hovering={hovering}
className="actionIcons"
Copy link
Author

Choose a reason for hiding this comment

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

Always rendered, but only visible (via CSS) on :hover of EntryContainer.

onCreateFile={onCreateModuleClick}
onCreateDirectory={onCreateDirectoryClick}
onUploadFile={onUploadFileClick}
Expand Down
13 changes: 13 additions & 0 deletions packages/app/src/app/pages/Sandbox/Editor/Workspace/elements.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,19 @@ export const getContainerStyles = props => {

export const EntryContainer = styled.span`
${props => getContainerStyles(props)};
.actionIcons,
Copy link
Author

Choose a reason for hiding this comment

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

Here's the magic.

.mainIndicator {
opacity: 0;
}

.actionIcons {
transition: opacity 0.2s;
}

&:hover .mainIndicator,
&:hover .actionIcons {
opacity: 1;
}
`;

export const Container = styled.div`
Expand Down