Skip to content

Commit

Permalink
Merge pull request #249 from cofacts/feature/new-article-details-page-ui
Browse files Browse the repository at this point in the history
Feature/new article details page ui
  • Loading branch information
MrOrz authored May 27, 2020
2 parents 268b1ed + d031e0b commit ba864b8
Show file tree
Hide file tree
Showing 41 changed files with 2,518 additions and 1,684 deletions.
2 changes: 1 addition & 1 deletion components/AppLayout/AppHeader.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const useStyles = makeStyles(theme => ({
position: 'sticky',
height: NAVBAR_HEIGHT + TABS_HEIGHT,
top: 0,
zIndex: 10,
zIndex: theme.zIndex.appBar,
[theme.breakpoints.up('md')]: {
height: NAVBAR_HEIGHT,
},
Expand Down
4 changes: 2 additions & 2 deletions components/ArticleInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ export default function ArticleInfo({ article }) {
<div>
<span className={classes.info}>
{ngettext(
msgid`${replyRequestCount} occurence`,
`${replyRequestCount} occurences`,
msgid`${replyRequestCount} occurrence`,
`${replyRequestCount} occurrences`,
replyRequestCount
)}
</span>
Expand Down
274 changes: 0 additions & 274 deletions components/ArticleReply.js

This file was deleted.

22 changes: 22 additions & 0 deletions components/ArticleReply/CopyButton.js
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;
57 changes: 57 additions & 0 deletions components/ArticleReply/ReplyActions.js
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;
Loading

0 comments on commit ba864b8

Please sign in to comment.