Skip to content

Commit 7d3d73d

Browse files
committed
Fix casing when formatting item type
1 parent ef643de commit 7d3d73d

8 files changed

Lines changed: 24 additions & 29 deletions

File tree

src/components/ItemTypeCategories.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ function selectCategory(name: string) {
147147
<!-- Item types -->
148148
<div class="flex flex-row flex-wrap gap-1 content-start justify-center max-h-48 h-auto overflow-x-scroll">
149149
<RouterLink v-for="item in categoryItems" :to="{ name: 'itemSales', params: { itemType: item.type } }"
150-
class="item-button" :title="formatItemType(item.type).toLocaleLowerCase()">
150+
class="item-button" :title="formatItemType(item.type)">
151151

152152
<!-- Item icon/picture -->
153153
<div v-if="item.info?.icon" class="text-xl">
@@ -158,8 +158,8 @@ function selectCategory(name: string) {
158158
</div>
159159

160160
<!-- Item name -->
161-
<div class="text-xs capitalize overflow-hidden text-ellipsis">
162-
{{ formatItemType(item.type).toLocaleLowerCase() }}
161+
<div class="text-xs overflow-hidden text-ellipsis">
162+
{{ formatItemType(item.type) }}
163163
</div>
164164
</RouterLink>
165165
</div>

src/components/ItemTypeSearch.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ function makeSelection(item: string | null) {
9999
class="max-h-48 p-3 overflow-y-auto text-sm text-gray-200 bg-gray-700 rounded-lg shadow-sm border border-gray-800"
100100
aria-labelledby="itemTypeSearchButton">
101101
<li v-for="itemType in filteredItemTypes" class="hyperlink" @click="makeSelection(itemType)">
102-
<div tabindex="0" class="flex items-center px-4 py-2 ps-2 rounded-sm hover:bg-gray-600 text-gray-300 text-sm font-medium capitalize">
103-
{{ formatItemType(itemType).toLocaleLowerCase() }}
102+
<div tabindex="0" class="flex items-center px-4 py-2 ps-2 rounded-sm hover:bg-gray-600 text-gray-300 text-sm font-medium">
103+
{{ formatItemType(itemType) }}
104104
</div>
105105
</li>
106106
</ul>

src/components/ShopsList.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ function childItemsSummary(items: ShopItem[]): string {
6767
}
6868
6969
summary += Object.keys(counts)
70-
.map((itemType) => `${counts[itemType]} ${formatItemType(itemType).toLocaleLowerCase()}`)
70+
.map((itemType) => `${counts[itemType]} ${formatItemType(itemType)}`)
7171
.join("\n");
7272
7373
return summary;
@@ -160,7 +160,7 @@ function groupedChildItems(items: ShopItem[]): ShopItem[] {
160160
<!-- Item type -->
161161
<div class="text-xs md:text-sm">
162162
<RouterLink :to="{ name: 'itemSales', params: { itemType: shop.item.type } }" class="hyperlink">
163-
{{ formatItemType(shop.item.type) }}
163+
{{ formatItemType(shop.item.type).toLocaleUpperCase() }}
164164
</RouterLink>
165165
</div>
166166

@@ -194,7 +194,7 @@ function groupedChildItems(items: ShopItem[]): ShopItem[] {
194194
<div v-if="child.parsedSNBT.enchantments.length > 0">
195195
<div>
196196
<span>{{ child.name }}&nbsp;</span>
197-
<span class="capitalize">({{ formatItemType(child.type).toLowerCase() }})</span>
197+
<span>({{ formatItemType(child.type) }})</span>
198198
</div>
199199
<div class="capitalize">
200200
{{ child.parsedSNBT.enchantments.map((e) => formatEnchantment(e)).join(", ") }}
@@ -204,7 +204,7 @@ function groupedChildItems(items: ShopItem[]): ShopItem[] {
204204
<!-- Potions -->
205205
<div v-else-if="child.parsedSNBT.potionEffect != null" class="capitalize">
206206
{{ child.quantity }}x {{ formatPotionEffect(child.parsedSNBT.potionEffect) }}
207-
{{ formatItemType(child.type).toLowerCase() }}
207+
{{ formatItemType(child.type) }}
208208
</div>
209209

210210
<!-- Custom music discs -->
@@ -239,12 +239,12 @@ function groupedChildItems(items: ShopItem[]): ShopItem[] {
239239

240240
<!-- Bundles -->
241241
<div v-else-if="(child.childItems?.length ?? 0) > 0">
242-
<div>{{ child.name }} (({{ formatItemType(child.type).toLowerCase() }}))</div>
242+
<div>{{ child.name }} (({{ formatItemType(child.type) }}))</div>
243243
<div>{{ child.childItems?.length }} items</div>
244244
</div>
245245

246246
<!-- All other item types -->
247-
<div v-else class="capitalize">{{ child.quantity }}x {{ formatItemType(child.type).toLowerCase() }}</div>
247+
<div v-else>{{ child.quantity }}x {{ formatItemType(child.type) }}</div>
248248
</div>
249249
</div>
250250
</div>

src/utilities/item-type-format.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
export function formatItemType(itemType: string | null | undefined, defaultValue?: string | null | undefined): string {
22
if (!itemType) return defaultValue ?? "";
33

4-
// TODO: Lowercase & capitalise first letter. Some places that use this want it uppercase; make them upper case it
5-
return itemType.replace(/_/g, " ");
4+
// Replace underscores with spaces & lowercase
5+
let formattedType = itemType.replace(/_/g, " ").toLocaleLowerCase();
6+
7+
// Capitalise first letter
8+
return formattedType.replace(/^./, formattedType[0]!.toUpperCase());
69
}

src/utilities/normalise-price.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ export function normalisePrice(totalPrice: number, quantity: number): Normalised
2525
return normalPrice;
2626
}
2727

28-
export function formatPrice(price: NormalisedPrice, itemType: string): string {
29-
return `${formatNumber(price.quantity, 2)} '${formatItemType(itemType)}' is worth ${formatNumber(price.price, 2)} diamonds(s)`;
30-
}
31-
3228
export function simpleNormalisedPrice(price: NormalisedPrice) {
3329
return `${formatNumber(price.quantity, 2)} for ${formatNumber(price.price, 2)} 💎`;
3430
}

src/utilities/text-format.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/views/ItemTypeView.vue

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { getItemInfo } from "@/models/item-info";
2222
import { itemsStore } from "@/store/items-state";
2323
import { debounce } from "lodash";
2424
import { setPageTitle } from "@/router/pageTitle";
25-
import { capitalizeFirstLetter } from "@/utilities/text-format";
2625
import { userStore } from "@/store/user-state";
2726
2827
interface Props {
@@ -84,7 +83,7 @@ onMounted(async () => {
8483
8584
userStore.addRecentlyViewedItem(props.itemType);
8685
87-
setPageTitle(capitalizeFirstLetter(formatItemType(props.itemType).toLocaleLowerCase()));
86+
setPageTitle(formatItemType(props.itemType));
8887
8988
// Load sales with any filters
9089
await loadSales();
@@ -270,7 +269,7 @@ function getWikiLink() {
270269
<!-- Item Info -->
271270
<div class="flex flex-col">
272271
<!-- Item type -->
273-
<h1 class="text-3xl font-bold capitalize">{{ formatItemType(itemType)?.toLocaleLowerCase() }}</h1>
272+
<h1 class="text-3xl font-bold">{{ formatItemType(itemType) }}</h1>
274273

275274

276275

@@ -353,8 +352,8 @@ function getWikiLink() {
353352
<div class="flex flex-column sm:flex-row flex-wrap space-y-1 items-end justify-between pb-2">
354353
<div class="flex flex-col gap-1">
355354
<h2 class="text-2xl font-bold">Shops</h2>
356-
<div class="text-gray-300 capitalize">
357-
<div>Selling {{ formatItemType(itemType)?.toLocaleLowerCase() }}</div>
355+
<div class="text-gray-300">
356+
<div>Selling {{ formatItemType(itemType) }}</div>
358357
<div class="text-gray-400 text-sm capitalize">{{ filtersText }}</div>
359358
</div>
360359
</div>

src/views/SaleView.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ let filteredAttributes = computed(() => {
136136
<table class="w-full text-left rtl:text-right text-gray-400 text-xs md:text-base mt-2">
137137
<tbody>
138138
<tr v-for="attribute in filteredAttributes" class="border-t border-gray-700">
139-
<td class="table-item wrap-anywhere capitalize">
140-
{{ formatItemType(attribute.key)?.toLocaleLowerCase() }}
139+
<td class="table-item wrap-anywhere">
140+
{{ formatItemType(attribute.key) }}
141141
</td>
142142

143143
<td class="table-item wrap-anywhere">
@@ -211,8 +211,8 @@ let filteredAttributes = computed(() => {
211211
<td class="table-item wrap-anywhere">
212212
<div
213213
v-for="attribute in subItem.itemAttributes.sort((a, b) => a.key.localeCompare(b.key) || a.value.localeCompare(b.value))">
214-
<span class="capitalize" v-if="attribute.key != 'PAINTING_ID'"
215-
>{{ formatItemType(attribute.key)?.toLocaleLowerCase() }}:
214+
<span v-if="attribute.key != 'PAINTING_ID'">
215+
{{ formatItemType(attribute.key) }}:
216216
</span>
217217

218218
<span v-if="attribute.key == 'POTION_EFFECT'" class="capitalize">

0 commit comments

Comments
 (0)