Skip to content
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

Add unequip all gems button to gem summary #4266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions ui/core/components/individual_sim_ui/gem_summary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Player } from '../../player';
import { UIGem as Gem } from '../../proto/ui.js';
import { ActionId } from '../../proto_utils/action_id';
import { SimUI } from '../../sim_ui';
import { TypedEvent } from '../../typed_event';
import { ContentBlock } from '../content_block';

interface GemSummaryData {
Expand All @@ -26,6 +27,20 @@ export class GemSummary extends Component {
header: { title: 'Gem Summary' },
});
player.gearChangeEmitter.on(() => this.updateTable());

const headerElement = this.container.headerElement;
if (headerElement) {
const unequipButton = document.createElement('button');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to just make rename this file to tsx and use fragments like in Cata

Copy link
Author

@dodoels dodoels Nov 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was hesitated to do so because making one component into tsx is inconsitent to the other files if no plan to make all of them tsx. But that is my opinion.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to start somewhere :D That's how I did it for the Cata repo as well. If you never do it you'll also never change it

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, I will proceed

unequipButton.innerHTML = `<i class="fas fa-times me-1"></i> Unequip All Gems`;
unequipButton.classList.add('btn', 'btn-sm', 'btn-link', 'gem-reset-button');
unequipButton.id = 'unequip-all-gems-btn';
unequipButton.onclick = () => this.unequipAllGems();
headerElement.appendChild(unequipButton);
}
}

private unequipAllGems() {
this.player.setGear(TypedEvent.nextEventID(), this.player.getGear().withoutGems());
}

private updateTable() {
Expand Down
10 changes: 9 additions & 1 deletion ui/scss/shared/_gems.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
position: relative;
width: var(--gem-width);
height: var(--gem-width);

&:not(:last-child) {
margin-right: 1px;
}
Expand All @@ -30,3 +30,11 @@
height: 100%;
inset: 0;
}

.gem-reset-button {
margin-left: auto;
display: flex;
align-items: center;
padding: 0;
color: #ef9eaa;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a color var for this, or maybe try to copy the btn-reset styling?

}