-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'improvement/ARTESCA-10858-empty-state' into q/1.0
- Loading branch information
Showing
26 changed files
with
599 additions
and
355 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,45 @@ | ||
import { DefaultTheme, useTheme } from "styled-components"; | ||
import { hex2RGB } from "../../utils"; | ||
import { useEffect, useRef, useState } from "react"; | ||
import { DefaultTheme, useTheme } from 'styled-components'; | ||
import { hex2RGB } from '../../utils'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
export const useComputeBackgroundColor = () => { | ||
const theme = useTheme(); | ||
const containerRef = useRef<HTMLDivElement | null>(null); | ||
const [backgroundColor, setBackgroundColor] = useState(''); | ||
|
||
useEffect(() => { | ||
containerRef.current && | ||
setBackgroundColor(getBackgroundColor(containerRef.current, theme)); | ||
}, [containerRef,theme]); | ||
|
||
return { | ||
containerRef, | ||
backgroundColor, | ||
}; | ||
const theme = useTheme(); | ||
const containerRef = useRef<HTMLDivElement | null>(null); | ||
const [backgroundColor, setBackgroundColor] = useState(''); | ||
|
||
useEffect(() => { | ||
containerRef.current && | ||
setBackgroundColor(getBackgroundColor(containerRef.current, theme)); | ||
}, [containerRef, theme]); | ||
|
||
return { | ||
containerRef, | ||
backgroundColor, | ||
}; | ||
}; | ||
|
||
export const getBackgroundColor = (element: HTMLElement, theme: DefaultTheme) => { | ||
if (element.parentElement) { | ||
const parentElementBackgroundColor = window.getComputedStyle( | ||
element.parentElement, | ||
)['background-color']; | ||
if (/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/.test(parentElementBackgroundColor) || !window.getComputedStyle(element.parentElement,)['background-color']) { | ||
return getBackgroundColor(element.parentElement, theme); | ||
} else { | ||
const rgbArray = hex2RGB(theme.backgroundLevel2); | ||
if ( | ||
`rgb(${rgbArray[0]}, ${rgbArray[1]}, ${rgbArray[2]})` === | ||
parentElementBackgroundColor | ||
) { | ||
return theme.backgroundLevel3; | ||
} | ||
export const getBackgroundColor = ( | ||
element: HTMLElement, | ||
theme: DefaultTheme, | ||
) => { | ||
if (element.parentElement) { | ||
const parentElementBackgroundColor = window.getComputedStyle( | ||
element.parentElement, | ||
)['background-color']; | ||
if ( | ||
/rgba\([0-9]+, [0-9]+, [0-9]+, 0\)/.test(parentElementBackgroundColor) || | ||
!window.getComputedStyle(element.parentElement)['background-color'] | ||
) { | ||
return getBackgroundColor(element.parentElement, theme); | ||
} else { | ||
const rgbArray = hex2RGB(theme.backgroundLevel2); | ||
if ( | ||
`rgb(${rgbArray[0]}, ${rgbArray[1]}, ${rgbArray[2]})` === | ||
parentElementBackgroundColor | ||
) { | ||
return theme.backgroundLevel3; | ||
} | ||
} | ||
return theme.backgroundLevel2; | ||
}; | ||
} | ||
return theme.backgroundLevel2; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.