From b46a5ddef41d42c246f46e0e6c6dd6fa8c0d36b5 Mon Sep 17 00:00:00 2001 From: Narcha <42248344+Narcha@users.noreply.github.com> Date: Sat, 20 Aug 2022 22:02:25 +0200 Subject: [PATCH] [@mantine/core] Title: Fix `inline` prop being ignored (#2182) * [@mantine/core] Title: Fixed `inline` prop * [@mantine/core] Title: Fixed small error --- src/mantine-core/src/Title/Title.styles.ts | 7 ++++--- src/mantine-core/src/Title/Title.tsx | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/mantine-core/src/Title/Title.styles.ts b/src/mantine-core/src/Title/Title.styles.ts index 1db8c3d9631..f8553bd77bc 100644 --- a/src/mantine-core/src/Title/Title.styles.ts +++ b/src/mantine-core/src/Title/Title.styles.ts @@ -7,6 +7,7 @@ export interface TitleStylesParams { element: HeadingElement; size: TitleSize; weight: React.CSSProperties['fontWeight']; + inline: boolean; } function getFontSize(size: TitleSize, element: HeadingElement, theme: MantineTheme) { @@ -19,19 +20,19 @@ function getFontSize(size: TitleSize, element: HeadingElement, theme: MantineThe function getLineHeight(size: TitleSize, element: HeadingElement, theme: MantineTheme) { if (typeof size !== 'undefined' && size in theme.headings.sizes) { - return theme.headings.sizes[element].lineHeight; + return theme.headings.sizes[size].lineHeight; } return theme.headings.sizes[element].lineHeight; } -export default createStyles((theme, { element, weight, size }: TitleStylesParams) => ({ +export default createStyles((theme, { element, weight, size, inline }: TitleStylesParams) => ({ root: { ...theme.fn.fontStyles(), fontFamily: theme.headings.fontFamily, fontWeight: weight || theme.headings.sizes[element].fontWeight || theme.headings.fontWeight, fontSize: getFontSize(size, element, theme), - lineHeight: getLineHeight(size, element, theme), + lineHeight: inline ? 1 : getLineHeight(size, element, theme), margin: 0, }, })); diff --git a/src/mantine-core/src/Title/Title.tsx b/src/mantine-core/src/Title/Title.tsx index d85bc817921..2c191d79af6 100644 --- a/src/mantine-core/src/Title/Title.tsx +++ b/src/mantine-core/src/Title/Title.tsx @@ -22,11 +22,11 @@ const defaultProps: Partial = { }; export const Title = forwardRef((props, ref) => { - const { className, order, children, unstyled, size, weight, ...others } = + const { className, order, children, unstyled, size, weight, inline, ...others } = useComponentDefaultProps('Title', defaultProps, props); const { classes, cx } = useStyles( - { element: `h${order}`, weight, size }, + { element: `h${order}`, weight, size, inline }, { name: 'Title', unstyled } );