12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- import hiDPI from './hiDPI'
- import PolishedError from '../internalHelpers/_errors'
- import type { Styles } from '../types/style'
- export default function retinaImage(
- filename: string,
- backgroundSize?: string,
- extension?: string = 'png',
- retinaFilename?: string,
- retinaSuffix?: string = '_2x',
- ): Styles {
- if (!filename) {
- throw new PolishedError(58)
- }
-
- const ext = extension.replace(/^\./, '')
- const rFilename = retinaFilename
- ? `${retinaFilename}.${ext}`
- : `${filename}${retinaSuffix}.${ext}`
- return {
- backgroundImage: `url(${filename}.${ext})`,
- [hiDPI()]: {
- backgroundImage: `url(${rFilename})`,
- ...(backgroundSize ? { backgroundSize } : {}),
- },
- }
- }
|