@pie-lib/tools 0.28.0 → 0.29.0-mui-update.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,18 +1,18 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { withStyles } from '@material-ui/core/styles';
3
+ import { styled } from '@mui/material/styles';
4
4
  import { noSelect, strokeColor } from '../style-utils';
5
5
  import range from 'lodash/range';
6
6
 
7
- const Tick = withStyles((theme) => ({
8
- tick: {
9
- stroke: strokeColor(theme),
10
- },
11
- }))(({ x, height, bottom, classes, major, minor }) => {
7
+ const StyledTick = styled('line')(({ theme }) => ({
8
+ stroke: strokeColor(theme),
9
+ }));
10
+
11
+ const Tick = ({ x, height, bottom, major, minor }) => {
12
12
  const y1 = major ? bottom - height * 2 : minor ? bottom - height * 1.5 : bottom - height;
13
13
 
14
- return <line y1={y1} y2={bottom} x1={x} x2={x} className={classes.tick} />;
15
- });
14
+ return <StyledTick y1={y1} y2={bottom} x1={x} x2={x} />;
15
+ };
16
16
 
17
17
  const Ticks = ({ count, width, height }) => {
18
18
  return (
@@ -40,48 +40,44 @@ Ticks.propTypes = {
40
40
  height: PropTypes.number.isRequired,
41
41
  };
42
42
 
43
+ const StyledEndTick = styled('line')(({ theme }) => ({
44
+ stroke: strokeColor(theme),
45
+ strokeWidth: 1,
46
+ }));
47
+
48
+ const StyledLabel = styled('text')(({ theme }) => ({
49
+ textAnchor: 'end',
50
+ fontSize: '12px',
51
+ fill: strokeColor(theme),
52
+ ...noSelect(),
53
+ }));
54
+
43
55
  export class Unit extends React.Component {
44
56
  static propTypes = {
45
57
  index: PropTypes.number.isRequired,
46
58
  width: PropTypes.number.isRequired,
47
59
  height: PropTypes.number.isRequired,
48
- classes: PropTypes.object.isRequired,
49
60
  last: PropTypes.bool.isRequired,
50
61
  config: PropTypes.object.isRequired,
51
62
  };
52
63
 
53
64
  render() {
54
- const { index, width, height, classes, last, config } = this.props;
65
+ const { index, width, height, last, config } = this.props;
55
66
 
56
67
  const style = {
57
68
  transform: `translate(${width * (index - 1)}px, 0px)`,
58
69
  };
59
70
  return (
60
71
  <g style={style}>
61
- {!last && <line x1={width} y1={0} x2={width} y2={height} className={classes.endTick} />}
72
+ {!last && <StyledEndTick x1={width} y1={0} x2={width} y2={height} />}
62
73
 
63
74
  <Ticks count={config.ticks} width={width} height={height} />
64
- <text width={width} className={classes.label} x={width - 5} y={15}>
75
+ <StyledLabel width={width} x={width - 5} y={15}>
65
76
  {index}
66
- </text>
77
+ </StyledLabel>
67
78
  </g>
68
79
  );
69
80
  }
70
81
  }
71
82
 
72
- export default withStyles((theme) => ({
73
- endTick: {
74
- stroke: strokeColor(theme),
75
- strokeWidth: 1,
76
- },
77
- label: {
78
- textAnchor: 'end',
79
- fontSize: '12px',
80
- fill: strokeColor(theme),
81
- ...noSelect(),
82
- },
83
- base: {
84
- fill: 'none',
85
- stroke: 'red',
86
- },
87
- }))(Unit);
83
+ export default Unit;