-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
31,719 additions
and
31,258 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,52 @@ | ||
{ | ||
"name": "client", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/user-event": "^13.5.0", | ||
"@types/jest": "^29.5.0", | ||
"@types/marked": "^5.0.0", | ||
"@types/dompurify": "^3.0.2", | ||
"@types/node": "^18.15.5", | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"dompurify": "^3.0.3", | ||
"marked": "^5.1.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-scripts": "^5.0.1", | ||
"typescript": "^4", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --passWithNoTests", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} | ||
{ | ||
"name": "client", | ||
"version": "0.1.0", | ||
"private": true, | ||
"dependencies": { | ||
"@testing-library/jest-dom": "^5.16.5", | ||
"@testing-library/react": "^13.4.0", | ||
"@testing-library/user-event": "^13.5.0", | ||
"@types/dompurify": "^3.0.2", | ||
"@types/jest": "^29.5.0", | ||
"@types/marked": "^5.0.0", | ||
"@types/node": "^18.15.5", | ||
"@types/react": "^18.0.28", | ||
"@types/react-dom": "^18.0.11", | ||
"dompurify": "^3.0.3", | ||
"marked": "^5.1.0", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"react-helmet": "^6.1.0", | ||
"react-scripts": "^5.0.1", | ||
"typescript": "^4", | ||
"web-vitals": "^2.1.4" | ||
}, | ||
"devDependencies": { | ||
"@babel/plugin-proposal-private-property-in-object": "7.21.0-placeholder-for-preset-env.2", | ||
"@types/react-helmet": "^6.1.11" | ||
}, | ||
"scripts": { | ||
"start": "react-scripts start", | ||
"build": "react-scripts build", | ||
"test": "react-scripts test --passWithNoTests", | ||
"eject": "react-scripts eject" | ||
}, | ||
"eslintConfig": { | ||
"extends": [ | ||
"react-app", | ||
"react-app/jest" | ||
] | ||
}, | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
} | ||
} |
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,19 @@ | ||
{ | ||
"short_name": "Midnight Machinations", | ||
"name": "Midnight Machinations", | ||
"icons": [ | ||
{ | ||
"src": "mafia_logo.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon", | ||
"purpose": "maskable" | ||
}, | ||
{ | ||
"src": "mafia_logo192.png", | ||
"type": "image/png", | ||
"sizes": "192x192", | ||
"purpose": "maskable" | ||
}, | ||
{ | ||
"src": "mafia_logo512.png", | ||
"type": "image/png", | ||
"sizes": "512x512", | ||
"purpose": "maskable" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#2d3646" | ||
"short_name": "Midnight Machinations", | ||
"name": "Midnight Machinations", | ||
"icons":[ | ||
{ | ||
"src":"/android-chrome-192x192.png", | ||
"sizes":"192x192", | ||
"type":"image/png" | ||
}, | ||
{ | ||
"src":"/android-chrome-512x512.png", | ||
"sizes":"512x512", | ||
"type":"image/png" | ||
} | ||
], | ||
"theme_color":"#ffffff", | ||
"background_color":"#2d3646", | ||
"display":"standalone" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,172 @@ | ||
import { ReactElement, useEffect, useMemo, useState } from "react"; | ||
import StyledText from "./StyledText"; | ||
import { sanitizePlayerMessage } from "./ChatMessage"; | ||
import GAME_MANAGER, { replaceMentions } from ".."; | ||
import React from "react"; | ||
import { Button } from "./Button"; | ||
import Icon from "./Icon"; | ||
import translate from "../game/lang"; | ||
import "./textAreaDropdown.css"; | ||
|
||
export function TextDropdownArea(props: Readonly<{ | ||
titleString: string, | ||
savedText: string, | ||
open?: boolean, | ||
onAdd?: () => void, | ||
onSubtract?: () => void, | ||
onSave: (text: string) => void, | ||
cantPost: boolean | ||
}>): ReactElement { | ||
const [field, setField] = useState<string>(props.savedText); | ||
|
||
useEffect(() => { | ||
setField(props.savedText) | ||
}, [props.savedText]) | ||
|
||
const unsaved = useMemo(() => { | ||
return props.savedText !== field | ||
}, [field, props.savedText]); | ||
|
||
function send(field: string){ | ||
save(field); | ||
GAME_MANAGER.sendSendMessagePacket('\n' + field); | ||
} | ||
|
||
function save(field: string) { | ||
props.onSave(field); | ||
} | ||
|
||
return ( | ||
<details className="text-area-dropdown" open={props.open ?? false}> | ||
<summary> | ||
<TextDropdownLabel | ||
titleString={props.titleString} | ||
savedText={props.savedText} | ||
field={field} | ||
onAdd={props.onAdd} | ||
onSubtract={props.onSubtract} | ||
onSave={save} | ||
cantPost={props.cantPost} | ||
/> | ||
</summary> | ||
{unsaved ? "Unsaved" : ""} | ||
<PrettyTextArea | ||
field={field} | ||
setField={setField} | ||
save={save} | ||
send={send} | ||
/> | ||
</details> | ||
) | ||
} | ||
|
||
function TextDropdownLabel( | ||
props: Readonly<{ | ||
titleString: string, | ||
savedText: string, | ||
field: string, | ||
open?: boolean, | ||
onAdd?: () => void, | ||
onSubtract?: () => void, | ||
onSave: (text: string) => void, | ||
cantPost: boolean | ||
}> | ||
): ReactElement { | ||
|
||
const unsaved = useMemo(() => { | ||
return props.savedText !== props.field | ||
}, [props.field, props.savedText]); | ||
|
||
function save(field: string) { | ||
props.onSave(field); | ||
} | ||
|
||
function send(field: string){ | ||
save(field); | ||
GAME_MANAGER.sendSendMessagePacket('\n' + field); | ||
} | ||
|
||
return <div> | ||
<StyledText>{props.titleString}</StyledText> | ||
<span> | ||
{props.onSubtract ? <Button | ||
onClick={() => { | ||
if(props.onSubtract) | ||
props.onSubtract(); | ||
}} | ||
pressedChildren={() => <Icon size="small">done</Icon>} | ||
aria-label={translate("menu.will.subtract")} | ||
> | ||
<Icon size="small">remove</Icon> | ||
</Button> : null} | ||
{props.onAdd ? <Button | ||
onClick={() => { | ||
if(props.onAdd) | ||
props.onAdd(); | ||
}} | ||
pressedChildren={() => <Icon size="small">done</Icon>} | ||
aria-label={translate("menu.will.add")} | ||
> | ||
<Icon size="small">add</Icon> | ||
</Button> : null} | ||
<Button | ||
highlighted={unsaved} | ||
onClick={() => { | ||
save(props.field); | ||
return true; | ||
}} | ||
pressedChildren={() => <Icon size="small">done</Icon>} | ||
aria-label={translate("menu.will.save")} | ||
> | ||
<Icon size="small">save</Icon> | ||
</Button> | ||
<Button | ||
disabled={props.cantPost} | ||
onClick={() => { | ||
send(props.field); | ||
return true; | ||
}} | ||
pressedChildren={() => <Icon size="small">done</Icon>} | ||
aria-label={translate("menu.will.post")} | ||
> | ||
<Icon size="small">send</Icon> | ||
</Button> | ||
</span> | ||
</div> | ||
} | ||
|
||
function PrettyTextArea(props: Readonly<{ | ||
field: string, | ||
setField: (field: string) => void, | ||
save: (field: string) => void, | ||
send: (field: string) => void, | ||
}>): ReactElement { | ||
const [writing, setWriting] = useState<boolean>(false); | ||
const [hover, setHover] = useState<boolean>(false); | ||
|
||
return <div | ||
onMouseEnter={() => setHover(true)} | ||
onMouseLeave={() => setHover(false)} | ||
onFocus={() => setWriting(true)} | ||
onBlur={() => setWriting(false)} | ||
> | ||
{(!writing && !hover) | ||
? <div className="textarea"> | ||
<StyledText noLinks={true}>{sanitizePlayerMessage(replaceMentions(props.field))}</StyledText> | ||
</div> | ||
: <textarea | ||
value={props.field} | ||
onChange={e => props.setField(e.target.value)} | ||
onKeyDown={(e) => { | ||
if (e.ctrlKey) { | ||
if (e.key === 's') { | ||
e.preventDefault(); | ||
props.save(props.field); | ||
} else if (e.key === "Enter") { | ||
props.send(props.field); | ||
} | ||
} | ||
}}> | ||
</textarea>} | ||
</div> | ||
} |
Oops, something went wrong.