Skip to content

Commit

Permalink
fix: paper plane button UI
Browse files Browse the repository at this point in the history
  • Loading branch information
teramotodaiki committed Nov 19, 2019
1 parent 70f9172 commit 89a54f1
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 2 deletions.
29 changes: 29 additions & 0 deletions src/CodeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function CodeView({ code }: CodeViewProps) {
<div className={classNames(style.header, flex.horizontal)}>
<img src={fileInfo.iconUrl} alt="" className={style.icon} />
<div className={style.name}>{fileInfo.name.ja}</div>
<PaperPlane />
</div>
{cellsRef.current.map(cell =>
cell.type === 'code' ? (
Expand Down Expand Up @@ -106,3 +107,31 @@ export function CodeView({ code }: CodeViewProps) {
function formatCodeCell(codeCell: ICodeCell) {
codeCell.value = appendEmptyLine(codeCell.value);
}

function PaperPlane({}) {
const [sent, setSent] = React.useState(false);
const [edited, setEdited] = React.useState(true);

const onClick = React.useCallback(() => {
setSent(true);
setTimeout(() => {
setSent(false);
}, 2000);
}, []);

return (
<div
className={classNames(
style.plane,
sent && style.sent,
!edited && style.hidden
)}
>
<img
src={require('./resources/paperPlane.svg')}
alt="✈"
onClick={onClick}
/>
</div>
);
}
11 changes: 11 additions & 0 deletions src/resources/paperPlane.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 33 additions & 2 deletions src/styles/code-view.scss
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
@import 'color';
@import 'shadow';

$space: 8px;

.header {
position: sticky;
position: -webkit-sticky;
top: 0;
padding-top: 8px;
padding-top: 15px;
background-color: $backgroundColor;
z-index: 10;
align-items: center;
Expand All @@ -14,12 +16,41 @@

.icon {
height: 100%;
margin-right: 8px;
margin-right: $space;
}

.name {
font-size: 21px;
font-weight: 600;
color: $textColor;
margin-right: $space;
}
}

.plane {
flex: 1;
display: flex;
flex-direction: row;
align-items: center;
&.sent {
animation: moveRight 250ms ease-in forwards;
}
&.hidden {
visibility: hidden;
}

& > img {
cursor: pointer;
}
}

@keyframes moveRight {
0% {
transform: translateX(0%);
opacity: 1;
}
100% {
transform: translateX(100%);
opacity: 0;
}
}

0 comments on commit 89a54f1

Please sign in to comment.