UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 1.05 kB
{"version":3,"file":"spacing-resolver.cjs","names":["rem"],"sources":["../../../../../../src/core/Box/style-props/resolvers/spacing-resolver/spacing-resolver.ts"],"sourcesContent":["import { MantineTheme } from '../../../../MantineProvider';\nimport { rem } from '../../../../utils';\n\nexport function spacingResolver(value: unknown, theme: MantineTheme) {\n if (typeof value === 'number') {\n return rem(value);\n }\n\n if (typeof value === 'string') {\n const mod = value.replace('-', '');\n\n if (!(mod in theme.spacing)) {\n return rem(value);\n }\n\n const variable = `--mantine-spacing-${mod}`;\n return value.startsWith('-') ? `calc(var(${variable}) * -1)` : `var(${variable})`;\n }\n\n return value;\n}\n"],"mappings":";;;AAGA,SAAgB,gBAAgB,OAAgB,OAAqB;AACnE,KAAI,OAAO,UAAU,SACnB,QAAOA,YAAAA,IAAI,MAAM;AAGnB,KAAI,OAAO,UAAU,UAAU;EAC7B,MAAM,MAAM,MAAM,QAAQ,KAAK,GAAG;AAElC,MAAI,EAAE,OAAO,MAAM,SACjB,QAAOA,YAAAA,IAAI,MAAM;EAGnB,MAAM,WAAW,qBAAqB;AACtC,SAAO,MAAM,WAAW,IAAI,GAAG,YAAY,SAAS,WAAW,OAAO,SAAS;;AAGjF,QAAO"}