Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/new article details page ui #249

Merged
merged 21 commits into from May 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion components/AppLayout/AppHeader.js
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
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
@@ -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
@@ -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;