File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -87,11 +87,23 @@ const DAISYUI_THEMES = [
8787] ;
8888
8989function oklchToHex ( oklch : string ) : string {
90- const match = oklch . match ( / o k l c h \( ( [ \d . ] + % ? ) \s + ( [ \d . ] + ) \s + ( [ \d . ] + ) \) / ) ;
90+ const match = oklch . match ( / o k l c h \( ( [ \d . ] + % ? ) \s + ( [ \d . ] + % ? ) \s + ( [ \d . ] + ) \) / ) ;
9191 if ( ! match ) return "#000000" ;
9292
93- const l = parseFloat ( match [ 1 ] . replace ( "%" , "" ) ) / 100 ;
94- const c = parseFloat ( match [ 2 ] ) ;
93+ let l : number ;
94+ if ( match [ 1 ] . includes ( "%" ) ) {
95+ l = parseFloat ( match [ 1 ] . replace ( "%" , "" ) ) / 100 ;
96+ } else {
97+ l = parseFloat ( match [ 1 ] ) ;
98+ }
99+
100+ let c : number ;
101+ if ( match [ 2 ] . includes ( "%" ) ) {
102+ c = parseFloat ( match [ 2 ] . replace ( "%" , "" ) ) / 100 ;
103+ } else {
104+ c = parseFloat ( match [ 2 ] ) ;
105+ }
106+
95107 const h = parseFloat ( match [ 3 ] ) ;
96108
97109 const a = c * Math . cos ( ( h * Math . PI ) / 180 ) ;
You can’t perform that action at this time.
0 commit comments