@grafana/ui
Version:
Grafana Components Library
1 lines • 3.18 kB
Source Map (JSON)
{"version":3,"file":"utils.mjs","sources":["../../../../src/components/Text/utils.ts"],"sourcesContent":["import { GrafanaTheme2, ThemeTypographyVariantTypes } from '@grafana/data';\n\nimport { TextProps } from './Text';\n\nexport const customWeight = (weight: TextProps['weight'], theme: GrafanaTheme2): number => {\n switch (weight) {\n case 'bold':\n return theme.typography.fontWeightBold;\n case 'medium':\n return theme.typography.fontWeightMedium;\n case 'light':\n return theme.typography.fontWeightLight;\n case 'regular':\n case undefined:\n return theme.typography.fontWeightRegular;\n }\n};\n\nexport const customColor = (color: TextProps['color'], theme: GrafanaTheme2): string | undefined => {\n switch (color) {\n case 'error':\n return theme.colors.error.text;\n case 'success':\n return theme.colors.success.text;\n case 'info':\n return theme.colors.info.text;\n case 'warning':\n return theme.colors.warning.text;\n default:\n return color ? theme.colors.text[color] : undefined;\n }\n};\n\nexport const customVariant = (\n theme: GrafanaTheme2,\n element: TextProps['element'],\n variant?: keyof ThemeTypographyVariantTypes\n) => {\n if (variant) {\n return theme.typography[variant];\n }\n switch (element) {\n //Span elements does not have a default variant to be able to take the parents style\n case 'span':\n return;\n case 'h1':\n return theme.typography.h1;\n case 'h2':\n return theme.typography.h2;\n case 'h3':\n return theme.typography.h3;\n case 'h4':\n return theme.typography.h4;\n case 'h5':\n return theme.typography.h5;\n case 'h6':\n return theme.typography.h6;\n default:\n return theme.typography.body;\n }\n};\n"],"names":[],"mappings":";AAIO,MAAM,YAAA,GAAe,CAAC,MAAA,EAA6B,KAAA,KAAiC;AACzF,EAAA,QAAQ,MAAA;AAAQ,IACd,KAAK,MAAA;AACH,MAAA,OAAO,MAAM,UAAA,CAAW,cAAA;AAAA,IAC1B,KAAK,QAAA;AACH,MAAA,OAAO,MAAM,UAAA,CAAW,gBAAA;AAAA,IAC1B,KAAK,OAAA;AACH,MAAA,OAAO,MAAM,UAAA,CAAW,eAAA;AAAA,IAC1B,KAAK,SAAA;AAAA,IACL,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