Merge pull request #5122 from urbit/hm/group-feed-spacing

PostContent: ensure group feed spacing correct
This commit is contained in:
Hunter Miller 2021-07-28 09:46:12 -05:00 committed by GitHub
commit db8bc2d3ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,6 +2,7 @@ import { Col, ColProps } from '@tlon/indigo-react';
import { Post } from '@urbit/api';
import React, { ReactElement, useCallback, useState } from 'react';
import styled, { css } from 'styled-components';
import { useResize } from '~/logic/lib/useResize';
import { GraphContent } from '~/views/landscape/components/Graph/GraphContent';
type TruncateProps = ColProps & {
@ -12,6 +13,7 @@ const TruncatedBox = styled(Col)<TruncateProps>`
display: -webkit-box;
-webkit-box-orient: vertical;
${p => p.truncate && css`
margin-bottom: ${p.theme.space[2]}px;
max-height: 300px;
mask-image: linear-gradient(to bottom, rgba(0,0,0,1) 0%, rgba(0,0,0,1) 60%, transparent 100%);
`}
@ -27,15 +29,13 @@ const PostContent = ({ post, isParent }: PostContentProps): ReactElement => {
const [height, setHeight] = useState(0);
const showFade = !isParent && height >= 300;
const measuredRef = useCallback((node) => {
if (node !== null) {
setHeight(node.getBoundingClientRect().height);
}
}, []);
const resizer = useResize<HTMLDivElement>(useCallback((entry) => {
setHeight(entry.target.getBoundingClientRect().height);
}, []));
return (
<TruncatedBox
ref={measuredRef}
ref={resizer.ref}
truncate={showFade}
display="-webkit-box"
width="90%"