Skip to content

Commit

Permalink
Merge pull request #1650 from terrestris/tool-menu-adaptability
Browse files Browse the repository at this point in the history
feat: adds auto-adjustability of color contrast  in ToolMenu
  • Loading branch information
AmandaTamanda committed Jun 14, 2024
2 parents 4f8d6b6 + 5c5c41e commit 559aed6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
6 changes: 6 additions & 0 deletions src/bootstrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,12 @@ const renderApp = async () => {
}
});

if (Color(style['--secondaryColor'])?.isLight() && Color(style['--primaryColor'])?.isLight()) {
style['--complementaryColor'] = (Color(style['--complementaryColor']).darken(0.5).hexa());
} else if (Color(style['--secondaryColor'])?.isDark() && Color(style['--primaryColor'])?.isDark()) {
style['--complementaryColor'] = (Color(style['--complementaryColor']).lighten(0.5).hexa());
}

Object.keys(style).forEach((key: any) => {
document.body.style.setProperty(key, style[key as keyof ThemeProperties] as string);
});
Expand Down
9 changes: 8 additions & 1 deletion src/components/ToolMenu/index.less
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

&:hover {
color: var(--secondaryColor);
font-weight: bold;
}

svg {
Expand Down Expand Up @@ -107,8 +108,14 @@
}

&.ant-collapse-item-active {
.ant-collapse-header-text span {
.ant-collapse-header {
background-color: var(--secondaryColor);
}

.ant-collapse-header-text> ,
.ant-collapse-expand-icon {
font-weight: bolder;
color: var(--complementaryColor);
}
}
}
Expand Down

0 comments on commit 559aed6

Please sign in to comment.