mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 06:18:42 +02:00
CODEBASE: Refactor KeyBindingPage (#1984)
This commit is contained in:
@@ -289,49 +289,36 @@ export function KeyBindingPage(): React.ReactElement {
|
||||
knowAboutBitverse() || !(SpoilerKeyBindingTypes as unknown as string[]).includes(keyBindingType),
|
||||
)
|
||||
.map((keyBindingType) => {
|
||||
const primaryKeyCombination = CurrentKeyBindings[keyBindingType][0] ? (
|
||||
parseKeyCombinationToString(CurrentKeyBindings[keyBindingType][0])
|
||||
) : (
|
||||
// Use a non-breaking space to make the button fit to the parent td element.
|
||||
<> </>
|
||||
);
|
||||
const secondaryKeyCombination = CurrentKeyBindings[keyBindingType][1] ? (
|
||||
parseKeyCombinationToString(CurrentKeyBindings[keyBindingType][1])
|
||||
) : (
|
||||
// Use a non-breaking space to make the button fit to the parent td element.
|
||||
<> </>
|
||||
);
|
||||
return (
|
||||
<tr key={keyBindingType}>
|
||||
<td>
|
||||
<Typography minWidth="250px">{keyBindingType}</Typography>
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
sx={{
|
||||
minWidth: "250px",
|
||||
color: `${
|
||||
isCustomKeyCombination(keyBindingType, true) ? Settings.theme.warning : Settings.theme.primary
|
||||
}`,
|
||||
}}
|
||||
onClick={() => showModal(keyBindingType, true)}
|
||||
>
|
||||
{primaryKeyCombination}
|
||||
</Button>
|
||||
</td>
|
||||
<td>
|
||||
<Button
|
||||
sx={{
|
||||
minWidth: "250px",
|
||||
color: `${
|
||||
isCustomKeyCombination(keyBindingType, false) ? Settings.theme.warning : Settings.theme.primary
|
||||
}`,
|
||||
}}
|
||||
onClick={() => showModal(keyBindingType, false)}
|
||||
>
|
||||
{secondaryKeyCombination}
|
||||
</Button>
|
||||
</td>
|
||||
{[0, 1].map((value) => {
|
||||
const isPrimary = value === 0;
|
||||
return (
|
||||
<td key={`${keyBindingType}-${value}`}>
|
||||
<Button
|
||||
sx={{
|
||||
minWidth: "250px",
|
||||
color: `${
|
||||
isCustomKeyCombination(keyBindingType, isPrimary)
|
||||
? Settings.theme.warning
|
||||
: Settings.theme.primary
|
||||
}`,
|
||||
}}
|
||||
onClick={() => showModal(keyBindingType, isPrimary)}
|
||||
>
|
||||
{CurrentKeyBindings[keyBindingType][value] ? (
|
||||
parseKeyCombinationToString(CurrentKeyBindings[keyBindingType][value])
|
||||
) : (
|
||||
// Use a non-breaking space to make the button fit to the parent td element.
|
||||
<> </>
|
||||
)}
|
||||
</Button>
|
||||
</td>
|
||||
);
|
||||
})}
|
||||
</tr>
|
||||
);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user