Skip to content

Commit 565fe7d

Browse files
authored
Merge pull request #7 from tailwindcss/bugfix-rounding
Fix rounding when number is whole & ends with 0
2 parents eed2de7 + 7afa723 commit 565fe7d

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)