aboutsummaryrefslogtreecommitdiffstats
path: root/webui/src/Label.tsx
diff options
context:
space:
mode:
authorQuentin Gliech <quentingliech@gmail.com>2020-02-13 00:53:29 +0100
committerQuentin Gliech <quentingliech@gmail.com>2020-02-13 00:53:29 +0100
commit8b85780d76ad45675582f4478eedb026b7ac25e1 (patch)
treeb6ffdc651259ec08ca608cb01acdf1dababccb55 /webui/src/Label.tsx
parent680dd91c0c0200bd4948173df0b601e16f511e6e (diff)
downloadgit-bug-8b85780d76ad45675582f4478eedb026b7ac25e1.tar.gz
webui: start reorganizing the component structure
Diffstat (limited to 'webui/src/Label.tsx')
-rw-r--r--webui/src/Label.tsx55
1 files changed, 0 insertions, 55 deletions
diff --git a/webui/src/Label.tsx b/webui/src/Label.tsx
deleted file mode 100644
index a33b4c2c..00000000
--- a/webui/src/Label.tsx
+++ /dev/null
@@ -1,55 +0,0 @@
-import { common } from '@material-ui/core/colors';
-import { makeStyles } from '@material-ui/core/styles';
-import {
- getContrastRatio,
- darken,
-} from '@material-ui/core/styles/colorManipulator';
-import React from 'react';
-
-import { LabelFragment } from './Label.generated';
-import { Color } from './gqlTypes';
-
-// Minimum contrast between the background and the text color
-const contrastThreshold = 2.5;
-
-// Guess the text color based on the background color
-const getTextColor = (background: string) =>
- getContrastRatio(background, common.white) >= contrastThreshold
- ? common.white // White on dark backgrounds
- : common.black; // And black on light ones
-
-const _rgb = (color: Color) =>
- 'rgb(' + color.R + ',' + color.G + ',' + color.B + ')';
-
-// Create a style object from the label RGB colors
-const createStyle = (color: Color) => ({
- backgroundColor: _rgb(color),
- color: getTextColor(_rgb(color)),
- borderBottomColor: darken(_rgb(color), 0.2),
-});
-
-const useStyles = makeStyles(theme => ({
- label: {
- ...theme.typography.body1,
- padding: '1px 6px 0.5px',
- fontSize: '0.9em',
- fontWeight: 500,
- margin: '0.05em 1px calc(-1.5px + 0.05em)',
- borderRadius: '3px',
- display: 'inline-block',
- borderBottom: 'solid 1.5px',
- verticalAlign: 'bottom',
- },
-}));
-
-type Props = { label: LabelFragment };
-function Label({ label }: Props) {
- const classes = useStyles();
- return (
- <span className={classes.label} style={createStyle(label.color)}>
- {label.name}
- </span>
- );
-}
-
-export default Label;