Code Monkey home page Code Monkey logo

next-image's Introduction

@sohanemon/next-image ๐ŸŒŸ

Enhance your Next.js image handling with ease using the @sohanemon/next-image npm package. This package provides two powerful components, Placeholder and Img, designed to simplify and optimize image loading and rendering within your Next.js applications. ๐Ÿš€

Installation ๐Ÿ› ๏ธ

You can install the package using npm:

npm install @sohanemon/next-image

Or with Yarn:

yarn add @sohanemon/next-image

Components ๐Ÿ–ผ๏ธ

Placeholder ๐ŸŒˆ

The Img component from '@sohanemon/next-image/dist/placeholder' directory takes care of loading and displaying images with placeholder support. It provides a smooth visual experience by showing a blurred placeholder image while the main image is loading. โณ

import Img from '@sohanemon/next-image/dist/placeholder';

<Img src='/path/to/your/image.png' />;

Key features:

  • Automatic generation of a base64-encoded blurred placeholder image.
  • Seamless loading of remote (HTTP) and local images.
  • Supports additional props from the Img component.

Img ๐Ÿ“ท

The Img component simplifies the integration of Next.js's Image component while allowing for easy customization. ๐ŸŽจ

import Img from '@sohanemon/next-image';

<Img src='/path/to/your/image.png' />;

Img/SVG ๐Ÿ“œ

The Img component also can inject svg directly to the dom.

import Img from '@sohanemon/next-image';

<Img inject src='/path/to/your/image.svg' />;

Key features:

  • Intuitive handling of image rendering and aspect ratio.
  • Inject svg element directly to the dom.
  • Automatic optimization for various screen sizes using the sizes attribute.
  • Use src prop as '/public/img.png', '/img.png' or 'https://hello.world/img.png'
  • Customization of className, imageClassName, placeholderProps, and more.

Usage ๐Ÿš€

Here's a quick guide on how to utilize the components in your Next.js project:

  1. Import the desired component:
import Img from '@sohanemon/next-image';
import Placeholder from '@sohanemon/next-image/dist/placeholder';
  1. Use the components within your JSX:
<Placeholder src="/path/to/your/image.png" alt="Description of the image" />

<Img src="/path/to/your/image.png" alt="Description of the image" />

Example ๐ŸŒŸ

import Img from '@sohanemon/next-image';
import Img from '@sohanemon/next-image/dist/placeholder';

// ...

<Placeholder src="/path/to/your/image.png" alt="Description of the image" />

// ...

<Img src="/path/to/your/image.png" alt="Description of the image" />

Contribution ๐Ÿค

Contributions to the @sohanemon/next-image package are welcome! If you encounter any issues or have suggestions for improvements, feel free to open an issue or pull request on the GitHub repository.

License ๐Ÿ“œ

This project is licensed under the MIT License.


Elevate your Next.js image handling to the next level with the @sohanemon/next-image package. Simplify your code and improve user experience by effortlessly integrating optimized images with placeholders. Happy coding! ๐ŸŽ‰

next-image's People

Contributors

sohanemon avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.