cleanup: separate info and description
This commit is contained in:
@@ -1,8 +1,14 @@
|
|||||||
|
import * as React from "react";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
import styled from "styled-components";
|
import styled from "styled-components";
|
||||||
import { s } from "@shared/styles";
|
import { s } from "@shared/styles";
|
||||||
import Text from "~/components/Text";
|
import Text from "~/components/Text";
|
||||||
|
|
||||||
|
const StyledText = styled(Text)`
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-top: 0.125em;
|
||||||
|
`;
|
||||||
|
|
||||||
export const Preview = styled(Link)`
|
export const Preview = styled(Link)`
|
||||||
cursor: var(--pointer);
|
cursor: var(--pointer);
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
@@ -11,15 +17,16 @@ export const Preview = styled(Link)`
|
|||||||
|
|
||||||
export const Title = styled.h2`
|
export const Title = styled.h2`
|
||||||
font-size: 1.25em;
|
font-size: 1.25em;
|
||||||
margin: 2px 0 0 0;
|
margin: 0.125em 0 0 0;
|
||||||
color: ${s("text")};
|
color: ${s("text")};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const Description = styled(Text)`
|
export const Info: React.FC = ({ children }) => (
|
||||||
margin-bottom: 0;
|
<StyledText type="tertiary" size="xsmall">
|
||||||
padding-top: 2px;
|
{children}
|
||||||
`;
|
</StyledText>
|
||||||
|
);
|
||||||
|
|
||||||
export const Summary = styled.div`
|
export const DescriptionContainer = styled.div`
|
||||||
margin-top: 8px;
|
margin-top: 0.5em;
|
||||||
`;
|
`;
|
||||||
@@ -156,7 +156,7 @@ function HoverPreviewInternal({ element, onClose }: Props) {
|
|||||||
<HoverPreviewMention
|
<HoverPreviewMention
|
||||||
url={data.thumbnailUrl}
|
url={data.thumbnailUrl}
|
||||||
title={data.title}
|
title={data.title}
|
||||||
description={data.description}
|
info={data.meta.info}
|
||||||
color={data.meta.color}
|
color={data.meta.color}
|
||||||
/>
|
/>
|
||||||
) : data.type === UnfurlType.Document ? (
|
) : data.type === UnfurlType.Document ? (
|
||||||
@@ -165,7 +165,7 @@ function HoverPreviewInternal({ element, onClose }: Props) {
|
|||||||
url={data.url}
|
url={data.url}
|
||||||
title={data.title}
|
title={data.title}
|
||||||
description={data.description}
|
description={data.description}
|
||||||
summary={data.meta.summary}
|
info={data.meta.info}
|
||||||
/>
|
/>
|
||||||
) : null}
|
) : null}
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import Editor from "~/components/Editor";
|
import Editor from "~/components/Editor";
|
||||||
import Flex from "~/components/Flex";
|
import Flex from "~/components/Flex";
|
||||||
import { Preview, Title, Description, Summary } from "./Components";
|
import { Preview, Title, Info, DescriptionContainer } from "./Components";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
/** Document id associated with the editor, if any */
|
/** Document id associated with the editor, if any */
|
||||||
@@ -10,25 +10,28 @@ type Props = {
|
|||||||
url: string;
|
url: string;
|
||||||
/** Title for the preview card */
|
/** Title for the preview card */
|
||||||
title: string;
|
title: string;
|
||||||
/** Description about recent activity on document */
|
/** Info about last activity on the document */
|
||||||
|
info: string;
|
||||||
|
/** Text preview of document content */
|
||||||
description: string;
|
description: string;
|
||||||
/** Summary of document content */
|
|
||||||
summary: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
function HoverPreviewDocument({ id, url, title, description, summary }: Props) {
|
function HoverPreviewDocument({ id, url, title, info, description }: Props) {
|
||||||
return (
|
return (
|
||||||
<Preview to={url}>
|
<Preview to={url}>
|
||||||
<Flex column>
|
<Flex column>
|
||||||
<Title>{title}</Title>
|
<Title>{title}</Title>
|
||||||
<Description type="tertiary" size="xsmall">
|
<Info>{info}</Info>
|
||||||
{description}
|
<DescriptionContainer>
|
||||||
</Description>
|
|
||||||
<Summary>
|
|
||||||
<React.Suspense fallback={<div />}>
|
<React.Suspense fallback={<div />}>
|
||||||
<Editor key={id} defaultValue={summary} embedsDisabled readOnly />
|
<Editor
|
||||||
|
key={id}
|
||||||
|
defaultValue={description}
|
||||||
|
embedsDisabled
|
||||||
|
readOnly
|
||||||
|
/>
|
||||||
</React.Suspense>
|
</React.Suspense>
|
||||||
</Summary>
|
</DescriptionContainer>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Preview>
|
</Preview>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -2,20 +2,20 @@ import * as React from "react";
|
|||||||
import Avatar from "~/components/Avatar";
|
import Avatar from "~/components/Avatar";
|
||||||
import { AvatarSize } from "~/components/Avatar/Avatar";
|
import { AvatarSize } from "~/components/Avatar/Avatar";
|
||||||
import Flex from "~/components/Flex";
|
import Flex from "~/components/Flex";
|
||||||
import { Preview, Title, Description } from "./Components";
|
import { Preview, Title, Info } from "./Components";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
/** Resource url, avatar url in case of user mention */
|
/** Resource url, avatar url in case of user mention */
|
||||||
url: string;
|
url: string;
|
||||||
/** Title for the preview card*/
|
/** Title for the preview card*/
|
||||||
title: string;
|
title: string;
|
||||||
/** Description about mentioned user's recent activity */
|
/** Info about mentioned user's recent activity */
|
||||||
description: string;
|
info: string;
|
||||||
/** Used for avatar's background color in absence of avatar url */
|
/** Used for avatar's background color in absence of avatar url */
|
||||||
color: string;
|
color: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
function HoverPreviewMention({ url, title, description, color }: Props) {
|
function HoverPreviewMention({ url, title, info, color }: Props) {
|
||||||
return (
|
return (
|
||||||
<Preview to="">
|
<Preview to="">
|
||||||
<Flex gap={12}>
|
<Flex gap={12}>
|
||||||
@@ -29,9 +29,7 @@ function HoverPreviewMention({ url, title, description, color }: Props) {
|
|||||||
/>
|
/>
|
||||||
<Flex column>
|
<Flex column>
|
||||||
<Title>{title}</Title>
|
<Title>{title}</Title>
|
||||||
<Description type="tertiary" size="xsmall">
|
<Info>{info}</Info>
|
||||||
{description}
|
|
||||||
</Description>
|
|
||||||
</Flex>
|
</Flex>
|
||||||
</Flex>
|
</Flex>
|
||||||
</Preview>
|
</Preview>
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ function presentDocument(
|
|||||||
url: document.url,
|
url: document.url,
|
||||||
type: UnfurlType.Document,
|
type: UnfurlType.Document,
|
||||||
title: document.titleWithDefault,
|
title: document.titleWithDefault,
|
||||||
description: presentLastActivityInfoFor(document, viewer),
|
description: document.getSummary(),
|
||||||
meta: {
|
meta: {
|
||||||
id: document.id,
|
id: document.id,
|
||||||
summary: document.getSummary(),
|
info: presentLastActivityInfoFor(document, viewer),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ async function presentMention(
|
|||||||
return {
|
return {
|
||||||
type: UnfurlType.Mention,
|
type: UnfurlType.Mention,
|
||||||
title: user.name,
|
title: user.name,
|
||||||
description: `${lastOnlineInfo} • ${lastViewedInfo}`,
|
|
||||||
thumbnailUrl: user.avatarUrl,
|
thumbnailUrl: user.avatarUrl,
|
||||||
meta: {
|
meta: {
|
||||||
id: user.id,
|
id: user.id,
|
||||||
color: user.color,
|
color: user.color,
|
||||||
|
info: `${lastOnlineInfo} • ${lastViewedInfo}`,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,7 +220,7 @@ export type Unfurl<T = OEmbedType> = {
|
|||||||
url?: string;
|
url?: string;
|
||||||
type: T;
|
type: T;
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description?: string;
|
||||||
thumbnailUrl?: string | null;
|
thumbnailUrl?: string | null;
|
||||||
meta?: Record<string, string>;
|
meta?: Record<string, string>;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user