Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@mantine/core] Title: Fix inline prop being ignored #2182

Merged
merged 2 commits into from Aug 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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