mirror of
https://github.com/vercel/commerce.git
synced 2025-07-27 20:21:22 +00:00
.vscode
assets
components
config
framework
lib
api
click-outside
hooks
colors.ts
focus-trap.tsx
get-slug.ts
range-map.ts
search.tsx
to-pixels.ts
usage-warns.ts
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
14 lines
316 B
TypeScript
14 lines
316 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
|