Redux #115
12 changed files with 63 additions and 87 deletions
|
@ -1,21 +0,0 @@
|
||||||
import React from 'react'
|
|
||||||
import {
|
|
||||||
connect,
|
|
||||||
} from 'react-redux'
|
|
||||||
import {
|
|
||||||
selectCurrentPage,
|
|
||||||
} from 'selectors/app'
|
|
||||||
import {
|
|
||||||
doNavigate,
|
|
||||||
} from 'actions/app'
|
|
||||||
import NavMain from './view'
|
|
||||||
|
|
||||||
const select = (state) => ({
|
|
||||||
currentPage: selectCurrentPage(state)
|
|
||||||
})
|
|
||||||
|
|
||||||
const perform = (dispatch) => ({
|
|
||||||
navigate: (path) => dispatch(doNavigate(path))
|
|
||||||
})
|
|
||||||
|
|
||||||
export default connect(select, perform)(NavMain)
|
|
|
@ -1,22 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
|
|
||||||
export const NavMain = (props) => {
|
|
||||||
const {
|
|
||||||
links,
|
|
||||||
currentPage,
|
|
||||||
navigate,
|
|
||||||
} = props
|
|
||||||
|
|
||||||
return (
|
|
||||||
<nav className="sub-header">{
|
|
||||||
Object.keys(links).map((link) => {
|
|
||||||
console.log(link + " vs " + currentPage);
|
|
||||||
return <a href="#" onClick={() => navigate(link)} key={link} className={link == currentPage ? 'sub-header-selected' : 'sub-header-unselected' }>
|
|
||||||
{links[link]}
|
|
||||||
</a>
|
|
||||||
})
|
|
||||||
}</nav>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NavMain
|
|
|
@ -1,7 +0,0 @@
|
||||||
import React from 'react'
|
|
||||||
import {
|
|
||||||
connect,
|
|
||||||
} from 'react-redux'
|
|
||||||
import NavSettings from './view'
|
|
||||||
|
|
||||||
export default connect(null, null)(NavSettings)
|
|
|
@ -1,11 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import NavMain from 'component/navMain'
|
|
||||||
|
|
||||||
export const NavSettings = () => {
|
|
||||||
return <NavMain links={{
|
|
||||||
'settings': 'Settings',
|
|
||||||
'help' : 'Help'
|
|
||||||
}} />;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NavSettings
|
|
|
@ -1,7 +0,0 @@
|
||||||
import React from 'react'
|
|
||||||
import {
|
|
||||||
connect,
|
|
||||||
} from 'react-redux'
|
|
||||||
import NavWallet from './view'
|
|
||||||
|
|
||||||
export default connect(null, null)(NavWallet)
|
|
|
@ -1,13 +0,0 @@
|
||||||
import React from 'react';
|
|
||||||
import NavMain from 'component/navMain'
|
|
||||||
|
|
||||||
export const NavWallet = () => {
|
|
||||||
return <NavMain links={{
|
|
||||||
'wallet': 'Overview',
|
|
||||||
'send': 'Send',
|
|
||||||
'receive': 'Receive',
|
|
||||||
'rewards': 'Rewards'
|
|
||||||
}} />
|
|
||||||
}
|
|
||||||
|
|
||||||
export default NavWallet
|
|
23
ui/js/component/subHeader/index.js
Normal file
23
ui/js/component/subHeader/index.js
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
import React from 'react'
|
||||||
|
import {
|
||||||
|
connect,
|
||||||
|
} from 'react-redux'
|
||||||
|
import {
|
||||||
|
selectCurrentPage,
|
||||||
|
selectHeaderLinks,
|
||||||
|
} from 'selectors/app'
|
||||||
|
import {
|
||||||
|
doNavigate,
|
||||||
|
} from 'actions/app'
|
||||||
|
import SubHeader from './view'
|
||||||
|
|
||||||
|
const select = (state, props) => ({
|
||||||
|
currentPage: selectCurrentPage(state),
|
||||||
|
subLinks: selectHeaderLinks(state),
|
||||||
|
})
|
||||||
|
|
||||||
|
const perform = (dispatch) => ({
|
||||||
|
navigate: (path) => dispatch(doNavigate(path)),
|
||||||
|
})
|
||||||
|
|
||||||
|
export default connect(select, perform)(SubHeader)
|
28
ui/js/component/subHeader/view.jsx
Normal file
28
ui/js/component/subHeader/view.jsx
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
import React from 'react'
|
||||||
|
|
||||||
|
const SubHeader = (props) => {
|
||||||
|
const {
|
||||||
|
subLinks,
|
||||||
|
currentPage,
|
||||||
|
navigate,
|
||||||
|
modifier,
|
||||||
|
} = props
|
||||||
|
|
||||||
|
const links = []
|
||||||
|
|
||||||
|
for(let link of Object.keys(subLinks)) {
|
||||||
|
links.push(
|
||||||
|
<a href="#" onClick={() => navigate(link)} key={link} className={link == currentPage ? 'sub-header-selected' : 'sub-header-unselected' }>
|
||||||
|
{subLinks[link]}
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<nav className={'sub-header' + (modifier ? ' sub-header--' + modifier : '')}>
|
||||||
|
{links}
|
||||||
|
</nav>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default SubHeader
|
|
@ -2,7 +2,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import lbry from 'lbry.js';
|
import lbry from 'lbry.js';
|
||||||
import Link from 'component/link';
|
import Link from 'component/link';
|
||||||
import NavSettings from 'component/navSettings';
|
import SubHeader from 'component/subHeader'
|
||||||
import {version as uiVersion} from 'json!../../../package.json';
|
import {version as uiVersion} from 'json!../../../package.json';
|
||||||
|
|
||||||
var HelpPage = React.createClass({
|
var HelpPage = React.createClass({
|
||||||
|
@ -50,7 +50,7 @@ var HelpPage = React.createClass({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="main--single-column">
|
<main className="main--single-column">
|
||||||
<NavSettings />
|
<SubHeader />
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="card__title-primary">
|
<div className="card__title-primary">
|
||||||
<h3>Read the FAQ</h3>
|
<h3>Read the FAQ</h3>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import lbryio from 'lbryio';
|
import lbryio from 'lbryio';
|
||||||
import {CreditAmount, Icon} from 'component/common.js';
|
import {CreditAmount, Icon} from 'component/common.js';
|
||||||
import NavWallet from 'component/navWallet';
|
import SubHeader from 'component/subHeader'
|
||||||
import {RewardLink} from 'component/reward-link';
|
import {RewardLink} from 'component/reward-link';
|
||||||
|
|
||||||
const RewardTile = React.createClass({
|
const RewardTile = React.createClass({
|
||||||
|
@ -55,7 +55,7 @@ export let RewardsPage = React.createClass({
|
||||||
render: function() {
|
render: function() {
|
||||||
return (
|
return (
|
||||||
<main className="main--single-column">
|
<main className="main--single-column">
|
||||||
<NavWallet />
|
<SubHeader />
|
||||||
<div>
|
<div>
|
||||||
{!this.state.userRewards
|
{!this.state.userRewards
|
||||||
? (this.state.failed ? <div className="empty">Failed to load rewards.</div> : '')
|
? (this.state.failed ? <div className="empty">Failed to load rewards.</div> : '')
|
||||||
|
|
|
@ -2,7 +2,7 @@ import React from 'react';
|
||||||
import lbry from 'lbry.js';
|
import lbry from 'lbry.js';
|
||||||
import Link from 'component/link';
|
import Link from 'component/link';
|
||||||
import Modal from 'component/modal';
|
import Modal from 'component/modal';
|
||||||
import NavWallet from 'component/navWallet';
|
import SubHeader from 'component/subHeader'
|
||||||
import {
|
import {
|
||||||
FormField,
|
FormField,
|
||||||
FormRow
|
FormRow
|
||||||
|
@ -248,7 +248,7 @@ const WalletPage = (props) => {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className="main--single-column">
|
<main className="main--single-column">
|
||||||
<NavWallet />
|
<SubHeader />
|
||||||
<section className="card">
|
<section className="card">
|
||||||
<div className="card__title-primary">
|
<div className="card__title-primary">
|
||||||
<h3>Balance</h3>
|
<h3>Balance</h3>
|
||||||
|
|
|
@ -198,6 +198,12 @@ export const selectHeaderLinks = createSelector(
|
||||||
'downloaded': 'Downloaded',
|
'downloaded': 'Downloaded',
|
||||||
'published': 'Published',
|
'published': 'Published',
|
||||||
};
|
};
|
||||||
|
case 'settings':
|
||||||
|
case 'help':
|
||||||
|
return {
|
||||||
|
'settings': 'Settings',
|
||||||
|
'help': 'Help',
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue