1.0.9 • Published 9 months ago

vikk v1.0.9

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

Nonreactive JS library

:zap: Zero Dependencies :zap:

npm npm npm package minimized gzipped size GitHub

Getting Started

npx vikk-app project

Options

npx vikk-app # in current folder
npx vikk-app -js # javascript
bunx vikk-bun # using bun

Usage

function App() {
    return <div> Hello from Vikk </div>
}
document.body.append(<App />)

Attributes

<div style="color: red"> Hello </div>

Events

const f = (text) => alert(text)
<div onclick={() => f("Hi")}> Click Me </div>

Arrays

<div> {[1, 2, 3].map(i => <div> {i} </div>)} </div>

Ternaries

<div> {true ? <div> Hello </div> : null} </div>

Nested elements

const inner = <div> Hello </div>
<div> {inner} </div>

Style object

const style = { color: "red" }
<div style={style}> Hello </div>

Components

Using element

function Component({ state }) {
    return <div> {state.data} </div>
}
function App() {
    const state = { data: "hello" }
    return <div>
        <Component state={state} />
    </div>
}
Element with multiple params
function Component({ param1, param2 }) {
    return <div> {param1} {param2} </div>
}
function App() {
    return <div>
        <Component param1="hello" param2="world" />
    </div>
}
Element with children
function Component({ state }, children) {
    return <div>
        {state.data}
        {children}
    </div>
}
function App() {
    const state = { data: "hello" }
    return <div>
        <Component state={state}>
            <div> child1 </div>
            <div> child2 </div>
        </Component>
    </div>
}

Using function call

function Component(state) {
    return <div> {state.data} </div>
}
function App() {
    const state = { data: "hello" }
    return <div>
        {Component(state)}
    </div>
}

Examples

Todo list

function App() {
    const input = <input />
    const list = <ul></ul>
    const add = () => list.prepend(<li> {input.value} </li>)
    const btn = <button onClick={add}> Add </button>
    return <div> {input} {btn} {list} </div>
}
document.body.append(<App />)

Licence

MIT

1.0.9

9 months ago

1.0.8

10 months ago

1.0.7

10 months ago

1.0.6

10 months ago

1.0.5

10 months ago

1.0.4

10 months ago

1.0.3

10 months ago

1.0.2

10 months ago

1.0.1

10 months ago

1.0.0

10 months ago

0.0.4

10 months ago

0.0.3

10 months ago

0.0.2

10 months ago

0.0.1

10 months ago