* POC displaying route in Tabs * WIP Add new menu style Co-authored-by: Krzysztof Jelski <krzysztof-jelski@users.noreply.github.com> * Rename Section to CurrentSection * Add new Tabs styling * WIP Add new menu styling * Set menu's max-width * Add theme styles to menu * Change font size and font weight * Remove r * Remove console logs * Update header styles * Fix settings link padding * Change nav link font weight * Change settings link font weight * Fix settings link paddings * Change nav links font size * Add menu padding * Change badge paddings * Change counter badge color to grey * Add space between menu items * Change chain name font styles * Remove color setting from chain css class * Restore previous whitish color * Move NodeInfo component to .menuContainer * Restore font-weights * Increase the max-width of chain name * Set darker color for TabsSectionDelimiter * Center vertically the left chain icon * Change ChainInfo's elements align and font-sizes * storke highlight * Restore ChainInfo alignment * Revert badges colors * Align right search bar * Change menu styling to prevent menu lists blending * Remove scrollbar from tabs * Resolve problem with search bar placement * Add margin-bottom to settings tab * Change setting padding when there is no badge * Make tab underline to ignore badge and move it under tabs bar * WIP Change menu * Apply contrast to menu hover * Add bright menu hover for chains with dark chain color * Add chain color to menu list * Set menu list hover * Add badge styles * Align items badge Co-authored-by: Krzysztof Jelski <krzysztof-jelski@users.noreply.github.com> Co-authored-by: Krzysztof Jelski <krzysztof@ethworks.io> Co-authored-by: alexcherman <sashacherman@gmail.com> Co-authored-by: Jaco Greeff <jacogr@gmail.com> Co-authored-by: Ewa Kowalska <ewcia.kowalska@gmail.com>
121 lines
2.6 KiB
TypeScript
121 lines
2.6 KiB
TypeScript
// Copyright 2017-2021 @polkadot/apps authors & contributors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
import type { ItemRoute } from './types';
|
|
|
|
import React from 'react';
|
|
import styled from 'styled-components';
|
|
|
|
import { Badge, Icon } from '@polkadot/react-components';
|
|
import { useToggle } from '@polkadot/react-hooks';
|
|
|
|
interface Props {
|
|
className?: string;
|
|
isLink?: boolean;
|
|
isToplevel?: boolean;
|
|
route: ItemRoute;
|
|
}
|
|
|
|
const DUMMY_COUNTER = () => 0;
|
|
|
|
function Item ({ className = '', isLink, isToplevel, route: { Modal, href, icon, name, text, useCounter = DUMMY_COUNTER } }: Props): React.ReactElement<Props> {
|
|
const [isModalVisible, toggleModal] = useToggle();
|
|
const count = useCounter();
|
|
|
|
return (
|
|
<li className={`ui--MenuItem ${className}${count ? ' withCounter' : ''} ${isLink ? 'isLink' : ''} ${isToplevel ? 'topLevel highlight--color-contrast' : ''}`}>
|
|
<a
|
|
href={Modal ? undefined : (href || `#/${name}`)}
|
|
onClick={Modal ? toggleModal : undefined}
|
|
rel='noopener noreferrer'
|
|
target={href ? '_blank' : undefined}
|
|
>
|
|
<Icon icon={icon} />
|
|
{text}
|
|
{!!count && (
|
|
<Badge
|
|
color={'white'}
|
|
info={count}
|
|
/>
|
|
)}
|
|
</a>
|
|
{Modal && isModalVisible && (
|
|
<Modal onClose={toggleModal} />
|
|
)}
|
|
</li>
|
|
);
|
|
}
|
|
|
|
export default React.memo(styled(Item)`
|
|
cursor: pointer;
|
|
position: relative;
|
|
white-space: nowrap;
|
|
|
|
&.topLevel {
|
|
font-size: 1rem;
|
|
font-weight: 400;
|
|
line-height: 1.214rem;
|
|
border-radius: 0.15rem;
|
|
margin-bottom: -5px;
|
|
|
|
a {
|
|
padding: 0.857rem 0.857em 0.786rem 1rem;
|
|
margin-bottom: 1.071rem;
|
|
line-height: 1.214rem;
|
|
border-radius: 0.285rem;
|
|
}
|
|
|
|
&.isActive.highlight--color-contrast {
|
|
font-size: 1.15rem;
|
|
font-weight: 400;
|
|
color: var(--color-text);
|
|
|
|
a {
|
|
background-color: var(--bg-tabs);
|
|
}
|
|
}
|
|
|
|
&.isActive {
|
|
border-radius: 0.15rem 0.15rem 0 0;
|
|
margin-bottom: -5px;
|
|
|
|
a {
|
|
padding: 0.857rem 1.429rem 1.857rem;
|
|
margin-bottom: 0;
|
|
cursor: default;
|
|
}
|
|
|
|
&&.withCounter a {
|
|
padding-right: 3.2rem;
|
|
}
|
|
}
|
|
|
|
.ui--Badge {
|
|
top: 0.7rem;
|
|
}
|
|
}
|
|
|
|
&&.withCounter a {
|
|
padding-right: 3.2rem;
|
|
}
|
|
|
|
a {
|
|
color: inherit !important;
|
|
display: block;
|
|
padding: 0.5rem 1.15rem 0.57rem;
|
|
text-decoration: none;
|
|
font-weight: 400;
|
|
font-size: 1rem;
|
|
line-height: 1.5rem;
|
|
}
|
|
|
|
.ui--Badge {
|
|
position: absolute;
|
|
right: 0.5rem;
|
|
}
|
|
|
|
.ui--Icon {
|
|
margin-right: 0.5rem;
|
|
}
|
|
`);
|