mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-10 18:22:39 +00:00
Prettify stuff
This commit is contained in:
@@ -19,11 +19,20 @@ const KEY_INCREMENT = 1;
|
||||
|
||||
export const AlertModal = (props, context) => {
|
||||
const { act, data } = useBackend<AlertModalData>(context);
|
||||
const { autofocus, buttons = [], large_buttons, message = '', timeout, title } = data;
|
||||
const {
|
||||
autofocus,
|
||||
buttons = [],
|
||||
large_buttons,
|
||||
message = '',
|
||||
timeout,
|
||||
title,
|
||||
} = data;
|
||||
const [selected, setSelected] = useLocalState<number>(context, 'selected', 0);
|
||||
// Dynamically sets window dimensions
|
||||
const windowHeight =
|
||||
115 + (message.length > 30 ? Math.ceil(message.length / 4) : 0) + (message.length && large_buttons ? 5 : 0);
|
||||
115 +
|
||||
(message.length > 30 ? Math.ceil(message.length / 4) : 0) +
|
||||
(message.length && large_buttons ? 5 : 0);
|
||||
const windowWidth = 325 + (buttons.length > 2 ? 55 : 0);
|
||||
const onKey = (direction: number) => {
|
||||
if (selected === 0 && direction === KEY_DECREMENT) {
|
||||
@@ -86,15 +95,28 @@ const ButtonDisplay = (props, context) => {
|
||||
const { selected } = props;
|
||||
|
||||
return (
|
||||
<Flex align="center" direction={!swapped_buttons ? 'row-reverse' : 'row'} fill justify="space-around" wrap>
|
||||
<Flex
|
||||
align="center"
|
||||
direction={!swapped_buttons ? 'row-reverse' : 'row'}
|
||||
fill
|
||||
justify="space-around"
|
||||
wrap>
|
||||
{buttons?.map((button, index) =>
|
||||
!!large_buttons && buttons.length < 3 ? (
|
||||
<Flex.Item grow key={index}>
|
||||
<AlertButton button={button} id={index.toString()} selected={selected === index} />
|
||||
<AlertButton
|
||||
button={button}
|
||||
id={index.toString()}
|
||||
selected={selected === index}
|
||||
/>
|
||||
</Flex.Item>
|
||||
) : (
|
||||
<Flex.Item key={index}>
|
||||
<AlertButton button={button} id={index.toString()} selected={selected === index} />
|
||||
<AlertButton
|
||||
button={button}
|
||||
id={index.toString()}
|
||||
selected={selected === index}
|
||||
/>
|
||||
</Flex.Item>
|
||||
)
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user