-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Edit app (rename, tags, description) done. Search for TODO
- Loading branch information
1 parent
e49e1f7
commit 382396a
Showing
4 changed files
with
303 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import { EditOutlined } from '@ant-design/icons' | ||
import React from 'react' | ||
import Utils from '../../utils/Utils' | ||
import ClickableLink from '../global/ClickableLink' | ||
|
||
interface EditableSpanProps { | ||
titleName: string | ||
onEditClick: () => void | ||
} | ||
|
||
class EditableSpan extends React.Component<EditableSpanProps> { | ||
private className: string | ||
|
||
constructor(props: EditableSpanProps) { | ||
super(props) | ||
this.className = `edit-icon-${Utils.hashCode(props.titleName)}` | ||
} | ||
|
||
handleMouseEnter = (e: React.MouseEvent<HTMLDivElement>) => { | ||
const editIcon = e.currentTarget.querySelector( | ||
'.' + this.className | ||
) as HTMLElement | ||
if (editIcon) editIcon.style.opacity = '1' | ||
} | ||
|
||
handleMouseLeave = (e: React.MouseEvent<HTMLDivElement>) => { | ||
const editIcon = e.currentTarget.querySelector( | ||
'.' + this.className | ||
) as HTMLElement | ||
if (editIcon) editIcon.style.opacity = '0' | ||
} | ||
|
||
render() { | ||
const { titleName: projectName, onEditClick } = this.props | ||
|
||
return ( | ||
<span | ||
style={{ | ||
position: 'relative', | ||
display: 'inline-block', | ||
cursor: 'pointer', | ||
paddingRight: 20, | ||
}} | ||
onClick={onEditClick} | ||
onMouseEnter={this.handleMouseEnter} | ||
onMouseLeave={this.handleMouseLeave} | ||
> | ||
{projectName} | ||
<span | ||
className={this.className} | ||
style={{ | ||
marginLeft: 10, | ||
opacity: 0, | ||
transition: 'opacity 0.3s', | ||
}} | ||
> | ||
<ClickableLink onLinkClicked={onEditClick}> | ||
<EditOutlined /> | ||
</ClickableLink> | ||
</span> | ||
</span> | ||
) | ||
} | ||
} | ||
|
||
export default EditableSpan |
Oops, something went wrong.