Skip to content

Fix/padding condition #926

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
function refactored
  • Loading branch information
MenamAfzal committed Jun 2, 2024
commit e3a4fb7bb5d93f63efb7b7a7cc950ddea78f1f66
86 changes: 58 additions & 28 deletions client/packages/lowcoder/src/comps/generators/uiCompBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -257,34 +257,64 @@ function UIView(props: {
boxShadowVal = defaultChildren.style?.children?.boxShadow?.valueAndMsg?.value;
restrictPaddingOnRotationVal = defaultChildren?.restrictPaddingOnRotation?.valueAndMsg?.value;
}
const getPadding = () =>(rotationVal === null ||
rotationVal === undefined ||
restrictPaddingOnRotation) &&
(boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px')
? restrictPaddingOnRotationVal === 'qrCode'
? rotationVal !== '' && rotationVal !== '0deg'?'35% 0px':'0px'
: restrictPaddingOnRotationVal === 'image'
? rotationVal !== '' && rotationVal !== '0deg'?'10% 0px':'0px'
: restrictPaddingOnRotationVal === 'controlButton'
? rotationVal !== '' && rotationVal !== '0deg'?'10% 0px':'0px'
: '0px' // Both rotation and box-shadow are empty or restricted
: rotationVal !== '' && rotationVal !== '0deg' // Rotation applied
? boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px'
? `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '')) / 90} * 100%)) 0px`
: boxShadowVal !== '' && boxShadowVal !== '0px' // Both rotation and box-shadow applied
? `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '') + parseFloat(boxShadowVal.replace('px', ''))) / 90} * 100%)) 0px`
: `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '')) / 90} * 100%)) 0px` // Only rotation applied
: boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px'
? '0px'
: boxShadowVal !== '' && boxShadowVal !== '0px' // Box-shadow applied
? `calc(min(50%, ${Math.abs(parseFloat(boxShadowVal.replace('px', ''))) / 90} * 100%)) 0px`
: '0px' // Default value if neither rotation nor box-shadow is applied
const getPadding = () => {
if (
(rotationVal === null ||
rotationVal === undefined ||
restrictPaddingOnRotation) &&
(boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px')
) {
if (restrictPaddingOnRotationVal === 'qrCode') {
if (rotationVal !== '' && rotationVal !== '0deg') {
return '35% 0px';
} else {
return '0px';
}
} else if (restrictPaddingOnRotationVal === 'image') {
if (rotationVal !== '' && rotationVal !== '0deg') {
return '10% 0px';
} else {
return '0px';
}
} else if (restrictPaddingOnRotationVal === 'controlButton') {
if (rotationVal !== '' && rotationVal !== '0deg') {
return '10% 0px';
} else {
return '0px';
}
} else {
return '0px'; // Both rotation and box-shadow are empty or restricted
}
} else if (rotationVal !== '' && rotationVal !== '0deg') {
// Rotation applied
if (
boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px'
) {
return `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '')) / 90} * 100%)) 0px`;
} else if (boxShadowVal !== '' && boxShadowVal !== '0px') {
// Both rotation and box-shadow applied
return `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '') + parseFloat(boxShadowVal.replace('px', ''))) / 90} * 100%)) 0px`;
} else {
return `calc(min(50%, ${Math.abs(rotationVal.replace('deg', '')) / 90} * 100%)) 0px`; // Only rotation applied
}
} else if (
boxShadowVal === null ||
boxShadowVal === undefined ||
boxShadowVal === '0px'
) {
return '0px';
} else if (boxShadowVal !== '' && boxShadowVal !== '0px') {
// Box-shadow applied
return `calc(min(50%, ${Math.abs(parseFloat(boxShadowVal.replace('px', ''))) / 90} * 100%)) 0px`;
} else {
return '0px'; // Default value if neither rotation nor box-shadow is applied
}
};

return (
<div
ref={props.innerRef}
Expand Down
Loading