datastake-daf 0.6.204 → 0.6.206
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/.env +8 -0
- package/.vscode/settings.json +13 -0
- package/dist/components/index.js +25 -11
- package/package.json +1 -1
- package/src/@daf/core/components/Dashboard/Widget/ProjectWidget/index.jsx +79 -77
- package/src/@daf/core/components/Dashboard/Widget/WidgetPlaceholder/WidgetPlaceholder.stories.js +1 -0
- package/src/@daf/core/components/Dashboard/Widget/WidgetPlaceholder/_style.scss +1 -1
- package/src/@daf/core/components/Dashboard/Widget/WidgetPlaceholder/index.jsx +7 -2
- package/src/@daf/core/components/Table/StickyTable/index.jsx +75 -71
- package/src/@daf/core/components/UI/SDGIcon/SGDIcon.stories.jsx +65 -44
- package/src/@daf/core/components/UI/SDGIcon/index.jsx +94 -93
package/.env
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"cSpell.words": ["cukura"],
|
|
3
|
+
"files.autoSave": "afterDelay",
|
|
4
|
+
"editor.wordWrap": "on",
|
|
5
|
+
"editor.autoClosingBrackets": "always",
|
|
6
|
+
"editor.autoClosingComments": "always",
|
|
7
|
+
"editor.autoClosingQuotes": "always",
|
|
8
|
+
"editor.defaultFormatter": "esbenp.prettier-vscode",
|
|
9
|
+
"editor.formatOnPaste": true,
|
|
10
|
+
"editor.formatOnSave": true,
|
|
11
|
+
"notebook.defaultFormatter": "esbenp.prettier-vscode",
|
|
12
|
+
"javascript.format.semicolons": "insert"
|
|
13
|
+
}
|
package/dist/components/index.js
CHANGED
|
@@ -11079,7 +11079,7 @@ var _templateObject$c;
|
|
|
11079
11079
|
const _excluded$s = ["size", "maxHeight", "containerHeight", "dataSource", "columns", "pagination", "doEmptyRows"];
|
|
11080
11080
|
function StickyTable(_ref) {
|
|
11081
11081
|
let {
|
|
11082
|
-
size =
|
|
11082
|
+
size = "small",
|
|
11083
11083
|
maxHeight = 300,
|
|
11084
11084
|
containerHeight = 525,
|
|
11085
11085
|
dataSource = [],
|
|
@@ -11089,6 +11089,9 @@ function StickyTable(_ref) {
|
|
|
11089
11089
|
} = _ref,
|
|
11090
11090
|
props = _objectWithoutProperties(_ref, _excluded$s);
|
|
11091
11091
|
const data = React__default["default"].useMemo(() => {
|
|
11092
|
+
if (!doEmptyRows) {
|
|
11093
|
+
return dataSource;
|
|
11094
|
+
}
|
|
11092
11095
|
const MIN_ROWS = 4;
|
|
11093
11096
|
if (dataSource.length < MIN_ROWS) {
|
|
11094
11097
|
const paddedData = [...dataSource];
|
|
@@ -11100,7 +11103,7 @@ function StickyTable(_ref) {
|
|
|
11100
11103
|
return paddedData;
|
|
11101
11104
|
}
|
|
11102
11105
|
return dataSource;
|
|
11103
|
-
}, [dataSource]);
|
|
11106
|
+
}, [dataSource, doEmptyRows]);
|
|
11104
11107
|
const Wrapper = React__default["default"].useMemo(() => {
|
|
11105
11108
|
return data.length > 5 ? ComponentWithFocus : "div";
|
|
11106
11109
|
}, [data.length]);
|
|
@@ -11130,7 +11133,7 @@ function StickyTable(_ref) {
|
|
|
11130
11133
|
})
|
|
11131
11134
|
});
|
|
11132
11135
|
}
|
|
11133
|
-
const Style$I = dt.div(_templateObject$c || (_templateObject$c = _taggedTemplateLiteral(["\n
|
|
11136
|
+
const Style$I = dt.div(_templateObject$c || (_templateObject$c = _taggedTemplateLiteral(["\n\tmax-width: calc(100% - 48px);\n\tmargin-left: var(--size-lg);\n\toverflow: hidden;\n\n\t.daf-table {\n\t\tpadding: 0px;\n\t\tmargin-top: 0px;\n\n\t\t.ant-tag {\n\t\t\ttext-align: center;\n\t\t}\n\t}\n\n\t.daf-select-filters .filters {\n\t\tpadding-top: 16px;\n\t\tpadding-left: 0;\n\t\tpadding-right: 0;\n\t}\n\n\t.daf-table {\n\t\tpadding-top: 16px;\n\t}\n"])));
|
|
11134
11137
|
StickyTable.propTypes = {
|
|
11135
11138
|
size: PropTypes__default["default"].any,
|
|
11136
11139
|
maxHeight: PropTypes__default["default"].number,
|
|
@@ -20294,6 +20297,8 @@ function WidgetPlaceholder(_ref) {
|
|
|
20294
20297
|
style = {},
|
|
20295
20298
|
iconWidth = 22,
|
|
20296
20299
|
iconHeight = 22,
|
|
20300
|
+
iconColor = "white",
|
|
20301
|
+
circleColor = "#2b2c2d",
|
|
20297
20302
|
inDevelopment = false,
|
|
20298
20303
|
description = ""
|
|
20299
20304
|
} = _ref;
|
|
@@ -20327,13 +20332,16 @@ function WidgetPlaceholder(_ref) {
|
|
|
20327
20332
|
})
|
|
20328
20333
|
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20329
20334
|
className: "icon-bubble-d",
|
|
20335
|
+
style: {
|
|
20336
|
+
backgroundColor: circleColor
|
|
20337
|
+
},
|
|
20330
20338
|
children: /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20331
20339
|
className: "flex justify-content-center",
|
|
20332
20340
|
children: /*#__PURE__*/jsxRuntime.jsx(CustomIcon, {
|
|
20333
20341
|
name: icon,
|
|
20334
20342
|
width: iconWidth,
|
|
20335
20343
|
height: iconHeight,
|
|
20336
|
-
color:
|
|
20344
|
+
color: iconColor
|
|
20337
20345
|
})
|
|
20338
20346
|
})
|
|
20339
20347
|
})
|
|
@@ -20849,7 +20857,8 @@ function SDGIcons(_ref) {
|
|
|
20849
20857
|
let {
|
|
20850
20858
|
sdgList = [],
|
|
20851
20859
|
t = str => str,
|
|
20852
|
-
iconSize = 24
|
|
20860
|
+
iconSize = 24,
|
|
20861
|
+
reverseDirection = false
|
|
20853
20862
|
} = _ref;
|
|
20854
20863
|
const containerRef = React__default["default"].useRef(null);
|
|
20855
20864
|
const [width, setWidth] = React__default["default"].useState(0);
|
|
@@ -20888,6 +20897,9 @@ function SDGIcons(_ref) {
|
|
|
20888
20897
|
return /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20889
20898
|
ref: containerRef,
|
|
20890
20899
|
children: /*#__PURE__*/jsxRuntime.jsxs(SDGList, {
|
|
20900
|
+
style: {
|
|
20901
|
+
flexDirection: reverseDirection ? "row-reverse" : "row"
|
|
20902
|
+
},
|
|
20891
20903
|
children: [visibleSdgs.map((sdg, index) => /*#__PURE__*/jsxRuntime.jsx("li", {
|
|
20892
20904
|
className: "project-widget-item",
|
|
20893
20905
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Tooltip, {
|
|
@@ -20968,8 +20980,8 @@ function ProjectWidget(_ref) {
|
|
|
20968
20980
|
onLinkClick,
|
|
20969
20981
|
image,
|
|
20970
20982
|
linkIcon = "Link",
|
|
20971
|
-
sdgList,
|
|
20972
|
-
items,
|
|
20983
|
+
sdgList = [],
|
|
20984
|
+
items = [],
|
|
20973
20985
|
onCardClick,
|
|
20974
20986
|
hideSDGList = false,
|
|
20975
20987
|
t = x => x
|
|
@@ -20981,9 +20993,10 @@ function ProjectWidget(_ref) {
|
|
|
20981
20993
|
} = useToken$i();
|
|
20982
20994
|
return /*#__PURE__*/jsxRuntime.jsxs(antd.Card, _objectSpread2(_objectSpread2({
|
|
20983
20995
|
style: {
|
|
20984
|
-
flex: 1,
|
|
20985
|
-
width:
|
|
20986
|
-
minWidth:
|
|
20996
|
+
// flex: 1,
|
|
20997
|
+
width: 318,
|
|
20998
|
+
minWidth: 318
|
|
20999
|
+
// minWidth: "200px",
|
|
20987
21000
|
},
|
|
20988
21001
|
hoverable: true,
|
|
20989
21002
|
onMouseEnter: () => setIsHovered(true),
|
|
@@ -20997,7 +21010,8 @@ function ProjectWidget(_ref) {
|
|
|
20997
21010
|
}
|
|
20998
21011
|
}) : /*#__PURE__*/jsxRuntime.jsx("div", {
|
|
20999
21012
|
style: {
|
|
21000
|
-
height: "103px"
|
|
21013
|
+
height: "103px",
|
|
21014
|
+
borderBottom: "1px solid var(--base-gray-30)"
|
|
21001
21015
|
},
|
|
21002
21016
|
children: /*#__PURE__*/jsxRuntime.jsx(antd.Empty, {
|
|
21003
21017
|
image: antd.Empty.PRESENTED_IMAGE_SIMPLE
|
package/package.json
CHANGED
|
@@ -7,85 +7,87 @@ const { Meta } = Card;
|
|
|
7
7
|
const { useToken } = theme;
|
|
8
8
|
|
|
9
9
|
export default function ProjectWidget({
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
10
|
+
title,
|
|
11
|
+
description,
|
|
12
|
+
onLinkClick,
|
|
13
|
+
image,
|
|
14
|
+
linkIcon = "Link",
|
|
15
|
+
sdgList = [],
|
|
16
|
+
items = [],
|
|
17
|
+
onCardClick,
|
|
18
|
+
hideSDGList = false,
|
|
19
|
+
t = (x) => x,
|
|
20
|
+
...props
|
|
21
21
|
}) {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const [isHovered, setIsHovered] = React.useState(false);
|
|
23
|
+
const { token } = useToken();
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
25
|
+
return (
|
|
26
|
+
<Card
|
|
27
|
+
style={{
|
|
28
|
+
// flex: 1,
|
|
29
|
+
width: 318,
|
|
30
|
+
minWidth: 318,
|
|
31
|
+
// minWidth: "200px",
|
|
32
|
+
}}
|
|
33
|
+
hoverable
|
|
34
|
+
onMouseEnter={() => setIsHovered(true)}
|
|
35
|
+
onMouseLeave={() => setIsHovered(false)}
|
|
36
|
+
onClick={onCardClick}
|
|
37
|
+
cover={
|
|
38
|
+
<ImageContainer>
|
|
39
|
+
{image ? (
|
|
40
|
+
<div
|
|
41
|
+
className="image"
|
|
42
|
+
style={{
|
|
43
|
+
backgroundImage: `url(${image})`,
|
|
44
|
+
}}
|
|
45
|
+
/>
|
|
46
|
+
) : (
|
|
47
|
+
<div
|
|
48
|
+
style={{
|
|
49
|
+
height: "103px",
|
|
50
|
+
borderBottom: "1px solid var(--base-gray-30)",
|
|
51
|
+
}}
|
|
52
|
+
>
|
|
53
|
+
<Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
|
|
54
|
+
</div>
|
|
55
|
+
)}
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
57
|
+
{onLinkClick && (
|
|
58
|
+
<div className="icon-container" onClick={onLinkClick}>
|
|
59
|
+
<CustomIcon
|
|
60
|
+
name={linkIcon}
|
|
61
|
+
width={16}
|
|
62
|
+
height={16}
|
|
63
|
+
color={isHovered ? token.colorPrimary7 : "black"}
|
|
64
|
+
/>
|
|
65
|
+
</div>
|
|
66
|
+
)}
|
|
67
|
+
</ImageContainer>
|
|
68
|
+
}
|
|
69
|
+
{...props}
|
|
70
|
+
>
|
|
71
|
+
<Meta title={title || undefined} description={description || undefined} />
|
|
72
|
+
<ProjectWidgetItems>
|
|
73
|
+
{items.map((item, index) => (
|
|
74
|
+
<li key={index} className="project-widget-item">
|
|
75
|
+
<Label>{item.label}</Label>
|
|
76
|
+
{item.render()}
|
|
77
|
+
</li>
|
|
78
|
+
))}
|
|
79
|
+
</ProjectWidgetItems>
|
|
78
80
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
81
|
+
{!hideSDGList && (
|
|
82
|
+
<div
|
|
83
|
+
style={{
|
|
84
|
+
borderTop: "1px solid var(--base-gray-30)",
|
|
85
|
+
paddingTop: "10px",
|
|
86
|
+
}}
|
|
87
|
+
>
|
|
88
|
+
<SdgList sdgList={sdgList} t={t} />
|
|
89
|
+
</div>
|
|
90
|
+
)}
|
|
91
|
+
</Card>
|
|
92
|
+
);
|
|
91
93
|
}
|
|
@@ -7,6 +7,8 @@ export default function WidgetPlaceholder({
|
|
|
7
7
|
style = {},
|
|
8
8
|
iconWidth = 22,
|
|
9
9
|
iconHeight = 22,
|
|
10
|
+
iconColor = "white",
|
|
11
|
+
circleColor = "#2b2c2d",
|
|
10
12
|
inDevelopment = false,
|
|
11
13
|
description = "",
|
|
12
14
|
}) {
|
|
@@ -36,13 +38,16 @@ export default function WidgetPlaceholder({
|
|
|
36
38
|
</div>
|
|
37
39
|
</div>
|
|
38
40
|
) : (
|
|
39
|
-
<div
|
|
41
|
+
<div
|
|
42
|
+
className="icon-bubble-d"
|
|
43
|
+
style={{ backgroundColor: circleColor }}
|
|
44
|
+
>
|
|
40
45
|
<div className="flex justify-content-center">
|
|
41
46
|
<CustomIcon
|
|
42
47
|
name={icon}
|
|
43
48
|
width={iconWidth}
|
|
44
49
|
height={iconHeight}
|
|
45
|
-
color=
|
|
50
|
+
color={iconColor}
|
|
46
51
|
/>
|
|
47
52
|
</div>
|
|
48
53
|
</div>
|
|
@@ -5,90 +5,94 @@ import PropTypes from "prop-types";
|
|
|
5
5
|
import ComponentWithFocus from "../../Dashboard/ComponentWithFocus/index.jsx";
|
|
6
6
|
|
|
7
7
|
export default function StickyTable({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
size = "small",
|
|
9
|
+
maxHeight = 300,
|
|
10
|
+
containerHeight = 525,
|
|
11
|
+
dataSource = [],
|
|
12
|
+
columns = {},
|
|
13
|
+
pagination = false,
|
|
14
|
+
doEmptyRows = true,
|
|
15
|
+
...props
|
|
16
16
|
}) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const data = React.useMemo(() => {
|
|
18
|
+
if (!doEmptyRows) {
|
|
19
|
+
return dataSource;
|
|
20
|
+
}
|
|
19
21
|
|
|
20
|
-
|
|
21
|
-
const paddedData = [...dataSource];
|
|
22
|
-
while (paddedData.length < MIN_ROWS) {
|
|
23
|
-
paddedData.push({ empty: true });
|
|
24
|
-
}
|
|
25
|
-
return paddedData;
|
|
26
|
-
}
|
|
22
|
+
const MIN_ROWS = 4;
|
|
27
23
|
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (dataSource.length < MIN_ROWS) {
|
|
25
|
+
const paddedData = [...dataSource];
|
|
26
|
+
while (paddedData.length < MIN_ROWS) {
|
|
27
|
+
paddedData.push({ empty: true });
|
|
28
|
+
}
|
|
29
|
+
return paddedData;
|
|
30
|
+
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}, [data.length]);
|
|
32
|
+
return dataSource;
|
|
33
|
+
}, [dataSource, doEmptyRows]);
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
35
|
+
const Wrapper = React.useMemo(() => {
|
|
36
|
+
return data.length > 5 ? ComponentWithFocus : "div";
|
|
37
|
+
}, [data.length]);
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<Wrapper>
|
|
41
|
+
<Style>
|
|
42
|
+
<div
|
|
43
|
+
className="daf-table-wrapper"
|
|
44
|
+
style={{
|
|
45
|
+
maxHeight: containerHeight,
|
|
46
|
+
overflowY: "auto",
|
|
47
|
+
}}
|
|
48
|
+
>
|
|
49
|
+
<div className="daf-sticky-table">
|
|
50
|
+
<Table
|
|
51
|
+
{...props}
|
|
52
|
+
size={size}
|
|
53
|
+
scroll
|
|
54
|
+
sticky
|
|
55
|
+
style={{ maxHeight }}
|
|
56
|
+
dataSource={data}
|
|
57
|
+
columns={columns}
|
|
58
|
+
pagination={pagination}
|
|
59
|
+
/>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</Style>
|
|
63
|
+
</Wrapper>
|
|
64
|
+
);
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
const Style = styled.div`
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
68
|
+
max-width: calc(100% - 48px);
|
|
69
|
+
margin-left: var(--size-lg);
|
|
70
|
+
overflow: hidden;
|
|
67
71
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
.daf-table {
|
|
73
|
+
padding: 0px;
|
|
74
|
+
margin-top: 0px;
|
|
71
75
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
.ant-tag {
|
|
77
|
+
text-align: center;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
76
80
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
.daf-select-filters .filters {
|
|
82
|
+
padding-top: 16px;
|
|
83
|
+
padding-left: 0;
|
|
84
|
+
padding-right: 0;
|
|
85
|
+
}
|
|
82
86
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
87
|
+
.daf-table {
|
|
88
|
+
padding-top: 16px;
|
|
89
|
+
}
|
|
86
90
|
`;
|
|
87
91
|
|
|
88
92
|
StickyTable.propTypes = {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
size: PropTypes.any,
|
|
94
|
+
maxHeight: PropTypes.number,
|
|
95
|
+
dataSource: PropTypes.array,
|
|
96
|
+
columns: PropTypes.object,
|
|
97
|
+
pagination: PropTypes.any,
|
|
94
98
|
};
|
|
@@ -2,54 +2,75 @@ import SDGIcon from "./index.jsx";
|
|
|
2
2
|
import ThemeLayout from "../../ThemeLayout/index.jsx";
|
|
3
3
|
|
|
4
4
|
export default {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
5
|
+
title: "Components/SDGIcon",
|
|
6
|
+
component: SDGIcon,
|
|
7
|
+
tags: ["autodocs"],
|
|
8
|
+
decorators: [
|
|
9
|
+
(Story) => (
|
|
10
|
+
<div style={{ margin: "3em" }}>
|
|
11
|
+
<ThemeLayout>
|
|
12
|
+
<Story />
|
|
13
|
+
</ThemeLayout>
|
|
14
|
+
</div>
|
|
15
|
+
),
|
|
16
|
+
],
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const Primary = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
20
|
+
name: "SDGIcon",
|
|
21
|
+
args: {
|
|
22
|
+
sdgList: [
|
|
23
|
+
"noPoverty",
|
|
24
|
+
"zeroHunger",
|
|
25
|
+
"goodHealthWellbeing",
|
|
26
|
+
"qualityEducation",
|
|
27
|
+
"genderEquality",
|
|
28
|
+
"cleanWaterSanitation",
|
|
29
|
+
"affordableCleanEnergy",
|
|
30
|
+
"decentWorkEconomicGrowth",
|
|
31
|
+
"industryInnovationInfrastructure",
|
|
32
|
+
"reducedInequalities",
|
|
33
|
+
"sustainableCitiesCommunities",
|
|
34
|
+
"responsibleConsumptionProduction",
|
|
35
|
+
"climateAction",
|
|
36
|
+
"lifeBelowWater",
|
|
37
|
+
"lifeOnLand",
|
|
38
|
+
"peaceJusticeStrongInstitutions",
|
|
39
|
+
"partnershipsForGoals",
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
export const BiggerIcons = {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
name: "BiggerIcons",
|
|
46
|
+
args: {
|
|
47
|
+
sdgList: ["noPoverty", "zeroHunger", "goodHealthWellbeing", "qualityEducation"],
|
|
48
|
+
iconSize: 80,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
export const ReverseDirection = {
|
|
53
|
+
name: "ReverseDirection",
|
|
54
|
+
args: {
|
|
55
|
+
sdgList: [
|
|
56
|
+
"noPoverty",
|
|
57
|
+
"zeroHunger",
|
|
58
|
+
"goodHealthWellbeing",
|
|
59
|
+
"qualityEducation",
|
|
60
|
+
"genderEquality",
|
|
61
|
+
"cleanWaterSanitation",
|
|
62
|
+
"affordableCleanEnergy",
|
|
63
|
+
"decentWorkEconomicGrowth",
|
|
64
|
+
"industryInnovationInfrastructure",
|
|
65
|
+
"reducedInequalities",
|
|
66
|
+
"sustainableCitiesCommunities",
|
|
67
|
+
"responsibleConsumptionProduction",
|
|
68
|
+
"climateAction",
|
|
69
|
+
"lifeBelowWater",
|
|
70
|
+
"lifeOnLand",
|
|
71
|
+
"peaceJusticeStrongInstitutions",
|
|
72
|
+
"partnershipsForGoals",
|
|
73
|
+
],
|
|
74
|
+
reverseDirection: true,
|
|
75
|
+
},
|
|
55
76
|
};
|
|
@@ -6,103 +6,104 @@ import { SDGList } from "./styles.js";
|
|
|
6
6
|
const GAP_BETWEEN_SDGS = 4;
|
|
7
7
|
|
|
8
8
|
export default function SDGIcons({
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
sdgList = [],
|
|
10
|
+
t = (str) => str,
|
|
11
|
+
iconSize = 24,
|
|
12
|
+
reverseDirection = false,
|
|
12
13
|
}) {
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
const containerRef = React.useRef(null);
|
|
15
|
+
const [width, setWidth] = React.useState(0);
|
|
15
16
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
React.useEffect(() => {
|
|
18
|
+
if (containerRef.current) {
|
|
19
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
20
|
+
for (let entry of entries) {
|
|
21
|
+
setWidth(entry.contentRect.width);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
resizeObserver.observe(containerRef.current);
|
|
24
25
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
return () => {
|
|
27
|
+
resizeObserver.disconnect();
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}, []);
|
|
30
31
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const maxSdgToShow = React.useMemo(() => {
|
|
33
|
+
const TOTAL_SPACE_FOR_SDG = iconSize + GAP_BETWEEN_SDGS;
|
|
34
|
+
return Math.floor(width / TOTAL_SPACE_FOR_SDG);
|
|
35
|
+
}, [width, iconSize]);
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
const { visibleSdgs, hiddenCount } = React.useMemo(() => {
|
|
38
|
+
if (sdgList.length <= maxSdgToShow) {
|
|
39
|
+
return { visibleSdgs: sdgList, hiddenCount: 0 };
|
|
40
|
+
}
|
|
41
|
+
return {
|
|
42
|
+
visibleSdgs: sdgList.slice(0, maxSdgToShow - 1),
|
|
43
|
+
hiddenCount: sdgList.length - (maxSdgToShow - 1),
|
|
44
|
+
};
|
|
45
|
+
}, [sdgList, maxSdgToShow]);
|
|
45
46
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
47
|
+
return (
|
|
48
|
+
<div ref={containerRef}>
|
|
49
|
+
<SDGList style={{ flexDirection: reverseDirection ? "row-reverse" : "row" }}>
|
|
50
|
+
{visibleSdgs.map((sdg, index) => (
|
|
51
|
+
<li key={index} className="project-widget-item">
|
|
52
|
+
<Tooltip title={t(`SDGS::${sdg}`)}>
|
|
53
|
+
<div
|
|
54
|
+
style={{
|
|
55
|
+
backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
|
|
56
|
+
height: iconSize,
|
|
57
|
+
width: iconSize,
|
|
58
|
+
}}
|
|
59
|
+
className="sdg-item-image"
|
|
60
|
+
/>
|
|
61
|
+
</Tooltip>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
{hiddenCount > 0 && (
|
|
65
|
+
<li className="project-widget-item">
|
|
66
|
+
<Popover
|
|
67
|
+
placement="top"
|
|
68
|
+
content={
|
|
69
|
+
<div
|
|
70
|
+
style={{
|
|
71
|
+
display: "flex",
|
|
72
|
+
gap: "4px",
|
|
73
|
+
flexWrap: "wrap",
|
|
74
|
+
maxWidth: 200,
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{sdgList.slice(visibleSdgs.length).map((sdg, idx) => (
|
|
78
|
+
<Tooltip key={idx} title={t(`SDGS::${sdg}`)}>
|
|
79
|
+
<div
|
|
80
|
+
style={{
|
|
81
|
+
width: iconSize,
|
|
82
|
+
height: iconSize,
|
|
83
|
+
backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
|
|
84
|
+
backgroundSize: "cover",
|
|
85
|
+
borderRadius: 4,
|
|
86
|
+
}}
|
|
87
|
+
title={t(`SDGS::${sdg}`)}
|
|
88
|
+
/>
|
|
89
|
+
</Tooltip>
|
|
90
|
+
))}
|
|
91
|
+
</div>
|
|
92
|
+
}
|
|
93
|
+
>
|
|
94
|
+
<div
|
|
95
|
+
className="sdg-item-image sdg-item-more"
|
|
96
|
+
style={{
|
|
97
|
+
height: iconSize,
|
|
98
|
+
width: iconSize,
|
|
99
|
+
}}
|
|
100
|
+
>
|
|
101
|
+
+{hiddenCount}
|
|
102
|
+
</div>
|
|
103
|
+
</Popover>
|
|
104
|
+
</li>
|
|
105
|
+
)}
|
|
106
|
+
</SDGList>
|
|
107
|
+
</div>
|
|
108
|
+
);
|
|
108
109
|
}
|