webiny-js icon indicating copy to clipboard operation
webiny-js copied to clipboard

fix: fixed issue with border for image

Open neatbyte-vnobis opened this issue 1 year ago • 7 comments

Changes

Resolve issue "Image border not applied correctly" Task provided by @SvenAlHamad no reference to issue or Notion.

Before Changes Знімок екрана 2023-09-22 о 16 11 32

After Changes Знімок екрана 2023-09-22 о 16 09 56

How Has This Been Tested?

Manually

Documentation

None

neatbyte-vnobis avatar Sep 22 '23 13:09 neatbyte-vnobis

There are two solutions for this issue. First of the solutions is used in this PR, and the second one I will provide in this comment.

In the second solution we would not need to use useEffect and loop through the styles for the element as we do in the first solution. What we need is to use

const borderStyles = border({ element: { ...element, type: "" }, theme });
const borderAssignedStyles = assignStyles({
   breakpoints: theme.breakpoints,
    styles: borderStyles || {}
});
const PbImg = styled.img({
  width: element.data.image.width,
  height: element.data.image.height,
  maxWidth: "100%",
  ...borderAssignedStyles
});

in packages/app-page-builder-elements/src/renderers/image.tsx.

And we should add additional if statement here packages/app-page-builder-elements/src/modifiers/styles/border.ts

if (element.type === "image") {
        return {};
}

And it would also work. @adrians5j What do you think?

neatbyte-ivelychko avatar Sep 22 '23 13:09 neatbyte-ivelychko

/cypress

neatbyte-vnobis avatar Sep 29 '23 17:09 neatbyte-vnobis

Cypress E2E tests have been initiated (for more information, click here). :sparkles:

github-actions[bot] avatar Sep 29 '23 17:09 github-actions[bot]

Will need to think a bit about this. Will need to see if we can do this in a better way.

adrians5j avatar Oct 13 '23 11:10 adrians5j

@adrians5j Any new thoughts on this PR? Or should we stick with one of the provided solutions?

neatbyte-vnobis avatar Dec 01 '23 09:12 neatbyte-vnobis

/cypress

neatbyte-vnobis avatar Dec 05 '23 17:12 neatbyte-vnobis

Cypress E2E tests have been initiated (for more information, click here). :sparkles:

github-actions[bot] avatar Dec 05 '23 17:12 github-actions[bot]