|
1 | 1 | import _ from 'lodash'
|
2 | 2 | import nameClass from '../util/nameClass'
|
3 |
| -import { toRgba } from '../util/withAlphaVariable' |
| 3 | +import { toHsla, toRgba } from '../util/withAlphaVariable' |
4 | 4 |
|
5 | 5 | export default function () {
|
6 | 6 | return function ({ addUtilities, theme, variants }) {
|
7 |
| - function safeCall(callback, defaultValue) { |
| 7 | + const ringColorDefault = (() => { |
| 8 | + const isHSL = (theme('ringColor.DEFAULT') || '').startsWith('hsl') |
| 9 | + const opacity = theme('ringOpacity.DEFAULT', '0.5') |
8 | 10 | try {
|
9 |
| - return callback() |
| 11 | + const [i, j, k] = isHSL |
| 12 | + ? toHsla(theme('ringColor.DEFAULT')) |
| 13 | + : toRgba(theme('ringColor.DEFAULT')) |
| 14 | + return `${isHSL ? 'hsla' : 'rgba'}(${i}, ${j}, ${k}, ${opacity})` |
10 | 15 | } catch (_error) {
|
11 |
| - return defaultValue |
| 16 | + return `rgba(147, 197, 253, ${opacity})` |
12 | 17 | }
|
13 |
| - } |
14 |
| - |
15 |
| - const ringColorDefault = (([r, g, b]) => { |
16 |
| - return `rgba(${r}, ${g}, ${b}, ${theme('ringOpacity.DEFAULT', '0.5')})` |
17 |
| - })(safeCall(() => toRgba(theme('ringColor.DEFAULT')), ['147', '197', '253'])) |
| 18 | + })() |
18 | 19 |
|
19 | 20 | addUtilities(
|
20 | 21 | {
|
|
0 commit comments