on master help sign in
formatting: restore components/ to their former glory
commit8767696a3ce15c6578e900fdbed60c3863a03374 authorMatt Condon (shrugs) <mattgcondon@gmail.com> dateTue 11 Jun 2019, 13:35 (7 years ago) parentbbcaa72
8 files changed+43−41
.prettierignore+1 src/bridge/components/DropdownItem.js+3−1 src/bridge/components/Header.js+26−29 src/bridge/components/HorizontalSelector.js+3−1 src/bridge/components/OldHeader.js+2−2 src/bridge/components/RenderedPoint.js+1−1 src/bridge/components/StatelessTransaction.js+4−6 src/bridge/components/icons/Chevron.js+3−1
.prettierignore+1
@@ -1 +1,2 @@
11nockjs/
2+components/
src/bridge/components/DropdownItem.js+3−1
@@ -10,7 +10,9 @@ const DropdownItem = props => {
1010 <button
1111 disabled={props.disabled}
1212 style={props.style}
13− className={`h-10 m-0 p-0 ph-2 bg-white flex align-center items-start bs-solid brw-2 blw-2 btw-0 bbw-0 sans ${_disabled} ${props.className}`}
13+ className={`h-10 m-0 p-0 ph-2 bg-white flex align-center items-start bs-solid brw-2 blw-2 btw-0 bbw-0 sans ${_disabled} ${
14+ props.className
15+ }`}
1416 onClick={props.onClick}>
1517 {props.children}
1618 </button>
src/bridge/components/Header.js+26−29
@@ -1,25 +1,24 @@
11import React from 'react';
22import { Button, Chevron } from '../components/Base';
33
4−import { getRouteBreadcrumb } from '../lib/router';
5−import { ROUTE_NAMES } from '../lib/routeNames';
6−import { useHistory } from '../store/history';
4+import { renderRoute } from '../lib/router';
75import { isLast } from '../lib/lib';
86
9−function Crumbs(props) {
10− const history = useHistory();
7+const Crumbs = props => {
8+ const { routeCrumbs, skipRoute } = props;
9+ const history = routeCrumbs.reverse();
1110
1211 // FIXME probably more straightforward to render them normally and just
1312 // return the reversed array of renders
14− const rendered = history.routes.map((route, idx) => {
13+ const rendered = history.map((route, idx) => {
1514 return (
1615 <div className={'flex items-center'} key={`history-${idx}`}>
1716 <Button
1817 prop-type={'link'}
1918 prop-size={'sm'}
2019 key={`history-button-${idx}`}
21− onClick={() => history.pop(history.size - idx - 1)}>
22− {getRouteBreadcrumb(props, route)}
20+ onClick={() => skipRoute(history.size - idx - 1)}>
21+ {renderRoute(props, route)}
2322 </Button>
2423
2524 {isLast(history.size, idx) ? (
@@ -32,30 +31,28 @@ function Crumbs(props) {
3231 });
3332
3433 return rendered;
35−}
36−
37−function Header(props) {
38− const history = useHistory();
39−
40− const showCrumbs = !history.includes(ROUTE_NAMES.INVITE_TICKET);
41−
42− if (showCrumbs) {
43− return (
44− <div className={'flex items-center h-10'}>
45− <Crumbs
46− networkType={props.networkType}
47− wallet={props.wallet}
48− pointCursor={props.pointCursor}
49− />
50− </div>
51− );
52− }
34+};
35+
36+const Header = props => {
37+ const crumbs = (
38+ <div className={'flex items-center h-10'}>
39+ <Crumbs
40+ routeCrumbs={props.routeCrumbs}
41+ skipRoute={props.skipRoute}
42+ networkType={props.networkType}
43+ wallet={props.wallet}
44+ pointCursor={props.pointCursor}
45+ />
46+ </div>
47+ );
5348
54− return (
55− <h2 className="mt-9 clickable" onClick={() => history.pop()}>
49+ const noCrumbs = (
50+ <h2 className="mt-9 clickable" onClick={() => props.skipRoute(1)}>
5651 Bridge
5752 </h2>
5853 );
59−}
54+
55+ return props.showCrumbs ? crumbs : noCrumbs;
56+};
6057
6158export default Header;
src/bridge/components/HorizontalSelector.js+3−1
@@ -22,7 +22,9 @@ class HorizontalSelector extends React.Component {
2222 let active = opt.value === this.state.option ? 'btn-primary active' : '';
2323 return (
2424 <button
25− className={`btn ${active} h-10 ph-4 flex sans ${this.props.className}`}
25+ className={`btn ${active} h-10 ph-4 flex sans ${
26+ this.props.className
27+ }`}
2628 value={opt.value}
2729 onClick={() => this.selectOption(opt.value)}>
2830 {opt.title}
src/bridge/components/OldHeader.js+2−2
@@ -1,7 +1,7 @@
11import React from 'react';
22import { Button, Chevron } from '../components/Base';
33
4−import { getRouteBreadcrumb } from '../lib/router';
4+import { renderRoute } from '../lib/router';
55import { isLast } from '../lib/lib';
66
77const Crumbs = props => {
@@ -19,7 +19,7 @@ const Crumbs = props => {
1919 color={'black'}
2020 key={`history-button-${idx}`}
2121 onClick={() => skipRoute(history.size - idx - 1)}>
22− {`${getRouteBreadcrumb(props, route)}`}
22+ {`${renderRoute(props, route)}`}
2323 </Button>
2424
2525 {isLast(history.size, idx) ? (
src/bridge/components/RenderedPoint.js+1−1
@@ -5,7 +5,7 @@ import { Button } from './Base';
55import { pour } from 'sigil-js';
66import * as ob from 'urbit-ob';
77
8−import { ROUTE_NAMES } from '../lib/routeNames';
8+import { ROUTE_NAMES } from '../lib/router';
99import ReactSVGComponents from './ReactSVGComponents';
1010
1111const RenderedPoint = props => {
src/bridge/components/StatelessTransaction.js+4−6
@@ -9,8 +9,7 @@ import { CheckboxButton, Input, InnerLabel, InnerLabelDropdown } from './Base';
99import { Warning } from '../components/Base';
1010
1111import { BRIDGE_ERROR } from '../lib/error';
12−import { ROUTE_NAMES } from '../lib/routeNames';
13−import { withHistory } from '../store/history';
12+import { ROUTE_NAMES } from '../lib/router';
1413import * as tank from '../lib/tank';
1514
1615import {
@@ -21,7 +20,6 @@ import {
2120 renderSignedTx,
2221 signTransaction,
2322} from '../lib/txn';
24−import { withTxnConfirmations } from '../store/txnConfirmations';
2523
2624const SUBMISSION_STATES = {
2725 PROMPT: 'Send transaction',
@@ -236,14 +234,14 @@ class StatelessTransaction extends React.Component {
236234 )
237235 .then(txHash => {
238236 props.onSent(Just(Ok(txHash)), state.stx.value);
237+ props.popRoute();
239238
240239 let routeData = {};
241240 if (props.networkSeed) {
242241 props.setNetworkSeedCache(props.networkSeed);
243242 routeData.promptKeyfile = true;
244243 }
245−
246− props.history.popAndPush(ROUTE_NAMES.SENT_TRANSACTION, routeData);
244+ props.pushRoute(ROUTE_NAMES.SENT_TRANSACTION, routeData);
247245 })
248246 .catch(err => {
249247 this.setState({
@@ -579,4 +577,4 @@ class StatelessTransaction extends React.Component {
579577 }
580578}
581579
582−export default withTxnConfirmations(withHistory(StatelessTransaction));
580+export default StatelessTransaction;
src/bridge/components/icons/Chevron.js+3−1
@@ -4,7 +4,9 @@ import PropTypes from 'prop-types';
44const Chevron = props => {
55 return (
66 <img
7− src={`data:image/svg+xml;utf8,<svg width="11" height="24" viewBox="0 0 11 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 12L10.387 12.3166L10.646 12L10.387 11.6833L10 12ZM0.613022 1.31662L9.61302 12.3166L10.387 11.6833L1.38698 0.68338L0.613022 1.31662ZM9.61302 11.6833L0.613021 22.6834L1.38698 23.3166L10.387 12.3166L9.61302 11.6833Z" stroke="${props.color}" stroke-width="${props.strokeWidth}" fill="${props.color}"/></svg>`}
7+ src={`data:image/svg+xml;utf8,<svg width="11" height="24" viewBox="0 0 11 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M10 12L10.387 12.3166L10.646 12L10.387 11.6833L10 12ZM0.613022 1.31662L9.61302 12.3166L10.387 11.6833L1.38698 0.68338L0.613022 1.31662ZM9.61302 11.6833L0.613021 22.6834L1.38698 23.3166L10.387 12.3166L9.61302 11.6833Z" stroke="${
8+ props.color
9+ }" stroke-width="${props.strokeWidth}" fill="${props.color}"/></svg>`}
810 alt=""
911 style={props.style}
1012 className={props.className}