Skip to content
This repository has been archived by the owner on Jul 12, 2023. It is now read-only.

Fix comment preview spacing #573

Merged
merged 8 commits into from
May 9, 2022
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion src/components/Preview/Preview.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
import React from 'react';
import { css } from '@emotion/react';

import { Preview } from './Preview';

export default { component: Preview, title: 'Preview' };

export const PreviewStory = () => (
<Preview previewHtml="<p>This is some preview text</p>" />
<div
css={css`
padding: 20px;
width: 700px;
`}
>
<Preview previewHtml="<p>This is some preview text</p>" />
</div>
);
PreviewStory.story = { name: 'default' };

export const PreviewStoryLinebreaks = () => (
<div
css={css`
padding: 20px;
width: 700px;
`}
>
<Preview previewHtml="<p>Hello world!<br>this is a line break </p> <p>this is two</p> <p><br>this is three</p>" />
</div>
);
PreviewStoryLinebreaks.story = { name: 'Preview comment with linebreaks' };
12 changes: 11 additions & 1 deletion src/components/Preview/Preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ const previewStyle = css`
font-family: monospace;
font-size: 1em;
}

/*
todo: this spacing is currently repeated here, on regular comments, and
on TopPick comments; can we factor out the common styling for these
three components?
*/
p {
margin-top: 0;
margin-bottom: ${space[3]}px;
}
`;

const spout = css`
Expand All @@ -53,7 +63,7 @@ const spout = css`
export const Preview = ({ previewHtml }: Props) => (
<>
<div css={spout} />
<p
<div
css={previewStyle}
dangerouslySetInnerHTML={{ __html: previewHtml || '' }}
/>
Expand Down