From f81c257df204b7979459ca5a37c6ffb1ce8a0d29 Mon Sep 17 00:00:00 2001 From: Jelmerovereem Date: Tue, 16 Sep 2025 18:03:47 +0200 Subject: [PATCH 01/11] add chartPrefix to ids. Fixes #733 --- src/BarChart.tsx | 66 ++++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/src/BarChart.tsx b/src/BarChart.tsx index 9af3a8b7..df15f54e 100644 --- a/src/BarChart.tsx +++ b/src/BarChart.tsx @@ -46,17 +46,25 @@ export interface BarChartProps extends AbstractChartProps { showValuesOnTopOfBars?: boolean; withCustomBarColorFromData?: boolean; flatColor?: boolean; - } type BarChartState = {}; class BarChart extends AbstractChart { + private chartPrefix: string; getBarPercentage = () => { const { barPercentage = 1 } = this.props.chartConfig; return barPercentage; }; + constructor() { + super(); + // Unique per chart instance + this.chartPrefix = Math.random() + .toString(36) + .substr(2, 6); + } + renderBars = ({ data, width, @@ -94,7 +102,7 @@ class BarChart extends AbstractChart { height={(Math.abs(barHeight) / 4) * 3} fill={ withCustomBarColorFromData - ? `url(#customColor_0_${i})` + ? `url(#customColor_${this.chartPrefix}_0_${i})` : "url(#fillShadowGradientFrom)" } /> @@ -150,7 +158,7 @@ class BarChart extends AbstractChart { return ( { {flatColor ? ( ) : ( - - )} + + )} ); })} @@ -185,13 +193,12 @@ class BarChart extends AbstractChart { const baseHeight = this.calcBaseHeight(data, height); const renderLabel = (value: number) => { - if(this.props.chartConfig.formatTopBarValue) { - return this.props.chartConfig.formatTopBarValue(value) - } - else { - return value + if (this.props.chartConfig.formatTopBarValue) { + return this.props.chartConfig.formatTopBarValue(value); + } else { + return value; } - } + }; return data.map((x, i) => { const barHeight = this.calcHeight(x, data, height); const barWidth = 32 * this.getBarPercentage(); @@ -202,7 +209,6 @@ class BarChart extends AbstractChart { paddingRight + (i * (width - paddingRight)) / data.length + barWidth / 1 - } y={((baseHeight - barHeight) / 4) * 3 + paddingTop - 1} fill={this.props.chartConfig.color(0.6)} @@ -246,12 +252,12 @@ class BarChart extends AbstractChart { (this.props.chartConfig && this.props.chartConfig.decimalPlaces) ?? 2, formatYLabel: (this.props.chartConfig && this.props.chartConfig.formatYLabel) || - function (label) { + function(label) { return label; }, formatXLabel: (this.props.chartConfig && this.props.chartConfig.formatXLabel) || - function (label) { + function(label) { return label; } }; @@ -278,32 +284,32 @@ class BarChart extends AbstractChart { {withInnerLines ? this.renderHorizontalLines({ - ...config, - count: segments, - paddingTop - }) + ...config, + count: segments, + paddingTop + }) : null} {withHorizontalLabels ? this.renderHorizontalLabels({ - ...config, - count: segments, - data: data.datasets[0].data, - paddingTop: paddingTop as number, - paddingRight: paddingRight as number - }) + ...config, + count: segments, + data: data.datasets[0].data, + paddingTop: paddingTop as number, + paddingRight: paddingRight as number + }) : null} {withVerticalLabels ? this.renderVerticalLabels({ - ...config, - labels: data.labels, - paddingRight: paddingRight as number, - paddingTop: paddingTop as number, - horizontalOffset: barWidth * this.getBarPercentage() - }) + ...config, + labels: data.labels, + paddingRight: paddingRight as number, + paddingTop: paddingTop as number, + horizontalOffset: barWidth * this.getBarPercentage() + }) : null} From dc5c57e181015c9af18ce7b24a88daf2b35a38a0 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 11:53:28 +0200 Subject: [PATCH 02/11] Create dependabot.yml --- .github/dependabot.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 00000000..b4179835 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,11 @@ +# To get started with Dependabot version updates, you'll need to specify which +# package ecosystems to update and where the package manifests are located. +# Please see the documentation for all configuration options: +# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file + +version: 2 +updates: + - package-ecosystem: "npm" # See documentation for possible values + directory: "/" # Location of package manifests + schedule: + interval: "daily" From 153af180388c03c94ac2b27817013171bbb78159 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 11:54:15 +0200 Subject: [PATCH 03/11] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 2700e56e..1d8de71c 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: hermanya # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: Jelmerovereem # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username From c0e6335843a77aa73c210c0a55bb3c8285104db9 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 11:59:33 +0200 Subject: [PATCH 04/11] Create node.js.yml --- .github/workflows/node.js.yml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .github/workflows/node.js.yml diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml new file mode 100644 index 00000000..c49c2ecb --- /dev/null +++ b/.github/workflows/node.js.yml @@ -0,0 +1,31 @@ +# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs + +name: Node.js CI + +on: + push: + branches: [ "master" ] + pull_request: + branches: [ "master" ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [22.x] + # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ + + steps: + - uses: actions/checkout@v5 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: 'yarn' + - run: yarn install + - run: yarn build + # - run: npm test From 17169c64b1308d88ead86f708f8f2a2c1922071d Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 12:01:11 +0200 Subject: [PATCH 05/11] Update node.js.yml --- .github/workflows/node.js.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index c49c2ecb..38708207 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -22,10 +22,10 @@ jobs: steps: - uses: actions/checkout@v5 - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 + uses: actions/setup-node@v5 with: node-version: ${{ matrix.node-version }} cache: 'yarn' - - run: yarn install + - run: npm install - run: yarn build # - run: npm test From 8a17a5e7fa1813528db17379b9675f61f00a2f63 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 12:01:49 +0200 Subject: [PATCH 06/11] remove cache --- .github/workflows/node.js.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 38708207..f5490a8b 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,7 +25,6 @@ jobs: uses: actions/setup-node@v5 with: node-version: ${{ matrix.node-version }} - cache: 'yarn' - run: npm install - run: yarn build # - run: npm test From e45a5573e6aa44038dd7339062b5a30a086004e5 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 12:02:27 +0200 Subject: [PATCH 07/11] Update node.js.yml --- .github/workflows/node.js.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index f5490a8b..dcc00897 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -25,6 +25,6 @@ jobs: uses: actions/setup-node@v5 with: node-version: ${{ matrix.node-version }} - - run: npm install + - run: yarn install - run: yarn build # - run: npm test From ec34a9b1b4f488c066a2d31d755700a34d0498b6 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 12:05:26 +0200 Subject: [PATCH 08/11] trying to fix tsc --- .github/workflows/node.js.yml | 2 +- tsconfig.json | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index dcc00897..6b676bd8 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -26,5 +26,5 @@ jobs: with: node-version: ${{ matrix.node-version }} - run: yarn install - - run: yarn build + # - run: yarn build # - run: npm test diff --git a/tsconfig.json b/tsconfig.json index 07904ad0..3e8e5251 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,7 @@ "inlineSources": true, "esModuleInterop": true, "noErrorTruncation": true, - "jsx": "react-native" - } + "jsx": "react-native", + }, + "exclude": ["node_modules"] } From 58350e8b3fe6be08aca7d9232b10a722380f51b4 Mon Sep 17 00:00:00 2001 From: Jelmer Overeem Date: Sun, 21 Sep 2025 12:07:11 +0200 Subject: [PATCH 09/11] ignore node_modules --- tsconfig.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index 3e8e5251..14775826 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -22,6 +22,6 @@ "esModuleInterop": true, "noErrorTruncation": true, "jsx": "react-native", - }, - "exclude": ["node_modules"] + "skipLibCheck": true + } } From d01291e11b1a53306cfbf3701ac11548aacb8098 Mon Sep 17 00:00:00 2001 From: Jelmerovereem Date: Sun, 21 Sep 2025 12:15:22 +0200 Subject: [PATCH 10/11] fix typescript --- .github/FUNDING.yml | 12 ------------ package.json | 2 +- src/BarChart.tsx | 4 ++-- src/contribution-graph/index.tsx | 2 +- tsconfig.json | 3 ++- 5 files changed, 6 insertions(+), 17 deletions(-) delete mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 1d8de71c..00000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,12 +0,0 @@ -# These are supported funding model platforms - -github: Jelmerovereem # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -patreon: # Replace with a single Patreon username -open_collective: # Replace with a single Open Collective username -ko_fi: # Replace with a single Ko-fi username -tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -liberapay: # Replace with a single Liberapay username -issuehunt: # Replace with a single IssueHunt username -otechie: # Replace with a single Otechie username -custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/package.json b/package.json index 9501f9f1..c1deb131 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "react-native-scrollable-tab-view": "^1.0.0", "react-native-svg": "11.0.1", "react-test-renderer": "16.7.0", - "typescript": "^3.9.5" + "typescript": "^5.9.2" }, "_main": "./node_modules/expo/AppEntry.js", "main": "./dist/index.js", diff --git a/src/BarChart.tsx b/src/BarChart.tsx index df15f54e..c6d0f86f 100644 --- a/src/BarChart.tsx +++ b/src/BarChart.tsx @@ -57,8 +57,8 @@ class BarChart extends AbstractChart { return barPercentage; }; - constructor() { - super(); + constructor(props) { + super(props); // Unique per chart instance this.chartPrefix = Math.random() .toString(36) diff --git a/src/contribution-graph/index.tsx b/src/contribution-graph/index.tsx index afa9d027..9997f0b2 100644 --- a/src/contribution-graph/index.tsx +++ b/src/contribution-graph/index.tsx @@ -19,7 +19,7 @@ export interface ContributionGraphProps extends AbstractChartProps { showOutOfRangeDays?: boolean; accessor?: string; getMonthLabel?: (monthIndex: number) => string; - onDayPress?: ({ count: number, date: Date }) => void; + onDayPress?: ({ count, date }: { count: number; date: Date }) => void; classForValue?: (value: string) => string; style?: Partial; titleForValue?: (value: ContributionChartValue) => string; diff --git a/tsconfig.json b/tsconfig.json index 14775826..db0dc6c8 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -23,5 +23,6 @@ "noErrorTruncation": true, "jsx": "react-native", "skipLibCheck": true - } + }, + "exclude": ["dist"] } From c62de01011ae432080d879421239059be1d9e49a Mon Sep 17 00:00:00 2001 From: Jelmerovereem Date: Sun, 21 Sep 2025 12:18:03 +0200 Subject: [PATCH 11/11] added test --- .github/workflows/node.js.yml | 20 +++++++++----------- package.json | 2 +- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6b676bd8..1f4c7c3a 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,13 +5,12 @@ name: Node.js CI on: push: - branches: [ "master" ] + branches: ["master"] pull_request: - branches: [ "master" ] + branches: ["master"] jobs: build: - runs-on: ubuntu-latest strategy: @@ -20,11 +19,10 @@ jobs: # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - - uses: actions/checkout@v5 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v5 - with: - node-version: ${{ matrix.node-version }} - - run: yarn install - # - run: yarn build - # - run: npm test + - uses: actions/checkout@v5 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v5 + with: + node-version: ${{ matrix.node-version }} + - run: yarn install + - run: yarn test diff --git a/package.json b/package.json index c1deb131..6b19b9a7 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "eject": "expo eject", "android": "expo start --android", "ios": "expo start --ios", - "test": "jest", + "test": "jest --passWithNoTests", "build": "tsc", "dev": "tsc --watch", "prepublish": "yarn build",