Merge pull request #79 from leanprover-community/automatic_inventory_doc
add automatic inventory doc
This commit is contained in:
@@ -4,7 +4,7 @@ import './inventory.css'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faLock, faLockOpen, faBook, faHammer, faBan } from '@fortawesome/free-solid-svg-icons'
|
||||
import Markdown from './Markdown';
|
||||
import { useLoadDocQuery, ComputedInventoryItem, LevelInfo } from '../state/api';
|
||||
import { useLoadDocQuery, InventoryTile, LevelInfo } from '../state/api';
|
||||
import { GameIdContext } from '../App';
|
||||
|
||||
export function Inventory({levelInfo, setInventoryDoc } :
|
||||
@@ -13,6 +13,7 @@ export function Inventory({levelInfo, setInventoryDoc } :
|
||||
setInventoryDoc: (inventoryDoc: {name: string, type: string}) => void,
|
||||
}) {
|
||||
|
||||
// TODO: This seems like a useless wrapper to me
|
||||
function openDoc(name, type) {
|
||||
setInventoryDoc({name, type})
|
||||
}
|
||||
@@ -36,7 +37,7 @@ export function Inventory({levelInfo, setInventoryDoc } :
|
||||
|
||||
function InventoryList({items, docType, openDoc, defaultTab=null, level=undefined} :
|
||||
{
|
||||
items: ComputedInventoryItem[],
|
||||
items: InventoryTile[],
|
||||
docType: string,
|
||||
openDoc(name: string, type: string): void,
|
||||
defaultTab? : string,
|
||||
@@ -103,6 +104,8 @@ export function Documentation({name, type}) {
|
||||
|
||||
return <>
|
||||
<h2 className="doc">{doc.data?.displayName}</h2>
|
||||
<Markdown>{doc.data?.text}</Markdown>
|
||||
<p><code>{doc.data?.statement}</code></p>
|
||||
{/* <code>docstring: {doc.data?.docstring}</code> */}
|
||||
<Markdown>{doc.data?.content}</Markdown>
|
||||
</>
|
||||
}
|
||||
|
||||
@@ -171,6 +171,7 @@ function PlayableLevel({worldId, levelId}) {
|
||||
}
|
||||
}, [editor, commandLineMode])
|
||||
|
||||
// if this is set to a pair `(name, type)` then the according doc will be open.
|
||||
const [inventoryDoc, setInventoryDoc] = useState<{name: string, type: string}>(null)
|
||||
|
||||
const levelTitle = <>{levelId && `Level ${levelId}`}{level?.data?.title && `: ${level?.data?.title}`}</>
|
||||
|
||||
@@ -10,7 +10,7 @@ interface GameInfo {
|
||||
conclusion: null|string,
|
||||
}
|
||||
|
||||
export interface ComputedInventoryItem {
|
||||
export interface InventoryTile {
|
||||
name: string,
|
||||
displayName: string,
|
||||
category: string,
|
||||
@@ -24,9 +24,9 @@ export interface LevelInfo {
|
||||
introduction: null|string,
|
||||
conclusion: null|string,
|
||||
index: number,
|
||||
tactics: ComputedInventoryItem[],
|
||||
lemmas: ComputedInventoryItem[],
|
||||
definitions: ComputedInventoryItem[],
|
||||
tactics: InventoryTile[],
|
||||
lemmas: InventoryTile[],
|
||||
definitions: InventoryTile[],
|
||||
descrText: null|string,
|
||||
descrFormat: null|string,
|
||||
lemmaTab: null|string,
|
||||
@@ -36,7 +36,10 @@ export interface LevelInfo {
|
||||
interface Doc {
|
||||
name: string,
|
||||
displayName: string,
|
||||
text: string
|
||||
content: string,
|
||||
statement: string,
|
||||
type: string, // TODO: can I remove these?
|
||||
category: string,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user