datastake-daf 0.6.148 → 0.6.150

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.
@@ -0,0 +1,44 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+
3
+ export const useMapOnExpandableWidget = ({isExpanded, data}) => {
4
+ const timeoutRef = useRef(null);
5
+ const [shouldRenderMap, setShouldRenderMap] = useState(false);
6
+ const [key, setKey] = useState(0);
7
+
8
+ useEffect(() => {
9
+ if (timeoutRef.current) {
10
+ clearTimeout(timeoutRef.current);
11
+ }
12
+
13
+ if (isExpanded) {
14
+ setShouldRenderMap(true);
15
+ } else {
16
+ timeoutRef.current = setTimeout(() => {
17
+ setShouldRenderMap(false);
18
+ }, 500);
19
+ }
20
+
21
+ return () => {
22
+ if (timeoutRef.current) {
23
+ clearTimeout(timeoutRef.current);
24
+ }
25
+ };
26
+ }, [isExpanded]);
27
+
28
+ useEffect(() => {
29
+ if (data?.length > 0 && shouldRenderMap) {
30
+ setKey(prevKey => prevKey + 1);
31
+ }
32
+ }, [data]);
33
+
34
+ useEffect(() => {
35
+ if (data?.length > 0 && !shouldRenderMap && !isExpanded) {
36
+ setShouldRenderMap(true);
37
+ }
38
+ }, [data]);
39
+
40
+ return {
41
+ shouldRenderMap,
42
+ key,
43
+ };
44
+ }
@@ -0,0 +1,55 @@
1
+ import React, { useState } from 'react'
2
+ import Widget from '../index.jsx'
3
+ import Map from '../../Map'
4
+ import Details from '../Details'
5
+ import { useMapOnExpandableWidget } from './hook'
6
+
7
+
8
+ /*
9
+ This is only as an example to render the map correctly when it is inside an expandable widget
10
+ */
11
+
12
+ function ExpandableMapWidget({loading, title, mapData, ...rest}) {
13
+ const [isExpanded, setIsExpanded] = useState(false);
14
+
15
+ const onExpanded = (isExpanded) => {
16
+ setIsExpanded(isExpanded);
17
+ }
18
+
19
+ // This hook does all the rendering job
20
+ const { shouldRenderMap, key } = useMapOnExpandableWidget({ isExpanded, data: mapData });
21
+
22
+ return (
23
+ <Widget
24
+ className="with-border-header h-w-btn-header"
25
+ loading={loading}
26
+ title={title}
27
+ expandable={true}
28
+ onExpandChange={onExpanded}
29
+ {...rest}
30
+ >
31
+ <Details />
32
+ <Widget title="MAP" className="no-p-body no-padding with-border-header">
33
+ <div style={{
34
+ width: '100%',
35
+ maxHeight: isExpanded ? '1000px' : '0px',
36
+ transition: 'max-height 0.5s ease-in-out',
37
+ overflow: 'hidden'
38
+ }}>
39
+ {shouldRenderMap && (
40
+ <Map
41
+ app="sbg"
42
+ isSatellite={true}
43
+ data={mapData}
44
+ key={key}
45
+ user={null}
46
+ mapConfig={{ zoom: 2 }}
47
+ />
48
+ )}
49
+ </div>
50
+ </Widget>
51
+ </Widget>
52
+ )
53
+ }
54
+
55
+ export default ExpandableMapWidget;
@@ -1,9 +1,11 @@
1
- import { Card, Tooltip } from "antd";
1
+ import React from "react";
2
+ import { Card, Tooltip, theme } from "antd";
2
3
  import { ImageContainer, ProjectWidgetItems, SDGList, Label } from "./style.js";
3
4
  import CustomIcon from "../../../Icon/CustomIcon.jsx";
4
5
  import { SDG_IMAGES } from "../../../../../../constants/SDGs.js";
5
6
 
6
7
  const { Meta } = Card;
8
+ const { useToken } = theme;
7
9
 
8
10
  export default function ProjectWidget({
9
11
  title,
@@ -16,14 +18,18 @@ export default function ProjectWidget({
16
18
  hideSDGList = false,
17
19
  t = (x) => x,
18
20
  }) {
21
+ const [isHovered, setIsHovered] = React.useState(false);
22
+ const { token } = useToken();
19
23
  return (
20
24
  <Card
21
25
  style={{
22
26
  flex: 1,
23
27
  }}
28
+ hoverable
29
+ onMouseEnter={() => setIsHovered(true)}
30
+ onMouseLeave={() => setIsHovered(false)}
24
31
  cover={
25
32
  <ImageContainer>
26
- {/* <img src={image} alt="ProjectWidget" /> */}
27
33
  <div
28
34
  className="image"
29
35
  style={{
@@ -36,7 +42,7 @@ export default function ProjectWidget({
36
42
  name={linkIcon}
37
43
  width={16}
38
44
  height={16}
39
- color="black"
45
+ color={isHovered ? token.colorPrimary7 : "black"}
40
46
  />
41
47
  </div>
42
48
  )}
@@ -111,7 +111,8 @@ export default function Widget({
111
111
  <div className="flex justify-content-end">
112
112
  <Button
113
113
  size="small"
114
- className="flex-1 no-min-width"
114
+ className="squareIconButton no-min-width"
115
+ style={{height: '25px', width: '25px'}}
115
116
  onClick={handleCollapseToggle}
116
117
  icon={
117
118
  isCollapsed ? (
@@ -1,13 +0,0 @@
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
- }