Skip to content

Commit a8494cb

Browse files
committed
Add tooltip marker to category headings
If category is excluded from weight, there is a help icon and a hover message
1 parent 4e57e7a commit a8494cb

File tree

5 files changed

+40
-11
lines changed

5 files changed

+40
-11
lines changed

frontend/src/app/Inventory/Table.tsx

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import * as React from 'react';
2+
import { Icon, Tooltip } from 'antd';
23

34
import { Category } from "types/category";
45
import { Item as ItemType } from 'types/item';
56
import { Update } from "types/api/item";
67

78
import Item from './Item';
89
import ExpandablePanel from "../components/ExpandablePanel";
10+
import { helpIconStyles } from "styles/common";
911

1012
interface TableProps {
1113
category: Category;
@@ -22,15 +24,25 @@ const Table: React.FC<TableProps> = ({ category, items, updateItem, fetchItems }
2224
fetchItems={fetchItems}/>
2325
);
2426

25-
const Header = <h3>{category.name}</h3>;
27+
function setHeader(category: Category): JSX.Element {
28+
if (category.exclude_weight) {
29+
return <h3> {category.name}
30+
<Tooltip title={"Items in this category will be excluded from base weight"}
31+
mouseEnterDelay={.1}>
32+
<Icon type="stop-o" style={helpIconStyles}/>
33+
</Tooltip>
34+
</h3>;
35+
}
36+
return <h3>{category.name}</h3>
37+
}
2638

2739
return (
2840
<div key={category.id} style={{ marginBottom: '24px' }}>
29-
<ExpandablePanel Header={Header}>
41+
<ExpandablePanel Header={setHeader(category)}>
3042
{itemList}
3143
</ExpandablePanel>
3244
</div>
3345
)
3446
};
3547

36-
export default Table;
48+
export default Table;

frontend/src/app/Pack/Items.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { getItemWeight, getWeightByCategory } from "lib/utils/weight";
1010
import { getCategories } from "lib/utils/categories";
1111

1212
import { ItemList, ItemName, ItemNotes, ItemDescription, ItemQuantity, ItemWeight, CategorySection } from "./styles";
13+
import { helpIconStyles } from "styles/common";
1314
import ExpandablePanel from 'app/components/ExpandablePanel';
1415

1516
interface ItemsProps {
@@ -42,7 +43,14 @@ const Items: React.FC<ItemsProps> = ({ items, unit }) => {
4243

4344
const Header = (
4445
<>
45-
<h3>{cat.name}</h3>
46+
<h3>
47+
{cat.name}
48+
{cat.exclude_weight &&
49+
<Tooltip title={"Items in this category are excluded from base weight"}
50+
mouseEnterDelay={.1}>
51+
<Icon type="stop-o" style={helpIconStyles}/>
52+
</Tooltip>}
53+
</h3>
4654
<strong>{catWeight!.total.label} {unit}</strong>
4755
</>
4856
)
@@ -99,4 +107,4 @@ const Items: React.FC<ItemsProps> = ({ items, unit }) => {
99107

100108
};
101109

102-
export default Items;
110+
export default Items;

frontend/src/app/components/FormFields/SwitchInput.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ const SwitchInput: React.FC<SwitchProps> = ({ checked, checkedText, uncheckedTex
1515
return (
1616
<InputContainer {...{ label, tip, style }} labelStyle = {{display:"inline", paddingRight: '8px'}}>
1717
<Switch
18-
checked = {checked}
18+
checked={checked}
1919
checkedChildren={checkedText}
20-
unCheckedChildren={uncheckedText}
20+
unCheckedChildren={uncheckedText}
2121
onChange={handleChange}
2222
/>
2323
</InputContainer>
2424
);
2525
};
2626

27-
export default SwitchInput;
27+
export default SwitchInput;

frontend/src/app/components/ItemForm/ItemForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ const ItemForm: React.FC<FormSpecs.Props> = ({ createItem, exportCsv, onSubmit }
101101
{isNewCategory &&
102102
<SwitchInput
103103
label="Exclude category from base weight"
104-
checked = {values.excludeWeight}
104+
checked={values.excludeWeight}
105105
checkedText="Yes"
106106
uncheckedText="No"
107107
tip="All items added to this category will be excluded from base weight"

frontend/src/app/components/PackItems/index.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import * as React from 'react';
2+
import { Icon, Tooltip } from 'antd';
23

34
import { WeightUnit } from "enums";
45
import { PackItem } from "types/item";
@@ -9,6 +10,7 @@ import Item from './Item';
910

1011
import { getCategories } from "lib/utils/categories";
1112
import { getWeightByCategory } from "lib/utils/weight";
13+
import { helpIconStyles } from "styles/common";
1214

1315
import { CategoryGroup } from "styles/common";
1416
import ExpandablePanel from '../ExpandablePanel';
@@ -42,7 +44,14 @@ const PackItems: React.FC<PackItemProps> = ({ items, removeItem, updateItem, wei
4244
const catWeight = weightByCategory.find(c => c.id === cat.id);
4345
const Header = (
4446
<>
45-
<h3>{cat.name}</h3>
47+
<h3>
48+
{cat.name}
49+
{cat.exclude_weight &&
50+
<Tooltip title={"Items in this category are excluded from base weight"}
51+
mouseEnterDelay={.1}>
52+
<Icon type="stop-o" style={helpIconStyles}/>
53+
</Tooltip>}
54+
</h3>
4655
<strong>{catWeight!.total.label} {weightUnit}</strong>
4756
</>
4857
);
@@ -71,4 +80,4 @@ const PackItems: React.FC<PackItemProps> = ({ items, removeItem, updateItem, wei
7180
)
7281
};
7382

74-
export default PackItems;
83+
export default PackItems;

0 commit comments

Comments
 (0)