From b2fdc5fa72aefddfcf36b0be520ce74fdc212e34 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Tue, 3 Dec 2019 00:12:17 +0100 Subject: [PATCH] Fix line wrapping of grid axis label --- src/ui/Grid.js | 47 ++++++++++++++++++----------------------------- 1 file changed, 18 insertions(+), 29 deletions(-) diff --git a/src/ui/Grid.js b/src/ui/Grid.js index e1bce06..6ce8c85 100644 --- a/src/ui/Grid.js +++ b/src/ui/Grid.js @@ -2,26 +2,32 @@ import React from 'react'; import { FlexRow, styled, Text } from 'flipper'; import { COLOR_SEPARATOR, COLOR_DISABLED } from './constants'; -const LABEL_HEIGHT = 15; +const LABEL_HEIGHT = 12; const LABEL_MARGIN = 10; const SpacedRow = styled(FlexRow)({ justifyContent: 'space-between', }); +const AxisLabel = styled('div')({ + position: 'relative', + width: 1, + marginBottom: LABEL_HEIGHT + LABEL_MARGIN, + backgroundColor: COLOR_SEPARATOR, +}); + const AxisText = styled(Text)({ fontSize: 12, + lineHeight: 1, color: '#999', + position: 'absolute', + top: '100%', + right: 0, + marginTop: LABEL_MARGIN, + textAlign: 'right', + whiteSpace: 'nowrap', }); -const Axis = ({ interval, numberOfIntervals, unit }) => ( - - {new Array(numberOfIntervals).fill(null).map((_, i) => ( - {i * interval} - ))} - -); - const identity = a => a; export const Grid = ({ @@ -50,26 +56,9 @@ export const Grid = ({ value === 0 ? (
) : ( -
- - {formatLabel(value)} - -
+ + {formatLabel(value)} + ) )}