cracket
Advanced tools
Comparing version 0.1.2 to 0.1.3
@@ -10,13 +10,14 @@ "use strict"; | ||
const term_size_1 = __importDefault(require("term-size")); | ||
const coin_chart_1 = __importDefault(require("./coin-chart")); | ||
const coin_market_chart_1 = __importDefault(require("./coin-market-chart")); | ||
const coin_detail_1 = __importDefault(require("./coin-detail")); | ||
const react_2 = require("@xstate/react"); | ||
const machine_1 = require("../machine"); | ||
const coin_ohlc_1 = __importDefault(require("./coin-ohlc")); | ||
const Detail = ({ id }) => { | ||
const { rows } = term_size_1.default(); | ||
const [current] = react_2.useService(machine_1.cracketService); | ||
const view = current.matches('detail.frequency.default') ? 'default' : 'daily'; | ||
const kind = current.matches('detail.kind.price') | ||
const view = current.matches('detail.line.frequency.default') ? 'default' : 'daily'; | ||
const kind = current.matches('detail.line.kind.price') | ||
? 'price' | ||
: current.matches('detail.kind.volume') | ||
: current.matches('detail.line.kind.volume') | ||
? 'volume' | ||
@@ -27,3 +28,6 @@ : 'market'; | ||
react_1.default.createElement(ink_1.Spacer, null), | ||
react_1.default.createElement(coin_chart_1.default, { view: view, kind: kind, id: id, height: Math.floor(rows / 2) - 5 }), | ||
current.matches('detail.ohlc') && | ||
react_1.default.createElement(coin_ohlc_1.default, { id: id, height: Math.floor(rows / 2) - 5 }), | ||
current.matches('detail.line') && | ||
react_1.default.createElement(coin_market_chart_1.default, { view: view, kind: kind, id: id, height: Math.floor(rows / 2) - 5 }), | ||
react_1.default.createElement(ink_1.Spacer, null), | ||
@@ -34,6 +38,6 @@ react_1.default.createElement(ink_1.Box, { justifyContent: "flex-end" }, | ||
' ', | ||
view, | ||
current.matches('detail.ohlc') ? '---' : view, | ||
' ', | ||
"[", | ||
kind, | ||
current.matches('detail.ohlc') ? 'OHLC' : kind, | ||
"]", | ||
@@ -40,0 +44,0 @@ ' ', |
@@ -21,2 +21,3 @@ "use strict"; | ||
['s', 'Switch between prices, total volumes, market caps'], | ||
['g', 'Switch between line and OHLC chart'], | ||
['q or ESC', 'Go back to home screen'], | ||
@@ -23,0 +24,0 @@ ]; |
@@ -6,15 +6,20 @@ interface CracketSchema { | ||
states: { | ||
frequency: { | ||
line: { | ||
states: { | ||
default: {}; | ||
daily: {}; | ||
frequency: { | ||
states: { | ||
default: {}; | ||
daily: {}; | ||
}; | ||
}; | ||
kind: { | ||
states: { | ||
price: {}; | ||
volume: {}; | ||
market: {}; | ||
}; | ||
}; | ||
}; | ||
}; | ||
kind: { | ||
states: { | ||
price: {}; | ||
volume: {}; | ||
market: {}; | ||
}; | ||
}; | ||
ohlc: {}; | ||
}; | ||
@@ -51,2 +56,4 @@ }; | ||
type: 'SWITCH'; | ||
} | { | ||
type: 'SWITCH_GRAPH'; | ||
}; | ||
@@ -53,0 +60,0 @@ interface CracketContext { |
@@ -27,3 +27,3 @@ "use strict"; | ||
detail: { | ||
type: 'parallel', | ||
initial: 'line', | ||
on: { | ||
@@ -34,35 +34,48 @@ BACK: 'home', | ||
states: { | ||
frequency: { | ||
initial: 'default', | ||
states: { | ||
default: { | ||
on: { | ||
VIEW: 'daily', | ||
}, | ||
}, | ||
daily: { | ||
on: { | ||
VIEW: 'default', | ||
}, | ||
}, | ||
ohlc: { | ||
on: { | ||
SWITCH_GRAPH: 'line', | ||
}, | ||
}, | ||
kind: { | ||
initial: 'price', | ||
line: { | ||
type: 'parallel', | ||
on: { | ||
SWITCH_GRAPH: 'ohlc', | ||
}, | ||
states: { | ||
price: { | ||
on: { | ||
SWITCH: 'volume', | ||
frequency: { | ||
initial: 'default', | ||
states: { | ||
default: { | ||
on: { | ||
VIEW: 'daily', | ||
}, | ||
}, | ||
daily: { | ||
on: { | ||
VIEW: 'default', | ||
}, | ||
}, | ||
}, | ||
}, | ||
volume: { | ||
on: { | ||
SWITCH: 'market', | ||
kind: { | ||
initial: 'price', | ||
states: { | ||
price: { | ||
on: { | ||
SWITCH: 'volume', | ||
}, | ||
}, | ||
volume: { | ||
on: { | ||
SWITCH: 'market', | ||
}, | ||
}, | ||
market: { | ||
on: { | ||
SWITCH: 'price', | ||
}, | ||
}, | ||
}, | ||
}, | ||
market: { | ||
on: { | ||
SWITCH: 'price', | ||
}, | ||
}, | ||
}, | ||
@@ -69,0 +82,0 @@ }, |
@@ -37,2 +37,4 @@ "use strict"; | ||
return send({ type: 'SWITCH' }); | ||
if (input === 'g') | ||
return send({ type: 'SWITCH_GRAPH' }); | ||
} | ||
@@ -39,0 +41,0 @@ if (input === 'q' || key.escape) |
{ | ||
"name": "cracket", | ||
"version": "0.1.2", | ||
"version": "0.1.3", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "CLI app to keep track of cryptocurrency trends", |
48376
30
1017