Skip to content

Commit

Permalink
[@mantine/core] Title: Fix inline prop being ignored (mantinedev#2182)
Browse files Browse the repository at this point in the history
* [@mantine/core] Title: Fixed `inline` prop

* [@mantine/core] Title: Fixed small error
  • Loading branch information
Narcha authored and nmay231 committed Aug 28, 2022
1 parent 4755e98 commit b46a5dd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/mantine-core/src/Title/Title.styles.ts
Expand Up @@ -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) {
Expand All @@ -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,
},
}));
4 changes: 2 additions & 2 deletions src/mantine-core/src/Title/Title.tsx
Expand Up @@ -22,11 +22,11 @@ const defaultProps: Partial<TitleProps> = {
};

export const Title = forwardRef<HTMLHeadingElement, TitleProps>((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 }
);

Expand Down

0 comments on commit b46a5dd

Please sign in to comment.