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 ADDED
@@ -0,0 +1,8 @@
1
+ REACT_APP_API_KEY=
2
+ REACT_APP_AUTH_DOMAIN=
3
+ REACT_APP_PROJECT_ID=
4
+ REACT_APP_STORAGE_BUCKED=
5
+ REACT_APP_SENDER_ID=
6
+ REACT_APP_APP_ID=
7
+ REACT_APP_MEASUREMENT_ID=
8
+ REACT_APP_VAPID_KEY=
@@ -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
+ }
@@ -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 = null,
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 max-width: calc(100% - 48px);\n margin-left: var(--size-lg);\n overflow: hidden;\n\n .daf-table {\n padding: 0px;\n margin-top: 0px;\n\n .ant-tag {\n text-align: center;\n }\n }\n\n .daf-select-filters .filters {\n padding-top: 16px;\n padding-left: 0;\n padding-right: 0;\n }\n\n .daf-table {\n padding-top: 16px;\n }\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: "white"
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: "100%",
20986
- minWidth: "200px"
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "datastake-daf",
3
- "version": "0.6.204",
3
+ "version": "0.6.206",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^5.2.5",
6
6
  "@antv/g2": "^5.1.1",
@@ -7,85 +7,87 @@ const { Meta } = Card;
7
7
  const { useToken } = theme;
8
8
 
