improve hover text for inventory items #144

wasm2
Jon Eugster 1 year ago
parent 4b7d540a80
commit 5fd49abb90

@ -90,21 +90,24 @@ function InventoryList({items, docType, openDoc, defaultTab=null, level=undefine
(x, y) => +(docType == "Lemma") * (+x.locked - +y.locked || +x.disabled - +y.disabled) || x.displayName.localeCompare(y.displayName)
).filter(item => !item.hidden && ((tab ?? categories[0]) == item.category)).map((item, i) => {
return <InventoryItem key={`${item.category}-${item.name}`}
item={item}
showDoc={() => {openDoc({name: item.name, type: docType})}}
name={item.name} displayName={item.displayName} locked={difficulty > 0 ? item.locked : false}
disabled={item.disabled} newly={item.new} enableAll={enableAll}/>
disabled={item.disabled} newly={item.new} enableAll={enableAll} />
})
}
</div>
</>
}
function InventoryItem({name, displayName, locked, disabled, newly, showDoc, enableAll=false}) {
function InventoryItem({item, name, displayName, locked, disabled, newly, showDoc, enableAll=false}) {
const icon = locked ? <FontAwesomeIcon icon={faLock} /> :
disabled ? <FontAwesomeIcon icon={faBan} /> : ""
disabled ? <FontAwesomeIcon icon={faBan} /> : item.st
const className = locked ? "locked" : disabled ? "disabled" : newly ? "new" : ""
// Note: This is somewhat a hack as the statement of lemmas comes currently in the form
// `Namespace.statement_name (x y : Nat) : some type`
const title = locked ? "Not unlocked yet" :
disabled ? "Not available in this level" : ""
disabled ? "Not available in this level" : item.altTitle.substring(item.altTitle.indexOf(' ') + 1)
const [copied, setCopied] = useState(false)

@ -35,6 +35,7 @@ export interface InventoryTile {
locked: boolean,
new: boolean,
hidden: boolean
altTitle: string,
}
export interface LevelInfo {

@ -781,6 +781,7 @@ elab "MakeGame" : command => do
name := item
displayName := data.displayName
category := data.category
altTitle := data.statement
hidden := hiddenItems.contains item })
@ -800,6 +801,7 @@ elab "MakeGame" : command => do
displayName := data.displayName
category := data.category
locked := false
altTitle := data.statement
hidden := hiddenItems.contains item }
itemsInWorld := itemsInWorld.insert worldId items
@ -819,6 +821,7 @@ elab "MakeGame" : command => do
displayName := data.displayName
category := data.category
locked := false
altTitle := data.statement
hidden := hiddenItems.contains item }
-- add the exercise statement from the previous level
@ -832,6 +835,7 @@ elab "MakeGame" : command => do
name := name
displayName := data.displayName
category := data.category
altTitle := data.statement
locked := false }
-- add marks for `disabled` and `new` lemmas here, so that they only apply to

@ -106,6 +106,8 @@ structure InventoryTile where
new := false
/-- hide the item in the inventory display -/
hidden := false
/-- hover text -/
altTitle : String := default
deriving ToJson, FromJson, Repr, Inhabited
def InventoryItem.toTile (item : InventoryItem) : InventoryTile := {

Loading…
Cancel
Save