0.3.2 • Published 2 years ago

small-cup v0.3.2

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

small-cup

a small javascript front end framework

Getting started

mkdir myapp
cd myapp
npm init small-cup@latest

API

enum DOMType { static dynamic }

type DOM {
    node: HTMLNode
    children: [DOM]
    map: {[String]: DOM}
    type: DOMType
    root: Boolean
    update: () => {}
    unload: () => {}
}

type Component {
    template: String
    onload: (el: HTMLNode, ctx: Object, rootDom: DOM) => undefined | Component
    components: {[key: String]: Component}
}

type ElementVNodeData {
    tag: String
    props: Object
    children: undefined | [VNodeType]
}

type TextVNodeData = String

type VNodeData = ElementVNodeData | TextVNodeData

enum VNodeType { element text }

type VNode {
    type: VNodeType
    data: VNodeData
}

type ChildVNode = String | VNode

render(root: HTMLNode, vnode: VNode, context: Object) => DOM

render vnode to root with context

mount(root: HTMLNode, vnode: VNode, context: Object)

render vnode to root with context when window.onpopstate triggerd

h(tag: String | HTMLNode, props: Object, children: undefined | ChildVNode) => VNode | HTMLNode

patch or create HTMLNode

Usage

<script type="module">
import { render, mount, h } from 'https://unpkg.com/small-cup/index.js'
</script>
npm i small-cup

Test

npm start

License

MIT

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.3.2

2 years ago

0.2.3

2 years ago

0.3.1

2 years ago

0.2.2

2 years ago

0.1.10

3 years ago

0.1.11

3 years ago

0.1.12

3 years ago

0.1.8

3 years ago

0.1.7

3 years ago

0.1.9

3 years ago

0.1.4

3 years ago

0.1.6

3 years ago

0.1.5

3 years ago

0.1.3

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago