Skip to content

Commit 1cfc117

Browse files
committed
[FIX]: Solve container width and scroll issue
1 parent b16ff50 commit 1cfc117

File tree

4 files changed

+37
-24
lines changed

4 files changed

+37
-24
lines changed

src/components/dropzone/components/Dropzone/Dropzone.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
align-items: center;
4646
justify-content: center;
4747
//overflow: hidden;
48-
padding: 24px 0;
48+
// padding: 24px 0;
4949
&.drag {
5050
border: none;
5151
}
@@ -78,7 +78,7 @@
7878
cursor: text;
7979
top: 0;
8080
display: flex;
81-
width: 100%;
81+
width: calc(100% - 10px);
8282
flex-direction: row;
8383
align-items: center;
8484
justify-content: flex-end;
@@ -95,7 +95,7 @@
9595
position: absolute;
9696
cursor: text;
9797
bottom: 0;
98-
width: 100%;
98+
width: calc(100% - 10px);
9999
display: flex;
100100
flex-direction: column;
101101
align-items: flex-start;

src/components/dropzone/components/Dropzone/Dropzone.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
111111
//ClassName for dynamic style
112112
const [onUploadingStart, setOnUploadingStart] = useState<boolean>(false);
113113
// const [queueFiles, setQueueFiles] = useState<FileValidated[]>([]);
114+
// const offset:number= header && footer? 50: (!header && footer?23:(header && !footer?22:0)) ;
115+
114116
const classNameCreated: string = useDropzoneStyles(
115117
color,
116118
backgroundColor,
117119
disableScroll ? undefined : maxHeight,
118-
minHeight
120+
minHeight,
121+
header && footer ? 50 : !header && footer ? 23 : header && !footer ? 22 : 0
119122
);
120123
const finalClassName: string = `dropzone-ui${classNameCreated}${
121124
isDragging ? ` drag` : ``
@@ -326,9 +329,9 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
326329
localValidator
327330
);
328331
if (!disableRipple) {
329-
createRippleFromElement(dz_ui_ripple_ref.current, evt,color as string);
332+
createRippleFromElement(dz_ui_ripple_ref.current, evt, color as string);
330333

331-
// createRipple(evt, color as string);
334+
// createRipple(evt, color as string);
332335
}
333336
setIsDragging(false);
334337
handleFilesChange(output);
@@ -417,7 +420,7 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
417420
let referenceInput = inputRef.current;
418421
referenceInput?.click();
419422
if (!disableRipple) {
420-
createRippleFromElement(dz_ui_ripple_ref.current,e, color as string);
423+
createRippleFromElement(dz_ui_ripple_ref.current, e, color as string);
421424
//createRipple(e, color as string);
422425
}
423426
onClick?.(e);
@@ -465,6 +468,8 @@ const Dropzone: React.FC<DropzoneProps> = (props: DropzoneProps) => {
465468
style={{
466469
minHeight: minHeight,
467470
maxHeight: disableScroll ? undefined : maxHeight,
471+
marginBottom: footer ? "23px" : undefined,
472+
marginTop: header ? "22px" : undefined,
468473
}}
469474
disableScroll={disableScroll}
470475
>

src/components/dropzone/components/hooks/useDropzoneStyles.ts

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,30 @@ const useDropzoneStyles = (
1515
color: string | undefined,
1616
backgroundColor: string | undefined,
1717
maxHeight: string | undefined,
18-
minHeight: string | undefined
18+
minHeight: string | undefined,
19+
offset: number
1920
): string => {
2021
const [idStyles, setIdStyles] = useState<string>("");
2122
const [styleInjected, setStyleInjected] = useState<boolean>(false);
2223
const [classNameCreated, setClassNameCreated] = useState<string>("");
2324

2425
useEffect(() => {
25-
/* const removeStyle = () => {
26-
if (styleInjected) {
27-
DynamiCSS.removeStyleSheet(idStyles);
28-
setStyleInjected(false);
29-
setIdStyles("");
30-
}
31-
}; */
26+
/* const removeStyle = () => {
27+
if (styleInjected) {
28+
DynamiCSS.removeStyleSheet(idStyles);
29+
setStyleInjected(false);
30+
setIdStyles("");
31+
}
32+
}; */
3233
const handleInserStyle = (
33-
color: DropzoneProps["color"],backgroundColor: string | undefined,
34+
color: DropzoneProps["color"], backgroundColor: string | undefined,
3435
maxHeight: string | undefined,
35-
minHeight: string | undefined
36+
minHeight: string | undefined,
37+
offset: number
3638
) => {
39+
console.log("offset: ", offset);
40+
console.log("result",(offset === 0 || offset === 50) ? "center" : "flex-start");
41+
console.log("minHeight",`calc(${minHeight} + ${offset}px)`);
3742
let styleSheet: DynamicSheet = {
3843
id: "dropzone-ui-styles",
3944
sheetRules: [
@@ -46,7 +51,9 @@ const useDropzoneStyles = (
4651
)}`,
4752
backgroundColor: backgroundColor,
4853
maxHeight: maxHeight,
49-
minHeight: `calc(${minHeight} + 50px)`
54+
//minHeight: `calc(${minHeight} + 50px)`
55+
minHeight: `calc(${minHeight} + ${offset}px)`,
56+
//justifyContent: (offset === 0 || offset === 50) ? "center" : "flex-start",
5057
},
5158
},
5259
{
@@ -83,12 +90,12 @@ const useDropzoneStyles = (
8390
};
8491

8592

86-
handleInserStyle(color,backgroundColor, maxHeight,minHeight);
87-
/* return () => {
88-
removeStyle();
89-
} */
93+
handleInserStyle(color, backgroundColor, maxHeight, minHeight, offset);
94+
/* return () => {
95+
removeStyle();
96+
} */
9097
// eslint-disable-next-line
91-
}, [color, backgroundColor, maxHeight,minHeight]);
98+
}, [color, backgroundColor, maxHeight, minHeight, offset]);
9299

93100
return classNameCreated;
94101
}

src/components/file-item/components/FileItemContainer/FileItemContainer.scss

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
background-color: transparent;
1818
color: black;
1919
min-height: 280px;
20-
width: 100%;
20+
//width: 100%;
21+
width: calc(100% - 10px);
2122
//margin: 100px 0;
2223
//width: inherit;
2324

0 commit comments

Comments
 (0)