Skip to content

Commit 87c4250

Browse files
committed
Fix and factor out modifiers view in inspector
1 parent f63d8e8 commit 87c4250

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

src/screens/home/displays/DisplayInspectorInputCard.tsx

+21-14
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import { motion } from 'framer-motion';
2121
import {
2222
GamepadEvent,
2323
KeyEvent,
24+
KeyModifiers,
2425
LegacyControllerEvent,
2526
LegacyKeyEvent,
2627
MouseEvent,
@@ -194,20 +195,7 @@ function KeyEventView({ event }: { event?: KeyEvent | LegacyKeyEvent }) {
194195
<div className="flex flex-col items-center gap-1">
195196
<ObjectInspectorTable objects={[event]} names={keyEventNames} />
196197
<Divider />
197-
<div className="flex flex-row gap-2">
198-
<ModifierView down={event.shiftKey}>
199-
<IconArrowBigUp />
200-
</ModifierView>
201-
<ModifierView down={event.ctrlKey}>
202-
<IconChevronUp />
203-
</ModifierView>
204-
<ModifierView down={event.altKey}>
205-
<IconAlt />
206-
</ModifierView>
207-
<ModifierView down={event.metaKey}>
208-
<IconCommand />
209-
</ModifierView>
210-
</div>
198+
<KeyModifiersView modifiers={event.modifiers} />
211199
<Divider />
212200
</div>
213201
)
@@ -216,6 +204,25 @@ function KeyEventView({ event }: { event?: KeyEvent | LegacyKeyEvent }) {
216204
);
217205
}
218206

207+
function KeyModifiersView({ modifiers }: { modifiers: KeyModifiers }) {
208+
return (
209+
<div className="flex flex-row gap-2">
210+
<ModifierView down={modifiers.shift}>
211+
<IconArrowBigUp />
212+
</ModifierView>
213+
<ModifierView down={modifiers.ctrl}>
214+
<IconChevronUp />
215+
</ModifierView>
216+
<ModifierView down={modifiers.alt}>
217+
<IconAlt />
218+
</ModifierView>
219+
<ModifierView down={modifiers.meta}>
220+
<IconCommand />
221+
</ModifierView>
222+
</div>
223+
);
224+
}
225+
219226
function ModifierView({
220227
down,
221228
children,

0 commit comments

Comments
 (0)