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

image-upload-wc

v2.0.1

Published

Web Component that handles image upload inside your form.

Downloads

5

Readme

image-upload-wc

image-upload-wc is a web component for handling image uploads within a form. It provides a user-friendly interface for selecting and previewing images before uploading.

Installation

You can install the package via npm:

npm install image-upload-wc

Usage

Basic Usage

Include the image-upload-wc component in your HTML:

<script type="module">
  import { defineImageUpload } from "image-upload-wc";
  defineImageUpload("image-upload-wc");
</script>

<form id="uploadForm" action="/postForm" method="post">
  <image-upload-wc multiple></image-upload-wc>
  <button type="submit">Submit</button>
</form>

Importing in JavaScript

If you are using a module bundler, you can import the component:

import { defineImageUpload } from "image-upload-wc";
defineImageUpload("image-upload-wc");

Customization

The image-upload-wc component comes with several customizable properties and event listeners.

Attributes

  • multiple: Allows multiple file selection. If this attribute is present, the user can select multiple files.
  • container-class: Allows custom class for the main container
  • label-class: Allows custom class for the Label
  • label-text: Allows custom text for the Label
  • button-class: Allows custom class for the Button
  • button-text: Allows custom text for the Button
  • preview-container-class: Allows custom text for the Preview Image Container
  • preview-class: Allows custom text for the Preview Images

Example

<form id="uploadForm" action="/postForm" method="post">
  <image-upload-wc
    multiple
    container-class="custom-container-classname"
    label-text="Drag and Drop or Click the Button Below"
    ...
  >
  </image-upload-wc>
  <button type="submit">Submit</button>
</form>

Handling Form Submission

Form Submission is intercepted by the component and selected files are added to the form. Errors related to the success of the form submission can be found in the console for now.

Development

Project Structure

image-upload-wc/
|-- src/
|   |-- index.ts
|   |-- eventListeners.ts
|   |-- handlers.ts
|   |-- icons.ts
|   |-- imagePreview.ts
|   |-- ImageUpload.ts
|   |-- render.ts
|   |-- styles.ts
|-- tests/
|   |-- imageupload.test.ts
|-- jest.config.js
|-- jest.setup.ts
|-- tsconfig.json
|-- package.json
|-- README.md
|-- LICENSE

Running Tests

Tests are written using Jest. To run the tests:

npm test

Building the Project

Compile the typescript into ECMAScript and CommonJS:

npm run compile

Contributing

Contributions are welcome! Please open an issue or submit a pull request on GitHub.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Issues

If you encounter any issues, please report them on the GitHub issues page.

Author

Created by thopl0.

Acknowledgments

Special thanks to the open-source community for their invaluable contributions and support.