Skip to content

Commit

Permalink
feat(Paper): Added the ref prop to the component (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
VagnerNico authored Mar 9, 2022
1 parent 0543af5 commit 6f47863
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/components/Paper/Paper.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @jsxImportSource theme-ui */
import React, { HTMLAttributes, useMemo } from "react"
import React, { forwardRef, HTMLAttributes, useMemo } from "react"

export interface PaperProps {
/** Paper elevation */
Expand All @@ -12,13 +12,10 @@ export interface PaperProps {
onClick?: HTMLAttributes<HTMLDivElement>["onClick"]
}

const Paper = ({
elevation = 1,
padding = 6,
children,
className,
onClick,
}: PaperProps) => {
const Paper = forwardRef<HTMLDivElement, PaperProps>(function PaperWithRef(
{ elevation = 1, padding = 6, children, className, onClick }: PaperProps,
ref
) {
const boxShadow = useMemo(() => {
if (elevation === 1) return "main"
if (elevation >= 2) return "dark"
Expand All @@ -28,6 +25,7 @@ const Paper = ({

return (
<div
ref={ref}
sx={{
p: padding,
borderRadius: 4,
Expand All @@ -40,6 +38,6 @@ const Paper = ({
{children}
</div>
)
}
})

export default Paper

1 comment on commit 6f47863

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for herzui ready!

✅ Preview
https://herzui-p0yefpxl2-micromed.vercel.app

Built with commit 6f47863.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.