npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

next-image-uploader

v0.0.5

Published

Drag and drop image uploader for Nextjs.

Downloads

9

Readme

Nextjs Image Uploader

Drag and drop image uploader for Nextjs.

Demo

Installation

pnpm add next-image-uploader

or

yarn add next-image-uploader

Usage

import React, { useState } from "react";
import ImageUploader from "react-image-uploader";

const App = () => {
	const [photo, setPhoto] = useState(null);

	return (
		<ImageUploader
			photo={photo}
			setPhoto={setPhoto}
			hoverIcon={hoverIcon}
			dropScope="window"
			onError={(error) => console.log(error)}
		/>
	);
};

export default App;

const hoverIcon = (
	<svg
		xmlns="http://www.w3.org/2000/svg"
		fill="none"
		viewBox="0 0 24 24"
		strokeWidth="1.5"
		stroke="currentColor"
		className="w-6 h-6"
	>
		<path
			strokeLinecap="round"
			strokeLinejoin="round"
			d="M6.827 6.175A2.31 2.31 0 015.186 7.23c-.38.054-.757.112-1.134.175C2.999 7.58 2.25 8.507 2.25 9.574V18a2.25 2.25 0 002.25 2.25h15A2.25 2.25 0 0021.75 18V9.574c0-1.067-.75-1.994-1.802-2.169a47.865 47.865 0 00-1.134-.175 2.31 2.31 0 01-1.64-1.055l-.822-1.316a2.192 2.192 0 00-1.736-1.039 48.774 48.774 0 00-5.232 0 2.192 2.192 0 00-1.736 1.039l-.821 1.316z"
		/>
		<path
			strokeLinecap="round"
			strokeLinejoin="round"
			d="M16.5 12.75a4.5 4.5 0 11-9 0 4.5 4.5 0 019 0zM18.75 10.5h.008v.008h-.008V10.5z"
		/>
	</svg>
);

Props

Main

| Name | Type | Default | Description | | -------- | -------- | ------- | ------------------------------------------- | | photo | string | '' | The preview image to be displayed. | | setPhoto | function | null | The callback function to receive the image. |

Additional

| Name | Type | Default | Description | | --------------- | --------------------------------- | --------- | --------------------------------------------------------------------------------------------------------------------- | | alt | string | 'image' | The alt text of the Image. | | objectFit | string | 'cover' | The object-fit property. | | setFileName | function | null | The callback func to get the file name. | | setSize | function | null | The callback func to get the file size (width, height) | | isFormik | boolean | false | If true, the setPhoto will receive the file object instead of the base64 string. | | getFileSize | function | null | The callback func to get the file size | | disabled | boolean | false | If true, the uploader will be disabled | | inputRef | React.RefObject | null | The ref of the input element, if you want to control the input element | | className | string | '' | The class name of the uploader's root | | hoverIcon | React.ReactNode | null | The icon to be displayed when hovering the uploader | | dropScope | string | 'element' | The drop area of the uploader. 'element' means the whole uploader, 'window' means the whole window. | | onError | function | null | The callback func to handle the error. | | onDraggingImage | string | null | The displayed image when dragging the image. |