Skip to content
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

Q :Is there any way to customize the OverlayCSUIContainer #1015

Open
2 of 3 tasks
a11yster opened this issue Jun 27, 2024 · 0 comments
Open
2 of 3 tasks

Q :Is there any way to customize the OverlayCSUIContainer #1015

a11yster opened this issue Jun 27, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@a11yster
Copy link

What happened?

Is there any way to customise the OverlayCSUIContainer to position it to the bottom right of the anchor rather than the default top-left.

the below one is the static container generated on the dev environment, is there a way to directly style this in the content script?

Version

Latest

What OS are you seeing the problem on?

No response

What browsers are you seeing the problem on?

No response

Relevant log output

export const OverlayCSUIContainer = (props: PlasmoCSUIContainerProps) => {
  const [top, setTop] = React.useState(0)
  const [left, setLeft] = React.useState(0)

  React.useEffect(() => {
    // Handle overlay repositioning
    if (props.anchor.type !== "overlay") {
      return
    }

    const updatePosition = async () => {
      const rect = props.anchor.element?.getBoundingClientRect()
      if (!rect) {
        return
      }

      const pos = {
        left: rect.left + window.scrollX,
        top: rect.top+ window.scrollY
      }

      setLeft(pos.left)
      setTop(pos.top)
    }

    updatePosition()

    const unwatch = props.watchOverlayAnchor?.(updatePosition)
    window.addEventListener("scroll", updatePosition)
    window.addEventListener("resize", updatePosition)

    return () => {
      if (typeof unwatch === "function") {
        unwatch()
      }
      window.removeEventListener("scroll", updatePosition)
      window.removeEventListener("resize", updatePosition)
    }
  }, [props.anchor.element])

  return (
    <div
      id={props.id}
      className="plasmo-csui-container"
      style={{
        display: "flex",
        position: "absolute",
        top,
        left
      }}>
      {props.children}
    </div>
  )
}

(OPTIONAL) Contribution

  • I would like to fix this BUG via a PR

Code of Conduct

  • I agree to follow this project's Code of Conduct
  • I checked the current issues for duplicate problems.
@a11yster a11yster added the bug Something isn't working label Jun 27, 2024
@a11yster a11yster changed the title [BUG] :Is there any way to customize the OverlayCSUIContainer Q :Is there any way to customize the OverlayCSUIContainer Jun 27, 2024
@a11yster a11yster reopened this Jun 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant