Skip to content

Commit

Permalink
feat(deviceImage): add support for PNG images
Browse files Browse the repository at this point in the history
  • Loading branch information
nurikk committed Feb 3, 2024
1 parent 9c8a877 commit 27d94a7
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/device-image/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@ type DeviceImageProps = {
};

type ImageGeneratorFn = (device: Device) => string | undefined;
export const getZ2mDeviceImage = (device: Device): string =>
`https://www.zigbee2mqtt.io/images/devices/${sanitizeZ2MDeviceName(device?.definition?.model)}.jpg`;
const z2mBasePath = 'https://www.zigbee2mqtt.io/images/devices/';

export const getZ2mDeviceImage = (device: Device): string =>`${z2mBasePath}${sanitizeZ2MDeviceName(device?.definition?.model)}.jpg`;
export const getZ2mDeviceImagePng = (device: Device): string =>`${z2mBasePath}${sanitizeZ2MDeviceName(device?.definition?.model)}.png`;
const getConverterDeviceImage = (device: Device): string | undefined => device.definition?.icon;

/* prettier-ignore */
const AVAILABLE_GENERATORS: ImageGeneratorFn[] = [
getConverterDeviceImage,
getZ2mDeviceImagePng,
getZ2mDeviceImage,
() => genericDevice,
];
Expand Down

0 comments on commit 27d94a7

Please sign in to comment.