Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release - Use the new @eeacms/countup library refs - #254634 #19

Merged
merged 3 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 9 additions & 18 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

### [2.0.0](https://github.com/eea/volto-statistic-block/compare/1.3.1...2.0.0) - 25 July 2023

#### :rocket: New Features

- feat: Use the new @eeacms/countup library refs - #254634 [dobri1408 - [`95f2e82`](https://github.com/eea/volto-statistic-block/commit/95f2e82dbbe44b4db7cb20433fc73b1851437e5c)]

#### :hammer_and_wrench: Others

- Release 2.0.0 [Alin Voinea - [`f9c2246`](https://github.com/eea/volto-statistic-block/commit/f9c224615a638c62f26de1115c1f957827d87949)]
### [1.3.1](https://github.com/eea/volto-statistic-block/compare/1.3.0...1.3.1) - 24 July 2023

#### :bug: Bug Fixes
Expand All @@ -20,7 +29,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :house: Internal changes

- chore: [JENKINS] Deprecate circularity website [valentinab25 - [`3dc3490`](https://github.com/eea/volto-statistic-block/commit/3dc34908cf22514318c3fd737d517c8261da7fd4)]

#### :hammer_and_wrench: Others

Expand All @@ -45,30 +53,16 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

- use countup.js@2.5.0 [Miu Razvan - [`9dad099`](https://github.com/eea/volto-statistic-block/commit/9dad099fb6519688752bf4788023712bd9719671)]
- bump version [Miu Razvan - [`e886513`](https://github.com/eea/volto-statistic-block/commit/e886513e63bf480dcdb5c9e0a627b31c6b4e989d)]
- Add Sonarqube tag using industry-frontend addons list [EEA Jenkins - [`7cf6d5b`](https://github.com/eea/volto-statistic-block/commit/7cf6d5b1427a9f17bb1c740d019130e323668286)]
### [1.1.0](https://github.com/eea/volto-statistic-block/compare/1.0.1...1.1.0) - 27 March 2023

#### :hammer_and_wrench: Others

- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`1ecdcec`](https://github.com/eea/volto-statistic-block/commit/1ecdcec0ef98c891d9157db9592365fc10760b59)]
- Add Sonarqube tag using ims-frontend addons list [EEA Jenkins - [`e5f76cc`](https://github.com/eea/volto-statistic-block/commit/e5f76cc8f90dfa21ba1f2bb25b2491ae0e1b102d)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`439ba7f`](https://github.com/eea/volto-statistic-block/commit/439ba7f0016eb5ba86ef267309e0ddef7b81f379)]
- Add Sonarqube tag using advisory-board-frontend addons list [EEA Jenkins - [`1e72601`](https://github.com/eea/volto-statistic-block/commit/1e72601f1f9a7e8023c9130407d9ce28f1d7b6f9)]
- Add Sonarqube tag using climate-energy-frontend addons list [EEA Jenkins - [`9ab65ad`](https://github.com/eea/volto-statistic-block/commit/9ab65ad0f5b300a14590f5f260659749f4831956)]
- test(Jenkins): Run tests and cypress with latest canary @plone/volto [Alin Voinea - [`75e506f`](https://github.com/eea/volto-statistic-block/commit/75e506fd7cf92296871ddf52f9b1c82a053ec931)]
- Add Sonarqube tag using cca-frontend addons list [EEA Jenkins - [`9297e9f`](https://github.com/eea/volto-statistic-block/commit/9297e9fb8a638a1564d7d7a6d2ebbea0056d775e)]
- Add Sonarqube tag using bise-frontend addons list [EEA Jenkins - [`6dde4aa`](https://github.com/eea/volto-statistic-block/commit/6dde4aae3c87bfe434a28719479e37078db11099)]
- yarn 3 [Alin Voinea - [`b4949e1`](https://github.com/eea/volto-statistic-block/commit/b4949e18f23a7965c76ef97a5790607a587987dc)]
- Add Sonarqube tag using marine-frontend addons list [EEA Jenkins - [`8820afa`](https://github.com/eea/volto-statistic-block/commit/8820afa4ab8fcebd17e90522196c1fde8b246e21)]
- Add Sonarqube tag using clms-frontend addons list [EEA Jenkins - [`8eb5b8d`](https://github.com/eea/volto-statistic-block/commit/8eb5b8de3f87152cb57faeb960233791b328c900)]
- Add Sonarqube tag using demo-kitkat-frontend addons list [EEA Jenkins - [`58f36bd`](https://github.com/eea/volto-statistic-block/commit/58f36bd4ae9dcdccbef182789957dbf0bb97da74)]
- Add Sonarqube tag using forests-frontend addons list [EEA Jenkins - [`3bb9a21`](https://github.com/eea/volto-statistic-block/commit/3bb9a2128a88c1196258722112a1957f60d332fc)]
### [1.0.1](https://github.com/eea/volto-statistic-block/compare/1.0.0...1.0.1) - 16 November 2022

#### :hammer_and_wrench: Others

- test(estlint): Fix .project.eslintrc.js [Alin Voinea - [`d81878f`](https://github.com/eea/volto-statistic-block/commit/d81878fff2ba1be4446dd330560c46d8161f8bc2)]
- Add Sonarqube tag using circularity-frontend addons list [EEA Jenkins - [`a58f436`](https://github.com/eea/volto-statistic-block/commit/a58f436c5bb052fcdd13b213895c497881e48c67)]
## [1.0.0](https://github.com/eea/volto-statistic-block/compare/0.3.0...1.0.0) - 28 October 2022

#### :nail_care: Enhancements
Expand All @@ -80,7 +74,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### :hammer_and_wrench: Others

- Cleanup [Alin Voinea - [`6d5f4a6`](https://github.com/eea/volto-statistic-block/commit/6d5f4a6d8048689e97e567316f24902d0865de88)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`5fd7ba7`](https://github.com/eea/volto-statistic-block/commit/5fd7ba7a4595e157bdb0ebb0932f1d3afd64b369)]
### [0.3.0](https://github.com/eea/volto-statistic-block/compare/0.2.0...0.3.0) - 19 September 2022

#### :nail_care: Enhancements
Expand Down Expand Up @@ -111,7 +104,6 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
#### :hammer_and_wrench: Others

- Remove useless from block title [Alin Voinea - [`a3daf0a`](https://github.com/eea/volto-statistic-block/commit/a3daf0ad63666d0cd87eef465f42f525a5a307bc)]
- Add Sonarqube tag using eea-website-frontend addons list [EEA Jenkins - [`4a9ea35`](https://github.com/eea/volto-statistic-block/commit/4a9ea35d0717941e9d96a29e46dc85717140fccf)]
### [0.1.1](https://github.com/eea/volto-statistic-block/compare/0.1.0...0.1.1) - 10 March 2022

#### :hammer_and_wrench: Others
Expand All @@ -122,5 +114,4 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### :hammer_and_wrench: Others

- yarn bootstrap [Alin Voinea - [`ba85706`](https://github.com/eea/volto-statistic-block/commit/ba857067b16dc04f9bc970b0c0d4afd479bb7528)]
- Initial commit [Alin Voinea - [`2e19fe2`](https://github.com/eea/volto-statistic-block/commit/2e19fe2708f89887d2d79f88696e197643ea10f4)]
8 changes: 2 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eeacms/volto-statistic-block",
"version": "1.3.1",
"version": "2.0.0",
"description": "@eeacms/volto-statistic-block: Volto add-on",
"main": "src/index.js",
"author": "European Environment Agency: IDM2 A-Team",
Expand All @@ -17,12 +17,8 @@
"url": "git@github.com:eea/volto-statistic-block.git"
},
"addons": [],
"resolutions": {
"react-countup/countup.js": "2.5.0"
},
"dependencies": {
"react-countup": "6.3.1",
"react-visibility-sensor": "5.1.1"
"@eeacms/countup": "*"
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
Expand Down
44 changes: 16 additions & 28 deletions src/StatisticBlock/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import React from 'react';
import isNumber from 'lodash/isNumber';
import isNaN from 'lodash/isNaN';
import cx from 'classnames';
import CountUp from 'react-countup';
import VisibilitySensor from 'react-visibility-sensor';
import { CountUp } from '@eeacms/countup';
import { Statistic } from 'semantic-ui-react';
import { UniversalLink } from '@plone/volto/components';
import {
Expand All @@ -18,25 +17,6 @@ import {

import './styles.less';

const CountUpWrapper = ({ countUpRef, start }) => {
const [visible, setVisible] = React.useState(false);

return (
<VisibilitySensor
onChange={(isVisible) => {
start();
if (isVisible && !visible) {
setVisible(true);
}
}}
active={!visible}
delayedCall
>
<span ref={countUpRef} />
</VisibilitySensor>
);
};

const View = ({ data, mode }) => {
const {
horizontal = false,
Expand Down Expand Up @@ -93,13 +73,21 @@ const View = ({ data, mode }) => {
{animation.enabled && isNumber(valueNo) && !isNaN(valueNo) ? (
<CountUp
end={valueNo}
duration={animation.duration > 0 ? animation.duration : 2}
decimals={animation.decimals > 0 ? animation.decimals : 0}
prefix={animation.prefix || ''}
suffix={animation.suffix || ''}
>
{(props) => <CountUpWrapper {...props} />}
</CountUp>
isCounting
duration={parseInt(
animation.duration > 0 ? animation.duration : 2,
)}
decimalPlaces={
animation.decimals > 0 ? animation.decimals : 0
}
formatter={(value) => {
let prefix = animation.prefix || '';
let suffix = animation.suffix || '';
return (
prefix + value.toFixed(animation.decimals) + suffix
);
}}
/>
) : (
_serializeNodes(valueNodes)
)}
Expand Down
6 changes: 5 additions & 1 deletion src/StatisticBlock/View.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ import '@testing-library/jest-dom/extend-expect';
jest.mock('lodash/isNumber', () => jest.fn(() => true));
jest.mock('lodash/isNaN', () => jest.fn(() => false));

jest.mock('react-countup', () => () => <div>Mocked CountUp</div>);
jest.mock('@eeacms/countup', () => ({
CountUp: () => {
return <div>Mocked CountUp</div>;
},
}));

jest.mock('@plone/volto/components', () => ({
UniversalLink: ({ children }) => <div>{children}</div>,
Expand Down