0.1.9 • Published 2 months ago

cydon v0.1.9

Weekly downloads
-
License
MIT
Repository
github
Last release
2 months ago

Cydon

npm-v npm-d brotli

A lightweight library for building fast, reactive web components.

Features

  • No dependencies
  • No virtual DOM, components are just DOM elements
  • Performant and ultra-lightweight: ~3kB minified & brotli'd
  • Intuitive and WYSIWYG: use HTML-based template syntax
  • Simple: only provide minimalistic API required to implement reactivity of web components

Preview

HTML:

<my-pagination page="1">
    <template shadowrootmode="open">
        <style>
            button {
                padding: 0.3em;
            }
            .wrapper {
                display: flex;
                align-items: center;
            }
        </style>
        <!-- Watch callback -->
        <div class="wrapper" :="console.log('page No. is', page)">
            <!-- Event binding -->
            <button @click="page--">Prev</button>
            <!-- Two-way binding -->
            <select c-model="perPage" title="items per page">
                <template c-for="n; perPages">
                    <!-- DOM prop binding, attr binding and text interpolation -->
                    <option .selected="perPage == n" value="$n">$n</option>
                </template>
            </select>
            <span>
                per page
                <!-- text interpolation using expressions -->
                ${(page-1)*perPage+!!total}-${Math.min(page*perPage,total)} / $total
            </span>
            <button @click="page++">Next</button>
        </div>
    </template>
</my-pagination>

TypeScript:

import { CydonElement, define } from 'cydon'

@define('my-pagination')
export class MyPagination extends CydonElement {
	static observedAttributes = ['page']

	perPages = [5, 10, 20, 50]
	perPage = 10
	page = 1
	total = 42

	attributeChangedCallback(name: string, _oldVal: string, newVal: string) {
		if (name == 'page')
			this.page = +newVal
	}
}

Directives

  • Builtin directives: c-for, ref, etc.
  • Extra directives: c-model, c-if, c-show, c-cloak, c-tp
  • Event Modifiers: .once, .passive, .capture, .away
  • Custom directives, including global and local directives

Documentation

https://0-v-0.github.io/cydon/

Examples

0.1.9

2 months ago

0.1.8

5 months ago

0.1.7

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago