-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #249 from cofacts/feature/new-article-details-page-ui
Feature/new article details page ui
- Loading branch information
Showing
41 changed files
with
2,518 additions
and
1,684 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
This file was deleted.
Oops, something went wrong.
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,22 @@ | ||
import React, { useRef, useEffect } from 'react'; | ||
import { Button } from '@material-ui/core'; | ||
import ClipboardJS from 'clipboard'; | ||
import { t } from 'ttag'; | ||
|
||
const CopyButton = React.memo(({ content = '', onClick = () => {} }) => { | ||
const copyBtnRef = useRef(null); | ||
|
||
useEffect(() => { | ||
const clipboard = new ClipboardJS(copyBtnRef.current, { | ||
text: () => content, | ||
}); | ||
clipboard.on('success', () => onClick()); | ||
return () => clipboard.destroy(); | ||
}, [copyBtnRef.current, content, onClick]); | ||
|
||
return <Button ref={copyBtnRef}>{t`Copy`}</Button>; | ||
}); | ||
|
||
CopyButton.displayName = 'CopyButton'; | ||
|
||
export default CopyButton; |
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,57 @@ | ||
import { useState } from 'react'; | ||
import { Button, Menu, MenuItem } from '@material-ui/core'; | ||
import { makeStyles } from '@material-ui/core/styles'; | ||
import MoreVertIcon from '@material-ui/icons/MoreVert'; | ||
|
||
const useStyles = makeStyles(theme => ({ | ||
button: { | ||
minWidth: 0, | ||
padding: '8px 14px', | ||
color: ({ open }) => | ||
open ? theme.palette.primary[500] : theme.palette.secondary[500], | ||
}, | ||
menu: { | ||
marginTop: 40, | ||
}, | ||
})); | ||
|
||
const ReplyActions = ({ disabled, handleAction, actionText }) => { | ||
const [anchorEl, setAnchorEl] = useState(null); | ||
|
||
const classes = useStyles({ open: !!anchorEl }); | ||
|
||
const handleClick = event => { | ||
setAnchorEl(event.currentTarget); | ||
}; | ||
|
||
const handleClose = () => { | ||
setAnchorEl(null); | ||
}; | ||
|
||
return ( | ||
<> | ||
<Button | ||
aria-controls="actions" | ||
aria-haspopup="true" | ||
className={classes.button} | ||
onClick={handleClick} | ||
> | ||
<MoreVertIcon /> | ||
</Button> | ||
<Menu | ||
id="actions" | ||
anchorEl={anchorEl} | ||
keepMounted | ||
open={!!anchorEl} | ||
onClose={handleClose} | ||
className={classes.menu} | ||
> | ||
<MenuItem disabled={disabled} onClick={handleAction}> | ||
{actionText} | ||
</MenuItem> | ||
</Menu> | ||
</> | ||
); | ||
}; | ||
|
||
export default ReplyActions; |
Oops, something went wrong.