Fix bad RGB syntax (#405)

Fixes #404
This commit is contained in:
Jordan Pittman
2025-09-23 09:25:28 -04:00
committed by GitHub
parent 027b439554
commit c0481a8517
2 changed files with 9 additions and 5 deletions
+3 -1
View File
@@ -7,7 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
- Nothing yet!
### Fixed
- Fixed broken color styles ([#405](https://github.com/tailwindlabs/tailwindcss-typography/pull/405))
## [0.5.18] - 2025-09-19
+6 -4
View File
@@ -14,14 +14,16 @@ const opacity = (color, opacity) => {
// values.
let hex = color.replace('#', '')
hex = hex.length === 3 ? hex.replace(/./g, '$&$&') : hex
const r = parseInt(hex.substring(0, 2), 16)
const g = parseInt(hex.substring(2, 4), 16)
const b = parseInt(hex.substring(4, 6), 16)
let r = parseInt(hex.substring(0, 2), 16)
let g = parseInt(hex.substring(2, 4), 16)
let b = parseInt(hex.substring(4, 6), 16)
if (Number.isNaN(r) || Number.isNaN(g) || Number.isNaN(b)) {
return `color-mix(in oklab, ${color} ${opacity}, transparent)`
}
return `rgb(${r}, ${g}, ${b} / ${opacity})`
return `rgb(${r} ${g} ${b} / ${opacity})`
}
let defaultModifiers = {