Skip to content

Commit 7afa723

Browse files
committed
Fix rounding when number is whole & ends with 0
Fixes #6
1 parent eed2de7 commit 7afa723

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/styles.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
const defaultTheme = require('tailwindcss/defaultTheme')
22

3-
const rem = (px) => `${px / 16}rem`
4-
const round = (num) => num.toFixed(7).replace(/[.0]+$/, '')
3+
const round = (num) =>
4+
num
5+
.toFixed(7)
6+
.replace(/(\.[0-9]+?)0+$/, '$1')
7+
.replace(/\.0$/, '')
8+
const rem = (px) => `${round(px / 16)}rem`
59
const em = (px, base) => `${round(px / base)}em`
610

711
module.exports = {

0 commit comments

Comments
 (0)