npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

weivjs

v0.0.8

Published

A home-brew UI view library for modern component-based web development

Downloads

8

Readme

What is weiv

weiv.js - A home-brew UI view library for modern component-oriented web development. Weiv is the reverse of the word View or 微V in Chinese which means micro-view literally.

Why weiv?

This is an era of front-end evolution with tons of front-end frameworks: React, Angular, Vue, Preact, Ractive, Svelte. Probably like me, you also feel tired to follow this one or another one. So I choose to reinvent the wheel and eat my own dog food.

How it's like

TODO MVC example

Weiv TODO MVC example

Source code

Edit weiv-demo

Basic feature example

Edit weiv-demo

import { Component, observable, action } from 'weivjs'

@Component({
  template: `
  <div>
    <span>TODO: {{a}}</span>
    <button onclick="changeProp" style="height: 30px">Try to change props?</button>
    <p>
      <slot>
        <p>show when no slot</p>
      </slot>
      <p>
        <input type="text" oninput="onInput"  />
        <button onclick="onSave" style="height: 30px">Save</button>
        <input type="text" disabled @bind:value="input" />
      </p>
      <ul>
        <slot name="item">show when no item slot</slot>
      </ul>
    </p>
  </div>
  `,
  props: {
    a: {type: 'number', required: true}
  },
  events: {
    save: {}
  }
})
export class Todo {
  changeProp() {
    try {
      this.a = 0
    } catch (err) {
      alert(err.message)
    }
  }

  onSave() {
    this.$emit('save', this.input, '')
  }

  @observable
  input = ''

  onInput(e) {
    this.input = e.target.value
    console.log('on input %o', e)
  }
}

@Component({
  template: `
  <div @var:i="100">
    <h1 @bind:title="counter">{{firstName}} {{lastName}}</h1><p>{{blogURL}}</p>
    <div @if="counter < 5">Location: {{location.city}} - {{location.country}}</div>
    <p>Countdown: {{counter}}</p>
    <button onclick="minus" style="width: 80px">➖</button>
    <button @on:click="plus" style="width: 80px">➕</button>
    <p>Tip: When counter is less than 5, location will be shown.</p>
    <ol>
      <li @for:i="[1,2,3]">
      {{i}} - {{$super.i}}
      </li>
    </ol>
    <todo @bind:a="counter" @on:save="onSave">
      <div>this is a default slot</div>
      <li slot="item">item1</li>
      <li slot="item">item2</li>
      <span>another default slot</span>
      <p>show var value: {{i}}</p>
    </todo>
  </div>
  `,
  components: {'todo': Todo}
})
export class App {
  firstName = 'Chao'
  lastName = 'Yang'
  blogURL = 'http://yangchao.me'
  location = {
    city: 'Auckland',
    country: 'New Zealand'
  }

  @observable counter = 10
  @action plus() {
    if (this.counter === 10) return
    this.counter += 1
  }
  @action minus() {
    if (this.counter === 0) return
    this.counter -= 1
  }

  onSave(a, b) {
    alert(`Are you sure to save: ${a} ${b}?`)
  }
}

new App().$mount('#app')

Building blocks & Credits

TODOs

  • [x] Add slots support
  • [x] Refine directive structure
  • [x] Add scope to support @for:i="" directive like for ... in
  • [x] Enhance events support
  • [ ] Add lifecycle hooks
  • [ ] Optimise: cache subtree via vdom-trunk
  • [ ] Optimise: batch update via main-loop
  • [ ] Optimise: try to use zone.js intead of mobx autorun
  • [ ] Write a UI component library like ElementUI