commerce/site/lib/to-pixels.ts
2022-04-20 15:29:34 +05:00

14 lines
320 B
TypeScript

// Convert numbers or strings to pixel value
// Helpful for styled-jsx when using a prop
// height: ${toPixels(height)}; (supports height={20} and height="20px")
const toPixels = (value: string | number) => {
if (typeof value === 'number') {
return `${value}px`;
}
return value;
};
export default toPixels;