Spaces:
Sleeping
Sleeping
Download InventoryApp.jsx from YoScratched/inventorytracker: direct link, hf CLI and curl.
- Browser
- Download file 20 kB
-
https://huggingface.co/spaces/YoScratched/inventorytracker/resolve/main/InventoryApp.jsx
- Command line
-
hf download hf://spaces/YoScratched/inventorytracker/InventoryApp.jsx
-
curl -L -o InventoryApp.jsx https://huggingface.co/spaces/YoScratched/inventorytracker/resolve/main/InventoryApp.jsx
20 kB
| import { useState, useMemo, useCallback } from "react"; | |
| // βββ Fenix Design Tokens βββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| const FENIX = { | |
| bg: "#0A0C0F", | |
| bgCard: "#111418", | |
| bgHover: "#181D24", | |
| border: "#1E252F", | |
| borderGlow:"#FF6B2B", | |
| accent: "#FF6B2B", | |
| accentDim: "#C44E18", | |
| accentGlow:"rgba(255,107,43,0.15)", | |
| text: "#E8EBF0", | |
| textMuted: "#6B7585", | |
| textDim: "#3D4553", | |
| gold: "#FFB800", | |
| red: "#FF4444", | |
| teal: "#00C9A7", | |
| blue: "#4A9EFF", | |
| }; | |
| const RARITY_COLORS = { | |
| "Consumer Grade": "#B0C3D9", | |
| "Industrial Grade": "#5E98D9", | |
| "Mil Spec": "#4B69FF", | |
| "Mil-Spec": "#4B69FF", | |
| "Restricted": "#8847FF", | |
| "Classified": "#D32CE6", | |
| "Covert": "#EB4B4B", | |
| "Contraband": "#E4AE33", | |
| "Extraordinary": "#FFD700", | |
| "Base Grade": "#B0C3D9", | |
| "High Grade": "#4B69FF", | |
| "Remarkable": "#8847FF", | |
| "Exotic": "#D32CE6", | |
| "Distinguished": "#4B69FF", | |
| "Exceptional": "#8847FF", | |
| "Superior": "#D32CE6", | |
| "Master": "#EB4B4B", | |
| "Normal": "#6B7585", | |
| }; | |
| const getRarityColor = (rarity) => | |
| RARITY_COLORS[rarity] || RARITY_COLORS["Normal"]; | |
| // βββ Fake demo data (replace with real API data) ββββββββββββββββββββββββββββββ | |
| const DEMO_ITEMS = [ | |
| { assetId:"1", name:"β Karambit | Doppler (Factory New)", price:1240.00, rarity:"Covert", quality:"Normal", type:"Normal", weaponType:"Knife", isKnife:true, isGlove:false }, | |
| { assetId:"2", name:"β Butterfly Knife | Fade (Minimal Wear)", price:980.50, rarity:"Covert", quality:"Normal", type:"Normal", weaponType:"Knife", isKnife:true, isGlove:false }, | |
| { assetId:"3", name:"StatTrakβ’ AK-47 | Redline (Field-Tested)", price:42.30, rarity:"Classified", quality:"Normal", type:"StatTrak",weaponType:"Rifle", isKnife:false, isGlove:false }, | |
| { assetId:"4", name:"AWP | Dragon Lore (Factory New)", price:8200.00, rarity:"Covert", quality:"Normal", type:"Normal", weaponType:"Sniper", isKnife:false, isGlove:false }, | |
| { assetId:"5", name:"M4A4 | Howl (Minimal Wear)", price:3100.00, rarity:"Contraband", quality:"Normal", type:"Normal", weaponType:"Rifle", isKnife:false, isGlove:false }, | |
| { assetId:"6", name:"β Sport Gloves | Pandora's Box (FT)", price:760.00, rarity:"Extraordinary", quality:"Normal", type:"Normal", weaponType:"Gloves", isKnife:false, isGlove:true }, | |
| { assetId:"7", name:"Glock-18 | Fade (Factory New)", price:18.20, rarity:"Restricted", quality:"Normal", type:"Normal", weaponType:"Pistol", isKnife:false, isGlove:false }, | |
| { assetId:"8", name:"StatTrakβ’ M4A1-S | Hyper Beast (FT)", price:55.80, rarity:"Covert", quality:"Normal", type:"StatTrak",weaponType:"Rifle", isKnife:false, isGlove:false }, | |
| { assetId:"9", name:"USP-S | Kill Confirmed (Factory New)", price:38.90, rarity:"Covert", quality:"Normal", type:"Normal", weaponType:"Pistol", isKnife:false, isGlove:false }, | |
| { assetId:"10",name:"AK-47 | Case Hardened (Well-Worn)", price:24.10, rarity:"Classified", quality:"Normal", type:"Normal", weaponType:"Rifle", isKnife:false, isGlove:false }, | |
| { assetId:"11",name:"Desert Eagle | Blaze (Factory New)", price:210.00, rarity:"Restricted", quality:"Normal", type:"Normal", weaponType:"Pistol", isKnife:false, isGlove:false }, | |
| { assetId:"12",name:"Souvenir AWP | Dragon Lore (FN)", price:15000.00,rarity:"Covert", quality:"Normal", type:"Souvenir",weaponType:"Sniper", isKnife:false, isGlove:false }, | |
| { assetId:"13",name:"P250 | See Ya Later (Factory New)", price:1.20, rarity:"Mil-Spec", quality:"Normal", type:"Normal", weaponType:"Pistol", isKnife:false, isGlove:false }, | |
| { assetId:"14",name:"FAMAS | Valence (Minimal Wear)", price:0.08, rarity:"Industrial Grade",quality:"Normal", type:"Normal", weaponType:"Rifle", isKnife:false, isGlove:false }, | |
| { assetId:"15",name:"β M9 Bayonet | Tiger Tooth (FN)", price:580.00, rarity:"Covert", quality:"Normal", type:"Normal", weaponType:"Knife", isKnife:true, isGlove:false }, | |
| ]; | |
| // βββ Sub-components ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| const css = (obj) => Object.entries(obj).reduce((a,[k,v])=>`${a}${k.replace(/([A-Z])/g,'-$1').toLowerCase()}:${v};`,""); | |
| function StatCard({ label, value, sub, accent }) { | |
| return ( | |
| <div style={{ | |
| background: FENIX.bgCard, | |
| border: `1px solid ${accent ? FENIX.borderGlow : FENIX.border}`, | |
| borderRadius: 10, | |
| padding: "18px 22px", | |
| boxShadow: accent ? `0 0 18px ${FENIX.accentGlow}` : "none", | |
| minWidth: 130, | |
| flex: "1 1 130px", | |
| }}> | |
| <div style={{ fontSize: 11, color: FENIX.textMuted, letterSpacing: "0.1em", textTransform: "uppercase", marginBottom: 6 }}>{label}</div> | |
| <div style={{ fontSize: 26, fontWeight: 700, color: accent ? FENIX.accent : FENIX.text, fontFamily: "'Bebas Neue', 'Impact', sans-serif", letterSpacing: "0.03em" }}>{value}</div> | |
| {sub && <div style={{ fontSize: 12, color: FENIX.textMuted, marginTop: 3 }}>{sub}</div>} | |
| </div> | |
| ); | |
| } | |
| function RarityBadge({ rarity }) { | |
| const color = getRarityColor(rarity); | |
| return ( | |
| <span style={{ | |
| fontSize: 10, | |
| fontWeight: 600, | |
| letterSpacing: "0.08em", | |
| padding: "2px 7px", | |
| borderRadius: 4, | |
| border: `1px solid ${color}44`, | |
| background: `${color}18`, | |
| color, | |
| whiteSpace: "nowrap", | |
| }}>{rarity.toUpperCase()}</span> | |
| ); | |
| } | |
| function TypeBadge({ type }) { | |
| if (type === "Normal") return null; | |
| const cfg = { | |
| StatTrak: { bg:"#FF6B2B22", color:"#FF6B2B", label:"STβ’" }, | |
| Souvenir: { bg:"#FFB80022", color:"#FFB800", label:"SV" }, | |
| }[type]; | |
| return ( | |
| <span style={{ | |
| fontSize: 10, fontWeight: 700, letterSpacing: "0.06em", | |
| padding: "2px 6px", borderRadius: 4, | |
| background: cfg.bg, color: cfg.color, | |
| border: `1px solid ${cfg.color}44`, | |
| }}>{cfg.label}</span> | |
| ); | |
| } | |
| function ItemRow({ item, rank }) { | |
| const [hovered, setHovered] = useState(false); | |
| const rarityColor = getRarityColor(item.rarity); | |
| return ( | |
| <div | |
| onMouseEnter={() => setHovered(true)} | |
| onMouseLeave={() => setHovered(false)} | |
| style={{ | |
| display: "grid", | |
| gridTemplateColumns: "36px 3fr 100px 130px 80px", | |
| alignItems: "center", | |
| gap: 12, | |
| padding: "12px 16px", | |
| borderRadius: 8, | |
| background: hovered ? FENIX.bgHover : "transparent", | |
| borderLeft: `3px solid ${hovered ? rarityColor : "transparent"}`, | |
| transition: "all 0.15s ease", | |
| cursor: "default", | |
| }} | |
| > | |
| {/* Rank */} | |
| <div style={{ fontSize: 12, color: FENIX.textDim, textAlign: "right", fontVariantNumeric: "tabular-nums" }}> | |
| {rank} | |
| </div> | |
| {/* Name + badges */} | |
| <div style={{ display: "flex", alignItems: "center", gap: 8, minWidth: 0 }}> | |
| <span style={{ | |
| width: 6, height: 6, borderRadius: "50%", flexShrink: 0, | |
| background: rarityColor, boxShadow: `0 0 6px ${rarityColor}`, | |
| }} /> | |
| <span style={{ | |
| fontSize: 13, color: FENIX.text, whiteSpace: "nowrap", | |
| overflow: "hidden", textOverflow: "ellipsis", | |
| }}> | |
| {item.isKnife ? "πͺ " : item.isGlove ? "π§€ " : ""}{item.name} | |
| </span> | |
| <TypeBadge type={item.type} /> | |
| </div> | |
| {/* Rarity */} | |
| <div><RarityBadge rarity={item.rarity} /></div> | |
| {/* Weapon type */} | |
| <div style={{ fontSize: 12, color: FENIX.textMuted }}>{item.weaponType}</div> | |
| {/* Price */} | |
| <div style={{ | |
| fontSize: 14, fontWeight: 700, color: item.price >= 1000 ? FENIX.gold : FENIX.accent, | |
| textAlign: "right", fontVariantNumeric: "tabular-nums", | |
| }}> | |
| ${item.price.toFixed(2)} | |
| </div> | |
| </div> | |
| ); | |
| } | |
| function FilterPill({ label, active, onClick }) { | |
| return ( | |
| <button | |
| onClick={onClick} | |
| style={{ | |
| padding: "6px 14px", | |
| borderRadius: 20, | |
| fontSize: 12, | |
| fontWeight: 600, | |
| letterSpacing: "0.05em", | |
| border: `1px solid ${active ? FENIX.borderGlow : FENIX.border}`, | |
| background: active ? FENIX.accentGlow : "transparent", | |
| color: active ? FENIX.accent : FENIX.textMuted, | |
| cursor: "pointer", | |
| transition: "all 0.15s ease", | |
| }} | |
| >{label}</button> | |
| ); | |
| } | |
| // βββ Main App ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| export default function InventoryApp() { | |
| const [steamUrl, setSteamUrl] = useState("https://steamcommunity.com/profiles/76561198080075870/inventory/"); | |
| const [loading, setLoading] = useState(false); | |
| const [items, setItems] = useState(DEMO_ITEMS); | |
| const [search, setSearch] = useState(""); | |
| const [filterType, setFilterType] = useState("All"); | |
| const [sortBy, setSortBy] = useState("price"); | |
| const [page, setPage] = useState(1); | |
| const PAGE_SIZE = 20; | |
| // Simulate fetch (wire to real Python API / FastAPI endpoint) | |
| const handleFetch = useCallback(async () => { | |
| if (!steamUrl.trim()) return; | |
| setLoading(true); | |
| await new Promise(r => setTimeout(r, 1800)); | |
| setItems([...DEMO_ITEMS].sort(() => Math.random() - 0.5)); | |
| setPage(1); | |
| setLoading(false); | |
| }, [steamUrl]); | |
| const stats = useMemo(() => ({ | |
| total: items.length, | |
| value: items.reduce((s,i)=>s+i.price,0), | |
| knives: items.filter(i=>i.isKnife).length, | |
| knifeVal: items.filter(i=>i.isKnife).reduce((s,i)=>s+i.price,0), | |
| gloves: items.filter(i=>i.isGlove).length, | |
| stattrak: items.filter(i=>i.type==="StatTrak").length, | |
| souvenir: items.filter(i=>i.type==="Souvenir").length, | |
| top: items.reduce((a,b)=>b.price>a.price?b:a, items[0] || {price:0}), | |
| }), [items]); | |
| const filtered = useMemo(() => { | |
| let list = [...items]; | |
| if (search) list = list.filter(i => i.name.toLowerCase().includes(search.toLowerCase())); | |
| if (filterType === "Knives") list = list.filter(i => i.isKnife); | |
| if (filterType === "Gloves") list = list.filter(i => i.isGlove); | |
| if (filterType === "StatTrak") list = list.filter(i => i.type === "StatTrak"); | |
| if (filterType === "Souvenir") list = list.filter(i => i.type === "Souvenir"); | |
| if (sortBy === "price") list.sort((a,b) => b.price - a.price); | |
| if (sortBy === "name") list.sort((a,b) => a.name.localeCompare(b.name)); | |
| if (sortBy === "rarity")list.sort((a,b) => (getRarityColor(b.rarity) > getRarityColor(a.rarity) ? 1 : -1)); | |
| return list; | |
| }, [items, search, filterType, sortBy]); | |
| const totalPages = Math.ceil(filtered.length / PAGE_SIZE); | |
| const pageItems = filtered.slice((page-1)*PAGE_SIZE, page*PAGE_SIZE); | |
| return ( | |
| <div style={{ | |
| minHeight: "100vh", | |
| background: FENIX.bg, | |
| color: FENIX.text, | |
| fontFamily: "'Inter', 'Segoe UI', system-ui, sans-serif", | |
| padding: "0 0 60px", | |
| }}> | |
| {/* ββ Header ββ */} | |
| <div style={{ | |
| borderBottom: `1px solid ${FENIX.border}`, | |
| background: `linear-gradient(180deg, #0D1117 0%, ${FENIX.bg} 100%)`, | |
| padding: "28px 40px 22px", | |
| position: "sticky", top: 0, zIndex: 10, | |
| }}> | |
| <div style={{ display:"flex", alignItems:"center", justifyContent:"space-between", flexWrap:"wrap", gap: 16 }}> | |
| <div style={{ display:"flex", alignItems:"center", gap: 14 }}> | |
| <div style={{ | |
| width: 38, height: 38, borderRadius: 8, | |
| background: `linear-gradient(135deg, ${FENIX.accent} 0%, ${FENIX.accentDim} 100%)`, | |
| display:"flex", alignItems:"center", justifyContent:"center", | |
| fontSize: 18, boxShadow: `0 0 16px ${FENIX.accentGlow}`, | |
| }}>π₯</div> | |
| <div> | |
| <div style={{ fontSize: 20, fontWeight: 800, letterSpacing:"-0.01em", fontFamily:"'Bebas Neue','Impact',sans-serif", letterSpacing:"0.05em" }}> | |
| FENIX INVENTORY | |
| </div> | |
| <div style={{ fontSize: 11, color: FENIX.textMuted, letterSpacing:"0.12em", textTransform:"uppercase" }}>CS2 SKIN TRACKER</div> | |
| </div> | |
| </div> | |
| {/* URL input + fetch */} | |
| <div style={{ display:"flex", gap: 10, flex:"1 1 400px", maxWidth: 620 }}> | |
| <input | |
| value={steamUrl} | |
| onChange={e => setSteamUrl(e.target.value)} | |
| placeholder="Steam inventory URLβ¦" | |
| style={{ | |
| flex: 1, | |
| background: FENIX.bgCard, | |
| border: `1px solid ${FENIX.border}`, | |
| borderRadius: 8, | |
| padding: "10px 14px", | |
| color: FENIX.text, | |
| fontSize: 13, | |
| outline: "none", | |
| fontFamily: "inherit", | |
| }} | |
| /> | |
| <button | |
| onClick={handleFetch} | |
| disabled={loading} | |
| style={{ | |
| padding: "10px 22px", | |
| borderRadius: 8, | |
| background: loading ? FENIX.accentDim : FENIX.accent, | |
| border: "none", | |
| color: "#fff", | |
| fontSize: 13, | |
| fontWeight: 700, | |
| letterSpacing: "0.05em", | |
| cursor: loading ? "not-allowed" : "pointer", | |
| transition: "background 0.15s", | |
| whiteSpace: "nowrap", | |
| }} | |
| > | |
| {loading ? "SCANNINGβ¦" : "SCAN"} | |
| </button> | |
| </div> | |
| </div> | |
| </div> | |
| <div style={{ maxWidth: 1200, margin:"0 auto", padding:"0 24px" }}> | |
| {/* ββ Stat Cards ββ */} | |
| <div style={{ display:"flex", flexWrap:"wrap", gap: 12, padding:"28px 0 20px" }}> | |
| <StatCard label="Total Items" value={stats.total} accent /> | |
| <StatCard label="Total Value" value={`$${stats.value.toLocaleString("en-US",{minimumFractionDigits:2,maximumFractionDigits:2})}`} /> | |
| <StatCard label="Knives" value={stats.knives} sub={`$${stats.knifeVal.toFixed(0)} value`} /> | |
| <StatCard label="Gloves" value={stats.gloves} /> | |
| <StatCard label="StatTrakβ’" value={stats.stattrak} /> | |
| <StatCard label="Souvenir" value={stats.souvenir} /> | |
| <StatCard label="Top Item" value={`$${stats.top.price?.toFixed(2) || "β"}`} sub={stats.top.name?.split("|")[0]?.trim()} /> | |
| </div> | |
| {/* ββ Controls ββ */} | |
| <div style={{ | |
| display:"flex", flexWrap:"wrap", alignItems:"center", | |
| gap: 12, marginBottom: 16, | |
| padding: "16px 20px", | |
| background: FENIX.bgCard, | |
| borderRadius: 10, | |
| border: `1px solid ${FENIX.border}`, | |
| }}> | |
| {/* Search */} | |
| <input | |
| value={search} | |
| onChange={e => { setSearch(e.target.value); setPage(1); }} | |
| placeholder="π Search itemsβ¦" | |
| style={{ | |
| background: FENIX.bg, | |
| border: `1px solid ${FENIX.border}`, | |
| borderRadius: 7, | |
| padding: "8px 14px", | |
| color: FENIX.text, | |
| fontSize: 13, | |
| outline: "none", | |
| fontFamily: "inherit", | |
| width: 220, | |
| }} | |
| /> | |
| {/* Filter pills */} | |
| <div style={{ display:"flex", gap: 6, flexWrap:"wrap" }}> | |
| {["All","Knives","Gloves","StatTrak","Souvenir"].map(f => ( | |
| <FilterPill key={f} label={f} active={filterType===f} onClick={()=>{ setFilterType(f); setPage(1); }} /> | |
| ))} | |
| </div> | |
| {/* Sort */} | |
| <div style={{ display:"flex", alignItems:"center", gap: 8, marginLeft:"auto" }}> | |
| <span style={{ fontSize: 12, color: FENIX.textMuted }}>Sort by</span> | |
| {["price","name","rarity"].map(s => ( | |
| <FilterPill key={s} label={s} active={sortBy===s} onClick={()=>setSortBy(s)} /> | |
| ))} | |
| </div> | |
| <div style={{ fontSize: 12, color: FENIX.textMuted, whiteSpace:"nowrap" }}> | |
| {filtered.length} items | |
| </div> | |
| </div> | |
| {/* ββ Table Header ββ */} | |
| <div style={{ | |
| display:"grid", | |
| gridTemplateColumns:"36px 3fr 100px 130px 80px", | |
| gap: 12, padding:"8px 16px", | |
| fontSize: 11, color: FENIX.textMuted, | |
| letterSpacing:"0.1em", textTransform:"uppercase", | |
| borderBottom: `1px solid ${FENIX.border}`, | |
| }}> | |
| <div style={{textAlign:"right"}}>#</div> | |
| <div>Name</div> | |
| <div>Rarity</div> | |
| <div>Type</div> | |
| <div style={{textAlign:"right"}}>Price</div> | |
| </div> | |
| {/* ββ Item List ββ */} | |
| <div style={{ marginTop: 4 }}> | |
| {pageItems.length === 0 ? ( | |
| <div style={{ padding:"60px 0", textAlign:"center", color: FENIX.textMuted, fontSize: 14 }}> | |
| No items match your filters. | |
| </div> | |
| ) : ( | |
| pageItems.map((item, i) => ( | |
| <ItemRow key={item.assetId} item={item} rank={(page-1)*PAGE_SIZE + i + 1} /> | |
| )) | |
| )} | |
| </div> | |
| {/* ββ Pagination ββ */} | |
| {totalPages > 1 && ( | |
| <div style={{ display:"flex", justifyContent:"center", gap: 8, paddingTop: 28 }}> | |
| <button | |
| onClick={() => setPage(p => Math.max(1, p-1))} | |
| disabled={page === 1} | |
| style={{ | |
| padding:"8px 18px", borderRadius: 7, border:`1px solid ${FENIX.border}`, | |
| background:"transparent", color: page===1 ? FENIX.textDim : FENIX.text, | |
| cursor: page===1 ? "not-allowed" : "pointer", fontSize: 13, | |
| }} | |
| >β Prev</button> | |
| {Array.from({length: Math.min(7, totalPages)}, (_,i) => { | |
| const p = totalPages <= 7 ? i+1 : Math.min(Math.max(page-3+i, 1), totalPages-6+i); | |
| return ( | |
| <button key={p} onClick={() => setPage(p)} style={{ | |
| width: 36, height: 36, borderRadius: 7, | |
| border: `1px solid ${p===page ? FENIX.borderGlow : FENIX.border}`, | |
| background: p===page ? FENIX.accentGlow : "transparent", | |
| color: p===page ? FENIX.accent : FENIX.textMuted, | |
| cursor: "pointer", fontSize: 13, fontWeight: p===page ? 700 : 400, | |
| }}>{p}</button> | |
| ); | |
| })} | |
| <button | |
| onClick={() => setPage(p => Math.min(totalPages, p+1))} | |
| disabled={page === totalPages} | |
| style={{ | |
| padding:"8px 18px", borderRadius: 7, border:`1px solid ${FENIX.border}`, | |
| background:"transparent", color: page===totalPages ? FENIX.textDim : FENIX.text, | |
| cursor: page===totalPages ? "not-allowed" : "pointer", fontSize: 13, | |
| }} | |
| >Next β</button> | |
| </div> | |
| )} | |
| {/* ββ Footer ββ */} | |
| <div style={{ marginTop: 48, borderTop:`1px solid ${FENIX.border}`, paddingTop: 20, fontSize: 11, color: FENIX.textDim, textAlign:"center", letterSpacing:"0.08em" }}> | |
| FENIX INVENTORY Β· PRICES VIA STEAMDT.COM Β· CNY β USD @ 0.14 | |
| </div> | |
| </div> | |
| </div> | |
| ); | |
| } | |