mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-08-21 20:20:33 +01:00
wire ui
This commit is contained in:
committed by
Aleksej Komarov
parent
158e70df99
commit
cf0239052c
@@ -1,59 +1,61 @@
|
||||
import { Fragment } from 'inferno';
|
||||
import { useBackend } from '../backend';
|
||||
import { Box, Button, LabeledList, Section } from '../components';
|
||||
import { Box, Button, LabeledList, Section, Layout } from '../components';
|
||||
|
||||
export const Wires = props => {
|
||||
const { act, data } = useBackend(props);
|
||||
export const Wires = (props, context) => {
|
||||
const { act, data } = useBackend(context);
|
||||
const wires = data.wires || [];
|
||||
const statuses = data.status || [];
|
||||
return (
|
||||
<Fragment>
|
||||
<Section>
|
||||
<LabeledList>
|
||||
{wires.map(wire => (
|
||||
<LabeledList.Item
|
||||
key={wire.color}
|
||||
className="candystripe"
|
||||
label={wire.color}
|
||||
labelColor={wire.color}
|
||||
color={wire.color}
|
||||
buttons={(
|
||||
<Fragment>
|
||||
<Button
|
||||
content={wire.cut ? 'Mend' : 'Cut'}
|
||||
onClick={() => act('cut', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
<Button
|
||||
content="Pulse"
|
||||
onClick={() => act('pulse', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
<Button
|
||||
content={wire.attached ? 'Detach' : 'Attach'}
|
||||
onClick={() => act('attach', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
</Fragment>
|
||||
)}>
|
||||
{!!wire.wire && (
|
||||
<i>
|
||||
({wire.wire})
|
||||
</i>
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
))}
|
||||
</LabeledList>
|
||||
</Section>
|
||||
{!!statuses.length && (
|
||||
<Layout>
|
||||
<Layout.Content>
|
||||
<Section>
|
||||
{statuses.map(status => (
|
||||
<Box key={status}>
|
||||
{status}
|
||||
</Box>
|
||||
))}
|
||||
<LabeledList>
|
||||
{wires.map(wire => (
|
||||
<LabeledList.Item
|
||||
key={wire.color}
|
||||
className="candystripe"
|
||||
label={wire.color}
|
||||
labelColor={wire.color}
|
||||
color={wire.color}
|
||||
buttons={(
|
||||
<Fragment>
|
||||
<Button
|
||||
content={wire.cut ? 'Mend' : 'Cut'}
|
||||
onClick={() => act('cut', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
<Button
|
||||
content="Pulse"
|
||||
onClick={() => act('pulse', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
<Button
|
||||
content={wire.attached ? 'Detach' : 'Attach'}
|
||||
onClick={() => act('attach', {
|
||||
wire: wire.color,
|
||||
})} />
|
||||
</Fragment>
|
||||
)}>
|
||||
{!!wire.wire && (
|
||||
<i>
|
||||
({wire.wire})
|
||||
</i>
|
||||
)}
|
||||
</LabeledList.Item>
|
||||
))}
|
||||
</LabeledList>
|
||||
</Section>
|
||||
)}
|
||||
</Fragment>
|
||||
{!!statuses.length && (
|
||||
<Section>
|
||||
{statuses.map(status => (
|
||||
<Box key={status}>
|
||||
{status}
|
||||
</Box>
|
||||
))}
|
||||
</Section>
|
||||
)}
|
||||
</Layout.Content>
|
||||
</Layout>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user