Skip to content

Commit

Permalink
Add working save button
Browse files Browse the repository at this point in the history
  • Loading branch information
oamaok committed Oct 17, 2021
1 parent a43d4cd commit 5d4277e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
21 changes: 13 additions & 8 deletions client/src/components/header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,30 @@ import * as api from '../../api'
const css = classNames.bind(styles)

const Menu = () => {
const savePatch = async () => {
const res = await api.saveNewPatch(patch)

history.pushState({}, '', `/patch/${res.id}`)
}

return (
<div className={css('menu')}>
<div className={css('item')}>Save patch</div>
{state.user && (
<button className={css('item')} onClick={savePatch}>
Save patch
</button>
)}
{/*
<div className={css('item')}>New patch</div>
<div className={css('item')}>My patches</div>
<div className={css('item')}>Browse all patches</div>
*/}
</div>
)
}

const Header = () => {
const headerState = useState({ isMenuOpen: false })

const savePatch = async () => {
const res = await api.saveNewPatch(patch)

history.pushState({}, '', `/patch/${res.id}`)
}

const openMenu = () => {}

const patchAuthor =
Expand Down
5 changes: 5 additions & 0 deletions client/src/components/header/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
flex-direction: column;
position: absolute;
box-shadow: var(--box-shadow);
width: 200px;
}

.menu::after {
Expand All @@ -55,3 +56,7 @@
.menu .item {
margin-bottom: 10px;
}

.menu .item:last-child {
margin-bottom: 0;
}

0 comments on commit 5d4277e

Please sign in to comment.