-
Notifications
You must be signed in to change notification settings - Fork 92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ui: Bin order tables by rate. #1090
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks perfect to me.
Appears to work as indented. However, we should be aware that while this is a UX improvement to some, it actually hides some important information that I hope we can strive to reveal again, perhaps in a future PR. Take the following simnet buy side entirely comprising my own orders: Another party just sees the Buy Orders table and has no idea if the 20 DCR best bid is one order or two. This may be an important factor in the user deciding if the transaction will be maximally efficient if they decide to sell. Even if the stars align and those maker orders do get batched by the taker/seller's redeem txn, that redeem is still larger than it would have been if there were just one match instead of two. Plus they still need to make two contracts for the two countparties. Then consider the 30 DCR at 0.003945. If a user's sell fills 20 DCR at that price level, what would they match against? They would need to see the unbinned orders sorted by time stamp (as before) to know what to expect (assuming no other takers got to those bids first). |
@chappjc There could be a little pop up that shows up when you hover over each row that contains this information. I may be wrong, but I don’t think people would be so concerned with this if the lot size is set properly and the transaction fees are negligible compared to the order. It definitely can’t hurt to have it there though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (row && row.getRate() === 0) row = row.nextSibling | ||
while (row) { | ||
if ((order.rate < row.order.rate) === order.sell) { | ||
if (order.rate === row.getRate()) { | ||
row.insertOrder(order) | ||
return | ||
} else if ((order.rate < row.getRate()) === order.sell) { | ||
const tr = this.orderTableRow([order], cssClass) | ||
tbody.insertBefore(tr, row) | ||
return | ||
} | ||
row = row.nextSibling | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll need to figure out a way to separate epoch queue orders and booked orders and create a row for each.
if (!tr.orderBin.length) { | ||
tr.remove() | ||
} else { | ||
tr.updateQty() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be two lines
if (!tr.orderBin.length) { | ||
tr.remove() | ||
} else { | ||
tr.updateQty() | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be two lines.
@buck54321 I've added a new column that shows the number of orders, let me know what you think. Also the epoch and non-epoch orders are now in separate rows. |
This reverts commit ac7d1f0.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@buck54321 I've added a new column that shows the number of orders, let me know what you think. Also the epoch and non-epoch orders are now in separate rows.
I think it uses a bit too much space. Just a number and no bulky column header like @buck54321 showed would be fine IMO. Here's what I see now:
But it gets a little glitchy at various window widths, putting "# Orders" on two rows, and often creating a horizontal scroll bar:
Otherwise, it works as intended. There's a separate row for epoch orders, and when booked, it merges that with the booked orders row and updates the # Orders count. No issues in browser JS console. Overall nice work, but I don't think the column header adds much, possibly even the separate column is unnecessary if the number is just after the quantity in the same column with appropriate styling. Like buck suggested, but perhaps with a tweaked styling:
@chappjc I've updated it. This definitely looks better. I thought it would be confusing to just have a number there without a column header, but I added a tooltip which explains what the number means. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good stuff. I've made a few more suggestions to round things out.
qtyDiv.innerText = qty.toFixed(8) | ||
ordersDiv.innerText = tr.orderBin.length |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's only show the qtyDiv
when there is more than one order.
@@ -427,6 +427,12 @@ table.balance-table button:hover { | |||
} | |||
} | |||
|
|||
div.numorders { | |||
color: white; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No white text, please. Inherited color
will work fine once you get the background colors adjusted.
@@ -24,6 +24,11 @@ body.dark { | |||
} | |||
} | |||
|
|||
div.numorders { | |||
background-color: rgb(25, 25, 180); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's darken this up quite a bit. Maybe like a #141488
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we could test out one of our primary colors: https://decred.org/brand/
Keep the hue / rgb ratio and tweak the brightness? If that clashes with the rest of the DEX scheme, no biggie.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first one is a lighter version of the dark blue primary color and the second is @buck54321 's suggestion. Very similar, but I think @buck54321 's suggestion is a closer match to the dex logo, which doesn't seem to be using any of the Decred colors.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
k, no sweat. Just wanted to try to keep us on-brand if possible, but best to stay internally consistent with other dex styles unless we rework the whole scheme.
But honestly, I like the top one you showed best. If you guys think it looks funny, we should go with the matching one.
border-radius: 3px; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The coloring is a little bright. It should blend in and match existing styles more closely.
To do that, I added line-height: 1; padding: 1px;
here, and then removed the px-1
class and added the align-items-center
class to the wrapper div
. You might want to play with font-size: 0.9em
too, but the font-size is already pretty small here so I'm not sure we want to push it.
@@ -427,6 +427,12 @@ table.balance-table button:hover { | |||
} | |||
} | |||
|
|||
div.numorders { | |||
color: white; | |||
background-color: rgb(94, 94, 130); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's lighten this up quite a bit. Maybe like a #c5c5e6
tr.insertOrder = (order) => { | ||
tr.orderBin.push(order) | ||
updateQtyTD() | ||
} | ||
tr.updateOrderQty = (token, qty) => { | ||
for (let i = 0; i < tr.orderBin.length; i++) { | ||
if (tr.orderBin[i].token === token) { | ||
tr.orderBin[i].qty = qty | ||
updateQtyTD() | ||
return true | ||
} | ||
} | ||
return false | ||
} | ||
tr.removeOrder = (token) => { | ||
const index = tr.orderBin.findIndex(order => order.token === token) | ||
if (index < 0) return false | ||
tr.orderBin.splice(index, 1) | ||
if (!tr.orderBin.length) tr.remove() | ||
else updateQtyTD() | ||
return true | ||
} | ||
tr.removeEpochOrders = (newEpoch) => { | ||
tr.orderBin = tr.orderBin.filter((order) => { | ||
return !(order.epoch && order.epoch !== newEpoch) | ||
}) | ||
if (!tr.orderBin.length) tr.remove() | ||
else updateQtyTD() | ||
} | ||
tr.getRate = () => { | ||
return tr.orderBin[0].rate | ||
} | ||
tr.getEpoch = () => { | ||
return tr.orderBin[0].epoch | ||
} | ||
tr.compare = (order) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good stuff, and it makes the semantics of updating these rows really clean, but once we're adding seven new functions as custom properties to an td
element, that's a big clue to me that we should just write a custom class to manage the element and make these class methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added a manager class that has a reference to the td
element the td
element has a reference to the manager class. It's definitely a lot cleaner.
const mainDiv = qtyTD.children[0] | ||
const [qtyDiv, ordersDiv] = mainDiv.children |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Try using the data-tmpl
/Doc.tmplElement
system used throughout, and assigning these elements as properties of the custom class mentioned in my other comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re-approving latest changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return this.sell | ||
} | ||
|
||
compare (order) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I try to doc all methods, but this method in particular could use a docstring.
bins.push(currEpochBin) | ||
return bins.filter(bin => bin.length > 0) | ||
} | ||
|
||
/* loadTables loads the order book side into its table. */ | ||
loadTableSide (sell) { | ||
const bookSide = sell ? this.book.sells : this.book.buys | ||
const tbody = sell ? this.page.sellRows : this.page.buyRows | ||
const cssClass = sell ? 'sellcolor' : 'buycolor' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cssClass
is unused outside of OrderTableRowManager
(via orderTableRow
). I'd recommend moving this cssClass
stuff into the OrderTableRowManager
constructor, and just passing the sell
boolean as an argument instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call.
@buck54321 The bug is fixed now. |
This PR updates the order tables on the market UI. Instead of displaying each individual order's quantity and rate on a separate row, the total quantity available at each rate will be displayed. Also, as discussed in matrix, epoch orders will be binned along with all other orders, and the check mark will no longer be displayed.
Closes #945.