0.3.2 • Published 6 months ago

small-cup v0.3.2

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months 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

6 months ago

0.2.1

6 months ago

0.2.0

6 months ago

0.3.2

6 months ago

0.2.3

6 months ago

0.3.1

6 months ago

0.2.2

6 months ago

0.1.10

2 years ago

0.1.11

2 years ago

0.1.12

1 year ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.9

2 years ago

0.1.4

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago