-
Notifications
You must be signed in to change notification settings - Fork 138
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
Gem summary UI #4061
Gem summary UI #4061
Changes from 7 commits
831e4d9
b949606
70dbd8b
0da78e4
eaf36fe
e0bcdc8
22cd3fe
99066d9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { SimUI } from "../../sim_ui"; | ||
import { Component } from "../../components/component"; | ||
import { Player } from "../../player"; | ||
import { setItemQualityCssClass } from "../../css_utils"; | ||
import { ActionId } from "../../proto_utils/action_id"; | ||
import { UIGem as Gem } from '../../proto/ui.js'; | ||
import { ContentBlock } from "../content_block"; | ||
|
||
interface GemSummaryData { | ||
gem: Gem | ||
count: number | ||
} | ||
|
||
export class GemSummary extends Component { | ||
private readonly simUI: SimUI; | ||
private readonly player: Player<any>; | ||
|
||
private readonly container: ContentBlock; | ||
|
||
constructor(parent: HTMLElement, simUI: SimUI, player: Player<any>) { | ||
super(parent, 'gem-summary-root'); | ||
this.simUI = simUI; | ||
this.player = player; | ||
|
||
this.container = new ContentBlock(this.rootElem, 'gem-summary-container', { | ||
header: {title: 'Gem Summary'} | ||
}); | ||
|
||
player.gearChangeEmitter.on(() => this.updateTable()); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor nit, but looks like indentation got messed up here maybe? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah looks like my editor made these new lines use spaces instead of tabs. Nice catch! It looked fine for me because I use 2-space tab sizing but I'll bet it looks funky if you use anything else |
||
|
||
private updateTable() { | ||
this.container.bodyElement.innerHTML = ``; | ||
const fullGemList = this.player.getGear().getAllGems(this.player.isBlacksmithing()); | ||
const gemCounts: Record<string, GemSummaryData> = {}; | ||
|
||
for (const gem of fullGemList) { | ||
if (gemCounts[gem.name]) { | ||
gemCounts[gem.name].count += 1 | ||
} else { | ||
gemCounts[gem.name] = { | ||
gem: gem, | ||
count: 1, | ||
} | ||
} | ||
} | ||
|
||
for (const gemName of Object.keys(gemCounts)) { | ||
const gemData = gemCounts[gemName] | ||
const row = document.createElement('div'); | ||
row.classList.add('d-flex', 'align-items-center', 'justify-content-between') | ||
row.innerHTML = ` | ||
<a class="gem-summary-link"> | ||
<img class="gem-icon"/> | ||
<div>${gemName}</div> | ||
</a> | ||
<div>${gemData.count.toFixed(0)}</div> | ||
`; | ||
|
||
const gemLinkElem = row.querySelector('.gem-summary-link') as HTMLAnchorElement; | ||
const gemIconElem = row.querySelector('.gem-icon') as HTMLImageElement; | ||
|
||
setItemQualityCssClass(gemLinkElem, gemData.gem.quality); | ||
|
||
ActionId.fromItemId(gemData.gem.id).fill().then(filledId => { | ||
gemIconElem.src = filledId.iconUrl; | ||
filledId.setWowheadHref(gemLinkElem); | ||
}); | ||
|
||
this.container.bodyElement.appendChild(row); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#gear-tab { | ||
.tab-pane-content-container { | ||
.gear-tab-left { | ||
flex-direction: column; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
.gem-summary-root { | ||
width: 50%; | ||
|
||
.gem-summary-link { | ||
--gem-width: 2rem; | ||
|
||
display: flex; | ||
align-items: center; | ||
|
||
.gem-icon { | ||
position: unset; | ||
margin-right: map-get($spacers, 1); | ||
border-radius: 0; | ||
border: $border-default; | ||
} | ||
|
||
&:not(:last-child) { | ||
margin-bottom: map-get($spacers, 1); | ||
} | ||
} | ||
} | ||
|
||
@include media-breakpoint-down(xl) { | ||
.gem-summary-root { | ||
margin-bottom: var(--container-padding); | ||
} | ||
} | ||
|
||
@include media-breakpoint-down(md) { | ||
.gem-summary-root { | ||
width: 100%; | ||
} | ||
} |
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 nested
item-picker-root
class was causing rendering issues particularly on mobile