Skip to content

Commit 680fdbc

Browse files
authored
Merge pull request #395 from devinit/development
v3.3.3
2 parents ceff0a8 + 8381c49 commit 680fdbc

File tree

22 files changed

+771
-512
lines changed

22 files changed

+771
-512
lines changed

.storybook/webpack.config.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const SRC_PATH = path.join(__dirname, '../src');
99

1010
// load the default config generator.
1111
const genDefaultConfig = require('@storybook/react/dist/server/config/defaults/webpack.config.js');
12-
12+
const API = process.env.API || packageJSON.config.API;
1313

1414
const newRules = [
1515
{
@@ -19,37 +19,36 @@ const newRules = [
1919
SRC_PATH
2020
]
2121
}
22-
]
22+
];
2323

24-
const newExtensions = ['.ts', '.tsx'];
24+
const newExtensions = [ '.ts', '.tsx' ];
2525

2626
const newPlugins = [
2727
new ProgressBarPlugin(),
2828
new webpack.DefinePlugin({
2929
'process.browser': true,
3030
'APP_VERSION': JSON.stringify(packageJSON.version),
31-
'API': JSON.stringify(packageJSON.config.API),
31+
'API': JSON.stringify(API),
3232
'OLD_DATAHUB_URL': JSON.stringify(packageJSON.config.OLD_DATAHUB_URL)
3333
}),
3434
new HappyPack({
3535
threads: 4,
3636
id: 'ts',
37-
loaders: [{
37+
loaders: [ {
3838
loader: 'ts-loader',
3939
query: { happyPackMode: true },
4040
options: { transpileOnly: true }
41-
}]
41+
} ]
4242
}),
4343
new ForkTsCheckerWebpackPlugin({ checkSyntacticErrors: true }),
4444
];
4545

46-
4746
module.exports = (oldConfig, env) => {
4847
const config = genDefaultConfig(oldConfig, env);
4948
const plugins = config.plugins.concat(newPlugins);
5049
const rules = config.module.rules.concat(newRules);
51-
const module = Object.assign(config.module, {rules})
50+
const module = Object.assign(config.module, {rules});
5251
const extensions = config.resolve.extensions.concat(newExtensions);
53-
const resolve = Object.assign(config.resolve, {extensions, enforceExtension: false})
52+
const resolve = Object.assign(config.resolve, {extensions, enforceExtension: false});
5453
return Object.assign(config, {resolve}, { module }, {plugins});
5554
};

build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/bash
22
rm -rf build.zip build
33

4+
npm run emit
45
npm run build-workers
56
npm run build-fragment
67
npm run build:next

next.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const Webpack = require('webpack');
55
const withTypescript = require('@zeit/next-typescript');
66
const packageJSON = require('./package.json');
77
const { ANALYZE } = process.env;
8+
const API = process.env.API || packageJSON.config.API;
89

