Add 'show specs' checkbox on creature page.
rodzic
a44c43a04e
commit
93e972256c
|
@ -1,4 +1,4 @@
|
||||||
import React, { useContext } from "react";
|
import React, { useContext, useState } from "react";
|
||||||
import { SvgVocabulary } from "../svg-vocabulary";
|
import { SvgVocabulary } from "../svg-vocabulary";
|
||||||
import {
|
import {
|
||||||
createSvgSymbolContext,
|
createSvgSymbolContext,
|
||||||
|
@ -142,9 +142,28 @@ const MuscleArm = createCreatureSymbol("muscle arm");
|
||||||
const Tail = createCreatureSymbol("tail");
|
const Tail = createCreatureSymbol("tail");
|
||||||
|
|
||||||
export const CreaturePage: React.FC<{}> = () => {
|
export const CreaturePage: React.FC<{}> = () => {
|
||||||
|
const [showSpecs, setShowSpecs] = useState(false);
|
||||||
|
const defaultCtx = useContext(CreatureContext);
|
||||||
|
const ctx: CreatureContextType = {
|
||||||
|
...defaultCtx,
|
||||||
|
fill: showSpecs ? "none" : defaultCtx.fill,
|
||||||
|
showSpecs,
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h1>Creature!</h1>
|
<h1>Creature!</h1>
|
||||||
|
<p>
|
||||||
|
<label>
|
||||||
|
<input
|
||||||
|
type="checkbox"
|
||||||
|
checked={showSpecs}
|
||||||
|
onChange={(e) => setShowSpecs(e.target.checked)}
|
||||||
|
/>{" "}
|
||||||
|
Show specs
|
||||||
|
</label>
|
||||||
|
</p>
|
||||||
|
<CreatureContext.Provider value={ctx}>
|
||||||
<svg width="1280px" height="720px">
|
<svg width="1280px" height="720px">
|
||||||
<g transform-origin="50% 50%" transform="scale(0.5 0.5)">
|
<g transform-origin="50% 50%" transform="scale(0.5 0.5)">
|
||||||
<Eye>
|
<Eye>
|
||||||
|
@ -170,6 +189,7 @@ export const CreaturePage: React.FC<{}> = () => {
|
||||||
</Eye>
|
</Eye>
|
||||||
</g>
|
</g>
|
||||||
</svg>
|
</svg>
|
||||||
|
</CreatureContext.Provider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
Ładowanie…
Reference in New Issue