style: sticky index column (#566)

* style: sticky index column
This commit is contained in:
Carlos Valente
2023-11-02 20:59:30 +01:00
committed by GitHub
parent 2f09d27813
commit 1e90ce4c1d
3 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -10,7 +10,7 @@ type ColourCombination = {
* @param bgColour
* @return {{backgroundColor, color: string}}
*/
export const getAccessibleColour = (bgColour: string): ColourCombination => {
export const getAccessibleColour = (bgColour?: string): ColourCombination => {
if (bgColour) {
try {
const textColor = Color(bgColour).isLight() ? 'black' : '#fffffa';
@@ -44,6 +44,11 @@ $table-header-font-size: calc(1rem - 3px);
min-width: 2rem;
text-align: right;
font-weight: 400;
position: sticky;
left: 0;
z-index: 1;
background-color: $gray-1300;
}
}
@@ -19,9 +19,8 @@ function EventRow(props: PropsWithChildren<EventRowProps>) {
const ownRef = useRef<HTMLTableRowElement>(null);
const [isVisible, setIsVisible] = useState(false);
const bgFallback = 'transparent';
const bgColour = colour || bgFallback;
const textColour = bgColour === bgFallback ? undefined : getAccessibleColour(bgColour);
const bgColour = colour;
const textColour = getAccessibleColour(bgColour);
useLayoutEffect(() => {
const observer = new IntersectionObserver(