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

@snaptopixel/quip

v0.2.0

Published

Better render functions for Vue with TypeScript

Downloads

1

Readme

quip

Better render functions for Vue. No more string templates, JSX, createElement, or .vue files to worry about.

How it works

Vue supports render functions out of the box, they just don't end up looking very pretty and can be hard to deal with. The concept is simple… You do some work based on the current state, return a tree of VNodes and Vue makes updates where necessary.

With Quip, we're wrapping the typical VNode creation process: createElement(tagName, data, children) with chainable function calls and a few TypeScript conventions to make the syntax more approachable, attractive, type-safe and less error-prone.

Setup

Installing Quip

yarn add @snaptopixel/quip

Registering Quip

import { QuipPlugin } from 'vue-quip';
import { Vue, Component } from 'vue-property-decorator';

Vue.use(QuipPlugin)

Basic usage

Quip is meant to be used inside of component render functions, where you generate and return a tree of VNodes.

Creating vnodes

VNodes are created by invoking a named opening function, followed by invoking an anonymous closing function:

const { ul } = this.$quip
return ul()()
// <ul></ul>

Referencing vnodes

You can optionally pass a ref value in the opening function in order to reference vnodes elsewhere in your component:

render() {
  const { div } = this.$quip
  return div('mydiv')()
}
mounted() {
  const ref = this.$refs.mydiv
}

Nesting vnodes

Use method chaining to build complex structures easily and efficiently. Any calls you make between opening and closing functions are applied to the current node.

Note the use of parentheses after return() to allow multiple lines

const { ul } = this.$quip
return(
  ul()
    .li()
      .span()()
    ()
  ()
)
// <ul>
//   <li>
//     <span></span>
//   </li>
// </ul>

Using plugins

Creating vnodes is fun, but not very useful in and of itself. In order to configure our newly created vnodes we use plugins. Quip comes with a set of useful plugins, as well as allowing for the creation of custom plugins.

css

// set classes directly
.div()
  .css('foo', 'bar')
()

// or provide an object
.div()
  .css({
    foo: true,
    bar: false
  })
()

style

// set properties individually
div()
  .style('fontSize', '10px')
  .style('fontWeight', 'bold')
()

// or provide an object
div()
  .style({
    display: 'block',
    textAlign: 'center'
  })
()

on

button()
  .on('click', this.onClick)
()

button()
  .on({
    mouseover: this.onMouseOver,
    mouseout: this.onMouseOut
  })
()

prop

// TODO

text

// TODO

map

// TODO

switch

// TODO
case
// TODO
default
// TODO

if

// TODO
else
// TODO

attr

// TODO

data

// TODO

bind

// TODO