Skip to content

Commit 4e4b297

Browse files
author
Robert Crocker
committed
Removed the global styles as they were interferring with the tooltip styles in a way they shouldn't have. Fixed the font style in the pie chart.
1 parent 8d0590d commit 4e4b297

File tree

9 files changed

+25
-14
lines changed

9 files changed

+25
-14
lines changed

src/App.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Container } from './styles/componentStyles';
1515
function App() {
1616
return (
1717
<Container className="app">
18-
<GlobalStyle />
1918
<PieChart
2019
theme="dark"
2120
data={fruit}
@@ -71,7 +70,7 @@ function App() {
7170
legendLabel="Markets"
7271
/>
7372
<ScatterPlot
74-
theme="dark"
73+
theme="light"
7574
height="100%"
7675
width="100%"
7776
data={penguins}

src/charts/PieChart/PieChart.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,14 @@ import {
1717

1818
import styled, { ThemeProvider } from 'styled-components';
1919

20+
const PieLabel = styled.text`
21+
font-family: Tahoma, Geneva, Verdana, sans-serif;
22+
text-anchor: middle;
23+
alignment-baseline: middle;
24+
fill: black;
25+
pointer-events: none;
26+
`;
27+
2028
const { light, dark } = themes;
2129

2230
export default function PieChart({
@@ -262,16 +270,12 @@ export default function PieChart({
262270
setTooltip={setTooltip}
263271
/>
264272
{pieLabel && (
265-
<text
273+
<PieLabel
266274
data-testid={`pie-chart-arc-text-${i}`}
267-
style={{ pointerEvents: 'none' }}
268275
transform={textTranform(d)}
269-
textAnchor={'middle'}
270-
alignmentBaseline={'middle'}
271-
fill={'black'}
272276
>
273277
{d.data[value]}
274-
</text>
278+
</PieLabel>
275279
)}
276280
</g>
277281
))}

src/components/ColorLegend.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,13 @@ const Legend = styled.div`
1515

1616
const LegendTitle = styled.text`
1717
font-size: 14px;
18+
font-family: Tahoma, Geneva, Verdana, sans-serif;
1819
fill: ${(props) => props.theme.textColor};
1920
`;
2021

2122
const LegendLabel = styled.text`
2223
font-size: 12px;
24+
font-family: Tahoma, Geneva, Verdana, sans-serif;
2325
fill: ${(props) => props.theme.textColor};
2426
`;
2527

src/components/ContinuousAxis.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import styled from 'styled-components';
77

88
const TickText = styled.text`
99
font-size: 12px;
10+
font-family: Tahoma, Geneva, Verdana, sans-serif;
1011
fill: ${(props) => props.theme.textColor};
1112
`;
1213

src/components/DiscreteAxis.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import styled from 'styled-components';
66

77
const TickText = styled.text`
88
font-size: 12px;
9+
font-family: Tahoma, Geneva, Verdana, sans-serif;
910
fill: ${(props) => props.theme.textColor};
1011
`;
1112

src/components/Label.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { Margin } from '../../types';
55
import styled from 'styled-components';
66
const AxisLabel = styled.text`
77
font-size: 16px;
8+
font-family: Tahoma, Geneva, Verdana, sans-serif;
89
fill: ${(props) => props.theme.textColor};
910
`;
1011

src/components/Tooltip.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,11 @@ const Tooltip = ({
2222

2323
const lightTheme = {
2424
strokeGridLineColor: '#ebebeb',
25-
textColor: '#8c8c8c',
25+
textColor: '#212121',
2626
axisBaseLineColor: '#ebebeb',
2727
legendBackgroundColor: '#ffffff',
2828
legendBorder: '1px solid #ebebeb',
29+
tooltipTextColor: '#e5e5e5',
2930
tooltipBackgroundColor: '#ffffff',
3031
tooltipBorder: '1px solid #ddd',
3132
tooltipShadow: `0 0 10px 0 rgba(80, 80, 80, 0.2)`,
@@ -37,7 +38,8 @@ const Tooltip = ({
3738
axisBaseLineColor: '#3d3d3d',
3839
legendBackgroundColor: '#1d1d1d',
3940
legendBorder: '1px solid #3d3d3d',
40-
tooltipBackgroundColor: '#1d1d1d',
41+
tooltipTextColor: '#e5e5e5',
42+
tooltipBackgroundColor: '#383838',
4143
tooltipBorder: '1px solid #3d3d3d',
4244
tooltipShadow: `0 0 10px 0 rgba(100, 100, 100, 0.2)`,
4345
};
@@ -125,7 +127,7 @@ const Tooltip = ({
125127
borderRight: `12px solid ${themes[theme].tooltipBackgroundColor}`,
126128
borderBottom: `6px solid ${themes[theme].tooltipBackgroundColor}`,
127129
borderLeft: `12px solid ${themes[theme].tooltipBackgroundColor}`,
128-
// padding: '0.6em 1em',
130+
padding: '0.6em 1em',
129131
borderRadius: '4px',
130132
minWidth: '140px',
131133
maxWidth: '240px',
@@ -134,7 +136,7 @@ const Tooltip = ({
134136
textAlign: 'center',
135137
lineHeight: '1.4em',
136138
fontSize: '12px',
137-
color: `${themes[theme].textColor}`,
139+
color: `${themes[theme].tooltipTextColor}`,
138140
// border: `${themes[theme].tooltipBorder}`,
139141
zIndex: '9',
140142
transition: 'all 0.1s ease-out',

src/styles/componentStyles.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ import styled from 'styled-components';
33
export const Container = styled.div`
44
height: 100vh;
55
width: 100vw;
6-
background-color: #ffffff;
6+
/* background-color: #ffffff; */
7+
background-color: #1d1d1d;
78
`;

src/styles/globals.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const GlobalStyle = createGlobalStyle`
77
outline:0;
88
box-sizing:border-box;
99
font-family: Tahoma, Geneva, Verdana, sans-serif;
10-
background-color: #1d1d1d;
10+
/* background-color: #1d1d1d; */
1111
/* background-color: #fff; */
1212
}
1313
`;

0 commit comments

Comments
 (0)