UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 1.78 kB
{"version":3,"file":"get-title-size.cjs","names":["rem"],"sources":["../../../src/components/Title/get-title-size.ts"],"sourcesContent":["import { rem } from '../../core';\nimport type { TitleOrder, TitleSize } from './Title';\n\nconst headings: unknown[] = ['h1', 'h2', 'h3', 'h4', 'h5', 'h6'];\nconst sizes: unknown[] = ['xs', 'sm', 'md', 'lg', 'xl'];\n\nexport interface GetTitleSizeResult {\n fontSize: string;\n fontWeight: string;\n lineHeight: string;\n}\n\nexport function getTitleSize(order: TitleOrder, size?: TitleSize): GetTitleSizeResult {\n const titleSize = size !== undefined ? size : `h${order}`;\n\n if (headings.includes(titleSize)) {\n return {\n fontSize: `var(--mantine-${titleSize}-font-size)`,\n fontWeight: `var(--mantine-${titleSize}-font-weight)`,\n lineHeight: `var(--mantine-${titleSize}-line-height)`,\n };\n } else if (sizes.includes(titleSize)) {\n return {\n fontSize: `var(--mantine-font-size-${titleSize})`,\n fontWeight: `var(--mantine-h${order}-font-weight)`,\n lineHeight: `var(--mantine-h${order}-line-height)`,\n };\n }\n\n return {\n fontSize: rem(titleSize),\n fontWeight: `var(--mantine-h${order}-font-weight)`,\n lineHeight: `var(--mantine-h${order}-line-height)`,\n };\n}\n"],"mappings":";;;AAGA,MAAM,WAAsB;CAAC;CAAM;CAAM;CAAM;CAAM;CAAM;AAAI;AAC/D,MAAM,QAAmB;CAAC;CAAM;CAAM;CAAM;CAAM;AAAI;AAQtD,SAAgB,aAAa,OAAmB,MAAsC;CACpF,MAAM,YAAY,SAAS,KAAA,IAAY,OAAO,IAAI;CAElD,IAAI,SAAS,SAAS,SAAS,GAC7B,OAAO;EACL,UAAU,iBAAiB,UAAU;EACrC,YAAY,iBAAiB,UAAU;EACvC,YAAY,iBAAiB,UAAU;CACzC;MACK,IAAI,MAAM,SAAS,SAAS,GACjC,OAAO;EACL,UAAU,2BAA2B,UAAU;EAC/C,YAAY,kBAAkB,MAAM;EACpC,YAAY,kBAAkB,MAAM;CACtC;CAGF,OAAO;EACL,UAAUA,YAAAA,IAAI,SAAS;EACvB,YAAY,kBAAkB,MAAM;EACpC,YAAY,kBAAkB,MAAM;CACtC;AACF"}