4
0
forked from crowetic/commerce
commerce/lib/to-pixels.ts

14 lines
316 B
TypeScript
Raw Normal View History

2020-10-15 11:10:07 -03:00
// 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