Skip to content

Commit

Permalink
Merge pull request #1775 from bernharduw/fix-paragraph-theme-margins
Browse files Browse the repository at this point in the history
  • Loading branch information
hasparus authored May 26, 2021
2 parents 7d6f6ff + ed79e13 commit 06857c0
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 7 deletions.
7 changes: 1 addition & 6 deletions packages/components/src/Paragraph.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
import React from 'react'
import Box from './Box'

export const Paragraph = React.forwardRef(function Paragraph(
props,
ref
) {
export const Paragraph = React.forwardRef(function Paragraph(props, ref) {
return (
<Box
ref={ref}
as="p"
variant="paragraph"
// reset margin by default: avoid relying on user-agent margins (not aware of theme-ui space scale)
m={0}
__themeKey="text"
__css={{
fontFamily: 'body',
Expand Down
1 change: 0 additions & 1 deletion packages/components/test/__snapshots__/index.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1097,7 +1097,6 @@ exports[`Paragraph renders 1`] = `
font-family: body;
font-weight: body;
line-height: body;
margin: 0;
}
<p
Expand Down
20 changes: 20 additions & 0 deletions packages/components/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,26 @@ describe('Paragraph', () => {
const json = renderJSON(<Paragraph m={margin} />)
expect(json).toHaveStyleRule('margin', margin)
})

test('renders with theme override', () => {
const margin = '8px'
const json = renderJSON(
<ThemeProvider theme={{ text: { paragraph: { margin } } }}>
<Paragraph />
</ThemeProvider>
)
expect(json).toHaveStyleRule('margin', margin)
})

test('renders with theme variant', () => {
const margin = '8px'
const json = renderJSON(
<ThemeProvider theme={{ text: { override: { margin } } }}>
<Paragraph variant="override" />
</ThemeProvider>
)
expect(json).toHaveStyleRule('margin', margin)
})
})

describe('Text', () => {
Expand Down

1 comment on commit 06857c0

@vercel
Copy link

@vercel vercel bot commented on 06857c0 May 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.