@coorpacademy/components 11.25.0 → 11.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -1
- package/es/atom/gradient/index.native.d.ts.map +1 -1
- package/es/atom/gradient/index.native.js +5 -7
- package/es/atom/gradient/index.native.js.map +1 -1
- package/es/atom/icon/index.d.ts +6 -0
- package/es/atom/icon/index.d.ts.map +1 -0
- package/es/atom/icon/index.js +67 -0
- package/es/atom/icon/index.js.map +1 -0
- package/es/atom/icon/style.css +7 -0
- package/es/globals.d.js.map +1 -1
- package/es/molecule/dashboard/learning-profile-banner/style.css +3 -5
- package/es/molecule/learning-profile-radar-chart/index.d.ts +57 -0
- package/es/molecule/learning-profile-radar-chart/index.d.ts.map +1 -0
- package/es/molecule/learning-profile-radar-chart/index.js +387 -0
- package/es/molecule/learning-profile-radar-chart/index.js.map +1 -0
- package/es/molecule/learning-profile-radar-chart/style.css +49 -0
- package/es/molecule/learning-profile-radar-chart/types.d.ts +145 -0
- package/es/molecule/learning-profile-radar-chart/types.d.ts.map +1 -0
- package/es/molecule/learning-profile-radar-chart/types.js +54 -0
- package/es/molecule/learning-profile-radar-chart/types.js.map +1 -0
- package/es/util/check-is-mobile.d.ts +2 -0
- package/es/util/check-is-mobile.d.ts.map +1 -0
- package/es/util/check-is-mobile.js +3 -0
- package/es/util/check-is-mobile.js.map +1 -0
- package/lib/atom/gradient/index.native.d.ts.map +1 -1
- package/lib/atom/gradient/index.native.js +5 -7
- package/lib/atom/gradient/index.native.js.map +1 -1
- package/lib/atom/icon/index.d.ts +6 -0
- package/lib/atom/icon/index.d.ts.map +1 -0
- package/lib/atom/icon/index.js +92 -0
- package/lib/atom/icon/index.js.map +1 -0
- package/lib/atom/icon/style.css +7 -0
- package/lib/globals.d.js.map +1 -1
- package/lib/molecule/dashboard/learning-profile-banner/style.css +3 -5
- package/lib/molecule/learning-profile-radar-chart/index.d.ts +57 -0
- package/lib/molecule/learning-profile-radar-chart/index.d.ts.map +1 -0
- package/lib/molecule/learning-profile-radar-chart/index.js +416 -0
- package/lib/molecule/learning-profile-radar-chart/index.js.map +1 -0
- package/lib/molecule/learning-profile-radar-chart/style.css +49 -0
- package/lib/molecule/learning-profile-radar-chart/types.d.ts +145 -0
- package/lib/molecule/learning-profile-radar-chart/types.d.ts.map +1 -0
- package/lib/molecule/learning-profile-radar-chart/types.js +67 -0
- package/lib/molecule/learning-profile-radar-chart/types.js.map +1 -0
- package/lib/util/check-is-mobile.d.ts +2 -0
- package/lib/util/check-is-mobile.d.ts.map +1 -0
- package/lib/util/check-is-mobile.js +10 -0
- package/lib/util/check-is-mobile.js.map +1 -0
- package/package.json +11 -4
package/README.md
CHANGED
|
@@ -169,7 +169,7 @@ For more info see the [mobile documentation](https://github.com/CoorpAcademy/mob
|
|
|
169
169
|
|
|
170
170
|
You may need to install these optional libs depending on which native components you use:
|
|
171
171
|
|
|
172
|
-
- `
|
|
172
|
+
- `colorjs.io`
|
|
173
173
|
- `react-native-modal`
|
|
174
174
|
- `react-native-render-html`
|
|
175
175
|
- `react-native-linear-gradient`
|
|
@@ -181,3 +181,10 @@ You may need to install these optional libs depending on which native components
|
|
|
181
181
|
Error when trying to launch the storybook:
|
|
182
182
|
|
|
183
183
|
Try to delete your ```node_modules```, go to the project's root and launch: ```yarn```
|
|
184
|
+
|
|
185
|
+
## Generating a Bundle Analyzer Report
|
|
186
|
+
|
|
187
|
+
To check the content of the bundle and optimize it if needed, we set up `webpack-bundle-analyzer`, which generates a bundle analysis report. This visualizes the size of webpack output files with an interactive zoomable treemap.
|
|
188
|
+
To generate it, just run `npm run build:stats`.
|
|
189
|
+
|
|
190
|
+

|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../../src/atom/gradient/index.native.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAIvC,oBAAY,KAAK,GAAG;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,oBAAoB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CACvE,CAAC;AAEF,QAAA,MAAM,QAAQ,qFAQX,KAAK,
|
|
1
|
+
{"version":3,"file":"index.native.d.ts","sourceRoot":"","sources":["../../../src/atom/gradient/index.native.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACvC,OAAO,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAIvC,oBAAY,KAAK,GAAG;IAClB,QAAQ,CAAC,EAAE,SAAS,CAAC;IACrB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACtB,oBAAoB,CAAC,EAAE,KAAK,GAAG,QAAQ,CAAC;IACxC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,EAAE,CAAC;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;CACvE,CAAC;AAEF,QAAA,MAAM,QAAQ,qFAQX,KAAK,gBAkCP,CAAC;AAEF,eAAe,QAAQ,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import LinearGradient from 'react-native-linear-gradient';
|
|
3
|
-
import Color from '
|
|
3
|
+
import Color from 'colorjs.io';
|
|
4
4
|
|
|
5
5
|
const Gradient = ({
|
|
6
6
|
children,
|
|
@@ -14,12 +14,10 @@ const Gradient = ({
|
|
|
14
14
|
let calculatedColors = colors;
|
|
15
15
|
|
|
16
16
|
if (colors.length === 1) {
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
} = Color(colors[0]).object();
|
|
22
|
-
calculatedColors = transparencyPosition === 'top' ? [`rgba(${r}, ${g}, ${b}, 0)`, colors[0], colors[0]] : [colors[0], colors[0], `rgba(${r}, ${g}, ${b}, 0)`];
|
|
17
|
+
const [raw] = colors;
|
|
18
|
+
const transparent = new Color(raw).to('srgb');
|
|
19
|
+
transparent.alpha = 0;
|
|
20
|
+
calculatedColors = transparencyPosition === 'top' ? [transparent.toString(), raw, raw] : [raw, raw, transparent.toString()];
|
|
23
21
|
}
|
|
24
22
|
|
|
25
23
|
const _style = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.native.js","names":["React","LinearGradient","Color","Gradient","children","colors","transparencyPosition","height","style","testID","pointerEvents","calculatedColors","length","
|
|
1
|
+
{"version":3,"file":"index.native.js","names":["React","LinearGradient","Color","Gradient","children","colors","transparencyPosition","height","style","testID","pointerEvents","calculatedColors","length","raw","transparent","to","alpha","toString","_style","push"],"sources":["../../../src/atom/gradient/index.native.tsx"],"sourcesContent":["import React, {ReactNode} from 'react';\nimport {ViewStyle} from 'react-native';\nimport LinearGradient from 'react-native-linear-gradient';\nimport Color from 'colorjs.io';\n\nexport type Props = {\n children?: ReactNode;\n colors: Array<string>;\n transparencyPosition?: 'top' | 'bottom';\n height?: number;\n style?: ViewStyle | ViewStyle[];\n testID?: string;\n pointerEvents?: 'auto' | 'none' | 'box-none' | 'box-only' | undefined;\n};\n\nconst Gradient = ({\n children,\n colors,\n transparencyPosition = 'top',\n height,\n style,\n testID,\n pointerEvents\n}: Props) => {\n let calculatedColors = colors;\n if (colors.length === 1) {\n const [raw] = colors;\n const transparent = new Color(raw).to('srgb');\n transparent.alpha = 0;\n\n calculatedColors =\n transparencyPosition === 'top'\n ? [transparent.toString(), raw, raw]\n : [raw, raw, transparent.toString()];\n }\n\n const _style = [];\n\n if (style) {\n _style.push(style);\n }\n if (height) {\n _style.push({height});\n }\n\n return (\n (\n <LinearGradient\n colors={calculatedColors}\n style={_style}\n pointerEvents={pointerEvents}\n testID={testID}\n >\n {children}\n </LinearGradient>\n ) || null\n );\n};\n\nexport default Gradient;\n"],"mappings":"AAAA,OAAOA,KAAP,MAA+B,OAA/B;AAEA,OAAOC,cAAP,MAA2B,8BAA3B;AACA,OAAOC,KAAP,MAAkB,YAAlB;;AAYA,MAAMC,QAAQ,GAAG,CAAC;EAChBC,QADgB;EAEhBC,MAFgB;EAGhBC,oBAAoB,GAAG,KAHP;EAIhBC,MAJgB;EAKhBC,KALgB;EAMhBC,MANgB;EAOhBC;AAPgB,CAAD,KAQJ;EACX,IAAIC,gBAAgB,GAAGN,MAAvB;;EACA,IAAIA,MAAM,CAACO,MAAP,KAAkB,CAAtB,EAAyB;IACvB,MAAM,CAACC,GAAD,IAAQR,MAAd;IACA,MAAMS,WAAW,GAAG,IAAIZ,KAAJ,CAAUW,GAAV,EAAeE,EAAf,CAAkB,MAAlB,CAApB;IACAD,WAAW,CAACE,KAAZ,GAAoB,CAApB;IAEAL,gBAAgB,GACdL,oBAAoB,KAAK,KAAzB,GACI,CAACQ,WAAW,CAACG,QAAZ,EAAD,EAAyBJ,GAAzB,EAA8BA,GAA9B,CADJ,GAEI,CAACA,GAAD,EAAMA,GAAN,EAAWC,WAAW,CAACG,QAAZ,EAAX,CAHN;EAID;;EAED,MAAMC,MAAM,GAAG,EAAf;;EAEA,IAAIV,KAAJ,EAAW;IACTU,MAAM,CAACC,IAAP,CAAYX,KAAZ;EACD;;EACD,IAAID,MAAJ,EAAY;IACVW,MAAM,CAACC,IAAP,CAAY;MAACZ;IAAD,CAAZ;EACD;;EAED,OACE,aACE,oBAAC,cAAD;IACE,MAAM,EAAEI,gBADV;IAEE,KAAK,EAAEO,MAFT;IAGE,aAAa,EAAER,aAHjB;IAIE,MAAM,EAAED;EAJV,GAMGL,QANH,CADF,IASK,IAVP;AAYD,CA1CD;;AA4CA,eAAeD,QAAf"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/atom/icon/index.js"],"names":[],"mappings":"AAgBA,mDAAoD;AAiB7C,iEACoE;;AAE3E,uDA6BG"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
|
+
import { fas } from '@fortawesome/pro-solid-svg-icons';
|
|
5
|
+
import { library } from '@fortawesome/fontawesome-svg-core';
|
|
6
|
+
import toLower from 'lodash/fp/toLower';
|
|
7
|
+
import merge from 'lodash/fp/merge';
|
|
8
|
+
import getOr from 'lodash/fp/getOr';
|
|
9
|
+
import Color from 'colorjs.io';
|
|
10
|
+
import style from './style.css';
|
|
11
|
+
library.add(fas);
|
|
12
|
+
const DEFAULT_PRESET = 'm';
|
|
13
|
+
const ICON_LUMINOSITY = 32;
|
|
14
|
+
const DEFAULT_WRAPPER_SIZE = 40;
|
|
15
|
+
export const DEFAULT_ICON_COLOR = 'hsl(0, 0%, 32%)';
|
|
16
|
+
const SIZE_CONFIGS = {
|
|
17
|
+
s: {
|
|
18
|
+
faSize: 'sm',
|
|
19
|
+
wrapperSize: 32
|
|
20
|
+
},
|
|
21
|
+
m: {
|
|
22
|
+
faSize: 'lg',
|
|
23
|
+
wrapperSize: DEFAULT_WRAPPER_SIZE
|
|
24
|
+
},
|
|
25
|
+
xl: {
|
|
26
|
+
faSize: 'xl',
|
|
27
|
+
wrapperSize: 48
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
export const getForegroundColor = backgroundColor => new Color(backgroundColor).to('hsl').set({
|
|
31
|
+
l: ICON_LUMINOSITY
|
|
32
|
+
}).toString();
|
|
33
|
+
const Icon = /*#__PURE__*/React.memo(function Icon({
|
|
34
|
+
iconName,
|
|
35
|
+
iconColor,
|
|
36
|
+
backgroundColor,
|
|
37
|
+
preset = DEFAULT_PRESET,
|
|
38
|
+
size
|
|
39
|
+
}) {
|
|
40
|
+
const effectiveIconColor = iconColor || backgroundColor ? getForegroundColor(backgroundColor) : DEFAULT_ICON_COLOR;
|
|
41
|
+
const effectiveSize = size ? merge(SIZE_CONFIGS[DEFAULT_PRESET], size) : getOr(SIZE_CONFIGS[DEFAULT_PRESET], toLower(preset), SIZE_CONFIGS);
|
|
42
|
+
const iconWrapperStyle = {
|
|
43
|
+
backgroundColor,
|
|
44
|
+
width: effectiveSize.wrapperSize,
|
|
45
|
+
height: effectiveSize.wrapperSize
|
|
46
|
+
};
|
|
47
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
48
|
+
className: style.iconWrapper,
|
|
49
|
+
style: iconWrapperStyle
|
|
50
|
+
}, /*#__PURE__*/React.createElement(FontAwesomeIcon, {
|
|
51
|
+
icon: `fa-${iconName}`,
|
|
52
|
+
color: effectiveIconColor,
|
|
53
|
+
size: effectiveSize.faSize
|
|
54
|
+
}));
|
|
55
|
+
});
|
|
56
|
+
Icon.propTypes = process.env.NODE_ENV !== "production" ? {
|
|
57
|
+
iconName: PropTypes.string.isRequired,
|
|
58
|
+
iconColor: PropTypes.string,
|
|
59
|
+
backgroundColor: PropTypes.string,
|
|
60
|
+
preset: PropTypes.oneOf(['s', 'm', 'xl']),
|
|
61
|
+
size: PropTypes.shape({
|
|
62
|
+
faSize: PropTypes.oneOf(['2xs', 'xs', 'sm', 'lg', 'xl', '2xl', '1x', '2x', '3x', '4x', '5x', '6x', '7x', '8x', '9x', '10x']),
|
|
63
|
+
wrapperSize: PropTypes.number
|
|
64
|
+
})
|
|
65
|
+
} : {};
|
|
66
|
+
export default Icon;
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["React","PropTypes","FontAwesomeIcon","fas","library","toLower","merge","getOr","Color","style","add","DEFAULT_PRESET","ICON_LUMINOSITY","DEFAULT_WRAPPER_SIZE","DEFAULT_ICON_COLOR","SIZE_CONFIGS","s","faSize","wrapperSize","m","xl","getForegroundColor","backgroundColor","to","set","l","toString","Icon","memo","iconName","iconColor","preset","size","effectiveIconColor","effectiveSize","iconWrapperStyle","width","height","iconWrapper","propTypes","string","isRequired","oneOf","shape","number"],"sources":["../../../src/atom/icon/index.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport {FontAwesomeIcon} from '@fortawesome/react-fontawesome';\nimport {fas} from '@fortawesome/pro-solid-svg-icons';\nimport {library} from '@fortawesome/fontawesome-svg-core';\nimport toLower from 'lodash/fp/toLower';\nimport merge from 'lodash/fp/merge';\nimport getOr from 'lodash/fp/getOr';\nimport Color from 'colorjs.io';\nimport style from './style.css';\n\nlibrary.add(fas);\n\nconst DEFAULT_PRESET = 'm';\nconst ICON_LUMINOSITY = 32;\nconst DEFAULT_WRAPPER_SIZE = 40;\nexport const DEFAULT_ICON_COLOR = 'hsl(0, 0%, 32%)';\n\nconst SIZE_CONFIGS = {\n s: {\n faSize: 'sm',\n wrapperSize: 32\n },\n m: {\n faSize: 'lg',\n wrapperSize: DEFAULT_WRAPPER_SIZE\n },\n xl: {\n faSize: 'xl',\n wrapperSize: 48\n }\n};\n\nexport const getForegroundColor = backgroundColor =>\n new Color(backgroundColor).to('hsl').set({l: ICON_LUMINOSITY}).toString();\n\nconst Icon = React.memo(function Icon({\n iconName,\n iconColor,\n backgroundColor,\n preset = DEFAULT_PRESET,\n size\n}) {\n const effectiveIconColor =\n iconColor || backgroundColor ? getForegroundColor(backgroundColor) : DEFAULT_ICON_COLOR;\n\n const effectiveSize = size\n ? merge(SIZE_CONFIGS[DEFAULT_PRESET], size)\n : getOr(SIZE_CONFIGS[DEFAULT_PRESET], toLower(preset), SIZE_CONFIGS);\n\n const iconWrapperStyle = {\n backgroundColor,\n width: effectiveSize.wrapperSize,\n height: effectiveSize.wrapperSize\n };\n\n return (\n <div className={style.iconWrapper} style={iconWrapperStyle}>\n <FontAwesomeIcon\n icon={`fa-${iconName}`}\n color={effectiveIconColor}\n size={effectiveSize.faSize}\n />\n </div>\n );\n});\n\nIcon.propTypes = {\n iconName: PropTypes.string.isRequired,\n iconColor: PropTypes.string,\n backgroundColor: PropTypes.string,\n preset: PropTypes.oneOf(['s', 'm', 'xl']),\n size: PropTypes.shape({\n faSize: PropTypes.oneOf([\n '2xs',\n 'xs',\n 'sm',\n 'lg',\n 'xl',\n '2xl',\n '1x',\n '2x',\n '3x',\n '4x',\n '5x',\n '6x',\n '7x',\n '8x',\n '9x',\n '10x'\n ]),\n wrapperSize: PropTypes.number\n })\n};\n\nexport default Icon;\n"],"mappings":"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"}
|
package/es/globals.d.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.d.js","names":[],"sources":["../src/globals.d.ts"],"sourcesContent":["declare module '@coorpacademy/nova-icons';\ndeclare module '@coorpacademy/react-native-slider';\ndeclare module '@react-native-community/blur';\ndeclare module '@coorpacademy/translate';\ndeclare module 'browser-env';\ndeclare module 'react-native/*';\ndeclare module '
|
|
1
|
+
{"version":3,"file":"globals.d.js","names":[],"sources":["../src/globals.d.ts"],"sourcesContent":["declare module '@coorpacademy/nova-icons';\ndeclare module '@coorpacademy/react-native-slider';\ndeclare module '@react-native-community/blur';\ndeclare module '@coorpacademy/translate';\ndeclare module 'browser-env';\ndeclare module 'react-native/*';\ndeclare module 'css-color-function';\ndeclare module 'classnames';\ndeclare module '*.css';\n"],"mappings":""}
|
|
@@ -148,10 +148,6 @@
|
|
|
148
148
|
font-size: 16px;
|
|
149
149
|
line-height: 19px;
|
|
150
150
|
}
|
|
151
|
-
|
|
152
|
-
.cta {
|
|
153
|
-
max-width: 175px;
|
|
154
|
-
}
|
|
155
151
|
}
|
|
156
152
|
|
|
157
153
|
@media mobile {
|
|
@@ -162,6 +158,8 @@
|
|
|
162
158
|
|
|
163
159
|
.banner {
|
|
164
160
|
justify-content: center;
|
|
161
|
+
padding-right: 24px;
|
|
162
|
+
padding-left: 24px;
|
|
165
163
|
}
|
|
166
164
|
|
|
167
165
|
.right {
|
|
@@ -183,7 +181,7 @@
|
|
|
183
181
|
}
|
|
184
182
|
|
|
185
183
|
.cta {
|
|
186
|
-
|
|
184
|
+
margin-top: 12px;
|
|
187
185
|
}
|
|
188
186
|
}
|
|
189
187
|
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { FormatedDataType, LearningProfileRadarChartPropTypes } from './types';
|
|
3
|
+
export declare const formatData: (legend: {
|
|
4
|
+
[ref: string]: string;
|
|
5
|
+
}, data_: LearningProfileRadarChartPropTypes['data']) => FormatedDataType[];
|
|
6
|
+
export declare const LearningProfileRadarChart: {
|
|
7
|
+
({ data, legend, totalDataset, colors: colorsProps, onClick, width, height }: LearningProfileRadarChartPropTypes): JSX.Element;
|
|
8
|
+
propTypes: {
|
|
9
|
+
data: import("prop-types").Validator<{
|
|
10
|
+
[x: string]: NonNullable<number | (number | null | undefined)[] | null | undefined> | null | undefined;
|
|
11
|
+
}>;
|
|
12
|
+
totalDataset: import("prop-types").Validator<number>;
|
|
13
|
+
onDotClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
14
|
+
colors: import("prop-types").Requireable<(import("prop-types").InferProps<{
|
|
15
|
+
gradient: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
16
|
+
fill: import("prop-types").Requireable<(string | null | undefined)[]>;
|
|
17
|
+
stroke: import("prop-types").Requireable<(string | null | undefined)[]>;
|
|
18
|
+
}>>;
|
|
19
|
+
percentage: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
20
|
+
color: import("prop-types").Requireable<string>;
|
|
21
|
+
background: import("prop-types").Requireable<string>;
|
|
22
|
+
}>>;
|
|
23
|
+
label: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
24
|
+
color: import("prop-types").Requireable<string>;
|
|
25
|
+
}>>;
|
|
26
|
+
}> | null | undefined)[]>;
|
|
27
|
+
width: import("prop-types").Requireable<number>;
|
|
28
|
+
height: import("prop-types").Requireable<number>;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
declare const ResponsiveLearningProfileRadarChart: {
|
|
32
|
+
(props: LearningProfileRadarChartPropTypes): JSX.Element;
|
|
33
|
+
propTypes: {
|
|
34
|
+
data: import("prop-types").Validator<{
|
|
35
|
+
[x: string]: NonNullable<number | (number | null | undefined)[] | null | undefined> | null | undefined;
|
|
36
|
+
}>;
|
|
37
|
+
totalDataset: import("prop-types").Validator<number>;
|
|
38
|
+
onDotClick: import("prop-types").Requireable<(...args: any[]) => any>;
|
|
39
|
+
colors: import("prop-types").Requireable<(import("prop-types").InferProps<{
|
|
40
|
+
gradient: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
41
|
+
fill: import("prop-types").Requireable<(string | null | undefined)[]>;
|
|
42
|
+
stroke: import("prop-types").Requireable<(string | null | undefined)[]>;
|
|
43
|
+
}>>;
|
|
44
|
+
percentage: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
45
|
+
color: import("prop-types").Requireable<string>;
|
|
46
|
+
background: import("prop-types").Requireable<string>;
|
|
47
|
+
}>>;
|
|
48
|
+
label: import("prop-types").Requireable<import("prop-types").InferProps<{
|
|
49
|
+
color: import("prop-types").Requireable<string>;
|
|
50
|
+
}>>;
|
|
51
|
+
}> | null | undefined)[]>;
|
|
52
|
+
width: import("prop-types").Requireable<number>;
|
|
53
|
+
height: import("prop-types").Requireable<number>;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
export default ResponsiveLearningProfileRadarChart;
|
|
57
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/molecule/learning-profile-radar-chart/index.tsx"],"names":[],"mappings":";AA6BA,OAAO,EAGL,gBAAgB,EAChB,kCAAkC,EAGnC,MAAM,SAAS,CAAC;AA+OjB,eAAO,MAAM,UAAU,EAAE,CACvB,MAAM,EAAE;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CAAC,EAC/B,KAAK,EAAE,kCAAkC,CAAC,MAAM,CAAC,KAC9C,gBAAgB,EAOX,CAAC;AAEX,eAAO,MAAM,yBAAyB;kFAQnC,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;CA8GpC,CAAC;AAEF,QAAA,MAAM,mCAAmC;YAAW,kCAAkC;;;;;;;;;;;;;;;;;;;;;;;CAIrF,CAAC;AAKF,eAAe,mCAAmC,CAAC"}
|
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
import _findKey from "lodash/fp/findKey";
|
|
2
|
+
import _flatten from "lodash/fp/flatten";
|
|
3
|
+
import _times from "lodash/fp/times";
|
|
4
|
+
import _fromPairs from "lodash/fp/fromPairs";
|
|
5
|
+
import _omit from "lodash/fp/omit";
|
|
6
|
+
import _isEmpty from "lodash/fp/isEmpty";
|
|
7
|
+
import _values from "lodash/fp/values";
|
|
8
|
+
import _toPairs from "lodash/fp/toPairs";
|
|
9
|
+
import _map from "lodash/fp/map";
|
|
10
|
+
import _getOr from "lodash/fp/getOr";
|
|
11
|
+
import _size from "lodash/fp/size";
|
|
12
|
+
import _mapValues from "lodash/fp/mapValues";
|
|
13
|
+
import _keyBy from "lodash/fp/keyBy";
|
|
14
|
+
import _pipe from "lodash/fp/pipe";
|
|
15
|
+
const _excluded = ["offset", "alignment"];
|
|
16
|
+
|
|
17
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
18
|
+
|
|
19
|
+
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
20
|
+
|
|
21
|
+
import React, { Fragment, useCallback, useEffect, useMemo, useState } from 'react';
|
|
22
|
+
import { Radar, RadarChart, PolarGrid, PolarAngleAxis, ResponsiveContainer, Tooltip, PolarRadiusAxis } from 'recharts';
|
|
23
|
+
import classnames from 'classnames';
|
|
24
|
+
import { isMobile as getIsMobile } from '../../util/check-is-mobile';
|
|
25
|
+
import style from './style.css';
|
|
26
|
+
import { learningProfileRadarChartPropTypes } from './types';
|
|
27
|
+
|
|
28
|
+
/* TICK_POSITIONS */
|
|
29
|
+
const top = {
|
|
30
|
+
offset: {
|
|
31
|
+
x: -100,
|
|
32
|
+
y: -65
|
|
33
|
+
},
|
|
34
|
+
alignment: 'center',
|
|
35
|
+
margin: 'auto'
|
|
36
|
+
};
|
|
37
|
+
const bottom = {
|
|
38
|
+
offset: {
|
|
39
|
+
x: -100,
|
|
40
|
+
y: 10
|
|
41
|
+
},
|
|
42
|
+
alignment: 'center',
|
|
43
|
+
margin: 'auto'
|
|
44
|
+
};
|
|
45
|
+
const right = {
|
|
46
|
+
offset: {
|
|
47
|
+
x: 30,
|
|
48
|
+
y: -10
|
|
49
|
+
},
|
|
50
|
+
alignment: 'start',
|
|
51
|
+
marginRight: 'auto'
|
|
52
|
+
};
|
|
53
|
+
const left = {
|
|
54
|
+
offset: {
|
|
55
|
+
x: -230,
|
|
56
|
+
y: -10
|
|
57
|
+
},
|
|
58
|
+
alignment: 'end',
|
|
59
|
+
marginLeft: 'auto'
|
|
60
|
+
};
|
|
61
|
+
/* CONSTANTS */
|
|
62
|
+
|
|
63
|
+
const BLACK = '#000000ff';
|
|
64
|
+
const WHITE = '#ffffffff';
|
|
65
|
+
const DEFAULT_MAIN_COLOR = '#0062ffff';
|
|
66
|
+
const DEFAULT_COLORS = {
|
|
67
|
+
gradient: {
|
|
68
|
+
fill: [DEFAULT_MAIN_COLOR, DEFAULT_MAIN_COLOR],
|
|
69
|
+
stroke: [DEFAULT_MAIN_COLOR, DEFAULT_MAIN_COLOR]
|
|
70
|
+
},
|
|
71
|
+
percentage: {
|
|
72
|
+
color: BLACK,
|
|
73
|
+
background: WHITE
|
|
74
|
+
},
|
|
75
|
+
label: {
|
|
76
|
+
color: BLACK
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const CHART_CONFIGS = {
|
|
80
|
+
triangle: {
|
|
81
|
+
name: 'triangle',
|
|
82
|
+
ticks: [top, right, left],
|
|
83
|
+
sideCount: 3
|
|
84
|
+
},
|
|
85
|
+
quadrilateral: {
|
|
86
|
+
name: 'quadrilateral',
|
|
87
|
+
ticks: [top, right, bottom, left],
|
|
88
|
+
sideCount: 4
|
|
89
|
+
},
|
|
90
|
+
pentagon: {
|
|
91
|
+
name: 'pentagon',
|
|
92
|
+
ticks: [top, right, right, left, left],
|
|
93
|
+
sideCount: 5
|
|
94
|
+
},
|
|
95
|
+
hexagon: {
|
|
96
|
+
name: 'hexagon',
|
|
97
|
+
ticks: [top, right, right, bottom, left, left],
|
|
98
|
+
sideCount: 6
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
const DOT_DEFAULT_PROPS = {
|
|
102
|
+
strokeWidth: 4,
|
|
103
|
+
strokeOpacity: 0.2,
|
|
104
|
+
fill: '#fff',
|
|
105
|
+
r: 8,
|
|
106
|
+
pointerEvents: 'all',
|
|
107
|
+
style: {
|
|
108
|
+
cursor: 'pointer'
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
const DOT_ACTIVE_PROPS = {
|
|
112
|
+
fill: '#fff',
|
|
113
|
+
r: 8,
|
|
114
|
+
strokeWidth: 6,
|
|
115
|
+
strokeOpacity: 0.5
|
|
116
|
+
};
|
|
117
|
+
const RADAR_DEFAULT_PROPS = {
|
|
118
|
+
strokeWidth: 6,
|
|
119
|
+
strokeOpacity: 0.2,
|
|
120
|
+
fillOpacity: 0.2
|
|
121
|
+
};
|
|
122
|
+
/* COMPONENTS */
|
|
123
|
+
|
|
124
|
+
const Gradient = ({
|
|
125
|
+
type,
|
|
126
|
+
colors: [firstColor, secondColor]
|
|
127
|
+
}) => /*#__PURE__*/React.createElement("defs", null, /*#__PURE__*/React.createElement("linearGradient", {
|
|
128
|
+
id: `gradient-${type}`,
|
|
129
|
+
x1: "0%",
|
|
130
|
+
y1: "0%",
|
|
131
|
+
x2: "0%",
|
|
132
|
+
y2: "100%"
|
|
133
|
+
}, /*#__PURE__*/React.createElement("stop", {
|
|
134
|
+
offset: "0%",
|
|
135
|
+
stopColor: firstColor
|
|
136
|
+
}), /*#__PURE__*/React.createElement("stop", {
|
|
137
|
+
offset: "100%",
|
|
138
|
+
stopColor: secondColor
|
|
139
|
+
})));
|
|
140
|
+
|
|
141
|
+
const CustomTooltip = ({
|
|
142
|
+
active,
|
|
143
|
+
payload,
|
|
144
|
+
label
|
|
145
|
+
}) => active && !!payload?.length ? /*#__PURE__*/React.createElement("div", {
|
|
146
|
+
className: style.tooltip
|
|
147
|
+
}, /*#__PURE__*/React.createElement("p", null, label), /*#__PURE__*/React.createElement("p", null, payload[0].value, "%")) : null;
|
|
148
|
+
|
|
149
|
+
const CustomDot = ({
|
|
150
|
+
cx,
|
|
151
|
+
cy,
|
|
152
|
+
payload,
|
|
153
|
+
onDotClick,
|
|
154
|
+
stroke,
|
|
155
|
+
activeDot,
|
|
156
|
+
dataName
|
|
157
|
+
}) => /*#__PURE__*/React.createElement("circle", _extends({}, DOT_DEFAULT_PROPS, payload?.payload.subject === activeDot?.label && DOT_ACTIVE_PROPS, {
|
|
158
|
+
stroke,
|
|
159
|
+
cx,
|
|
160
|
+
cy,
|
|
161
|
+
onClick: e => {
|
|
162
|
+
e.stopPropagation();
|
|
163
|
+
if (!payload?.name) return;
|
|
164
|
+
onDotClick(payload.name);
|
|
165
|
+
},
|
|
166
|
+
'data-name': dataName
|
|
167
|
+
}));
|
|
168
|
+
|
|
169
|
+
const buildRadars = (totalDataset, handleOnDotClick, activeDot) => _times(index => {
|
|
170
|
+
const datakey = `value${index + 1}`;
|
|
171
|
+
const dataset = `dataset-${index + 1}`;
|
|
172
|
+
return /*#__PURE__*/React.createElement(Radar, _extends({}, RADAR_DEFAULT_PROPS, {
|
|
173
|
+
fill: `url(#gradient-fill-${index})`,
|
|
174
|
+
stroke: `url(#gradient-stroke-${index})`,
|
|
175
|
+
key: dataset,
|
|
176
|
+
name: dataset,
|
|
177
|
+
dataKey: datakey,
|
|
178
|
+
activeDot: _extends({}, DOT_ACTIVE_PROPS, {
|
|
179
|
+
stroke: `url(#gradient-stroke-${index})`
|
|
180
|
+
}) // only on mobile
|
|
181
|
+
// to handle dot style on hover (convert to click)
|
|
182
|
+
// use with the tooltip component
|
|
183
|
+
,
|
|
184
|
+
dot: /*#__PURE__*/React.createElement(CustomDot, {
|
|
185
|
+
onDotClick: handleOnDotClick(datakey),
|
|
186
|
+
activeDot: activeDot,
|
|
187
|
+
dataKey: datakey,
|
|
188
|
+
stroke: `url(#gradient-stroke-${index})`,
|
|
189
|
+
dataName: dataset
|
|
190
|
+
})
|
|
191
|
+
}));
|
|
192
|
+
}, totalDataset);
|
|
193
|
+
|
|
194
|
+
const buildCustomLabel = ({
|
|
195
|
+
index,
|
|
196
|
+
x,
|
|
197
|
+
y,
|
|
198
|
+
percentagesValues,
|
|
199
|
+
label,
|
|
200
|
+
activeDot,
|
|
201
|
+
chartType,
|
|
202
|
+
formatedColors
|
|
203
|
+
}) => {
|
|
204
|
+
const isCurrentDotActive = activeDot?.label === label;
|
|
205
|
+
|
|
206
|
+
const _CHART_CONFIGS$chartT = CHART_CONFIGS[chartType].ticks[index],
|
|
207
|
+
{
|
|
208
|
+
offset: {
|
|
209
|
+
x: offsetX,
|
|
210
|
+
y: offsetY
|
|
211
|
+
},
|
|
212
|
+
alignment
|
|
213
|
+
} = _CHART_CONFIGS$chartT,
|
|
214
|
+
rest = _objectWithoutPropertiesLoose(_CHART_CONFIGS$chartT, _excluded);
|
|
215
|
+
|
|
216
|
+
return /*#__PURE__*/React.createElement("g", null, /*#__PURE__*/React.createElement("foreignObject", {
|
|
217
|
+
x: x + offsetX,
|
|
218
|
+
y: y + offsetY,
|
|
219
|
+
width: "200",
|
|
220
|
+
height: "65"
|
|
221
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
222
|
+
className: classnames(style.tickWrapper, isCurrentDotActive && style.tickWrapperFocus),
|
|
223
|
+
style: _extends({}, rest, {
|
|
224
|
+
alignItems: alignment,
|
|
225
|
+
textAlign: alignment,
|
|
226
|
+
opacity: !_isEmpty(activeDot) && !isCurrentDotActive ? 0.3 : 1
|
|
227
|
+
})
|
|
228
|
+
}, formatedColors.map(({
|
|
229
|
+
percentage: {
|
|
230
|
+
color,
|
|
231
|
+
background
|
|
232
|
+
},
|
|
233
|
+
label: {
|
|
234
|
+
color: colorLabel
|
|
235
|
+
}
|
|
236
|
+
}, i) => /*#__PURE__*/React.createElement(Fragment, {
|
|
237
|
+
key: i
|
|
238
|
+
}, /*#__PURE__*/React.createElement("span", {
|
|
239
|
+
className: style.tickValue,
|
|
240
|
+
style: {
|
|
241
|
+
color,
|
|
242
|
+
background
|
|
243
|
+
}
|
|
244
|
+
}, percentagesValues[i]), /*#__PURE__*/React.createElement("span", {
|
|
245
|
+
className: style.tickLabel,
|
|
246
|
+
style: {
|
|
247
|
+
color: colorLabel
|
|
248
|
+
}
|
|
249
|
+
}, label))))));
|
|
250
|
+
};
|
|
251
|
+
/* UTILS */
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
const CHART_CONFIGS_BY_SIDE_COUNT = _pipe(_keyBy('sideCount'), _mapValues('name'))(CHART_CONFIGS);
|
|
255
|
+
|
|
256
|
+
const formatValues = _pipe(values_ => _flatten([values_]), values_ => values_.map((val, i) => [`value${i + 1}`, val]), _fromPairs);
|
|
257
|
+
/* this convert incoming component data to rechart data structure */
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
export const formatData = (legend, data_) => _pipe(_toPairs, _map(([ref, values_]) => _extends({}, formatValues(values_), {
|
|
261
|
+
subject: legend[ref]
|
|
262
|
+
})))(data_);
|
|
263
|
+
export const LearningProfileRadarChart = ({
|
|
264
|
+
data,
|
|
265
|
+
legend,
|
|
266
|
+
totalDataset,
|
|
267
|
+
colors: colorsProps,
|
|
268
|
+
onClick,
|
|
269
|
+
width,
|
|
270
|
+
height
|
|
271
|
+
}) => {
|
|
272
|
+
const [isMobile, setIsMobile] = useState(false);
|
|
273
|
+
const [activeDot, setActiveDot] = useState();
|
|
274
|
+
|
|
275
|
+
const formatedColors = _times(i => {
|
|
276
|
+
if (!colorsProps?.length) return DEFAULT_COLORS;
|
|
277
|
+
const colors = colorsProps[i];
|
|
278
|
+
return colors ? Object.assign({}, DEFAULT_COLORS, colors) : DEFAULT_COLORS;
|
|
279
|
+
})(totalDataset);
|
|
280
|
+
|
|
281
|
+
const chartType = useMemo(() => _getOr('hexagon', _size(data), CHART_CONFIGS_BY_SIDE_COUNT), [data]);
|
|
282
|
+
const gradients = useMemo(() => formatedColors.map(({
|
|
283
|
+
gradient: {
|
|
284
|
+
fill,
|
|
285
|
+
stroke
|
|
286
|
+
}
|
|
287
|
+
}, index) => /*#__PURE__*/React.createElement("svg", {
|
|
288
|
+
key: `gradient-${index}`
|
|
289
|
+
}, /*#__PURE__*/React.createElement(Gradient, {
|
|
290
|
+
type: `fill-${index}`,
|
|
291
|
+
colors: fill
|
|
292
|
+
}), /*#__PURE__*/React.createElement(Gradient, {
|
|
293
|
+
type: `stroke-${index}`,
|
|
294
|
+
colors: stroke
|
|
295
|
+
}))), [formatedColors]);
|
|
296
|
+
const userAgent = navigator?.userAgent;
|
|
297
|
+
const isMobile_ = useMemo(() => getIsMobile(userAgent), [userAgent]);
|
|
298
|
+
const setIsMobile_ = useCallback(() => {
|
|
299
|
+
setIsMobile(isMobile_);
|
|
300
|
+
}, [isMobile_]);
|
|
301
|
+
useEffect(() => setIsMobile_(), [setIsMobile_]);
|
|
302
|
+
useEffect(() => {
|
|
303
|
+
const handleClick = () => setActiveDot(undefined);
|
|
304
|
+
|
|
305
|
+
!_isEmpty(activeDot) && window.addEventListener('click', handleClick);
|
|
306
|
+
return () => {
|
|
307
|
+
window.removeEventListener('click', handleClick);
|
|
308
|
+
};
|
|
309
|
+
}, [activeDot]);
|
|
310
|
+
|
|
311
|
+
function handleOnDotClick(datakey) {
|
|
312
|
+
return label => {
|
|
313
|
+
const payload = formatedData.find(data_ => data_.subject === label);
|
|
314
|
+
|
|
315
|
+
const skillRef = _findKey(val => val === payload?.subject, legend);
|
|
316
|
+
|
|
317
|
+
if (payload && skillRef) {
|
|
318
|
+
setActiveDot({
|
|
319
|
+
key: datakey,
|
|
320
|
+
value: payload[datakey],
|
|
321
|
+
label: payload.subject
|
|
322
|
+
});
|
|
323
|
+
onClick(skillRef);
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
function renderCustomLabel({
|
|
329
|
+
x,
|
|
330
|
+
y,
|
|
331
|
+
payload: {
|
|
332
|
+
value: label
|
|
333
|
+
},
|
|
334
|
+
index
|
|
335
|
+
}) {
|
|
336
|
+
const currentData = formatedData.find(({
|
|
337
|
+
subject
|
|
338
|
+
}) => subject === label);
|
|
339
|
+
|
|
340
|
+
const percentagesValues = _pipe(_omit('subject'), _mapValues(value => `${value}%`), _values)(currentData);
|
|
341
|
+
|
|
342
|
+
return buildCustomLabel({
|
|
343
|
+
index,
|
|
344
|
+
x,
|
|
345
|
+
y,
|
|
346
|
+
percentagesValues,
|
|
347
|
+
label,
|
|
348
|
+
activeDot,
|
|
349
|
+
chartType,
|
|
350
|
+
formatedColors
|
|
351
|
+
});
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
const formatedData = useMemo(() => formatData(legend, data), [legend, data]);
|
|
355
|
+
return /*#__PURE__*/React.createElement(RadarChart, {
|
|
356
|
+
width: width,
|
|
357
|
+
height: height,
|
|
358
|
+
cx: "50%",
|
|
359
|
+
cy: "50%",
|
|
360
|
+
outerRadius: "80%",
|
|
361
|
+
data: formatedData
|
|
362
|
+
}, gradients, buildRadars(totalDataset, handleOnDotClick, activeDot), /*#__PURE__*/React.createElement(PolarGrid, {
|
|
363
|
+
strokeDasharray: 15,
|
|
364
|
+
strokeWidth: 3,
|
|
365
|
+
radialLines: false
|
|
366
|
+
}), /*#__PURE__*/React.createElement(PolarAngleAxis, {
|
|
367
|
+
dataKey: "subject",
|
|
368
|
+
tick: !isMobile && renderCustomLabel
|
|
369
|
+
}), /*#__PURE__*/React.createElement(PolarRadiusAxis, {
|
|
370
|
+
tick: false,
|
|
371
|
+
axisLine: false,
|
|
372
|
+
domain: [0, 100]
|
|
373
|
+
}), isMobile ? /*#__PURE__*/React.createElement(Tooltip, {
|
|
374
|
+
cursor: false,
|
|
375
|
+
content: /*#__PURE__*/React.createElement(CustomTooltip, null)
|
|
376
|
+
}) : null);
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const ResponsiveLearningProfileRadarChart = props => /*#__PURE__*/React.createElement(ResponsiveContainer, {
|
|
380
|
+
width: "100%",
|
|
381
|
+
height: "100%"
|
|
382
|
+
}, /*#__PURE__*/React.createElement(LearningProfileRadarChart, props));
|
|
383
|
+
|
|
384
|
+
LearningProfileRadarChart.propTypes = process.env.NODE_ENV !== "production" ? learningProfileRadarChartPropTypes : {};
|
|
385
|
+
ResponsiveLearningProfileRadarChart.propTypes = process.env.NODE_ENV !== "production" ? learningProfileRadarChartPropTypes : {};
|
|
386
|
+
export default ResponsiveLearningProfileRadarChart;
|
|
387
|
+
//# sourceMappingURL=index.js.map
|