@@ -761,3 +761,70 @@ it('Theme functions can reference values with slashes in brackets', () => {
761
761
` )
762
762
} )
763
763
} )
764
+
765
+ it ( 'works with opacity values defined as a placeholder or a function in when colors is a function' , ( ) => {
766
+ let config = {
767
+ content : [
768
+ {
769
+ raw : html `
770
+ <div
771
+ class= "bg-foo10 bg-foo20 bg-foo30 bg-foo40 bg-foo11 bg-foo21 bg-foo31 bg-foo41"
772
+ > </ div>
773
+ ` ,
774
+ } ,
775
+ ] ,
776
+ theme : {
777
+ colors : ( ) => ( {
778
+ foobar1 : ( { opacityValue } ) => `rgb(255 100 0 / ${ opacityValue ?? '100%' } )` ,
779
+ foobar2 : `rgb(255 100 0 / <alpha-value>)` ,
780
+ foobar3 : {
781
+ 100 : ( { opacityValue } ) => `rgb(255 100 0 / ${ opacityValue ?? '100%' } )` ,
782
+ 200 : `rgb(255 100 0 / <alpha-value>)` ,
783
+ } ,
784
+ } ) ,
785
+ extend : {
786
+ backgroundColor : ( { theme } ) => ( {
787
+ foo10 : theme ( 'colors.foobar1' ) ,
788
+ foo20 : theme ( 'colors.foobar2' ) ,
789
+ foo30 : theme ( 'colors.foobar3.100' ) ,
790
+ foo40 : theme ( 'colors.foobar3.200' ) ,
791
+ foo11 : theme ( 'colors.foobar1 / 50%' ) ,
792
+ foo21 : theme ( 'colors.foobar2 / 50%' ) ,
793
+ foo31 : theme ( 'colors.foobar3.100 / 50%' ) ,
794
+ foo41 : theme ( 'colors.foobar3.200 / 50%' ) ,
795
+ } ) ,
796
+ } ,
797
+ } ,
798
+ }
799
+
800
+ return run ( '@tailwind utilities' , config ) . then ( ( result ) => {
801
+ expect ( result . css ) . toMatchCss ( css `
802
+ .bg-foo10 {
803
+ background-color : rgb (255 100 0 / 100% );
804
+ }
805
+ .bg-foo20 {
806
+ --tw-bg-opacity : 1 ;
807
+ background-color : rgb (255 100 0 / var (--tw-bg-opacity ));
808
+ }
809
+ .bg-foo30 {
810
+ background-color : rgb (255 100 0 / 100% );
811
+ }
812
+ .bg-foo40 {
813
+ --tw-bg-opacity : 1 ;
814
+ background-color : rgb (255 100 0 / var (--tw-bg-opacity ));
815
+ }
816
+ .bg-foo11 {
817
+ background-color : rgb (255 100 0 / 50% );
818
+ }
819
+ .bg-foo21 {
820
+ background-color : rgb (255 100 0 / 50% );
821
+ }
822
+ .bg-foo31 {
823
+ background-color : rgb (255 100 0 / 50% );
824
+ }
825
+ .bg-foo41 {
826
+ background-color : rgb (255 100 0 / 50% );
827
+ }
828
+ ` )
829
+ } )
830
+ } )
0 commit comments