forked from tgstation/tgstation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Jukebox TGUI * Line endings * Review fixes
- Loading branch information
Showing
3 changed files
with
176 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import { sortBy } from 'common/collections'; | ||
import { flow } from 'common/fp'; | ||
import { useBackend } from '../backend'; | ||
import { Box, Button, Dropdown, Section, Knob, LabeledControls, LabeledList } from '../components'; | ||
import { Window } from '../layouts'; | ||
|
||
export const Jukebox = (props, context) => { | ||
const { act, data } = useBackend(context); | ||
const { | ||
active, | ||
track_selected, | ||
track_length, | ||
track_beat, | ||
volume, | ||
} = data; | ||
const songs = flow([ | ||
sortBy( | ||
song => song.name), | ||
])(data.songs || []); | ||
return ( | ||
<Window> | ||
<Window.Content> | ||
<Section | ||
title="Song Player" | ||
buttons={( | ||
<Button | ||
icon={active ? 'pause' : 'play'} | ||
content={active ? 'Stop' : 'Play'} | ||
selected={active} | ||
onClick={() => act('toggle')} /> | ||
)}> | ||
<LabeledList> | ||
<LabeledList.Item label="Track Selected"> | ||
<Dropdown | ||
overflow-y="scroll" | ||
width="240px" | ||
options={songs.map(song => song.name)} | ||
disabled={active} | ||
selected={track_selected || "Select a Track"} | ||
onSelected={value => act('select_track', { | ||
track: value, | ||
})} /> | ||
</LabeledList.Item> | ||
<LabeledList.Item label="Track Length"> | ||
{track_selected ? track_length : "No Track Selected"} | ||
</LabeledList.Item> | ||
<LabeledList.Item label="Track Beat"> | ||
{track_selected ? track_beat : "No Track Selected"} | ||
{track_beat === 1 ? " beat" : " beats"} | ||
</LabeledList.Item> | ||
</LabeledList> | ||
</Section> | ||
<Section title="Machine Settings"> | ||
<LabeledControls justify="center"> | ||
<LabeledControls.Item label="Volume"> | ||
<Box position="relative"> | ||
<Knob | ||
size={3.2} | ||
color={volume >= 50 ? 'red' : 'green'} | ||
value={volume} | ||
unit="%" | ||
minValue={0} | ||
maxValue={100} | ||
step={1} | ||
stepPixelSize={1} | ||
disabled={active} | ||
onDrag={(e, value) => act('set_volume', { | ||
volume: value, | ||
})} /> | ||
<Button | ||
fluid | ||
position="absolute" | ||
top="-2px" | ||
right="-22px" | ||
color="transparent" | ||
icon="fast-backward" | ||
onClick={() => act('set_volume', { | ||
volume: "min", | ||
})} /> | ||
<Button | ||
fluid | ||
position="absolute" | ||
top="16px" | ||
right="-22px" | ||
color="transparent" | ||
icon="fast-forward" | ||
onClick={() => act('set_volume', { | ||
volume: "max", | ||
})} /> | ||
<Button | ||
fluid | ||
position="absolute" | ||
top="34px" | ||
right="-22px" | ||
color="transparent" | ||
icon="undo" | ||
onClick={() => act('set_volume', { | ||
volume: "reset", | ||
})} /> | ||
</Box> | ||
</LabeledControls.Item> | ||
</LabeledControls> | ||
</Section> | ||
</Window.Content> | ||
</Window> | ||
); | ||
}; |
Large diffs are not rendered by default.
Oops, something went wrong.