File tree Expand file tree Collapse file tree 7 files changed +31
-14
lines changed
nucleus/src/components/listbox/assets Expand file tree Collapse file tree 7 files changed +31
-14
lines changed Original file line number Diff line number Diff line change 1
- import Color from '../../../utils/color ' ;
1
+ import { Color } from '@nebula.js/theme ' ;
2
2
import { resolveBgColor , resolveBgImage } from '../../../utils/style/styling-props' ;
3
3
4
4
const LIGHT = '#FFF' ;
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import paletteResolverFn from './palette-resolver';
6
6
import styleResolverFn from './style-resolver' ;
7
7
import contrasterFn from './contraster/contraster' ;
8
8
import luminance from './contraster/luminance' ;
9
+ import Color from './utils/color/color' ;
9
10
10
11
export default function theme ( ) {
11
12
let resolvedThemeJSON ;
@@ -186,3 +187,5 @@ export default function theme() {
186
187
internalAPI,
187
188
} ;
188
189
}
190
+
191
+ export { Color } ;
Original file line number Diff line number Diff line change
1
+ import Color from './utils/color/color' ;
2
+
1
3
/**
2
4
* @interface Theme~ScalePalette
3
5
* @property {string } key
@@ -82,21 +84,33 @@ export default function theme(resolvedTheme) {
82
84
if ( ! somethingIsValid ) {
83
85
return undefined ;
84
86
}
85
- // eslint-disable-next-line no-param-reassign
86
- shift = ! ! shift ;
87
- if ( c ?. index < 0 || typeof c ?. index === 'undefined' ) {
88
- return c . color ;
89
- }
90
- if ( typeof uiPalette === 'undefined' ) {
91
- uiPalette = this . uiPalettes ( ) [ 0 ] || false ;
92
- }
93
- if ( ! uiPalette ) {
94
- return c . color ;
87
+ const getColor = ( ) => {
88
+ // eslint-disable-next-line no-param-reassign
89
+ shift = ! ! shift ;
90
+ if ( c ?. index < 0 || typeof c ?. index === 'undefined' ) {
91
+ return c . color ;
92
+ }
93
+ if ( typeof uiPalette === 'undefined' ) {
94
+ uiPalette = this . uiPalettes ( ) [ 0 ] || false ;
95
+ }
96
+ if ( ! uiPalette ) {
97
+ return c . color ;
98
+ }
99
+ if ( typeof uiPalette . colors [ c . index - shift ] === 'undefined' ) {
100
+ return c . color ;
101
+ }
102
+ return uiPalette . colors [ c . index - shift ] ;
103
+ } ;
104
+ const color = getColor ( ) ;
105
+ if ( c . alpha === undefined || c . alpha >= 1 || c . alpha < 0 ) {
106
+ return color ;
95
107
}
96
- if ( typeof uiPalette . colors [ c . index - shift ] === 'undefined' ) {
97
- return c . color ;
108
+ const rgbaColor = new Color ( color ) ;
109
+ rgbaColor . setAlpha ( c . alpha ) ;
110
+ if ( rgbaColor . isInvalid ( ) ) {
111
+ return color ;
98
112
}
99
- return uiPalette . colors [ c . index - shift ] ;
113
+ return rgbaColor . toRGBA ( ) ;
100
114
} ,
101
115
} ;
102
116
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
You can’t perform that action at this time.
0 commit comments