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

Commit

Permalink
fix(components): show highlights without unnecessary margins
Browse files Browse the repository at this point in the history
  • Loading branch information
filipowm committed May 28, 2020
1 parent 59f8d84 commit 1ad8792
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/components/mdxComponents/highlights.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import React from "react"
import styled from "styled-components"
import {useTheme} from "emotion-theming";
import {AlertCircle, AlertOctagon, AlertTriangle} from "react-feather";
import {css} from "@emotion/core";

const skipParagraph = css`
.paragraph {
&:first-child {
margin-top: 0
}
&:last-child {
margin-bottom: 0;
}
}
`

const HighlightWrapper = styled(({className, children}) =>
<div className={className}>
Expand All @@ -18,6 +30,7 @@ display: flex;
border-radius: 4px;
`;


const Highlight = ({children, border, background, font, icon, ...props}) => {
const theme = useTheme();
const borderColor = theme.colors[border];
Expand All @@ -28,7 +41,9 @@ const Highlight = ({children, border, background, font, icon, ...props}) => {
<div css={{marginRight: '16px', lineHeight: 0}}>
{icon({color: borderColor, size: 24})}
</div>
<span>{children}</span>
<div css={skipParagraph}>
{children}
</div>
</HighlightWrapper>
)
};
Expand Down

0 comments on commit 1ad8792

Please sign in to comment.