Skip to content

Commit

Permalink
[@mantine/prism] Fix unexpected code margin when used within `Typogra…
Browse files Browse the repository at this point in the history
…phyStylesProvider` (#4452)
  • Loading branch information
mrbnclt committed Jul 4, 2023
1 parent 3b389a0 commit 9cf1c51
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/mantine-prism/src/Prism/Prism.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ export default createStyles(
overflowX: native ? 'auto' : undefined,
borderRadius: theme.fn.radius(radius),
padding: `${theme.spacing.sm} 0`,
marginTop: 0,
marginBottom: 0,

'&.mantine-Prism-code': {
marginTop: 0,
marginBottom: 0,
},
},

copy: {
Expand Down
8 changes: 8 additions & 0 deletions src/mantine-prism/src/Prism/Prism.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,12 @@ describe('@mantine/prism/Prism', () => {
);
expect(withoutLineNumbers.querySelectorAll('.mantine-Prism-lineNumber')).toHaveLength(0);
});

it('renders pre element without top and bottom margin', () => {
const { container: prism } = render(<Prism {...defaultProps} />);
expect(prism.querySelector('.mantine-Prism-code')).toHaveStyle({
marginTop: 0,
marginBottom: 0,
});
});
});

0 comments on commit 9cf1c51

Please sign in to comment.