Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/mervinpraison/web-elements-ui


https://github.com/mervinpraison/web-elements-ui

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*

- [web-components-ui-elements](#web-components-ui-elements)
- [Installation](#installation)
- [Usage](#usage)
- [API](#api)
- [Modal Window](#modal-window)
- [Tag Name](#tag-name)
- [Methods](#methods)
- [Open](#open)
- [Close](#close)
- [ICD](#icd)
- [Config](#config)
- [Contributing](#contributing)

# web-components-ui-elements
A web components UI library.

## Installation
`npm install web-components-ui-elements`

## Usage
You can require the whole library:

`import * from web-components-ui-elements;`

And use in the DOM like this:

``

And then use the API:
```
const modal = document.querySelector('#modal-window');
modal.open({
content: '

Hello Modal!

'
});

// close the modal when clicking on it
function closeModal() {
modal.close();
modal.removeEventListener('click', closeModal);
}
modal.addEventListener('click', closeModal);

```

If you want, you can just create the element on your own and add it to the DOM:
```
const modalWindow = document.createElement('ce-modal-window');
modalWindow.addEventListener('click', () => {
modalWindow.close();
});
document.body.appendChild(modalWindow);

const button = document.createElement('button');
button.innerText = 'Open modal';

button.addEventListener('click', () => {
modalWindow.open({
content: '

Hello Modal

',
height: 50,
width: 100
});
});
document.body.appendChild(button);
```

## API

### Modal Window
#### Tag Name
`ce-modal-window`
#### Methods
##### Open
Accepts a config object and opens the modal.
##### Close
Closes the modal
#### ICD
##### Config
```
{
content: '', // HTML snippet to show inside the modal
hideOverlay: false, // show or hide the opack overlay behind the modal
height: 150, // height of the modal
width: 150, // width of the modal
}
```
## Contributing
- Clone
- `npm i`
- `npm run build` to get the build
- `npm run test` to test
- `npm run serve` to run a development environment