Socket
Book a DemoInstallSign in
Socket

af-image-uploader

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

af-image-uploader

AppFeel Image Uploader

1.0.1
latest
Source
npmnpm
Version published
Maintainers
1
Created
Source

AppFeel Image Uploader WebComponent
License NPM version NPM downloads Built With Stencil

This web component implements a drag and drop component to upload and preview images. Example of use:

<!DOCTYPE html>
<html dir="ltr" lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=5.0">
    <title>AppFeel Image Uploader WebComponent</title>
    <script src='https://unpkg.com/af-image-uploader@latest/dist/af-image-uploader.js'></script>

</head>

<body>

    <af-image-uploader id="imageUploader" width="300px" height="100px" onchange="onChange(event)" onload="onLoad(event)"></af-image-uploader>
    <button onclick="reset()">Reset</button>
    <button onclick="getFile()">Get File</button>
</body>
<script>
    const imageUploader = document.getElementById('imageUploader');
    function reset() {
        imageUploader.reset();
    }
    function onChange(image) {
        console.log('Image selected', image.detail);
    }
    function onLoad(image) {
        console.log('Image preview completed', image.detail);
    }
    async function getFile() {
        console.log('Selected image', await imageUploader.getFile());
    }
</script>
</html>

Properties

PropertyAttributeDescriptionTypeDefault
activeColoractive-colorThe color when it is activestring'green'
baseColorbase-colorThe default colorstring'#ccc'
heightheightHeight of the componentstring'300px'
hoverOutlineColorhover-outline-colorThe hover outline colorstring'#aaa'
iconSrcicon-srcIcon source image (svg, png, jpg, gif, ...)string'./assets/upload-cloud-flat.svg'
overlayColoroverlay-colorThe overlay colorstring'rgba(255,255,255,0.5)'
widthwidthWidth of the componentstring'100%'

Events

EventDescriptionType
changeRaised when the upload has finishedCustomEvent<File>
invalidformatRaised when the file tried to upload was in wrong formatCustomEvent<string>
loadRaised when the image has finished to loadCustomEvent<File>

Methods

getFile() => Promise<File>

Obtains the selected or dropped file if any, or undefined if none available

Returns

Type: Promise<File>

selected or dropped file

reset() => void

Reset the component to void state

Returns

Type: void

Using this component

Script tag

  • Publish to NPM
  • Put a script tag similar to this <script src='https://unpkg.com/af-image-uploader@latest/dist/af-image-uploader.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

Node Modules

  • Run npm install af-image-uploader --save
  • Put a script tag similar to this <script src='node_modules/af-image-uploader/dist/af-image-uploader.js'></script> in the head of your index.html
  • Then you can use the element anywhere in your template, JSX, html etc

In a stencil-starter app

  • Run npm install af-image-uploader --save
  • Add an import to the npm packages import af-image-uploader;
  • Then you can use the element anywhere in your template, JSX, html etc

FAQs

Package last updated on 27 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.