diff --git a/components/comment.js b/components/comment.js index 6bc8aead..230797bb 100644 --- a/components/comment.js +++ b/components/comment.js @@ -46,56 +46,53 @@ export default function Comment ({ item, children, replyOpen, includeParent, cac const [reply, setReply] = useState(replyOpen) return ( - <> -
-
-
- -
-
- - @{item.user.name} - - - {timeSince(new Date(item.createdAt))} - \ - {item.sats} sats - {!!item.boost && - <> - \ - {item.boost} boost - } - \ - - {item.ncomments} replies - - {includeParent && } -
-
- {item.text} -
+
+
+ +
+
+ {item.sats} sats + \ + {item.boost} boost + \ + + {item.ncomments} replies + + \ + + @{item.user.name} + + + {timeSince(new Date(item.createdAt))} + {includeParent && }
-
-
- {!noReply && -
setReply(!reply)} - > - {reply ? 'cancel' : 'reply'} -
} - {reply && setReply(replyOpen || false)} cacheId={cacheId} />} - {children} -
- {item.comments && !noComments - ? item.comments.map((item) => ( - - )) - : null} +
+ {item.text}
- +
+ {!noReply && +
setReply(!reply)} + > + {reply ? 'cancel' : 'reply'} +
} + {reply && +
+ setReply(replyOpen || false)} cacheId={cacheId} /> +
} + {children} +
+ {item.comments && !noComments + ? item.comments.map((item) => ( + + )) + : null} +
+
+
) } diff --git a/components/comment.module.css b/components/comment.module.css index bb95a262..4a560d8f 100644 --- a/components/comment.module.css +++ b/components/comment.module.css @@ -3,7 +3,7 @@ } .upvote { - margin-top: .3rem; + margin-top: 9px; } .text { @@ -13,19 +13,17 @@ .reply { font-weight: bold; cursor: pointer; - text-decoration: underline; + padding-bottom: .5rem; } .children { - margin-top: .4rem; + margin-top: .25rem; } .comments { - margin-left: 16px; - margin-top: .5rem; + margin-left: -1rem; } - .skeleton .hunk { width: 100%; } @@ -33,4 +31,22 @@ .skeleton .text { height: 100px; border-radius: .4rem; +} + +.comment { + background-color: rgba(0, 0, 0, 0.03); + border-radius: .4rem; + padding-top: .5rem; + padding-left: .2rem; +} + +.comment:not(:last-child) { + border-bottom-left-radius: 0; + border-bottom-right-radius: 0; +} + +.comment:not(:first-child) { + padding-top: .25rem; + border-top-left-radius: 0; + border-top-right-radius: 0; } \ No newline at end of file diff --git a/components/comments.js b/components/comments.js index b1b82e9c..0d339f26 100644 --- a/components/comments.js +++ b/components/comments.js @@ -3,9 +3,7 @@ import Comment, { CommentSkeleton } from './comment' export default function Comments ({ comments, ...props }) { return comments.map(item => ( -
- -
+ )) } @@ -13,9 +11,7 @@ export function CommentsSkeleton () { const comments = new Array(3).fill(null) return comments.map((_, i) => ( -
- -
+ )) } diff --git a/components/header.js b/components/header.js index b40130d4..4892e42c 100644 --- a/components/header.js +++ b/components/header.js @@ -5,6 +5,7 @@ import Link from 'next/link' import styles from './header.module.css' import { useRouter } from 'next/router' import { Container } from 'react-bootstrap' +import Price from './price' export default function Header () { const [session, loading] = useSession() @@ -54,6 +55,9 @@ export default function Header () { jobs + + + diff --git a/components/item.js b/components/item.js index d9d59b47..5b4e03b6 100644 --- a/components/item.js +++ b/components/item.js @@ -57,7 +57,7 @@ export function ItemSkeleton ({ rank, children }) { {rank}
}
- +
diff --git a/components/item.module.css b/components/item.module.css index 0a86e302..d76c9106 100644 --- a/components/item.module.css +++ b/components/item.module.css @@ -4,6 +4,10 @@ margin-right: .5rem; } +.upvote { + margin-top: 9px; +} + .link { font-size: 80%; white-space: nowrap; @@ -19,7 +23,6 @@ .item { display: flex; justify-content: flex-start; - align-items: center; min-width: 0; } @@ -40,7 +43,7 @@ .rank { font-weight: 600; - align-items: center; + margin-top: 8px; display: flex; color: grey; font-size: 90%; diff --git a/components/price.js b/components/price.js index cdfa5298..b76d9400 100644 --- a/components/price.js +++ b/components/price.js @@ -3,9 +3,14 @@ import useSWR from 'swr' const fetcher = url => fetch(url).then(res => res.json()) export default function Price () { - const { data } = useSWR('https://api.coinbase.com/v2/prices/BTC-USD/spot', fetcher) + const { data } = useSWR( + 'https://api.coinbase.com/v2/prices/BTC-USD/spot', + fetcher, + { + refreshInterval: 30000 + }) if (!data) return null - return data.data.amount + return '$' + data.data.amount } diff --git a/components/reply.module.css b/components/reply.module.css index 9fbca204..b4ffc671 100644 --- a/components/reply.module.css +++ b/components/reply.module.css @@ -1,6 +1,5 @@ .reply { max-width: 600px; - margin-top: 1rem; } .skeleton .input { diff --git a/pages/items/[id].js b/pages/items/[id].js index 79840e8a..1a68ee12 100644 --- a/pages/items/[id].js +++ b/pages/items/[id].js @@ -7,6 +7,7 @@ import Comments, { CommentsSkeleton } from '../../components/comments' import { COMMENTS } from '../../fragments/comments' import { ITEM_FIELDS } from '../../fragments/items' import { gql, useQuery } from '@apollo/client' +import styles from '../../styles/item.module.css' export async function getServerSideProps ({ params: { id } }) { return { @@ -68,7 +69,7 @@ function LoadItem ({ query }) { )} -
+
diff --git a/styles/item.module.css b/styles/item.module.css new file mode 100644 index 00000000..4d3efa70 --- /dev/null +++ b/styles/item.module.css @@ -0,0 +1,11 @@ +.comments { + margin-top: 3rem; +} + +@media only screen and (max-width: 600px) { + .comments { + margin-top: 3rem; + margin-left: -15px; + margin-right: -15px; + } +} \ No newline at end of file