From f739558ec51ecec9b7eef00062c21f707f464972 Mon Sep 17 00:00:00 2001 From: Sebastian Denhi Vega Saint Martin Date: Tue, 27 Aug 2024 17:05:12 -0600 Subject: [PATCH] UI Improvements (#9) * Reordenamiento sample * Arreglo tooltip barras con rango * Pruebas unitarias * Ui color/layout changes * Linting --- jest-setup.tsx | 1 - package-lock.json | 10 +- package.json | 2 +- samples/utils/BarChartControls.tsx | 217 ++++++++--------------- samples/utils/BarChartWrapper.tsx | 88 ++++----- samples/utils/NavBar.tsx | 36 ++-- src/Bar/Bar.spec.tsx | 24 +++ src/BarChart/BarChart.spec.tsx | 76 +++----- src/BarChart/index.tsx | 10 +- src/CartesianGrid/CartesianGrid.spec.tsx | 23 +++ src/Legend/Legend.spec.tsx | 32 ++++ src/Legend/index.tsx | 2 +- src/Tooltip/Tooltip.spec.tsx | 30 ++++ src/Tooltip/index.tsx | 4 +- src/XAxis/XAxis.spec.tsx | 39 ++++ src/YAxis/YAxis.spec.tsx | 23 +++ src/YAxis/index.tsx | 7 +- tsconfig.test.json | 5 +- 18 files changed, 355 insertions(+), 274 deletions(-) create mode 100644 src/Bar/Bar.spec.tsx create mode 100644 src/CartesianGrid/CartesianGrid.spec.tsx create mode 100644 src/Legend/Legend.spec.tsx create mode 100644 src/Tooltip/Tooltip.spec.tsx create mode 100644 src/XAxis/XAxis.spec.tsx create mode 100644 src/YAxis/YAxis.spec.tsx diff --git a/jest-setup.tsx b/jest-setup.tsx index 142d1be..7b0828b 100644 --- a/jest-setup.tsx +++ b/jest-setup.tsx @@ -1,2 +1 @@ -// jest-setup.tsx import '@testing-library/jest-dom'; diff --git a/package-lock.json b/package-lock.json index 0bd674e..a64b477 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "devDependencies": { "@rsbuild/core": "^0.7.10", "@rsbuild/plugin-react": "^0.7.10", - "@testing-library/jest-dom": "^6.4.8", + "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.12", "@types/node": "^22.4.1", @@ -1820,13 +1820,12 @@ } }, "node_modules/@testing-library/jest-dom": { - "version": "6.4.8", - "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.4.8.tgz", - "integrity": "sha512-JD0G+Zc38f5MBHA4NgxQMR5XtO5Jx9g86jqturNTt2WUfRmLDIY7iKkWHDCCTiDuFMre6nxAD5wHw9W5kI4rGw==", + "version": "6.5.0", + "resolved": "https://registry.npmjs.org/@testing-library/jest-dom/-/jest-dom-6.5.0.tgz", + "integrity": "sha512-xGGHpBXYSHUUr6XsKBfs85TWlYKpTc37cSBBVrXcib2MkHLboWlkClhWF37JKlDb9KEq3dHs+f2xR7XJEWGBxA==", "dev": true, "dependencies": { "@adobe/css-tools": "^4.4.0", - "@babel/runtime": "^7.9.2", "aria-query": "^5.0.0", "chalk": "^3.0.0", "css.escape": "^1.5.1", @@ -2011,7 +2010,6 @@ "resolved": "https://registry.npmjs.org/@types/jest/-/jest-29.5.12.tgz", "integrity": "sha512-eDC8bTvT/QhYdxJAulQikueigY5AsdBRH2yDKW3yveW7svY3+DzN84/2NUgkw10RTiJbWqZrTtoGVdYlvFJdLw==", "dev": true, - "license": "MIT", "dependencies": { "expect": "^29.0.0", "pretty-format": "^29.0.0" diff --git a/package.json b/package.json index 524c64f..7013f06 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "devDependencies": { "@rsbuild/core": "^0.7.10", "@rsbuild/plugin-react": "^0.7.10", - "@testing-library/jest-dom": "^6.4.8", + "@testing-library/jest-dom": "^6.5.0", "@testing-library/react": "^16.0.0", "@types/jest": "^29.5.12", "@types/node": "^22.4.1", diff --git a/samples/utils/BarChartControls.tsx b/samples/utils/BarChartControls.tsx index d25db08..9465da4 100644 --- a/samples/utils/BarChartControls.tsx +++ b/samples/utils/BarChartControls.tsx @@ -55,164 +55,95 @@ const BarChartControls: React.FC = ({ }; return ( -
-
- -
-
- -
-
-
); }; diff --git a/samples/utils/BarChartWrapper.tsx b/samples/utils/BarChartWrapper.tsx index 524e922..17078ef 100644 --- a/samples/utils/BarChartWrapper.tsx +++ b/samples/utils/BarChartWrapper.tsx @@ -21,49 +21,53 @@ const BarChartWrapper: React.FC = ({ data, children }) => const [showLegend, setShowLegend] = useState(true); return ( -
- - - {showCartesianGrid && } - {showXAxis && } - {showYAxis && } - {showTooltip && } - {showLegend && } - {children} - +
+
+ +
+
+ + {showCartesianGrid && } + {showXAxis && } + {showYAxis && } + {showTooltip && } + {showLegend && } + {children} + +
); }; -export default BarChartWrapper; +export default BarChartWrapper; \ No newline at end of file diff --git a/samples/utils/NavBar.tsx b/samples/utils/NavBar.tsx index f75907a..1732d76 100644 --- a/samples/utils/NavBar.tsx +++ b/samples/utils/NavBar.tsx @@ -1,19 +1,31 @@ import React from 'react'; -import { Link } from 'react-router-dom'; +import { Link, useLocation } from 'react-router-dom'; const NavBar = () => { + const location = useLocation(); + + const navItems = [ + { name: 'Normal BarChart', path: '/' }, + { name: 'Stacked BarChart', path: '/stacked' }, + { name: 'Ranged BarChart', path: '/ranged' }, + ]; + return ( -