@@ -4,6 +4,7 @@ import { useUser } from '../context/UserContext';
4
4
import { useAuth } from '../context/AuthContext' ;
5
5
import { getUserById } from '../../APIFunctions/User' ;
6
6
import { useBackgroundColor } from '../context/BackgroundColorContext' ;
7
+ import { getIconTextColor } from '../../APIFunctions/Profile' ;
7
8
8
9
export default function UserNavbar ( props ) {
9
10
const { user } = useUser ( ) ;
@@ -37,35 +38,6 @@ export default function UserNavbar(props) {
37
38
} ;
38
39
} , [ authenticated , user , backgroundColorVersion ] ) ;
39
40
40
- // using w3c guidelines
41
- function getIconTextColor ( color ) {
42
- if ( typeof color !== 'string' ) {
43
- throw new TypeError ( 'color must be a string' ) ;
44
- }
45
- if ( color == '' || color == '#2a323c' ) {
46
- return '#FFFFFF' ;
47
- }
48
- // get rgb values 0-255
49
- const r = parseInt ( color . substring ( 1 , 3 ) , 16 ) ;
50
- const g = parseInt ( color . substring ( 3 , 5 ) , 16 ) ;
51
- const b = parseInt ( color . substring ( 5 , 7 ) , 16 ) ;
52
- // linearize the colors
53
- const colors = [ r / 255.0 , g / 255.0 , b / 255.0 ] ;
54
- const c = colors . map ( ( color ) => {
55
- if ( color <= 0.04045 ) {
56
- return color / 12.92 ;
57
- }
58
- return Math . pow ( ( ( color + 0.055 ) / 1.055 ) , 2.4 ) ;
59
- } ) ;
60
- // luminance value
61
- const L = 0.2126 * c [ 0 ] + 0.7152 * c [ 1 ] + 0.0722 * c [ 2 ] ;
62
- // threshold of 0.179
63
- if ( L > 0.179 ) {
64
- return '#000000' ;
65
- }
66
- return '#FFFFFF' ;
67
- }
68
-
69
41
let initials = '' ;
70
42
if ( user && user . firstName && user . lastName ) {
71
43
initials = user . firstName [ 0 ] + user . lastName [ 0 ] ;
0 commit comments