From 1867154ed25bdf5ae2616331b89db5aa1764a963 Mon Sep 17 00:00:00 2001 From: checktheroads Date: Sat, 2 May 2020 18:58:15 -0700 Subject: [PATCH] fix structured output table --- hyperglass/constants.py | 2 +- hyperglass/ui/components/Card/CardBody.js | 29 ++++++++ hyperglass/ui/components/Card/index.js | 31 ++------ hyperglass/ui/components/Table/TableCell.js | 1 + .../Table/{MainTable.js => TableMain.js} | 5 +- hyperglass/ui/components/Table/TableRow.js | 2 +- .../ui/components/Table/TableSelectShow.js | 2 +- hyperglass/ui/components/Table/index.js | 49 ++++++++----- hyperglass/ui/components/Table/styles.js | 70 ------------------- hyperglass/ui/pages/_app.js | 8 +-- hyperglass/ui/pages/structured.js | 13 +++- 11 files changed, 86 insertions(+), 126 deletions(-) create mode 100644 hyperglass/ui/components/Card/CardBody.js rename hyperglass/ui/components/Table/{MainTable.js => TableMain.js} (94%) delete mode 100644 hyperglass/ui/components/Table/styles.js diff --git a/hyperglass/constants.py b/hyperglass/constants.py index cca0ed0..40fa3f4 100644 --- a/hyperglass/constants.py +++ b/hyperglass/constants.py @@ -31,7 +31,7 @@ PARSED_RESPONSE_FIELDS = ( ("RPKI State", "rpki_state", "center"), ("AS Path", "as_path", "left"), ("Next Hop", "next_hop", "left"), - ("Origin", "source_as", "right"), + ("Origin", "source_as", None), ("Weight", "weight", "center"), ("Local Preference", "local_preference", "center"), ("MED", "med", "center"), diff --git a/hyperglass/ui/components/Card/CardBody.js b/hyperglass/ui/components/Card/CardBody.js new file mode 100644 index 0000000..a6c35e2 --- /dev/null +++ b/hyperglass/ui/components/Card/CardBody.js @@ -0,0 +1,29 @@ +import * as React from "react"; +import { Flex, useColorMode } from "@chakra-ui/core"; + +const bg = { light: "white", dark: "original.dark" }; +const color = { light: "original.dark", dark: "white" }; + +const CardBody = ({ onClick = () => false, children, ...props }) => { + const { colorMode } = useColorMode(); + return ( + + {children} + + ); +}; + +CardBody.displayName = "CardBody"; + +export default CardBody; diff --git a/hyperglass/ui/components/Card/index.js b/hyperglass/ui/components/Card/index.js index fd99e3f..58e18ce 100644 --- a/hyperglass/ui/components/Card/index.js +++ b/hyperglass/ui/components/Card/index.js @@ -1,28 +1,5 @@ -import * as React from "react"; -import { Flex, useColorMode } from "@chakra-ui/core"; +import CardBody from "./CardBody"; +import CardFooter from "./CardFooter"; +import CardHeader from "./CardHeader"; -const bg = { light: "white", dark: "black" }; -const color = { light: "black", dark: "white" }; - -const Card = ({ onClick = () => false, children, ...props }) => { - const { colorMode } = useColorMode(); - return ( - - {children} - - ); -}; - -Card.displayName = "Card"; - -export default Card; +export { CardBody, CardFooter, CardHeader }; diff --git a/hyperglass/ui/components/Table/TableCell.js b/hyperglass/ui/components/Table/TableCell.js index 71cc783..8c24022 100644 --- a/hyperglass/ui/components/Table/TableCell.js +++ b/hyperglass/ui/components/Table/TableCell.js @@ -39,6 +39,7 @@ const TableCell = ({ m={0} w="1%" whiteSpace="nowrap" + textAlign={align} {...borderProps} {...props} > diff --git a/hyperglass/ui/components/Table/MainTable.js b/hyperglass/ui/components/Table/TableMain.js similarity index 94% rename from hyperglass/ui/components/Table/MainTable.js rename to hyperglass/ui/components/Table/TableMain.js index 38790ef..856630a 100644 --- a/hyperglass/ui/components/Table/MainTable.js +++ b/hyperglass/ui/components/Table/TableMain.js @@ -1,4 +1,4 @@ -/*@jsx jsx*/ +/** @jsx jsx */ import { jsx } from "@emotion/core"; import { Box, css, useTheme, useColorMode } from "@chakra-ui/core"; @@ -12,6 +12,7 @@ const MainTable = ({ children, ...props }) => { return ( { "-ms-overflow-style": { display: "none" } })(theme)} - overflow="auto" + overflowX="auto" borderRadius="md" boxSizing="border-box" {...props} diff --git a/hyperglass/ui/components/Table/TableRow.js b/hyperglass/ui/components/Table/TableRow.js index 8407793..9447bfc 100644 --- a/hyperglass/ui/components/Table/TableRow.js +++ b/hyperglass/ui/components/Table/TableRow.js @@ -9,7 +9,7 @@ import { opposingColor } from "~/util"; // } // `; -const hoverBg = { dark: "whiteAlpha.100", light: "blackAlpha.100" }; +const hoverBg = { dark: "whiteAlpha.50", light: "blackAlpha.50" }; const bgStripe = { dark: "whiteAlpha.50", light: "blackAlpha.50" }; const rowBorder = { dark: { borderTop: "1px", borderTopColor: "whiteAlpha.100" }, diff --git a/hyperglass/ui/components/Table/TableSelectShow.js b/hyperglass/ui/components/Table/TableSelectShow.js index a61040f..b172325 100644 --- a/hyperglass/ui/components/Table/TableSelectShow.js +++ b/hyperglass/ui/components/Table/TableSelectShow.js @@ -16,7 +16,7 @@ import { Select } from "@chakra-ui/core"; const TableSelectShow = ({ value, onChange, children, ...props }) => { return ( - {[5, 10, 20, 30, 40, 50].map(value => (