diff --git a/ui/src/App.css b/ui/src/App.css index 4bebad4..b4d6ec7 100644 --- a/ui/src/App.css +++ b/ui/src/App.css @@ -49,14 +49,61 @@ border-radius: 10%; } -.want { - border-collapse: collapse; +.coin { + width: 2em; + margin: 10px; } -.want td { - border: 1px solid; +.trade { + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; + background: #171717; + border-radius: 25px; + margin-bottom: 15px; +} + +.item-col { + display: flex; + flex-direction: column; + align-items: center; + padding: 0 15px 25px 15px; + margin: 5px; +} + +.row-center { + display: flex; + flex-direction: row; + align-items: center; +} + +input { + border: none; + background: #242424; + text-align: center; + padding: 5px 10px; + border-radius: 15px; + font-size: 1.2rem; + width: 75px; +} + +@media (prefers-color-scheme: light) { + .trade { + background: #fafafa; + border: 1px solid #e5e5e5; + } + input { + background: #e5e5e5; + } } .error { - background-color: red; + background-color: #E11D48; + color: #fff; +} + +/* increment/decrement arrows always visible */ +input[type=number]::-webkit-inner-spin-button { + opacity: 1 } diff --git a/ui/src/assets/IST.png b/ui/src/assets/IST.png new file mode 100644 index 0000000..cb79edf Binary files /dev/null and b/ui/src/assets/IST.png differ diff --git a/ui/src/components/Trade.tsx b/ui/src/components/Trade.tsx index a4801cb..a13d9c2 100644 --- a/ui/src/components/Trade.tsx +++ b/ui/src/components/Trade.tsx @@ -1,10 +1,11 @@ import { FormEvent, useState } from 'react'; import { stringifyAmountValue } from '@agoric/ui-components'; import scrollIcon from '../assets/scroll.png'; +import istIcon from '../assets/IST.png'; import mapIcon from '../assets/map.png'; import potionIcon from '../assets/potionBlue.png'; -const { entries, keys, values } = Object; +const { entries, values } = Object; const sum = (xs: bigint[]) => xs.reduce((acc, next) => acc + next, 0n); const terms = { @@ -25,14 +26,49 @@ const parseValue = (numeral: string, purse: Purse): bigint => { return BigInt(num); }; +const Item = ({ + icon, + coinIcon, + label, + value, + onChange, + inputClassName, + inputStep, +}: { + icon?: string; + coinIcon?: string; + label: string; + value: number | string; + onChange: React.ChangeEventHandler; + inputClassName: string; + inputStep?: string; +}) => ( +
+ + {icon && } + {coinIcon && } + +
+); + type TradeProps = { makeOffer: (giveValue: bigint, wantChoices: Record) => void; istPurse: Purse; walletConnected: boolean; }; -// TODO: don't wait for connect wallet to show Give. -// IST displayInfo is available in vbankAsset or boardAux +// TODO: IST displayInfo is available in vbankAsset or boardAux const Trade = ({ makeOffer, istPurse, walletConnected }: TradeProps) => { const [giveValue, setGiveValue] = useState(terms.price); const [choices, setChoices] = useState({ map: 1n, scroll: 2n }); @@ -48,84 +84,49 @@ const Trade = ({ makeOffer, istPurse, walletConnected }: TradeProps) => { setChoices(newChoices); }; - const renderGiveValue = (purse: Purse) => ( - setGiveValue(parseValue(ev?.target?.value, purse))} - className={giveValue >= terms.price ? 'ok' : 'error'} - step="0.01" - /> - ); - - const WantPlaces = () => ( + return ( <> - - - Want: Choose up to 3 items - - - - +
+

Want: Choose up to 3 items

+
{entries(nameToIcon).map(([title, icon]) => ( - - - - ))} - - - - {keys(nameToIcon).map(title => ( - - -
- {title} - + ))} - - - - ); - - return ( - <> - - - {istPurse && ( - <> - - - - - - - - - - - - - - )} -
- Give: Offer at least 0.25 IST -
{renderGiveValue(istPurse)}IST
+
+
+
+

Give: Offer at least 0.25 IST

+
+ + setGiveValue(parseValue(ev?.target?.value, istPurse)) + } + inputClassName={giveValue >= terms.price ? 'ok' : 'error'} + inputStep="0.01" + /> +
+
{walletConnected && (