Move Chart to styled-components (#1098)

This commit is contained in:
Jaco Greeff 2019-05-07 15:40:05 +02:00 committed by GitHub
parent 8f9d9ae96b
commit 92a0967ed9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 12 deletions

View File

@ -0,0 +1,37 @@
// Copyright 2017-2019 @polkadot/ui-app authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
import { BareProps } from '../types';
import React from 'react';
import styled from 'styled-components';
import { classes } from '../util';
type Props = BareProps & {
children: React.ReactNode
};
const Wrapper = styled.div`
position: relative;
display: inline-block;
padding: 1em 1em 0;
height: 15vw;
width: 15vw;
`;
export default class BaseChart extends React.PureComponent<Props> {
render () {
const { children, className, style } = this.props;
return (
<Wrapper
className={classes('ui--Chart', className)}
style={style}
>
{children}
</Wrapper>
);
}
}

View File

@ -9,7 +9,7 @@ import React from 'react';
import { Doughnut } from 'react-chartjs-2';
import { bnToBn } from '@polkadot/util';
import { classes } from '../util';
import Base from './Base';
type Value = {
colors: Array<string>,
@ -48,8 +48,8 @@ export default class ChartDoughnut extends React.PureComponent<Props> {
} as Options);
return (
<div
className={classes('ui--Chart', className)}
<Base
className={className}
style={style}
>
<Doughnut
@ -64,7 +64,7 @@ export default class ChartDoughnut extends React.PureComponent<Props> {
height={size}
width={size}
/>
</div>
</Base>
);
}
}

View File

@ -217,14 +217,6 @@ header .ui--Button-Group {
}
}
.ui--Chart {
position: relative;
display: inline-block;
padding: 1em 1em 0;
height: 15vw;
width: 15vw;
}
.ui--CopyButton {
cursor: copy !important;
margin-left: 0.25rem !important;