1
0
mirror of https://github.com/checktheroads/hyperglass synced 2024-05-11 05:55:08 +00:00

63 lines
2.3 KiB
JavaScript
Raw Normal View History

2020-01-17 02:50:57 -07:00
import React from "react";
import { Flex, useColorMode, useTheme } from "@chakra-ui/core";
export default React.forwardRef(
2020-01-20 00:37:04 -07:00
({ value, label, labelColor, valueBg, valueColor, ...props }, ref) => {
2020-01-17 02:50:57 -07:00
const theme = useTheme();
const { colorMode } = useColorMode();
2020-01-20 00:37:04 -07:00
const _labelColor = { dark: "whiteAlpha.700", light: "blackAlpha.700" };
2020-01-17 02:50:57 -07:00
const _valueBg = { light: theme.colors.primary[600], dark: theme.colors.primary[600] };
2020-01-20 00:37:04 -07:00
const _valueColor = { light: "white", dark: "white" };
2020-01-17 02:50:57 -07:00
return (
2020-01-20 00:37:04 -07:00
<Flex
ref={ref}
flexWrap="nowrap"
alignItems="center"
justifyContent="flex-start"
mx={[1, 2, 2, 2]}
my={2}
{...props}
>
2020-01-17 02:50:57 -07:00
<Flex
display="inline-flex"
justifyContent="center"
lineHeight="1.5"
2020-01-20 00:37:04 -07:00
px={[1, 3, 3, 3]}
2020-01-17 02:50:57 -07:00
whiteSpace="nowrap"
mb={2}
mr={0}
bg={valueBg || _valueBg[colorMode]}
color={valueColor || _valueColor[colorMode]}
borderBottomLeftRadius={4}
borderTopLeftRadius={4}
borderBottomRightRadius={0}
borderTopRightRadius={0}
fontWeight="bold"
2020-01-20 00:37:04 -07:00
fontSize={["xs", "sm", "sm", "sm"]}
2020-01-17 02:50:57 -07:00
>
{value}
</Flex>
<Flex
display="inline-flex"
justifyContent="center"
lineHeight="1.5"
px={3}
whiteSpace="nowrap"
mb={2}
ml={0}
mr={0}
2020-01-20 00:37:04 -07:00
boxShadow={`inset 0px 0px 0px 1px ${valueBg || _valueBg[colorMode]}`}
2020-01-17 02:50:57 -07:00
color={labelColor || _labelColor[colorMode]}
borderBottomRightRadius={4}
borderTopRightRadius={4}
borderBottomLeftRadius={0}
borderTopLeftRadius={0}
2020-01-20 00:37:04 -07:00
fontSize={["xs", "sm", "sm", "sm"]}
2020-01-17 02:50:57 -07:00
>
{label}
</Flex>
</Flex>
);
}
);