Per-chain color highlights (#2336)

* Color overrides

* Adjust

* Keep at default colors (for the time being)

* Swap color to top
This commit is contained in:
Jaco Greeff 2020-03-06 19:18:10 +01:00 committed by GitHub
parent f8c340ae46
commit 87910c435e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
25 changed files with 127 additions and 35 deletions

View File

@ -4,8 +4,8 @@ General config for various services, including settings, external links & types.
- [api](./api) - Here you can add any chain or node-type specific types configuration. When added, it means that when the UI connects to either a runtime with a spec name, or a chain with a specific name, the types will be automatically added to the API as used in the app.
- [links](./links) - These are all links to external providers such as explorers. This information is used anywhere where there is an external lik to determine the providers for these links.
- [logos](./logos) - Logos for chain and node spec specific overrides. This means that when the runtime/chain is detected, the specific logo would be used.
- [settings](./settings) - These are used in dropdowns, specifically under the settings page.
- [ui](./ui) - Logos & color settings for chain and node spec specific overrides. This means that when the runtime/chain is detected, the specific logo would be used.
Customization for each of these are discussed next.
@ -22,17 +22,17 @@ The actual type definitions you should be familiar with, it is exactly the same
We are not going to spend too much time here, since it is generally applicable to explorers and like services. However, should you run one of these services, you can take a look at the existing configs and customize for your setup.
## Logos
These are self-explanatory and config here actually does get used in other parts such as well. Basically the information here is broken down into a couple of catagories -
- chains - Specific logos when connecting to a specific chain
- nodes - Logos that are used when connecting to a specific runtime spec type (catch-all)
- named - These logos are used [settings](./settings)
## Settings
There are 2 general areas of interest here -
- [endpoints](./settings/endpoints) - This is where we can add additional endpoints to appear in the dropdowns. We would like to keep this to mostly live networks, although based on demand can probably extend to a testing-only section as well.
- [ss58](./settings/ss58) - Should you wish to add your ss58Format to the settings dropdown, this is where the configuration take place
## UI
These are self-explanatory and config here actually does get used in other parts such as well. Basically the information here is broken down into a couple of catagories -
- chains - Specific logos when connecting to a specific chain
- nodes - Logos that are used when connecting to a specific runtime spec type (catch-all)
- named - These logos are used [settings](./settings)

View File

@ -0,0 +1,45 @@
// Copyright 2017-2020 @polkadot/apps-config authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
const defaultColor = undefined; // '#f19135'
const emptyColor = '#999';
const chainKulupu = '#003366';
const chainKusama = '#d32e79';
const chainWestend = '#da68a7';
const nodeCentrifuge = '#fcc367';
const nodeEdgeware = '#0a95df';
// overrides based on the actual matched chain name
const chainColors: Record<string, any> = [
['Kulupu', chainKulupu],
['Kusama', chainKusama], // new name after CC3
['Kusama CC1', chainKusama],
['Kusama CC2', chainKusama],
['Kusama CC3', chainKusama],
['Westend', chainWestend]
].reduce((colors, [chain, color]): Record<string, any> => ({
...colors,
[chain.toLowerCase()]: color
}), {});
// overrides based on the actual software node type (all '-' converted to ' ')
const nodeColors: Record<string, any> = [
['centrifuge chain', nodeCentrifuge],
['edgeware node', nodeEdgeware],
['node template', emptyColor],
['parity polkadot', emptyColor],
['substrate node', emptyColor]
].reduce((colors, [node, color]): Record<string, any> => ({
...colors,
[node.toLowerCase().replace(/-/g, ' ')]: color
}), {});
export {
defaultColor,
chainColors,
emptyColor,
nodeColors
};

View File

Before

Width:  |  Height:  |  Size: 589 B

After

Width:  |  Height:  |  Size: 589 B

View File

Before

Width:  |  Height:  |  Size: 364 B

After

Width:  |  Height:  |  Size: 364 B

View File

@ -16,21 +16,24 @@ import nodeSubstrate from './nodes/substrate-hexagon.svg';
import emptyLogo from './empty.svg';
// overrides based on the actual matched chain name
const chainLogos: Record<string, any> = {
kusama: chainKusama, // new name after CC3
'kusama cc1': chainKusama,
'kusama cc2': chainKusama,
'kusama cc3': chainKusama
};
const chainLogos: Record<string, any> = [
['Kusama', chainKusama], // new name after CC3
['Kusama CC1', chainKusama],
['Kusama CC2', chainKusama],
['Kusama CC3', chainKusama]
].reduce((logos, [chain, logo]): Record<string, any> => ({
...logos,
[chain.toLowerCase()]: logo
}), {});
// overrides based on the actual software node type (all '-' converted to ' ')
const nodeLogos: Record<string, any> = [
['centrifuge chain', nodeCentrifuge],
['edgeware node', nodeEdgeware],
['node template', nodeSubstrate],
['parity polkadot', nodePolkadot],
['polkadot js', nodePolkadotJs],
['substrate node', nodeSubstrate]
['Edgeware Node', nodeEdgeware],
['node-template', nodeSubstrate],
['parity-polkadot', nodePolkadot],
['polkadot-js', nodePolkadotJs],
['substrate-node', nodeSubstrate]
].reduce((logos, [node, logo]): Record<string, any> => ({
...logos,
[node.toLowerCase().replace(/-/g, ' ')]: logo

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -4,9 +4,10 @@
import { BareProps as Props } from '@polkadot/react-components/types';
import React, { useEffect, useState } from 'react';
import React, { useEffect, useMemo, useState } from 'react';
import store from 'store';
import styled from 'styled-components';
import { defaultColor, chainColors, emptyColor, nodeColors } from '@polkadot/apps-config/ui/general';
import GlobalStyle from '@polkadot/react-components/styles';
import { useApi, useCall } from '@polkadot/react-hooks';
import Signer from '@polkadot/react-signer';
@ -24,6 +25,10 @@ interface SidebarState {
transition: SideBarTransition;
}
function sanitize (value?: string): string {
return value?.toLowerCase().replace('-', ' ') || '';
}
function WarmUp (): React.ReactElement {
const { api, isApiReady } = useApi();
const fees = useCall<any>(isApiReady ? api.derive.balances?.fees : undefined, []);
@ -42,6 +47,7 @@ function WarmUp (): React.ReactElement {
}
function Apps ({ className }: Props): React.ReactElement<Props> {
const { systemChain, systemName } = useApi();
const [sidebar, setSidebar] = useState<SidebarState>({
isCollapsed: false,
isMenuOpen: false,
@ -49,6 +55,9 @@ function Apps ({ className }: Props): React.ReactElement<Props> {
...store.get('sidebar', {}),
isMenu: window.innerWidth < SIDEBAR_MENU_THRESHOLD
});
const uiHighlight = useMemo((): string => {
return chainColors[sanitize(systemChain)] || nodeColors[sanitize(systemName)] || emptyColor;
}, [systemChain, systemName]);
const { isCollapsed, isMenu, isMenuOpen } = sidebar;
const _setSidebar = (update: Partial<SidebarState>): void =>
@ -71,7 +80,7 @@ function Apps ({ className }: Props): React.ReactElement<Props> {
return (
<>
<GlobalStyle />
<GlobalStyle uiHighlight={defaultColor || uiHighlight} />
<div className={`apps--Wrapper ${isCollapsed ? 'collapsed' : 'expanded'} ${isMenu && 'fixed'} ${isMenuOpen && 'menu-open'} theme--default ${className}`}>
<div
className={`apps--Menu-bg ${isMenuOpen ? 'open' : 'closed'}`}
@ -113,17 +122,20 @@ export default styled(Apps)`
background: #5f5f5f;
border-radius: 0.28571429rem 0 0 0.28571429rem;
color: #eee;
margin-right: 0.25rem;
}
}
a.apps--SideBar-Item-NavLink-active {
background: #fafafa;
border-radius: 0.28571429rem 0 0 0.28571429rem;
// border-bottom: 2px solid transparent;
color: #3f3f3f;
&:hover {
background: #fafafa;
color: #3f3f3f;
margin-right: 0;
}
}
}
@ -188,7 +200,7 @@ export default styled(Apps)`
}
.apps--Menu-bg {
background: rgba(0,0,0,0.6);
background: transparent;
height: 100%;
left: 0;
position: absolute;

View File

@ -130,7 +130,7 @@ export default function Item ({ route, isCollapsed, onClick }: Props): React.Rea
)
: (
<NavLink
activeClassName='apps--SideBar-Item-NavLink-active'
activeClassName='apps--SideBar-Item-NavLink-active ui--highlight--border'
className='apps--SideBar-Item-NavLink'
data-for={`nav-${name}`}
data-tip

View File

@ -70,6 +70,7 @@ function SideBar ({ className, collapse, handleResize, isCollapsed, isMenuOpen,
<NetworkModal onClose={_toggleModal('network')}/>
)}
<div className='apps--SideBar'>
<div className='apps--SideBar-border ui--highlight--border' />
<Menu
secondary
vertical
@ -138,8 +139,8 @@ function SideBar ({ className, collapse, handleResize, isCollapsed, isMenuOpen,
}
</div>
<Responsive
minWidth={SIDEBAR_MENU_THRESHOLD}
className={`apps--SideBar-collapse ${isCollapsed ? 'collapsed' : 'expanded'}`}
minWidth={SIDEBAR_MENU_THRESHOLD}
>
<Button
icon={`angle double ${isCollapsed ? 'right' : 'left'}`}
@ -160,6 +161,8 @@ function SideBar ({ className, collapse, handleResize, isCollapsed, isMenuOpen,
);
}
const sideBorderWidth = '0.125rem';
export default styled(SideBar)`
display: flex;
position: relative;
@ -177,6 +180,7 @@ export default styled(SideBar)`
.apps--SideBar {
align-items: center;
background: #4f4f4f;
box-sizing: border-box;
display: flex;
flex-flow: column;
height: auto;
@ -184,6 +188,14 @@ export default styled(SideBar)`
transition: left 0.3s linear;
width: 100%;
.apps--SideBar-border {
border-top: ${sideBorderWidth} solid transparent;
position: fixed;
left: 0;
right: 0;
top: 0;
}
.ui.vertical.menu {
display: flex;
height: 100vh;

View File

@ -164,7 +164,7 @@ function Account ({ address, className, filter, isFavorite, toggleFavorite }: Pr
<tr className={className}>
<td className='favorite'>
<Icon
className={`${isFavorite && 'isSelected'}`}
className={`${isFavorite && 'ui--highlight--color'}`}
name={isFavorite ? 'star' : 'star outline'}
onClick={_onFavorite}
/>

View File

@ -157,7 +157,7 @@ function Address ({ address, className, filter, isFavorite, toggleFavorite }: Pr
<tr className={className}>
<td className='favorite'>
<Icon
className={`${isFavorite && 'isSelected'}`}
className={`${isFavorite && 'ui--highlight--color'}`}
name={isFavorite ? 'star' : 'star outline'}
onClick={_onFavorite}
/>

View File

@ -136,7 +136,7 @@ export default function Address ({ address, className, filterName, hasQueries, h
<tr className={`${className} ${isAuthor && 'isHighlight'} ${!isVisible && 'staking--hidden'}`}>
<td className='favorite'>
<Icon
className={`${isFavorite && 'isSelected'}`}
className={`${isFavorite && 'ui--highlight--color'}`}
name={isFavorite ? 'star' : 'star outline'}
onClick={_onFavorite}
/>

View File

@ -27,7 +27,7 @@ export default function Validator ({ info: { accountId, bondOther, bondOwn, bond
<tr className={`${isNominating && 'isHighlight'}`}>
<td className='favorite'>
<Icon
className={`${isFavorite && 'isSelected'}`}
className={`${isFavorite && 'ui--highlight--color'}`}
name={isFavorite ? 'star' : 'star outline'}
onClick={_onFavorite}
/>

View File

@ -4,7 +4,7 @@
import React, { useMemo } from 'react';
import styled from 'styled-components';
import { chainLogos, emptyLogo, namedLogos, nodeLogos } from '@polkadot/apps-config/logos';
import { chainLogos, emptyLogo, namedLogos, nodeLogos } from '@polkadot/apps-config/ui/logos';
import { useApi } from '@polkadot/react-hooks';
interface Props {

View File

@ -170,10 +170,6 @@ export default styled(Table)`
border-right-width: 1px;
border-radius: 0 0.25rem 0.25rem 0;
}
&.favorite i.icon.isSelected {
color: darkorange;
}
}
th {

View File

@ -12,7 +12,31 @@ import cssRx from './rx';
import cssSemantic from './semantic';
import cssTheme from './theme';
export default createGlobalStyle`
interface Props {
uiHighlight?: string;
}
export default createGlobalStyle<Props>`
.ui--highlight--all {
/* .theme--default .ui.blue.progress > .bar */
background: ${(props): string => (props.uiHighlight || '#999')} !important;
border-color: ${(props): string => (props.uiHighlight || '#999')} !important;
color: ${(props): string => (props.uiHighlight || '#999')} !important;
}
.ui--highlight--bg {
background: ${(props): string => (props.uiHighlight || '#999')} !important;
}
.ui--highlight--border {
/* .theme--default .ui.menu.tabular > .item.active */
border-color: ${(props): string => (props.uiHighlight || '#999')} !important;
}
.ui--highlight--color {
color: ${(props): string => (props.uiHighlight || '#999')} !important;
}
#root {
color: #4e4e4e;
font-family: sans-serif;