-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MIRROR] Converts ListInputModal to actually be a Modal | Adds ListIn…
…putWindow which uses it (#2139) * Converts ListInputModal to actually be a Modal | Adds ListInputWindow which uses it (#82792) ## About The Pull Request If we say something is a Modal it should actually be a Modal ## Why It's Good For The Game You can now use this system in other windows if you want. Fixed the misnomer. --------- Co-authored-by: Jeremiah <[email protected]> * Converts ListInputModal to actually be a Modal | Adds ListInputWindow which uses it --------- Co-authored-by: Zephyr <[email protected]> Co-authored-by: Jeremiah <[email protected]>
- Loading branch information
1 parent
df3285b
commit 938336f
Showing
4 changed files
with
144 additions
and
97 deletions.
There are no files selected for viewing
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
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,44 @@ | ||
import { useBackend } from '../../backend'; | ||
import { Window } from '../../layouts'; | ||
import { Loader } from '../common/Loader'; | ||
import { ListInputModal } from './ListInputModal'; | ||
|
||
type ListInputData = { | ||
init_value: string; | ||
items: string[]; | ||
large_buttons: boolean; | ||
message: string; | ||
timeout: number; | ||
title: string; | ||
}; | ||
|
||
export const ListInputWindow = () => { | ||
const { act, data } = useBackend<ListInputData>(); | ||
const { | ||
items = [], | ||
message = '', | ||
init_value, | ||
large_buttons, | ||
timeout, | ||
title, | ||
} = data; | ||
|
||
// Dynamically changes the window height based on the message. | ||
const windowHeight = | ||
325 + Math.ceil(message.length / 3) + (large_buttons ? 5 : 0); | ||
|
||
return ( | ||
<Window title={title} width={325} height={windowHeight}> | ||
{timeout && <Loader value={timeout} />} | ||
<Window.Content> | ||
<ListInputModal | ||
items={items} | ||
default_item={init_value} | ||
message={message} | ||
on_selected={(entry) => act('submit', { entry })} | ||
on_cancel={() => act('cancel')} | ||
/> | ||
</Window.Content> | ||
</Window> | ||
); | ||
}; |
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