Skip to content

Commit

Permalink
fix(components): allow themed Paragraph margins
Browse files Browse the repository at this point in the history
  • Loading branch information
bernharduw committed May 25, 2021
1 parent e85cbd0 commit ed79e13
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

0 comments on commit ed79e13

Please sign in to comment.