Skip to content

Commit

Permalink
Merge pull request #305 from xiv-gear-planner/remove-food-button
Browse files Browse the repository at this point in the history
Add button to remove food
  • Loading branch information
xpdota authored Sep 4, 2024
2 parents d973fa1 + 38aa961 commit 32f142c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/common-ui/styles/common.less
Original file line number Diff line number Diff line change
Expand Up @@ -1260,9 +1260,9 @@ table.gear-items-table, table.food-items-table {
}
}

&.gear-items-edit-table {
&.gear-items-edit-table, &.food-items-edit-table {
tr {
.item-name-holder-editable {
.item-name-holder-editable, .food-name-holder-editable {
display: flex;
flex-direction: row;

Expand All @@ -1273,14 +1273,14 @@ table.gear-items-table, table.food-items-table {
text-overflow: ellipsis;
}

.remove-item-button {
.remove-item-button, .remove-food-button {
display: none;
}
}

&:hover {
&[is-selected="true"] {
.remove-item-button {
.remove-item-button, .remove-food-button{
background: none;
display: block;
.borderless-button;
Expand All @@ -1290,6 +1290,7 @@ table.gear-items-table, table.food-items-table {

height: min-content;
width: min-content;

svg {
fill: var(--fg-color);
}
Expand Down
9 changes: 9 additions & 0 deletions packages/frontend/src/scripts/components/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ export class FoodItemsTable extends CustomTable<FoodItem, FoodItem> {
constructor(sheet: GearPlanSheet, gearSet: CharacterGearSet) {
super();
this.classList.add("food-items-table");
this.classList.add("food-items-edit-table");
this.classList.add("hoverable");
super.columns = [
{
Expand All @@ -240,6 +241,14 @@ export class FoodItemsTable extends CustomTable<FoodItem, FoodItem> {
getter: item => {
return item.name;
},
renderer: (name: string, rowValue: FoodItem) => {
const trashButton = quickElement('button', ['remove-food-button'], [makeTrashIcon()]);
trashButton.addEventListener('click', (ev) => {
gearSet.food = undefined;
this.refreshSelection();
});
return quickElement('div', ['food-name-holder-editable'], [quickElement('span', [], [name]), trashButton]);
}
// renderer: name => {
// return quickElement('div', [], [document.createTextNode(name)]);
// }
Expand Down

0 comments on commit 32f142c

Please sign in to comment.