Skip to content

Commit

Permalink
feat: add next-js image integration
Browse files Browse the repository at this point in the history
  • Loading branch information
segunadebayo committed Mar 18, 2023
1 parent 9d1335c commit 46bd146
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
6 changes: 6 additions & 0 deletions .changeset/quiet-fireants-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@chakra-ui/next-js": minor
---

Add `Image` component that supercharges the Next.js optimized image with Chakra
style props.
9 changes: 9 additions & 0 deletions packages/integrations/next-js/src/image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { chakra, ChakraComponent, HTMLChakraProps } from "@chakra-ui/react"
import NextImage, { ImageProps as NextImageProps } from "next/image"

export type ImageProps = NextImageProps &
Omit<HTMLChakraProps<"img">, keyof NextImageProps>

export const Image: ChakraComponent<"img", NextImageProps> = chakra(NextImage, {
shouldForwardProp: (prop) => ["width", "height", "src", "alt"].includes(prop),
})
4 changes: 4 additions & 0 deletions packages/integrations/next-js/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
export { CacheProvider } from "./emotion-cache-provider"
export type { CacheProviderProps } from "./emotion-cache-provider"

export { Link } from "./link"
export type { LinkProps } from "./link"

export { Image } from "./image"
export type { ImageProps } from "./image"

1 comment on commit 46bd146

@vercel
Copy link

@vercel vercel bot commented on 46bd146 Mar 18, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.