From 49cd2fedfb7262920a905067133318ca93f3eb8a Mon Sep 17 00:00:00 2001 From: Kim Truong <47833996+khtruong@users.noreply.github.com> Date: Mon, 11 Mar 2019 19:02:50 -0700 Subject: [PATCH] feat: add properties for font sizing (#10) * feat: add properties for font sizing * revert package.json changes * refactor: rename bigNum to header * chore: empty commit to kick off travis --- .../src/BigNumber/BigNumber.jsx | 20 ++++++++++--------- .../src/BigNumber/transformProps.js | 4 ++++ 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.jsx b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.jsx index fd00513a49227..23a9a33608c78 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.jsx +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/BigNumber.jsx @@ -35,10 +35,8 @@ const CHART_MARGIN = { }; const PROPORTION = { - HEADER: 0.4, - SUBHEADER: 0.14, - HEADER_WITH_TRENDLINE: 0.3, - SUBHEADER_WITH_TRENDLINE: 0.125, + HEADER: 0.3, + SUBHEADER: 0.125, TRENDLINE: 0.3, }; @@ -78,7 +76,9 @@ const propTypes = { height: PropTypes.number.isRequired, bigNumber: PropTypes.number.isRequired, formatBigNumber: PropTypes.func, + headerFontSize: PropTypes.number, subheader: PropTypes.string, + subheaderFontSize: PropTypes.number, showTrendLine: PropTypes.bool, startYAxisAtZero: PropTypes.bool, trendLineData: PropTypes.array, @@ -88,7 +88,9 @@ const propTypes = { const defaultProps = { className: '', formatBigNumber: identity, + headerFontSize: PROPORTION.HEADER, subheader: '', + subheaderFontSize: PROPORTION.SUBHEADER, showTrendLine: false, startYAxisAtZero: true, trendLineData: null, @@ -217,7 +219,7 @@ class BigNumberVis extends React.PureComponent { } render() { - const { showTrendLine, height } = this.props; + const { showTrendLine, height, headerFontSize, subheaderFontSize } = this.props; const className = this.getClassName(); if (showTrendLine) { @@ -227,8 +229,8 @@ class BigNumberVis extends React.PureComponent { return (
- {this.renderHeader(Math.ceil(PROPORTION.HEADER_WITH_TRENDLINE * height))} - {this.renderSubheader(Math.ceil(PROPORTION.SUBHEADER_WITH_TRENDLINE * height))} + {this.renderHeader(Math.ceil(headerFontSize * height))} + {this.renderSubheader(Math.ceil(subheaderFontSize * height))}
{this.renderTrendline(chartHeight)}
@@ -237,8 +239,8 @@ class BigNumberVis extends React.PureComponent { return (
- {this.renderHeader(Math.ceil(PROPORTION.HEADER * height))} - {this.renderSubheader(Math.ceil(PROPORTION.SUBHEADER * height))} + {this.renderHeader(Math.ceil(headerFontSize * height))} + {this.renderSubheader(Math.ceil(subheaderFontSize * height))}
); } diff --git a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.js b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.js index 3d6e9ea032bfd..476981c0e73a6 100644 --- a/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.js +++ b/superset-frontend/temporary_superset_ui/superset-ui/plugins/superset-ui-plugins/packages/superset-ui-legacy-preset-chart-big-number/src/BigNumber/transformProps.js @@ -29,6 +29,8 @@ export default function transformProps(chartProps) { colorPicker, compareLag: compareLagInput, compareSuffix = '', + headerFontSize, + subheaderFontSize, metric, showTrendLine, startYAxisAtZero, @@ -88,6 +90,8 @@ export default function transformProps(chartProps) { bigNumber, className, formatBigNumber: formatValue, + headerFontSize, + subheaderFontSize, mainColor, renderTooltip: renderTooltipFactory(formatValue), showTrendLine: supportAndShowTrendLine,