UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

1 lines 3.07 kB
{"version":3,"file":"BackgroundImage.cjs","names":["createVarsResolver","getRadius","polymorphicFactory","useProps","Box","useStyles","classes"],"sources":["../../../src/components/BackgroundImage/BackgroundImage.tsx"],"sourcesContent":["import {\n Box,\n BoxProps,\n createVarsResolver,\n getRadius,\n MantineRadius,\n polymorphicFactory,\n PolymorphicFactory,\n StylesApiProps,\n useProps,\n useStyles,\n} from '../../core';\nimport classes from './BackgroundImage.module.css';\n\nexport type BackgroundImageStylesNames = 'root';\nexport type BackgroundImageCssVariables = {\n root: '--bi-radius';\n};\n\nexport interface BackgroundImageProps extends BoxProps, StylesApiProps<BackgroundImageFactory> {\n /** Key of `theme.radius` or any valid CSS value to set border-radius, numbers are converted to rem @default 0 */\n radius?: MantineRadius;\n\n /** Image url */\n src: string;\n}\n\nexport type BackgroundImageFactory = PolymorphicFactory<{\n props: BackgroundImageProps;\n defaultRef: HTMLDivElement;\n defaultComponent: 'div';\n stylesNames: BackgroundImageStylesNames;\n vars: BackgroundImageCssVariables;\n}>;\n\nconst varsResolver = createVarsResolver<BackgroundImageFactory>((_, { radius }) => ({\n root: { '--bi-radius': radius === undefined ? undefined : getRadius(radius) },\n}));\n\nexport const BackgroundImage = polymorphicFactory<BackgroundImageFactory>((_props) => {\n const props = useProps('BackgroundImage', null, _props);\n const {\n classNames,\n className,\n style,\n styles,\n unstyled,\n vars,\n radius,\n src,\n variant,\n attributes,\n ...others\n } = props;\n\n const getStyles = useStyles<BackgroundImageFactory>({\n name: 'BackgroundImage',\n props,\n classes,\n className,\n style,\n classNames,\n styles,\n unstyled,\n attributes,\n vars,\n varsResolver,\n });\n\n return (\n <Box\n variant={variant}\n {...getStyles('root', { style: { backgroundImage: `url(${src})` } })}\n {...others}\n />\n );\n});\n\nBackgroundImage.classes = classes;\nBackgroundImage.varsResolver = varsResolver;\nBackgroundImage.displayName = '@mantine/core/BackgroundImage';\n\nexport namespace BackgroundImage {\n export type Props = BackgroundImageProps;\n export type CssVariables = BackgroundImageCssVariables;\n export type Factory = BackgroundImageFactory;\n export type StylesNames = BackgroundImageStylesNames;\n}\n"],"mappings":";;;;;;;;;;;AAmCA,MAAM,eAAeA,6BAAAA,oBAA4C,GAAG,EAAE,cAAc,EAClF,MAAM,EAAE,eAAe,WAAW,KAAA,IAAY,KAAA,IAAYC,iBAAAA,UAAU,MAAM,EAAE,EAC9E,EAAE;AAEF,MAAa,kBAAkBC,4BAAAA,oBAA4C,WAAW;CACpF,MAAM,QAAQC,kBAAAA,SAAS,mBAAmB,MAAM,MAAM;CACtD,MAAM,EACJ,YACA,WACA,OACA,QACA,UACA,MACA,QACA,KACA,SACA,YACA,GAAG,WACD;CAgBJ,OACE,iBAAA,GAAA,kBAAA,KAACC,YAAAA,KAAD;EACW;EACT,GAjBcC,mBAAAA,UAAkC;GAClD,MAAM;GACN;GACA,SAAA,+BAAA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;GACA;EACF,CAKgB,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,OAAO,IAAI,GAAG,EAAE,CAAC;EACnE,GAAI;CACL,CAAA;AAEL,CAAC;AAED,gBAAgB,UAAUC,+BAAAA;AAC1B,gBAAgB,eAAe;AAC/B,gBAAgB,cAAc"}