mirror of
https://github.com/trezor/trezor-wallet
synced 2025-06-02 06:08:47 +00:00
Merge branch 'styled-components-refactor' of https://github.com/satoshilabs/trezor-wallet into styled-components-refactor
This commit is contained in:
commit
287e7b2a1c
@ -1,58 +0,0 @@
|
|||||||
article {
|
|
||||||
|
|
||||||
nav {
|
|
||||||
.account-tabs {
|
|
||||||
position: relative;
|
|
||||||
display: flex;
|
|
||||||
flex: 1;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: space-between;
|
|
||||||
padding: 0px 28px; // 20px padding arround links
|
|
||||||
max-width: 600px;
|
|
||||||
|
|
||||||
a {
|
|
||||||
font-weight: 500;
|
|
||||||
font-size: 14px;
|
|
||||||
color: @color_text_secondary;
|
|
||||||
margin: 0px 4px;
|
|
||||||
padding: 20px;
|
|
||||||
.hover();
|
|
||||||
|
|
||||||
&.active,
|
|
||||||
&:hover {
|
|
||||||
color: @color_text_primary;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:first-child {
|
|
||||||
margin-left: 0px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&:last-child {
|
|
||||||
margin-right: 0px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.indicator {
|
|
||||||
position: absolute;
|
|
||||||
bottom: -1px;
|
|
||||||
left: 0;
|
|
||||||
width: 100px;
|
|
||||||
height: 2px;
|
|
||||||
background: @color_green_primary;
|
|
||||||
transition: all 0.3s ease-in-out;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
|
||||||
flex: 1;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background: @color_white;
|
|
||||||
|
|
||||||
p {
|
|
||||||
padding: 0px 48px;
|
|
||||||
color: @color_text_secondary;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,7 +1,6 @@
|
|||||||
@import './fonts.less';
|
@import './fonts.less';
|
||||||
@import './colors.less';
|
@import './colors.less';
|
||||||
@import './mixins.less';
|
@import './mixins.less';
|
||||||
@import './content.less';
|
|
||||||
|
|
||||||
@import './reactSelect.less';
|
@import './reactSelect.less';
|
||||||
@import './rcTooltip.less';
|
@import './rcTooltip.less';
|
||||||
|
@ -0,0 +1,76 @@
|
|||||||
|
import styled from 'styled-components';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
import React, { Component } from 'react';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0px;
|
||||||
|
left: 0;
|
||||||
|
width: 100px;
|
||||||
|
height: 2px;
|
||||||
|
background: ${colors.GREEN_PRIMARY};
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
|
`;
|
||||||
|
|
||||||
|
class Indicator extends Component<Props, State> {
|
||||||
|
reposition: () => void;
|
||||||
|
|
||||||
|
state: State;
|
||||||
|
|
||||||
|
constructor(props: Props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
this.state = {
|
||||||
|
style: {
|
||||||
|
width: 0,
|
||||||
|
left: 0,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
this.reposition = this.reposition.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleResize() {
|
||||||
|
this.reposition();
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.reposition();
|
||||||
|
window.addEventListener('resize', this.reposition, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
window.removeEventListener('resize', this.reposition, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
componentDidUpdate(newProps: Props) {
|
||||||
|
this.reposition();
|
||||||
|
}
|
||||||
|
|
||||||
|
reposition() {
|
||||||
|
const tabs = document.querySelector('.account-tabs');
|
||||||
|
if (!tabs) return;
|
||||||
|
const active = tabs.querySelector('.active');
|
||||||
|
if (!active) return;
|
||||||
|
const bounds = active.getBoundingClientRect();
|
||||||
|
|
||||||
|
const left = bounds.left - tabs.getBoundingClientRect().left;
|
||||||
|
|
||||||
|
if (this.state.style.left !== left) {
|
||||||
|
this.setState({
|
||||||
|
style: {
|
||||||
|
width: bounds.width,
|
||||||
|
left,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<Wrapper style={this.state.style}>{ this.props.pathname }</Wrapper>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Indicator;
|
@ -1,104 +1,53 @@
|
|||||||
/* @flow */
|
import styled from 'styled-components';
|
||||||
|
import React from 'react';
|
||||||
|
|
||||||
import React, { Component } from 'react';
|
|
||||||
import { NavLink } from 'react-router-dom';
|
import { NavLink } from 'react-router-dom';
|
||||||
|
import colors from 'config/colors';
|
||||||
|
import Indicator from './components/Indicator';
|
||||||
|
|
||||||
|
const Wrapper = styled.div`
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
flex: 1;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 0px 28px;
|
||||||
|
max-width: 600px;
|
||||||
|
`;
|
||||||
|
|
||||||
type Props = {
|
const StyledNavLink = styled(NavLink)`
|
||||||
pathname: string;
|
font-weight: 500;
|
||||||
}
|
font-size: 14px;
|
||||||
type State = {
|
color: ${colors.TEXT_SECONDARY};
|
||||||
style: {
|
margin: 0px 4px;
|
||||||
width: number,
|
padding: 20px;
|
||||||
left: number
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
class Indicator extends Component<Props, State> {
|
&.active,
|
||||||
reposition: () => void;
|
&:hover {
|
||||||
|
transition: all 0.3s ease-in-out;
|
||||||
state: State;
|
color: ${colors.TEXT_PRIMARY};
|
||||||
|
|
||||||
constructor(props: Props) {
|
|
||||||
super(props);
|
|
||||||
|
|
||||||
this.state = {
|
|
||||||
style: {
|
|
||||||
width: 0,
|
|
||||||
left: 0,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
this.reposition = this.reposition.bind(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
handleResize() {
|
&:first-child {
|
||||||
this.reposition();
|
margin-left: 0px;
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
&:last-child {
|
||||||
this.reposition();
|
margin-right: 0px;
|
||||||
window.addEventListener('resize', this.reposition, false);
|
|
||||||
}
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
componentWillUnmount() {
|
|
||||||
window.removeEventListener('resize', this.reposition, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
componentDidUpdate(newProps: Props) {
|
|
||||||
this.reposition();
|
|
||||||
}
|
|
||||||
|
|
||||||
reposition() {
|
|
||||||
const tabs = document.querySelector('.account-tabs');
|
|
||||||
if (!tabs) return;
|
|
||||||
const active = tabs.querySelector('.active');
|
|
||||||
if (!active) return;
|
|
||||||
const bounds = active.getBoundingClientRect();
|
|
||||||
|
|
||||||
const left = bounds.left - tabs.getBoundingClientRect().left;
|
|
||||||
|
|
||||||
if (this.state.style.left !== left) {
|
|
||||||
this.setState({
|
|
||||||
style: {
|
|
||||||
width: bounds.width,
|
|
||||||
left,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
return (
|
|
||||||
<div className="indicator" style={this.state.style}>{ this.props.pathname }</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const TopNavigationAccount = (props: any) => {
|
const TopNavigationAccount = (props: any) => {
|
||||||
const urlParams = props.match.params;
|
const urlParams = props.match.params;
|
||||||
const basePath = `/device/${urlParams.device}/network/${urlParams.network}/account/${urlParams.account}`;
|
const basePath = `/device/${urlParams.device}/network/${urlParams.network}/account/${urlParams.account}`;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="account-tabs">
|
<Wrapper className="account-tabs">
|
||||||
{/* <NavLink to={ `${basePath}` }>
|
<StyledNavLink exact to={`${basePath}`}>Summary</StyledNavLink>
|
||||||
History
|
<StyledNavLink to={`${basePath}/send`}>Send</StyledNavLink>
|
||||||
</NavLink> */}
|
<StyledNavLink to={`${basePath}/receive`}>Receive</StyledNavLink>
|
||||||
<NavLink exact to={`${basePath}`}>
|
|
||||||
Summary
|
|
||||||
</NavLink>
|
|
||||||
<NavLink to={`${basePath}/send`}>
|
|
||||||
Send
|
|
||||||
</NavLink>
|
|
||||||
<NavLink to={`${basePath}/receive`}>
|
|
||||||
Receive
|
|
||||||
</NavLink>
|
|
||||||
{/* <NavLink to={ `${basePath}/signverify` }>
|
|
||||||
Sign & Verify
|
|
||||||
</NavLink> */}
|
|
||||||
<Indicator pathname={props.match.pathname} />
|
<Indicator pathname={props.match.pathname} />
|
||||||
</div>
|
</Wrapper>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user