910
module.exports = withTypescript({
1011
webpack(config, options) {
@@ -19,7 +20,7 @@ module.exports = withTypescript({
1920
config.plugins.push(
2021
new Webpack.DefinePlugin({
2122
'APP_VERSION': JSON.stringify(packageJSON.version),
22-
'API': JSON.stringify(packageJSON.config.API),
23+
'API': JSON.stringify(API),
2324
'OLD_DATAHUB_URL': JSON.stringify(packageJSON.config.OLD_DATAHUB_URL)
2425
}));
2526

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devinit/dh-app",
3-
"version": "3.3.0",
3+
"version": "3.3.3-beta",
44
"config": {
55
"API": "http://212.111.41.68:3000/graphql",
66
"PUPPETEER_SKIP_CHROMIUM_DOWNLOAD": true,

src/apollo/fragment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@
33
*/
44
import * as fetch from 'isomorphic-fetch';
55
import * as fs from 'fs-extra';
6-
const packageJson = require('../../package.json');
6+
const packageJSON = require('../../package.json');
7+
const API = process.env.API || packageJSON.config.API;
78

89
const main = (): void => {
9-
fetch(packageJson.config.API, {
10+
fetch(API, {
1011
method: 'POST',
1112
headers: { 'Content-Type': 'application/json' },
1213
body: JSON.stringify({

src/components/MethodologyData/global-picture.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,13 +261,13 @@ export default {
261261
{
262262
name: 'Gross ODA received, US$',
263263
description:
264-
'Gross official development assistance (ODA) includes monetary transfers (e.g. grants and loans to governments and for project-type interventions), non-monetary transfers (e.g. food aid, technical cooperation) and ODA that resulted in no additional transfer of resources (e.g. debt relief). Data shown is from OECD DAC and multilateral donors and is in constant 2015 prices',
264+
'Gross official development assistance (ODA) includes monetary transfers (e.g. grants and loans to governments and for project-type interventions), non-monetary transfers (e.g. food aid, technical cooperation) and ODA that resulted in no additional transfer of resources (e.g. debt relief). Data shown is from OECD DAC and multilateral donors and is in constant 2016 prices',
265265
methodology: '',
266-
uom: 'constant 2015 US$',
266+
uom: 'constant 2016 US$',
267267
csv:
268-
'https://github.com/devinit/digital-platform/blob/master/user-data/in-oda-gross-2015',
268+
'https://github.com/devinit/digital-platform/blob/master/user-data/in-oda-gross-constant',
269269
zip:
270-
'https://github.com/devinit/digital-platform/blob/master/user-data/in-oda-gross-2015.zip?raw=true',
270+
'https://github.com/devinit/digital-platform/blob/master/user-data/in-oda-gross-constant.zip?raw=true',
271271
source: {
272272
name: 'OECD DAC 2A.',
273273
link: 'https://stats.oecd.org/DownloadFiles.aspx?DatasetCode=table2a.'

src/components/atoms/BaseMap/index.tsx

Lines changed: 24 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -453,29 +453,9 @@ class BaseMap extends React.Component<Props, State> {
453453
});
454454
}
455455

456-
static foldOverSurveyMapFeatures(features: Feature[]): DH.IMapUnit {
457-
type FeatureProps = Feature['properties'] & {total: number; sum: number};
458-
const props: FeatureProps = features.reverse().reduce((acc, feature) => {
459-
// this is a country feature;
460-
const p20: number = feature.properties && feature.properties.p20 ? feature.properties.p20 : 0;
461-
if (p20 === 0) { return { ...acc, ...feature.properties }; }
462-
const sum = acc.sum + p20;
463-
const total = acc.total + 1;
464-
465-
return { ...acc, sum, total, ...feature.properties };
466-
}, { total: 0, sum: 0 });
467-
const value: number = props.total ? Math.round((props.sum / props.total) * 100) : 0;
468-
const id: string = props.ISO2 || '';
469-
const countryName: string = props.NAME || '';
470-
const region: string = props.DHSREGNA || '';
471-
const name = region ? `Region: ${region} , ${countryName}` : countryName;
472-
473-
return { value, id, name, detail: '', uid: '', year: 2013, color: '', slug: '' };
474-
}
475-
476456
private pointDataForPreStyledMap(features: Feature[], indicator: string): DH.IMapUnit | null {
477-
if (indicator === 'surveyp20') {
478-
return BaseMap.foldOverSurveyMapFeatures(features);
457+
if (indicator === 'surveyp20' || indicator === 'survey_p20' || indicator === 'subnational_p20') {
458+
return BaseMap.fetchDataFromMapsWithCustomStyles(features);
479459
}
480460
const feature = this.getFeature(features);
481461
if (!feature.properties) {
@@ -495,6 +475,28 @@ class BaseMap extends React.Component<Props, State> {
495475
return { value, id, name, detail: '', uid: '', year: 2013, color: '', slug };
496476
}
497477

478+
static fetchDataFromMapsWithCustomStyles(features: Feature[]): DH.IMapUnit {
479+
type FeatureProps = Feature['properties'] & {total: number; sum: number};
480+
const props: FeatureProps = features.reverse().reduce((acc, feature) => {
481+
// this is a country feature;
482+
const { properties } = feature;
483+
let p20: number = properties && properties.p20 ? properties.p20 : 0;
484+
p20 = p20 || (properties && properties.P20 ? properties.P20 : 0);
485+
if (p20 === 0) { return { ...acc, ...feature.properties }; }
486+
const sum = acc.sum + p20;
487+
const total = acc.total + 1;
488+
489+
return { ...acc, sum, total, ...feature.properties };
490+
}, { total: 0, sum: 0 });
491+
const value: number = props.total ? Math.round((props.sum / props.total) * 100) : 0;
492+
const id: string = props.ISO2 || '';
493+
const countryName: string = props.NAME || '';
494+
const region: string = props.DHSREGNA || '';
495+
const name = region ? `Region: ${region} , ${countryName}` : countryName;
496+
497+
return { value, id, name, detail: '', uid: '', year: 2013, color: '', slug: '' };
498+
}
499+
498500
static setPointDataValue(
499501
value: number, uom?: string, indicator?: string): string {
500502
if (indicator === 'surveyp20' || indicator === 'regionalp20') {

src/components/atoms/Menu/DesktopMenuItem/index.tsx

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import * as React from 'react';
22
import { Li } from 'glamorous';
33
import { Icon, List } from 'semantic-ui-react';
4-
import {LinkState} from 'next/link';
4+
import { LinkState } from 'next/link';
55
import MenuLink from '../MenuLink';
6-
import {MenuItem} from '../../../molecules/Menu/types';
6+
import { MenuItem } from '../../../molecules/Menu/types';
77

88
export interface Props {
99
menu: MenuItem;
@@ -15,34 +15,38 @@ const menuItem = (props: Props) => {
1515
let hasSubMenu = false;
1616
if (props.menu.children) {
1717
const childrenList = props.menu.children.map(item =>
18-
(<List.Item key={item.name}>
18+
<List.Item key={ item.name }>
1919
<List.Content>
20-
{props.nextLink ?
21-
<props.nextLink href={item.link} prefetch>
22-
<a role="link">
23-
{item.name}
24-
<Icon name={item.icon} />
25-
</a>
26-
</props.nextLink> :
27-
<a href={item.link} >
28-
<Icon name={item.icon} />
29-
{item.name}
30-
</a>
20+
{
21+
props.nextLink
22+
?
23+
<props.nextLink href={ item.link } prefetch>
24+
<a role="link">
25+
<Icon name={ item.icon } />
26+
{ item.name }
27+
</a>
28+
</props.nextLink>
29+
:
30+
<a href={ item.link } >
31+
<Icon name={ item.icon } />
32+
{ item.name }
33+
</a>
3134
}
3235
</List.Content>
33-
</List.Item>),
36+
</List.Item>
3437
);
3538
menuLinkChildren = (
3639
<List>
37-
{childrenList}
40+
{ childrenList }
3841
</List>
3942
);
4043
hasSubMenu = true;
4144
}
45+
4246
return (
43-
<Li display={'inline'}>
44-
<MenuLink menu={props.menu.name} link={props.menu.link || ''} hasSubMenu={hasSubMenu}>
45-
{menuLinkChildren}
47+
<Li display={ 'inline' }>
48+
<MenuLink menu={ props.menu.name } link={ props.menu.link || '' } hasSubMenu={ hasSubMenu }>
49+
{ menuLinkChildren }
4650
</MenuLink>
4751
</Li>
4852
);

src/components/molecules/Menu/DesktopMenu/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import glamorous from 'glamorous';
2-
import { white } from '../../../theme/semantic';
3-
import { mediaQueries } from '../../../theme';
4-
import { DesktopMenuItem } from '../../../atoms/Menu';
5-
import { Props } from '..';
62
import * as React from 'react';
3+
import { Props } from '..';
4+
import { DesktopMenuItem } from '../../../atoms/Menu';
5+
import { mediaQueries } from '../../../theme';
6+
import { white } from '../../../theme/semantic';
77

88
const ListContainer = glamorous.ul({
99
flexDirection: 'column',

0 commit comments

Comments
 (0)