Skip to content

Commit eff3c1f

Browse files
authored
Merge pull request #279 from csfloat/fix/market-entry-stickers-update
Fix: Steam Market Sticker Container
2 parents 749c4c6 + 1073df5 commit eff3c1f

File tree

3 files changed

+37
-9
lines changed

3 files changed

+37
-9
lines changed

src/lib/components/market/helpers.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ function generateStickerInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[]
8888
function generateKeychainInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[] {
8989
const description = getKeychainDescription(itemInfo, asset);
9090

91-
if (!description || description.type !== 'html' || !description.value.includes('sticker')) {
91+
if (!description || description.type !== 'html' || description.value.includes('sticker')) {
9292
return [];
9393
}
9494

@@ -107,6 +107,11 @@ function generateKeychainInlineHTML(itemInfo: ItemInfo, asset: rgAsset): string[
107107
export function inlineStickersAndKeychains(itemNameBlock: JQuery<Element>, itemInfo: ItemInfo, asset: rgAsset) {
108108
if (!itemNameBlock) return;
109109

110+
// Remove Steam's inspect button
111+
itemNameBlock.parent().find('.market_listing_row_action')?.parent().remove();
112+
// Remove Steam's stickers and keychains
113+
itemNameBlock.parent().find('.market_listing_row_details')?.remove();
114+
110115
if (itemNameBlock.find('.csfloat-stickers-container').length) {
111116
// Don't inline stickers if they're already inlined
112117
return;
@@ -117,11 +122,16 @@ export function inlineStickersAndKeychains(itemNameBlock: JQuery<Element>, itemI
117122
return;
118123
}
119124

125+
const elementId = `listing_${itemInfo.m}_csfloat`;
126+
120127
itemNameBlock.prepend(`
121-
<div class="csfloat-stickers-container">
128+
<div class="csfloat-stickers-container" id="${elementId}">
122129
${blobs.reduce((acc, v) => acc + v, '')}
123130
</div>
124131
`);
132+
133+
// Add Steam's item popover on-hover
134+
CreateItemHoverFromContainer(g_rgAssets, elementId, asset.appid, asset.contextid, asset.id, asset.amount);
125135
}
126136

127137
/**

src/lib/components/market/item_row_wrapper.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ export class ItemRowWrapper extends FloatElement {
140140
// dialogs opening.
141141
MarketCheckHash();
142142
}
143+
144+
// Make sure the parent containers can overflow
145+
const parentContainer = $J(this).parent();
146+
if (parentContainer) {
147+
parentContainer.css('overflow', 'visible');
148+
parentContainer.parent().css('overflow', 'visible');
149+
}
143150
}
144151

145152
render() {
@@ -161,8 +168,9 @@ export class ItemRowWrapper extends FloatElement {
161168
return html`
162169
<div class="float-row-wrapper">
163170
${this.renderFloatBar()}
164-
<span> Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)} </span>
165-
<br />
171+
<span style="display: block;">
172+
Float: ${this.itemInfo.floatvalue.toFixed(14)} ${renderClickableRank(this.itemInfo)}
173+
</span>
166174
Paint Seed:
167175
${formatSeed(this.itemInfo)}${fadePercentage !== undefined
168176
? html`<br />

src/lib/types/steam.d.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,18 @@ export interface TradeInventory {
219219
success: boolean;
220220
}
221221

222+
export type SteamAssets = {
223+
[appId in AppId]: {
224+
[contextId in ContextId]: {[assetId: string]: rgAsset};
225+
};
226+
};
227+
222228
// Declares globals available in the Steam Page Context
223229
declare global {
224230
const $J: typeof $;
225231
const g_rgListingInfo: {[listingId: string]: ListingData};
226232
const g_rgWalletInfo: WalletInfo | undefined; // Not populated when user is signed-out
227-
const g_rgAssets: {
228-
[appId in AppId]: {
229-
[contextId in ContextId]: {[assetId: string]: rgAsset};
230-
};
231-
};
233+
const g_rgAssets: SteamAssets;
232234
const g_ActiveInventory: CInventory | undefined; // Only populated on Steam inventory pages
233235
const g_steamID: string;
234236
const g_oSearchResults: CAjaxPagingControls;
@@ -250,6 +252,14 @@ declare global {
250252
const MoveItemToTrade: (el: HTMLElement) => void; // Only populated on create offer pages
251253
const g_rgCurrentTradeStatus: CurrentTradeStatus;
252254
const ShowItemInventory: (appID: AppId, contextID: ContextId, AssetID?: number) => void;
255+
const CreateItemHoverFromContainer: (
256+
g_rgAssets: SteamAssets,
257+
elementId: string,
258+
appid: AppId,
259+
contextid: string,
260+
id: string,
261+
amount: number
262+
) => void;
253263
}
254264

255265
export {};

0 commit comments

Comments
 (0)