An open API service indexing awesome lists of open source software.

https://github.com/github/file-attachment-element

Attach files via drag and drop or file input.
https://github.com/github/file-attachment-element

custom-elements keep web-components

Last synced: 10 months ago
JSON representation

Attach files via drag and drop or file input.

Awesome Lists containing this project

README

          

# <file-attachment> element

Attach files via drag and drop or file input.

## Installation

```
$ npm install @github/file-attachment-element
```

## Usage

```js
import '@github/file-attachment-element'
```

```html

```

### Optional attributes

- `file-attachment[directory]` enables traversing directories.
- `file-attachment[input]` points to the ID of a file input inside of ``. If supplied, only files selected from the corresponding `` will be attached to ``.

### Styling drag state

A boolean `[hover]` attribute is present on `` while files are dragged over the element.

```css
file-attachment[hover] { border: 2px dashed grey; }
```

### Events

- `file-attachment-accept` – Files were dropped onto the element. Call `event.preventDefault()` to prevent the drop. Bubbles.
- `file-attachment-accepted` – Files were added to the attachment list and can be uploaded by the host app. Bubbles.

## Browser support

Browsers without native [custom element support][support] require a [polyfill][].

- Chrome
- Firefox
- Safari
- Microsoft Edge

[support]: https://caniuse.com/#feat=custom-elementsv1
[polyfill]: https://github.com/webcomponents/custom-elements

## Development

```
npm install
npm test
```

## License

Distributed under the MIT license. See LICENSE for details.