@griddo/ax 10.4.4 → 10.4.6

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@griddo/ax",
3
3
  "description": "Griddo Author Experience",
4
- "version": "10.4.4",
4
+ "version": "10.4.6",
5
5
  "authors": [
6
6
  "Álvaro Sánchez' <alvaro.sanches@secuoyas.com>",
7
7
  "Carlos Torres <carlos.torres@secuoyas.com>",
@@ -231,5 +231,5 @@
231
231
  "publishConfig": {
232
232
  "access": "public"
233
233
  },
234
- "gitHead": "1177d9b185f1b8768e69600651b07fb028d14b47"
234
+ "gitHead": "bf836216af29607748b79d098210379423c6914f"
235
235
  }
@@ -88,7 +88,7 @@ const AsyncSelect = (props: IAsyncSelectProps): JSX.Element => {
88
88
  // eslint-disable-next-line react-hooks/exhaustive-deps
89
89
  }, [entity, site, lang, selectedContent, entityId, mandatory, placeholder, filter, isCategories, isPage, options]);
90
90
 
91
- const handleChange = (selectedValue: ICheck | IOption | null) => {
91
+ const handleChange = (selectedValue: ICheck | IOption | null) => {
92
92
  const newValue = selectedValue ? selectedValue.value : selectedValue;
93
93
  onChange(newValue);
94
94
  };
@@ -4,7 +4,7 @@ export const DatePickerWrapper = styled.div`
4
4
  .react-datepicker-popper,
5
5
  .react-datepicker-popper[data-placement^="bottom"],
6
6
  .react-datepicker-popper[data-placement^="bottom-start"] {
7
- margin-top: 0
7
+ margin-top: 0;
8
8
  z-index: 2;
9
9
  }
10
10
 
@@ -27,24 +27,40 @@ const ImageField = (props: IImageFieldProps) => {
27
27
  const isModalOpen = isLinkableImage && !hasImage;
28
28
  const { isOpen, toggleModal } = useModal(isModalOpen);
29
29
  const [previewSrc, setPreviewSrc] = useState<string>();
30
- const [imageHeight, setImageHeight] = useState<number>();
30
+ const [previewHeight, setPreviewHeight] = useState<{ height: string | number }>({ height: "auto" });
31
31
  const previewRef = useRef<HTMLDivElement>(null);
32
+ const [imageLoaded, setImageLoaded] = useState(false);
32
33
 
33
34
  const imageUrl = value ? (typeof value === "string" ? value : value.url) : "";
34
35
  const imagePosition = value && typeof value === "object" ? value.position : "center";
35
36
 
36
37
  useEffect(() => {
37
38
  setPreviewSrc(imageUrl);
39
+ setImageLoaded(false);
38
40
  }, [imageUrl]);
39
41
 
40
- useEffect(() => {
42
+ const calculateImageHeight = () => {
41
43
  if (previewRef.current) {
42
- setImageHeight(previewRef.current.clientHeight);
44
+ const height = previewRef.current.getBoundingClientRect().height;
45
+
46
+ if (!cropPreview && height < 180) {
47
+ setPreviewHeight({ height: "180px" });
48
+ } else {
49
+ setPreviewHeight({ height: "auto" });
50
+ }
51
+ }
52
+ };
53
+
54
+ const handleImageLoad = () => {
55
+ if (!imageLoaded) {
56
+ calculateImageHeight();
57
+ setImageLoaded(true);
43
58
  }
44
- }, [previewRef.current]);
59
+ };
45
60
 
46
61
  const handleDelete = () => {
47
62
  if (!disabled) {
63
+ setPreviewHeight({ height: "auto" });
48
64
  setPreviewSrc("");
49
65
  onChange({});
50
66
  }
@@ -81,7 +97,6 @@ const ImageField = (props: IImageFieldProps) => {
81
97
  }
82
98
  };
83
99
 
84
- const previewHeight = cropPreview || (imageHeight && imageHeight < 180) ? { height: 180 } : {};
85
100
  return (
86
101
  <>
87
102
  <S.FieldWrapper
@@ -108,7 +123,11 @@ const ImageField = (props: IImageFieldProps) => {
108
123
  </S.ImageDataWrapper>
109
124
  )}
110
125
  <S.Preview preview={!!previewSrc} data-testid="previewDiv" ref={previewRef}>
111
- {previewSrc && <Image url={previewSrc} width={320} {...previewHeight} />}
126
+ {previewSrc && (
127
+ <S.ImageContainer style={{ height: previewHeight.height }}>
128
+ <Image url={previewSrc} width={320} onLoad={handleImageLoad} />
129
+ </S.ImageContainer>
130
+ )}
112
131
  <S.PositionWrapper>
113
132
  <S.PositionTitle>
114
133
  <Icon name="grid" size="16" />
@@ -84,13 +84,13 @@ const PositionGrid = styled.div`
84
84
  margin-top: ${(p) => p.theme.spacing.xs};
85
85
  `;
86
86
 
87
- const Position = styled.div<{active?: boolean}>`
87
+ const Position = styled.div<{ active?: boolean }>`
88
88
  width: ${(p) => p.theme.spacing.m};
89
89
  height: ${(p) => p.theme.spacing.m};
90
90
  border-radius: ${(p) => p.theme.radii.xs};
91
- background-color: ${(p) => p.active ? p.theme.color.interactive01 : p.theme.color.uiBackground03};
91
+ background-color: ${(p) => (p.active ? p.theme.color.interactive01 : p.theme.color.uiBackground03)};
92
92
  :hover {
93
- background-color: ${(p) => p.active ? p.theme.color.interactive01 : p.theme.color.overlayPressedPrimary};
93
+ background-color: ${(p) => (p.active ? p.theme.color.interactive01 : p.theme.color.overlayPressedPrimary)};
94
94
  }
95
95
  `;
96
96
 
@@ -143,6 +143,12 @@ const ImageDataWrapper = styled.div`
143
143
  max-width: ${(p) => `calc(${p.theme.spacing.xl} * 5)`};
144
144
  `;
145
145
 
146
+ const ImageContainer = styled.div`
147
+ display: flex;
148
+ justify-content: center;
149
+ align-items: center;
150
+ `;
151
+
146
152
  const FileName = styled.div`
147
153
  ${(p) => p.theme.textStyle.fieldLabel};
148
154
  margin-bottom: ${(p) => p.theme.spacing.xs};
@@ -160,6 +166,7 @@ export {
160
166
  PreviewActions,
161
167
  Preview,
162
168
  ImageDataWrapper,
169
+ ImageContainer,
163
170
  FileName,
164
171
  ImageData,
165
172
  PositionWrapper,
@@ -90,6 +90,10 @@ export const ButtonWrapper = styled.div`
90
90
  `;
91
91
 
92
92
  export const ModalFooter = styled.div`
93
+ position: fixed;
94
+ bottom: 0;
95
+ left: 0;
96
+ width: 100%;
93
97
  background: ${(p) => p.theme.color.uiBackground01};
94
98
  display: flex;
95
99
  justify-content: flex-end;