UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 1.77 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;CAAK;AAChE,MAAM,QAAmB;CAAC;CAAM;CAAM;CAAM;CAAM;CAAK;AAQvD,SAAgB,aAAa,OAAmB,MAAsC;CACpF,MAAM,YAAY,SAAS,KAAA,IAAY,OAAO,IAAI;AAElD,KAAI,SAAS,SAAS,UAAU,CAC9B,QAAO;EACL,UAAU,iBAAiB,UAAU;EACrC,YAAY,iBAAiB,UAAU;EACvC,YAAY,iBAAiB,UAAU;EACxC;UACQ,MAAM,SAAS,UAAU,CAClC,QAAO;EACL,UAAU,2BAA2B,UAAU;EAC/C,YAAY,kBAAkB,MAAM;EACpC,YAAY,kBAAkB,MAAM;EACrC;AAGH,QAAO;EACL,UAAUA,YAAAA,IAAI,UAAU;EACxB,YAAY,kBAAkB,MAAM;EACpC,YAAY,kBAAkB,MAAM;EACrC"}