({ negative }: { negative: boolean })
| 2755 | } |
| 2756 | |
| 2757 | function handleBgLinear({ negative }: { negative: boolean }) { |
| 2758 | return (candidate: Extract<Candidate, { kind: 'functional' }>) => { |
| 2759 | if (!candidate.value) return |
| 2760 | |
| 2761 | if (candidate.value.kind === 'arbitrary') { |
| 2762 | if (candidate.modifier) return |
| 2763 | |
| 2764 | let value = candidate.value.value |
| 2765 | let type = candidate.value.dataType ?? inferDataType(value, ['angle']) |
| 2766 | |
| 2767 | switch (type) { |
| 2768 | case 'angle': { |
| 2769 | value = negative ? `calc(${value} * -1)` : `${value}` |
| 2770 | |
| 2771 | return [ |
| 2772 | decl('--tw-gradient-position', value), |
| 2773 | decl('background-image', `linear-gradient(var(--tw-gradient-stops,${value}))`), |
| 2774 | ] |
| 2775 | } |
| 2776 | default: { |
| 2777 | if (negative) return |
| 2778 | |
| 2779 | return [ |
| 2780 | decl('--tw-gradient-position', value), |
| 2781 | decl('background-image', `linear-gradient(var(--tw-gradient-stops,${value}))`), |
| 2782 | ] |
| 2783 | } |
| 2784 | } |
| 2785 | } |
| 2786 | |
| 2787 | let value = candidate.value.value |
| 2788 | |
| 2789 | if (!negative && linearGradientDirections.has(value)) { |
| 2790 | value = linearGradientDirections.get(value)! |
| 2791 | } else if (isPositiveInteger(value)) { |
| 2792 | value = negative ? `calc(${value}deg * -1)` : `${value}deg` |
| 2793 | } else { |
| 2794 | return |
| 2795 | } |
| 2796 | |
| 2797 | let interpolationMethod = resolveInterpolationModifier(candidate.modifier) |
| 2798 | |
| 2799 | return [ |
| 2800 | decl('--tw-gradient-position', `${value}`), |
| 2801 | rule('@supports (background-image: linear-gradient(in lab, red, red))', [ |
| 2802 | decl('--tw-gradient-position', `${value} ${interpolationMethod}`), |
| 2803 | ]), |
| 2804 | decl('background-image', `linear-gradient(var(--tw-gradient-stops))`), |
| 2805 | ] |
| 2806 | } |
| 2807 | } |
| 2808 | |
| 2809 | utilities.functional('-bg-linear', handleBgLinear({ negative: true })) |
| 2810 | utilities.functional('bg-linear', handleBgLinear({ negative: false })) |
no test coverage detected