Improved message display
This commit is contained in:
@@ -44,6 +44,9 @@ const theme = deepMerge(grommet, {
|
|||||||
vertical: "xsmall",
|
vertical: "xsmall",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
layer: {
|
||||||
|
background: "#00000000",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
import React, { useState, useEffect, Fragment } from "react";
|
import React, { useState, useEffect, useContext } from "react";
|
||||||
import { useMutation, useApolloClient } from "@apollo/react-hooks";
|
import { useMutation, useApolloClient } from "@apollo/react-hooks";
|
||||||
import { msgToColor } from "../../utils/indi";
|
import { msgToColor } from "../../utils/indi";
|
||||||
import Property from "./property";
|
import Property from "./property";
|
||||||
import gql from "graphql-tag";
|
import gql from "graphql-tag";
|
||||||
import { Box, Button, Tabs, Tab, Text, Layer } from "grommet";
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Tabs,
|
||||||
|
Tab,
|
||||||
|
Text,
|
||||||
|
Layer,
|
||||||
|
ResponsiveContext,
|
||||||
|
} from "grommet";
|
||||||
import { Close, Trash } from "grommet-icons";
|
import { Close, Trash } from "grommet-icons";
|
||||||
|
|
||||||
const CONNECT_DEVICE = gql`
|
const CONNECT_DEVICE = gql`
|
||||||
@@ -28,6 +36,7 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
|||||||
const [groups, setGroups] = useState([]);
|
const [groups, setGroups] = useState([]);
|
||||||
const [selectedTabs, setSelectedTabs] = useState({});
|
const [selectedTabs, setSelectedTabs] = useState({});
|
||||||
const [currentTab, setCurrentTab] = useState(0);
|
const [currentTab, setCurrentTab] = useState(0);
|
||||||
|
const size = useContext(ResponsiveContext);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const groups = new Set();
|
const groups = new Set();
|
||||||
@@ -36,7 +45,7 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
|||||||
});
|
});
|
||||||
setGroups(Array.from(groups));
|
setGroups(Array.from(groups));
|
||||||
setCurrentTab(selectedTabs[device.id] || 0);
|
setCurrentTab(selectedTabs[device.id] || 0);
|
||||||
}, [device]);
|
}, [device, selectedTabs]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box>
|
<Box>
|
||||||
@@ -72,8 +81,13 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
|||||||
|
|
||||||
{messages ? (
|
{messages ? (
|
||||||
<Layer position="right" full="vertical" modal={false}>
|
<Layer position="right" full="vertical" modal={false}>
|
||||||
<Box direction="row">
|
<Box
|
||||||
<Button icon={<Close />} onClick={() => onMessagesClosed()} />
|
background={{ color: "light-1", opacity: "strong" }}
|
||||||
|
fill="vertical"
|
||||||
|
align="start"
|
||||||
|
width={size}
|
||||||
|
>
|
||||||
|
<Box direction="row" justify="end" fill="horizontal">
|
||||||
<Button
|
<Button
|
||||||
icon={<Trash />}
|
icon={<Trash />}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
@@ -87,12 +101,14 @@ const Device = ({ device, messages, onMessagesClosed }) => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
<Button icon={<Close />} onClick={() => onMessagesClosed()} />
|
||||||
</Box>
|
</Box>
|
||||||
<Box width="medium" pad="small">
|
<Box pad="medium">
|
||||||
{device.messages.map((msg) => (
|
{device.messages.map((msg) => (
|
||||||
<Text color={msgToColor(msg)}>{msg}</Text>
|
<Text color={msgToColor(msg)}>{msg}</Text>
|
||||||
))}
|
))}
|
||||||
</Box>
|
</Box>
|
||||||
|
</Box>
|
||||||
</Layer>
|
</Layer>
|
||||||
) : null}
|
) : null}
|
||||||
</Box>
|
</Box>
|
||||||
|
|||||||
@@ -33,7 +33,6 @@ const TextValue = ({ vector, value }) => {
|
|||||||
name: value.name,
|
name: value.name,
|
||||||
value: newval,
|
value: newval,
|
||||||
};
|
};
|
||||||
console.log(input);
|
|
||||||
sendOneText({ variables: { input } });
|
sendOneText({ variables: { input } });
|
||||||
}}
|
}}
|
||||||
></Button>
|
></Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user