Added player name input
This commit is contained in:
parent
bc4cf2bce0
commit
d6279df8bf
|
@ -105,11 +105,13 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
appLayout.currency &&
|
appLayout.currency &&
|
||||||
setCurrencySelect(currencyOptions.indexOf(appLayout.currency));
|
setCurrencySelect(currencyOptions.indexOf(appLayout.currency));
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [appLayout.currency]);
|
}, [appLayout.currency]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
currencySelect >= 0 &&
|
currencySelect >= 0 &&
|
||||||
appLayout.setCurrency(currencyOptions[currencySelect]);
|
appLayout.setCurrency(currencyOptions[currencySelect]);
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [currencySelect]);
|
}, [currencySelect]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -398,6 +400,16 @@ export default function AppLayout(props: AppLayoutProps): JSX.Element {
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<h3 className="text-xl">Player name</h3>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="<player>"
|
||||||
|
className="w-48"
|
||||||
|
onInput={(e) => appLayout.setPlayerName(e.target.value)}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Popup>
|
</Popup>
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { useAppLayout } from "contexts/AppLayoutContext";
|
||||||
import Markdown from "markdown-to-jsx";
|
import Markdown from "markdown-to-jsx";
|
||||||
import SceneBreak from "./SceneBreak";
|
import SceneBreak from "./SceneBreak";
|
||||||
|
|
||||||
|
@ -7,6 +8,8 @@ type ScenBreakProps = {
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Markdawn(props: ScenBreakProps): JSX.Element {
|
export default function Markdawn(props: ScenBreakProps): JSX.Element {
|
||||||
|
const appLayout = useAppLayout();
|
||||||
|
|
||||||
if (props.text) {
|
if (props.text) {
|
||||||
return (
|
return (
|
||||||
<Markdown
|
<Markdown
|
||||||
|
@ -17,7 +20,13 @@ export default function Markdawn(props: ScenBreakProps): JSX.Element {
|
||||||
component: SceneBreak,
|
component: SceneBreak,
|
||||||
},
|
},
|
||||||
player: {
|
player: {
|
||||||
component: () => {return <span className="text-dark opacity-70">{"<player>"}</span>}
|
component: () => {
|
||||||
|
return (
|
||||||
|
<span className="text-dark opacity-70">
|
||||||
|
{appLayout.playerName ? appLayout.playerName : "<player>"}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -49,7 +49,7 @@ export default function Select(props: SelectProps): JSX.Element {
|
||||||
{index !== props.state && (
|
{index !== props.state && (
|
||||||
<div
|
<div
|
||||||
className="bg-light hover:bg-mid transition-colors cursor-pointer p-1 last-of-type:rounded-b-[1em]"
|
className="bg-light hover:bg-mid transition-colors cursor-pointer p-1 last-of-type:rounded-b-[1em]"
|
||||||
key={option}
|
key={index}
|
||||||
id={option}
|
id={option}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setOpened(false);
|
setOpened(false);
|
||||||
|
|
|
@ -13,6 +13,7 @@ export interface AppLayoutState {
|
||||||
fontSize: number | undefined;
|
fontSize: number | undefined;
|
||||||
dyslexic: boolean | undefined;
|
dyslexic: boolean | undefined;
|
||||||
currency: string | undefined;
|
currency: string | undefined;
|
||||||
|
playerName: string | undefined;
|
||||||
setSubPanelOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
setSubPanelOpen: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
||||||
setLanguagePanelOpen: React.Dispatch<
|
setLanguagePanelOpen: React.Dispatch<
|
||||||
React.SetStateAction<boolean | undefined>
|
React.SetStateAction<boolean | undefined>
|
||||||
|
@ -29,6 +30,7 @@ export interface AppLayoutState {
|
||||||
setFontSize: React.Dispatch<React.SetStateAction<number | undefined>>;
|
setFontSize: React.Dispatch<React.SetStateAction<number | undefined>>;
|
||||||
setDyslexic: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
setDyslexic: React.Dispatch<React.SetStateAction<boolean | undefined>>;
|
||||||
setCurrency: React.Dispatch<React.SetStateAction<string | undefined>>;
|
setCurrency: React.Dispatch<React.SetStateAction<string | undefined>>;
|
||||||
|
setPlayerName: React.Dispatch<React.SetStateAction<string | undefined>>;
|
||||||
}
|
}
|
||||||
|
|
||||||
const initialState: AppLayoutState = {
|
const initialState: AppLayoutState = {
|
||||||
|
@ -42,6 +44,7 @@ const initialState: AppLayoutState = {
|
||||||
fontSize: 1,
|
fontSize: 1,
|
||||||
dyslexic: false,
|
dyslexic: false,
|
||||||
currency: "USD",
|
currency: "USD",
|
||||||
|
playerName: "",
|
||||||
setSubPanelOpen: () => {},
|
setSubPanelOpen: () => {},
|
||||||
setLanguagePanelOpen: () => {},
|
setLanguagePanelOpen: () => {},
|
||||||
setMainPanelReduced: () => {},
|
setMainPanelReduced: () => {},
|
||||||
|
@ -52,6 +55,7 @@ const initialState: AppLayoutState = {
|
||||||
setFontSize: () => {},
|
setFontSize: () => {},
|
||||||
setDyslexic: () => {},
|
setDyslexic: () => {},
|
||||||
setCurrency: () => {},
|
setCurrency: () => {},
|
||||||
|
setPlayerName: () => {},
|
||||||
};
|
};
|
||||||
|
|
||||||
const AppContext = React.createContext<AppLayoutState>(initialState);
|
const AppContext = React.createContext<AppLayoutState>(initialState);
|
||||||
|
@ -105,6 +109,10 @@ export const AppContextProvider = (props: Props) => {
|
||||||
initialState.currency
|
initialState.currency
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const [playerName, setPlayerName] = useStateWithLocalStorage<
|
||||||
|
string | undefined
|
||||||
|
>("playerName", initialState.playerName);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<AppContext.Provider
|
<AppContext.Provider
|
||||||
value={{
|
value={{
|
||||||
|
@ -118,6 +126,7 @@ export const AppContextProvider = (props: Props) => {
|
||||||
fontSize,
|
fontSize,
|
||||||
dyslexic,
|
dyslexic,
|
||||||
currency,
|
currency,
|
||||||
|
playerName,
|
||||||
setSubPanelOpen,
|
setSubPanelOpen,
|
||||||
setLanguagePanelOpen,
|
setLanguagePanelOpen,
|
||||||
setConfigPanelOpen,
|
setConfigPanelOpen,
|
||||||
|
@ -128,6 +137,7 @@ export const AppContextProvider = (props: Props) => {
|
||||||
setFontSize,
|
setFontSize,
|
||||||
setDyslexic,
|
setDyslexic,
|
||||||
setCurrency,
|
setCurrency,
|
||||||
|
setPlayerName,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{props.children}
|
{props.children}
|
||||||
|
|
|
@ -80,6 +80,20 @@
|
||||||
.prose blockquote {
|
.prose blockquote {
|
||||||
@apply border-l-dark;
|
@apply border-l-dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* INPUT */
|
||||||
|
|
||||||
|
input {
|
||||||
|
@apply rounded-full p-2 text-center bg-light outline outline-mid outline-2 outline-offset-[-2px] hover:outline-[transparent] text-dark hover:bg-mid transition-all;
|
||||||
|
}
|
||||||
|
|
||||||
|
input::placeholder {
|
||||||
|
@apply text-dark opacity-60;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus-visible {
|
||||||
|
@apply outline-none bg-mid shadow-inner-sm;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@layer components {
|
@layer components {
|
||||||
|
|
Loading…
Reference in New Issue