migrated RadarGrid to material-ui styles

This commit is contained in:
Bilawal Hameed
2020-04-23 17:17:57 +02:00
parent c521e175f9
commit 1c3c6aa2a4
2 changed files with 30 additions and 31 deletions
@@ -1,24 +0,0 @@
.ring {
fill: none;
stroke: #bbb;
stroke-width: 1px;
}
.axis {
fill: none;
stroke: #bbb;
stroke-width: 1px;
}
.text {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
sans-serif;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
pointer-events: none;
user-select: none;
fill: #e5e5e5;
font-size: 25px;
font-weight: bold;
}
@@ -16,14 +16,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core';
import * as CommonPropTypes from '../../utils/prop-types';
import styles from './RadarGrid.css';
const styles = {
ring: {
fill: 'none',
stroke: '#bbb',
strokeWidth: '1px',
},
axis: {
fill: 'none',
stroke: '#bbb',
strokeWidth: '1px',
},
text: {
pointerEvents: 'none',
userSelect: 'none',
fill: '#e5e5e5',
fontSize: '25px',
fontWeight: 800,
},
};
// A component for the background grid of the radar, with axes, rings etc. It will render around the origin, i.e.
// assume that (0, 0) is in the middle of the drawing.
export default class RadarGrid extends React.PureComponent {
class RadarGrid extends React.PureComponent {
render() {
const { radius, rings } = this.props;
const { radius, rings, classes } = this.props;
const makeRingNode = (ringRadius, ringIndex) => [
<circle
@@ -31,13 +51,13 @@ export default class RadarGrid extends React.PureComponent {
cx={0}
cy={0}
r={ringRadius}
className={styles.ring}
className={classes.ring}
/>,
<text
key={`t${ringIndex}`}
y={-ringRadius + 42}
textAnchor="middle"
className={styles.text}
className={classes.text}
>
{rings[ringIndex].name}
</text>,
@@ -51,7 +71,7 @@ export default class RadarGrid extends React.PureComponent {
y1={-radius}
x2={0}
y2={radius}
className={styles.axis}
className={classes.axis}
/>,
// Y axis
<line
@@ -60,7 +80,7 @@ export default class RadarGrid extends React.PureComponent {
y1={0}
x2={radius}
y2={0}
className={styles.axis}
className={classes.axis}
/>,
];
@@ -73,4 +93,7 @@ export default class RadarGrid extends React.PureComponent {
RadarGrid.propTypes = {
radius: PropTypes.number.isRequired,
rings: PropTypes.arrayOf(PropTypes.shape(CommonPropTypes.RING)).isRequired,
classes: PropTypes.array.isRequired, // this is the withStyles HOC
};
export default withStyles(styles)(RadarGrid);