Contrast menu on brightness (#3701)
* Add contrast colors on menu (dark vs light) * Adjust contrast detection * Adjust contrasts * Don't match, use indexes
This commit is contained in:
parent
59b24e9f1a
commit
90b1f12c04
@ -4,7 +4,7 @@
|
||||
|
||||
// defaults
|
||||
const defaultColor = undefined; // '#f19135'
|
||||
const emptyColor = '#999';
|
||||
const emptyColor = '#99999';
|
||||
|
||||
// based on chain name
|
||||
// alphabetical
|
||||
@ -13,7 +13,7 @@ const chainCrust = '#ff8812';
|
||||
const chainKulupu = '#003366';
|
||||
const chainPhala = '#4dc56a';
|
||||
const chainPolkadot = '#e6007a';
|
||||
const chainKusama = '#000'; // '#d32e79';
|
||||
const chainKusama = '#000000';
|
||||
const chainRocco = '#6f36dc';
|
||||
const chainRoccoAcala = '#173DC9';
|
||||
const chainRoccoDarwinia = '#7C30DD';
|
||||
|
||||
@ -28,7 +28,7 @@ function ChainInfo ({ className }: Props): React.ReactElement<Props> {
|
||||
return (
|
||||
<div className={className}>
|
||||
<div
|
||||
className={`apps--SideBar-logo-inner${canToggle ? ' isClickable' : ''}`}
|
||||
className={`apps--SideBar-logo-inner${canToggle ? ' isClickable' : ''} highlight--color-contrast`}
|
||||
onClick={toggleEndpoints}
|
||||
>
|
||||
<ChainImg />
|
||||
|
||||
@ -29,7 +29,7 @@ function Grouping ({ className = '', name, routes }: Props): React.ReactElement<
|
||||
|
||||
return (
|
||||
<li className={className}>
|
||||
<div className='groupHdr'>
|
||||
<div className='groupHdr highlight--color-contrast'>
|
||||
<span>{name}</span>
|
||||
<Icon icon='caret-down' />
|
||||
</div>
|
||||
@ -78,11 +78,10 @@ export default React.memo(styled(Grouping)`
|
||||
}
|
||||
|
||||
&:hover {
|
||||
color: #4e4e4e;
|
||||
|
||||
.groupHdr,
|
||||
.groupMenu li {
|
||||
background: #fff;
|
||||
color: #4e4e4e;
|
||||
}
|
||||
|
||||
.groupHdr {
|
||||
|
||||
@ -22,7 +22,7 @@ function Item ({ className = '', isToplevel, route: { Modal, href, icon, name, t
|
||||
const count = useCounter();
|
||||
|
||||
return (
|
||||
<li className={`${className}${count ? ' withCounter' : ''} ${isToplevel ? 'topLevel' : 'highlight--hover-color'}`}>
|
||||
<li className={`${className}${count ? ' withCounter' : ''} ${isToplevel ? 'topLevel highlight--color-contrast' : 'highlight--hover-color'}`}>
|
||||
<a
|
||||
href={Modal ? undefined : (href || `#/${name}`)}
|
||||
onClick={Modal ? toggleModal : undefined}
|
||||
|
||||
@ -18,7 +18,7 @@ function NodeInfo ({ className = '' }: Props): React.ReactElement<Props> {
|
||||
const { api, isApiReady } = useApi();
|
||||
|
||||
return (
|
||||
<div className={`${className} media--1400`}>
|
||||
<div className={`${className} media--1400 highlight--color-contrast`}>
|
||||
{isApiReady && (
|
||||
<div>
|
||||
<NodeName />
|
||||
|
||||
@ -161,14 +161,13 @@ function Menu ({ className = '' }: Props): React.ReactElement<Props> {
|
||||
|
||||
export default React.memo(styled(Menu)`
|
||||
align-items: center;
|
||||
color: #f5f3f1;
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 0;
|
||||
z-index: 220;
|
||||
|
||||
&.isLoading {
|
||||
background: #888 !important;
|
||||
background: #999 !important;
|
||||
|
||||
&:before {
|
||||
filter: grayscale(1);
|
||||
|
||||
@ -34,7 +34,7 @@ function Badge ({ className = '', color = 'normal', hover, icon, info, isSmall,
|
||||
return (
|
||||
<div
|
||||
{...extraProps}
|
||||
className={`ui--Badge${hover ? ' isTooltip' : ''}${isSmall ? ' isSmall' : ''}${onClick ? ' isClickable' : ''}${isHighlight ? ' highlight--bg' : ''}${color === 'counterInvert' ? ' highlight--color' : ''} ${color}Color ${className}`}
|
||||
className={`ui--Badge${hover ? ' isTooltip' : ''}${isSmall ? ' isSmall' : ''}${onClick ? ' isClickable' : ''}${isHighlight ? ' highlight--bg' : ''}${color === 'counterInvert' ? ' highlight--bg-contrast highlight--color' : ''} ${color}Color ${className}`}
|
||||
onClick={onClick}
|
||||
>
|
||||
{info || (icon && <Icon icon={icon} />)}
|
||||
@ -102,10 +102,6 @@ export default React.memo(styled(Badge)`
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
&.counterInvertColor {
|
||||
background: #eeedec;
|
||||
}
|
||||
|
||||
&.grayColor {
|
||||
background: #eeedec !important;
|
||||
color: #aaa9a8;
|
||||
|
||||
@ -15,10 +15,24 @@ interface Props {
|
||||
uiHighlight?: string;
|
||||
}
|
||||
|
||||
const defaultHighlight = '#f19135'; // #999
|
||||
const BRIGHTNESS = 128 + 32;
|
||||
const FACTORS = [0.2126, 0.7152, 0.0722];
|
||||
const PARTS = [0, 2, 4];
|
||||
|
||||
const getHighlight = (props: Props): string =>
|
||||
(props.uiHighlight || defaultHighlight);
|
||||
const defaultHighlight = '#f19135'; // '#f19135'; // #999
|
||||
|
||||
function getHighlight (props: Props): string {
|
||||
return (props.uiHighlight || defaultHighlight);
|
||||
}
|
||||
|
||||
function getContrast (props: Props): string {
|
||||
const hc = getHighlight(props).replace('#', '').toLowerCase();
|
||||
const brightness = PARTS.reduce((b, p, index) => b + (parseInt(hc.substr(p, 2), 16) * FACTORS[index]), 0);
|
||||
|
||||
return brightness > BRIGHTNESS
|
||||
? 'rgba(47, 45, 43, 0.9)'
|
||||
: 'rgba(247, 245, 243, 0.9)';
|
||||
}
|
||||
|
||||
export default createGlobalStyle<Props>`
|
||||
.highlight--all {
|
||||
@ -39,6 +53,10 @@ export default createGlobalStyle<Props>`
|
||||
background: ${getHighlight} !important;
|
||||
}
|
||||
|
||||
.highlight--bg-contrast {
|
||||
background: ${getContrast};
|
||||
}
|
||||
|
||||
.highlight--bg-faint,
|
||||
.highlight--bg-light {
|
||||
background: white;
|
||||
@ -72,6 +90,10 @@ export default createGlobalStyle<Props>`
|
||||
color: ${getHighlight} !important;
|
||||
}
|
||||
|
||||
.highlight--color-contrast {
|
||||
color: ${getContrast};
|
||||
}
|
||||
|
||||
.highlight--fill {
|
||||
fill: ${getHighlight} !important;
|
||||
}
|
||||
@ -107,7 +129,7 @@ export default createGlobalStyle<Props>`
|
||||
&.withoutLink:not(.isDisabled) {
|
||||
.ui--Icon {
|
||||
background: ${getHighlight};
|
||||
color: #f5f5f4;
|
||||
color: ${getContrast};
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +150,7 @@ export default createGlobalStyle<Props>`
|
||||
&:hover:not(.isDisabled):not(.isReadOnly),
|
||||
&.isSelected {
|
||||
background: ${getHighlight};
|
||||
color: #f5f5f4;
|
||||
color: ${getContrast};
|
||||
text-shadow: none;
|
||||
|
||||
&:not(.isIcon),
|
||||
@ -145,7 +167,7 @@ export default createGlobalStyle<Props>`
|
||||
&.withoutLink:not(.isDisabled) {
|
||||
&:hover {
|
||||
.ui--Icon {
|
||||
color: #f5f5f4;
|
||||
color: ${getContrast};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user