Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/knovour/basic-trigger


https://github.com/knovour/basic-trigger

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

# Basic Trigger

Some html toggle event implementation.

**Bind all elements**
```js
import { bindAll } 'basic-trigger'

bindAll()
```

## Dialog
#### Basic structure
```html
open dialog


reset
confirm
confirm

```

#### Custom Events
```js
import { bind } 'basic-trigger'

bind('dialog')
const $dialog = document.querySelector('dialog')
$dialog.addEventListener('dialog:show', () => {
console.info('This will trigger when dialog appear')
})

$dialog.addEventListener('dialog:CUSTOM_NAME', () => {
console.info('data-dialog-event will be your CUSTOM_NAME, except close')
})
```

## Tablist
Basic structure
```html


  • first tab

  • second tab

  • third tab

first panel

second panel

third panel

```

#### Custom Events
```js
import { bind } from 'basic-trigger'

bind('tablist')
const $tablist = document.querySelector('[role=tablist]')
$tablist.addEventListener('tab:selected', ({ detail }) => {
const { $tab, $panel } = detail
})
```

## Press Button
Basic structure
```html
button
```

#### Custom Events
```js
import { bind } from 'basic-trigger'

bind('pressButton')
const $btn = document.querySelector('button')
$btn.addEventListener('btn:pressed', () => {})
$btn.addEventListener('btn:unpressed', () => {})
```

## Checklist
Basic structure
```html




checkbox 1



checkbox 2



checkbox 3



checkbox 4



checkbox 5


```

#### Custom Events
```js
import { bind } from 'basic-trigger'

bind('checklist')
const $checklist = document.querySelector('[role=checklist]')
$checklist.addEventListener('checklist:change', ({ detail }) => {
const { value, checked } = detail
})
```