Skip to content

Commit d4ca49e

Browse files
Copilotryan-roemer
andcommitted
Fix Heading component styles not being applied
Changed Heading from extending Text with attrs to being a standalone styled.div with its own attrs. This fixes the issue where attrs from parent components were overriding child component defaults. Co-authored-by: ryan-roemer <445557+ryan-roemer@users.noreply.github.com>
1 parent e18c34e commit d4ca49e

2 files changed

Lines changed: 8 additions & 2 deletions

File tree

packages/spectacle/src/components/typography.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@ describe('<Heading />', () => {
3434
const { getByText } = mountWithTheme(<Heading>Spectacle!</Heading>);
3535
expect(getByText('Spectacle!')).toHaveStyle({ fontSize: 'h1' });
3636
});
37+
38+
it('should apply the secondary color from theme', () => {
39+
const { getByText } = mountWithTheme(<Heading>Spectacle!</Heading>);
40+
expect(getByText('Spectacle!')).toHaveStyle({ color: '#fc6986' });
41+
});
3742
});
3843

3944
describe('<Quote />', () => {

packages/spectacle/src/components/typography.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,16 @@ const Link = styled.a.attrs<CommonTypographyProps & DecorationProps>(
5353
compose(color, typography, space, decoration)
5454
);
5555

56-
const Heading = styled(Text).attrs<CommonTypographyProps>((props) => ({
56+
const Heading = styled.div.attrs<CommonTypographyProps>((props) => ({
5757
color: 'secondary',
5858
fontFamily: 'header',
5959
fontSize: 'h1',
6060
fontWeight: 'bold',
6161
textAlign: 'center',
6262
margin: 1,
63+
padding: 0,
6364
...props
64-
}))<CommonTypographyProps>({});
65+
}))<CommonTypographyProps>(compose(color, typography, space));
6566

6667
const Quote = styled(
6768
Text as FC<

0 commit comments

Comments
 (0)