Skip to content

Commit 634744c

Browse files
fix: text box widgets design to enter value issue in mobile view
1 parent c8f5c80 commit 634744c

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

apps/OpenSign/src/components/pdf/BorderResize.js

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
import React from "react";
22

3-
function BorderResize({ right, top }) {
3+
function BorderResize(props) {
4+
const getHeight = () => {
5+
const height = props.posHeight(props.pos, props.isSignYourself);
6+
if (height > 14) {
7+
return "14px";
8+
} else {
9+
return `${height}px`;
10+
}
11+
};
12+
413
return (
514
<div
6-
className={`${right ? `-right-[12px]` : "-right-[1px]"} ${
7-
top ? `-bottom-[11px]` : "-bottom-[1px]"
8-
} absolute inline-block w-[14px] h-[14px] hover:cursor-sw-resize border-r-[3px] border-b-[3px] border-[#188ae2]`}
15+
style={{
16+
width: getHeight() || "14px",
17+
height: getHeight() || "14px"
18+
}}
19+
className={`${props.right ? `-right-[12px]` : "-right-[2px]"} ${
20+
props.top ? `-bottom-[12px]` : "-bottom-[2px] "
21+
} absolute inline-block hover:cursor-sw-resize border-r-[3px] border-b-[3px] border-[#188ae2]`}
922
></div>
1023
);
1124
}

apps/OpenSign/src/components/pdf/Placeholder.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,12 +791,22 @@ function Placeholder(props) {
791791
props.pos.type !== radioButtonWidget &&
792792
props.pos.type !== "checkbox" &&
793793
props.pos.key === props.selectWidgetId ? (
794-
<BorderResize right={-12} top={-11} />
794+
<BorderResize
795+
right={-12}
796+
top={-11}
797+
pos={props.pos}
798+
posHeight={props.posHeight}
799+
isSignYourself={props.isSignYourself}
800+
/>
795801
) : props.data && props.isNeedSign && props.pos.type !== "checkbox" ? (
796802
props.data?.signerObjId === props.signerObjId &&
797803
props.pos.type !== radioButtonWidget &&
798804
props.pos.type !== "checkbox" ? (
799-
<BorderResize />
805+
<BorderResize
806+
posHeight={props.posHeight}
807+
isSignYourself={props.isSignYourself}
808+
pos={props.pos}
809+
/>
800810
) : (
801811
<></>
802812
)
@@ -862,6 +872,7 @@ function Placeholder(props) {
862872
startDate={startDate}
863873
handleSaveDate={handleSaveDate}
864874
xPos={props.xPos}
875+
posHeight={props.posHeight}
865876
/>
866877
</div>
867878
) : (
@@ -889,6 +900,7 @@ function Placeholder(props) {
889900
startDate={startDate}
890901
handleSaveDate={handleSaveDate}
891902
xPos={props.xPos}
903+
posHeight={props.posHeight}
892904
/>
893905
</>
894906
)}

apps/OpenSign/src/components/pdf/PlaceholderType.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ function PlaceholderType(props) {
2929
const [textValue, setTextValue] = useState();
3030
const [selectedCheckbox, setSelectedCheckbox] = useState([]);
3131
const years = range(1990, getYear(new Date()) + 16, 1);
32-
const fontSize = (props.pos.options?.fontSize || "12") + "px";
32+
const height = props.posHeight(props.pos, props.isSignYourself);
33+
const fontSize =
34+
(props.pos.options?.fontSize || (height > 14 ? 12 : height / 2)) + "px";
3335
const fontColor = props.pos.options?.fontColor || "black";
3436
const months = [
3537
"January",

apps/OpenSign/src/constant/Utils.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1283,8 +1283,14 @@ export const changeImageWH = async (base64Image) => {
12831283
};
12841284

12851285
//function to calculate font size of text area widgets
1286-
const calculateFontSize = (position, containerScale, signyourself) => {
1287-
const font = position?.options?.fontSize || 12;
1286+
const calculateFontSize = (
1287+
position,
1288+
containerScale,
1289+
signyourself,
1290+
widgetHeight
1291+
) => {
1292+
const font =
1293+
position?.options?.fontSize || widgetHeight > 14 ? 12 : widgetHeight / 2;
12881294
if (!signyourself && position?.isMobile && position?.scale) {
12891295
return font / position?.scale / containerScale;
12901296
} else {
@@ -1480,7 +1486,8 @@ export const multiSignEmbed = async (
14801486
const fontSize = calculateFontSize(
14811487
position,
14821488
containerScale,
1483-
signyourself
1489+
signyourself,
1490+
widgetHeight
14841491
);
14851492
parseInt(fontSize);
14861493
let textContent;
@@ -1655,7 +1662,7 @@ export const multiSignEmbed = async (
16551662
});
16561663
}
16571664
const pdfBytes = await pdfDoc.saveAsBase64({ useObjectStreams: false });
1658-
//console.log("pdf", pdfBytes);
1665+
// console.log("pdf", pdfBytes);
16591666
return pdfBytes;
16601667
};
16611668

0 commit comments

Comments
 (0)