9
9
  export default function ProjectWidget({
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
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
- const [isHovered, setIsHovered] = React.useState(false);
23
- const { token } = useToken();
22
+ const [isHovered, setIsHovered] = React.useState(false);
23
+ const { token } = useToken();
24
24
 
25
- return (
26
- <Card
27
- style={{
28
- flex: 1,
29
- width: "100%",
30
- minWidth: "200px",
31
- }}
32
- hoverable
33
- onMouseEnter={() => setIsHovered(true)}
34
- onMouseLeave={() => setIsHovered(false)}
35
- onClick={onCardClick}
36
- cover={
37
- <ImageContainer>
38
- {image ? (
39
- <div
40
- className="image"
41
- style={{
42
- backgroundImage: `url(${image})`,
43
- }}
44
- />
45
- ) : (
46
- <div
47
- style={{
48
- height: "103px",
49
- }}
50
- >
51
- <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
52
- </div>
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
- {onLinkClick && (
56
- <div className="icon-container" onClick={onLinkClick}>
57
- <CustomIcon
58
- name={linkIcon}
59
- width={16}
60
- height={16}
61
- color={isHovered ? token.colorPrimary7 : "black"}
62
- />
63
- </div>
64
- )}
65
- </ImageContainer>
66
- }
67
- {...props}
68
- >
69
- <Meta title={title || undefined} description={description || undefined} />
70
- <ProjectWidgetItems>
71
- {items.map((item, index) => (
72
- <li key={index} className="project-widget-item">
73
- <Label>{item.label}</Label>
74
- {item.render()}
75
- </li>
76
- ))}
77
- </ProjectWidgetItems>
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
- {!hideSDGList && (
80
- <div
81
- style={{
82
- borderTop: "1px solid var(--base-gray-30)",
83
- paddingTop: "10px",
84
- }}
85
- >
86
- <SdgList sdgList={sdgList} t={t} />
87
- </div>
88
- )}
89
- </Card>
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
  }
@@ -22,6 +22,7 @@ export const Primary = {
22
22
  title: "Select a focus operator to visualise its supply chain",
23
23
  height: 500,
24
24
  icon: "KYC",
25
+ circleColor: "#014A4B",
25
26
  description:
26
27
  "This is based on information compiled by your organisation and approved sources.",
27
28
  },
@@ -30,7 +30,7 @@
30
30
  }
31
31
 
32
32
  .icon-bubble-d {
33
- background-color: #2b2c2d;
33
+ // background-color: #2b2c2d;
34
34
  border-radius: 100%;
35
35
  width: 57px;
36
36
  height: 57px;
@@ -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 className="icon-bubble-d">
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="white"
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
- size = null,
9
- maxHeight = 300,
10
- containerHeight = 525,
11
- dataSource = [],
12
- columns = {},
13
- pagination = false,
14
- doEmptyRows = true,
15
- ...props
8
+ size = "small",
9
+ maxHeight = 300,
10
+ containerHeight = 525,
11
+ dataSource = [],
12
+ columns = {},
13
+ pagination = false,
14
+ doEmptyRows = true,
15
+ ...props
16
16
  }) {
17
- const data = React.useMemo(() => {
18
- const MIN_ROWS = 4;
17
+ const data = React.useMemo(() => {
18
+ if (!doEmptyRows) {
19
+ return dataSource;
20
+ }
19
21
 
20
- if (dataSource.length < MIN_ROWS) {
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
- return dataSource;
29
- }, [dataSource]);
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
- const Wrapper = React.useMemo(() => {
32
- return data.length > 5 ? ComponentWithFocus : "div";
33
- }, [data.length]);
32
+ return dataSource;
33
+ }, [dataSource, doEmptyRows]);
34
34
 
35
- return (
36
- <Wrapper>
37
- <Style>
38
- <div
39
- className="daf-table-wrapper"
40
- style={{
41
- maxHeight: containerHeight,
42
- overflowY: "auto",
43
- }}
44
- >
45
- <div className="daf-sticky-table">
46
- <Table
47
- {...props}
48
- size={size}
49
- scroll
50
- sticky
51
- style={{ maxHeight }}
52
- dataSource={data}
53
- columns={columns}
54
- pagination={pagination}
55
- />
56
- </div>
57
- </div>
58
- </Style>
59
- </Wrapper>
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
- max-width: calc(100% - 48px);
65
- margin-left: var(--size-lg);
66
- overflow: hidden;
68
+ max-width: calc(100% - 48px);
69
+ margin-left: var(--size-lg);
70
+ overflow: hidden;
67
71
 
68
- .daf-table {
69
- padding: 0px;
70
- margin-top: 0px;
72
+ .daf-table {
73
+ padding: 0px;
74
+ margin-top: 0px;
71
75
 
72
- .ant-tag {
73
- text-align: center;
74
- }
75
- }
76
+ .ant-tag {
77
+ text-align: center;
78
+ }
79
+ }
76
80
 
77
- .daf-select-filters .filters {
78
- padding-top: 16px;
79
- padding-left: 0;
80
- padding-right: 0;
81
- }
81
+ .daf-select-filters .filters {
82
+ padding-top: 16px;
83
+ padding-left: 0;
84
+ padding-right: 0;
85
+ }
82
86
 
83
- .daf-table {
84
- padding-top: 16px;
85
- }
87
+ .daf-table {
88
+ padding-top: 16px;
89
+ }
86
90
  `;
87
91
 
88
92
  StickyTable.propTypes = {
89
- size: PropTypes.any,
90
- maxHeight: PropTypes.number,
91
- dataSource: PropTypes.array,
92
- columns: PropTypes.object,
93
- pagination: PropTypes.any,
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
- 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
- ],
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
- 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
- },
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
- name: "BiggerIcons",
46
- args: {
47
- sdgList: [
48
- "noPoverty",
49
- "zeroHunger",
50
- "goodHealthWellbeing",
51
- "qualityEducation",
52
- ],
53
- iconSize: 80,
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
- sdgList = [],
10
- t = (str) => str,
11
- iconSize = 24,
9
+ sdgList = [],
10
+ t = (str) => str,
11
+ iconSize = 24,
12
+ reverseDirection = false,
12
13
  }) {
13
- const containerRef = React.useRef(null);
14
- const [width, setWidth] = React.useState(0);
14
+ const containerRef = React.useRef(null);
15
+ const [width, setWidth] = React.useState(0);
15
16
 
16
- React.useEffect(() => {
17
- if (containerRef.current) {
18
- const resizeObserver = new ResizeObserver((entries) => {
19
- for (let entry of entries) {
20
- setWidth(entry.contentRect.width);
21
- }
22
- });
23
- resizeObserver.observe(containerRef.current);
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
- return () => {
26
- resizeObserver.disconnect();
27
- };
28
- }
29
- }, []);
26
+ return () => {
27
+ resizeObserver.disconnect();
28
+ };
29
+ }
30
+ }, []);
30
31
 
31
- const maxSdgToShow = React.useMemo(() => {
32
- const TOTAL_SPACE_FOR_SDG = iconSize + GAP_BETWEEN_SDGS;
33
- return Math.floor(width / TOTAL_SPACE_FOR_SDG);
34
- }, [width, iconSize]);
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
- const { visibleSdgs, hiddenCount } = React.useMemo(() => {
37
- if (sdgList.length <= maxSdgToShow) {
38
- return { visibleSdgs: sdgList, hiddenCount: 0 };
39
- }
40
- return {
41
- visibleSdgs: sdgList.slice(0, maxSdgToShow - 1),
42
- hiddenCount: sdgList.length - (maxSdgToShow - 1),
43
- };
44
- }, [sdgList, maxSdgToShow]);
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
- return (
47
- <div ref={containerRef}>
48
- <SDGList>
49
- {visibleSdgs.map((sdg, index) => (
50
- <li key={index} className="project-widget-item">
51
- <Tooltip title={t(`SDGS::${sdg}`)}>
52
- <div
53
- style={{
54
- backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
55
- height: iconSize,
56
- width: iconSize,
57
- }}
58
- className="sdg-item-image"
59
- />
60
- </Tooltip>
61
- </li>
62
- ))}
63
- {hiddenCount > 0 && (
64
- <li className="project-widget-item">
65
- <Popover
66
- placement="top"
67
- content={
68
- <div
69
- style={{
70
- display: "flex",
71
- gap: "4px",
72
- flexWrap: "wrap",
73
- maxWidth: 200,
74
- }}
75
- >
76
- {sdgList.slice(visibleSdgs.length).map((sdg, idx) => (
77
- <Tooltip key={idx} title={t(`SDGS::${sdg}`)}>
78
- <div
79
- style={{
80
- width: iconSize,
81
- height: iconSize,
82
- backgroundImage: `url(${SDG_IMAGES[sdg].img})`,
83
- backgroundSize: "cover",
84
- borderRadius: 4,
85
- }}
86
- title={t(`SDGS::${sdg}`)}
87
- />
88
- </Tooltip>
89
- ))}
90
- </div>
91
- }
92
- >
93
- <div
94
- className="sdg-item-image sdg-item-more"
95
- style={{
96
- height: iconSize,
97
- width: iconSize,
98
- }}
99
- >
100
- +{hiddenCount}
101
- </div>
102
- </Popover>
103
- </li>
104
- )}
105
- </SDGList>
106
- </div>
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
  }