• Stars
    star
    172
  • Rank 221,201 (Top 5 %)
  • Language
    TypeScript
  • License
    Other
  • Created over 4 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Build UIs at the speed of thought

Checks

This project has been moved over to Tandem



Paperclip is a DSL for UI builders. Here's what a basic UI file looks like:

<!--
  @frame { height: 768, visible: false, width: 1024, x: -176, y: 173 }
-->
<ul component as="List">
  <style>
    padding: 14px;
    margin: 0px;
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    gap: 8px;
    list-style-type: none;
  </style>
  {children}
</ul>

<!--
  @frame { height: 768, visible: false, width: 1024, x: -1, y: 0 }
-->
<li component as="ListItem">
  {children}
</li>

<!--
  @frame { height: 366, title: "Todos", width: 258, x: 766, y: 402 }
-->
<List>
  <ListItem>buy cereal</ListItem>
  <ListItem>buy milk</ListItem>
</List>

Here's a demo of a UI builder prototype that works with Paperclip:

alt something

Paperclip UIs cover just HTML, CSS, and primitive components for now, and can be imported directly into code like so:

import * as styles from "./styles.pc";

export const List = ({items}) => {
  return <styles.List>
    {items.map(item) => {
      return <styles.ListItem key={item.id}>{item.label}</styles.ListItem>;
    }}
  </styles.List>;
};

Language features

Paperclip is limited to bare minimum features that are necessary for building presentational components. This includes:

  • Syntax is based on plain HTML & CSS
  • Primitive components
  • Styles and variants
  • Slots (being able to insert children in certain areas of a component)
  • Attribute bindings

Tooling features

  • Designed to compile down to just about any language. Currently targets React & static HTML.
  • Can compile to strongly-typed code.
  • Comes with visual regression & code coverage tooling (for tracking how much of the UI is covered for visual regressions).

UI Builder features

Paperclip aims to provide an easy-to-use API for UI builders:

  • APIs for editing source code.
  • Rust-based engine for smooth editing.
  • multi-player editing capabilities (CRDT based).

Here's a basic example of the editing API (still very much WIP):

import { WorkspaceClient } from "@tandem-ui/workspace-client";
import { renderFrames, patchFrames } from "@paperclip-ui/web-renderer";

const client = new WorkspaceClient();
const project = await = client.openProject({
  uri: "file:///path/to/project/directory"
});

const doc = await project.getDocuments().open("file:///path/to/project/directory/src/components/button.pc");

// render the document
const mount = document.createElement("div");
let frames = renderFrames(doc.getContent());
document.body.appendChild(mount);

// When the document changes, re-render
doc.onAppliedChanges((newData) => {
  frames = patchFrames(frames, newData);
});

// Make a change to the 
doc.editVirtualObjects({
  kind: VirtualObjectEditKind.AppendChild,

  // path to element to append the child to
  nodePath: "0",

  // Child HTML
  child: {
    value: `Hello World`,
  },
});

Goal

The goal for Paperclip is to be a scalable data format for UI builders, and safe enough for non-engineers to feel confident about making visual changes.

In a perfect world, Paperclip could be the engine for a UI builder that enables:

  • Designers to have complete control over HTML and CSS development with Webflow-like tooling.
  • PMs and anyone else to create variant UIs / text / styles for a/b testing.
  • Enable anyone on a team to spot-edit visual bugs that are in production (wouldn't it be great to right-click any staging / production element and edit it on the spot??).

It seems that the general direction of many UI builders is that they're mostly adopting the same principles (primitive components, slots, variants), and could benefit from using an open-source data model that's geared more for developers. Hopefully in the future, developers of UI builders can add their own rendering engine, create supersets, and rules on top of Paperclip according to features that their UI builder supports.

Why focus on the data model?

Mostly because the data model is easier to shape than a UI builder based on feedback. And, as a developer, I care mostly about how a tool influences the direction of a codebase. If I believe that a tool is detrimental to the overall health of the codebase, then there's no point in using it.

It's also a hard sell to allow anyone to write code who isn't a developer. That's why the data model is such a focus in ensuring that anyone working with it (written by hand or in a UI builder) has enough guardrails (removing incidental complexity, and providing safety tooling) to create shippable UIs.

Why code as a data model?

Mostly for maintainability, collaboration, and safety.

  • A readable UI file can be easily reviewed for any structural problems.
  • A readable UI file makes merge conflicts easy to resolve.
  • Sometimes it's easier to write functionality by hand.
  • Easier escape hatch for engineers that are worried about locked into a UI builder (esp. for engineers looking to collaborate).
  • Easier to debug.
  • Easier to reason about when wiring up with logic.

Why not use an existing language?

Mostly to have total control over the data model, and to only have features specifically for visual development. Most languages contain features that make it difficult to effectively map to a practical UI builder (even vanilla HTML and CSS to an extent). I think for a UI builder to be flexible and simple, that simplicity needs to be reflected in the data model.

Another reason why Paperclip was created is to ensure that multiple languages could be targeted. Eventually the plan is for Paperclip to compile down to just about any language.

What's the status of this Project?

Paperclip has been in active development for a few years. Now it's at an inflection point where a UI builder is necessary to help shape the DSL.

Can I use Paperclip now?

Yes! Paperclip can be used to build React applications. Currently it's powering most of the HTML and CSS at Hum Capital.

Installation

Just run this command in your existing project to get started

npx @paperclip-ui/cli init

This will walk you through a brief setup process. Next, just run:

npx @paperclip-ui/cli build

Resources

Contributing

Most of the focus right now for Paperclip is around UI builder APIs, so if you would like to help out, feel free to reach out! Some other areas in the future will include:

  • More compilers: Java, Ruby, Python, PHP.
  • Migration tooling to help people translate their existing HTML & CSS into Paperclip UIs
  • Get VS Code extension to work with github.dev, making it easier for people to edit UI files online.
  • Help with language featuers that are mappable to UI tooling.
  • Performance adjustments around Rust rendering engine.
  • More tooling that enables Paperclip to be edited or visualized in other mediums (not just UI builders).
    • e.g: ability to edit any UI directly in staging
  • More safety features that give non-engineers confidence about shipping UIs.
    • visual regression coverage
    • More robust inferencing engine
  • More functionality to the rendering engine
    • Ability to change type of rendering (e.g: React Native)
    • Ability to inject custom web components
    • CSS Houdini support
  • Help on shaping the DSL for more visual development capabilities

More Repositories

1

sift.js

Use Mongodb queries in JavaScript
JavaScript
1,604
star
2

mesh.js

utility library for async iterable iterators
JavaScript
1,008
star
3

paperclip.js

Document format for visual editors that compiles to languages & frameworks.
JavaScript
527
star
4

celeri

CLI library for node.js
JavaScript
166
star
5

slugr

Bundle node.js apps into a single executable file
JavaScript
145
star
6

bindable.js

flexible data-binding
JavaScript
135
star
7

fourk.js

threads in the browser
JavaScript
119
star
8

node-supervisord

Supervisord library for node.js
JavaScript
67
star
9

mojo.js

A non-opinionated, customizable JavaScript framework designed for writing scalable web, mobile, and server-side programs
JavaScript
65
star
10

node-awsm

awesome AWS library
JavaScript
60
star
11

cupboard

Your project command center
JavaScript
56
star
12

caplet.js

Universal models library
JavaScript
53
star
13

gittyup

application deployment library for node.js
JavaScript
48
star
14

emailify

Make HTML pages email-safe
JavaScript
39
star
15

sardines

combine node / browser apps into a single script.
JavaScript
37
star
16

fiddle.js

mongodb-inspired object manipulation
JavaScript
31
star
17

outcome.js

better error handling in JavaScript
JavaScript
30
star
18

connect-router

Connect router with syntactic sugar
JavaScript
27
star
19

catchall

catch all javascript errors
JavaScript
23
star
20

boo.js

run CPU heavy tasks when the user is inactive
JavaScript
22
star
21

obj-stream

lightweight object streams
JavaScript
19
star
22

structr.js

Structure for Javascript
JavaScript
16
star
23

plugin.js

Simple plugin system for javascript
JavaScript
14
star
24

beanpoll.js

Universal router with syntactic sugar
CoffeeScript
11
star
25

mesh-mongodb

streamable mongodb library
JavaScript
11
star
26

figmark

Import Figma designs in React code
TypeScript
11
star
27

node-scaffoldit

scaffolding library
JavaScript
11
star
28

comerr.js

various error codes I use throughout my projects
JavaScript
10
star
29

node-mongodblite

zero-configuration, self-contained version of mongodb in node.js
JavaScript
10
star
30

aerial

Realtime visual programming engine for web applications.
TypeScript
7
star
31

node-watchr

watch files recursively
JavaScript
7
star
32

mesh-loki

Loki db streams
JavaScript
6
star
33

gumbo.js

node.js database with mongodb feel
JavaScript
6
star
34

webflow-componentizer

Converts Webflow sites into components that can be used in React apps
TypeScript
6
star
35

dref.js

deep object referencing
JavaScript
6
star
36

dbmonster

paperclip db monster
JavaScript
5
star
37

bindable-object.js

data-bindable object
JavaScript
5
star
38

node-guava

firehose library
JavaScript
5
star
39

hurryUp.js

timeout library for callbacks
JavaScript
5
star
40

mesh-socket.io

socket.io streams
JavaScript
5
star
41

maestro

cloud management
JavaScript
5
star
42

immutable-virtual-dom

JavaScript
5
star
43

document-section.js

controllable document fragments
JavaScript
4
star
44

beet

upstart processes and keep them running
JavaScript
4
star
45

mediocre.js

javascript mediator
JavaScript
3
star
46

daisy.js

expose beanpole routes to http, amqp, websockets, etc.
JavaScript
3
star
47

mesh-http

RESTful adapter
JavaScript
3
star
48

tandem-old

Live web development directly within VS Code
Rust
3
star
49

node-awsm-ssh

ssh into one, or many instances
JavaScript
3
star
50

node-s3cp

s3 file copy
CoffeeScript
3
star
51

starch

crowdfunding platform
JavaScript
3
star
52

gridly.js

jQuery plugin that places items in a grid
JavaScript
3
star
53

node-cronworker

cron tabs + workers
JavaScript
3
star
54

strscan.js

lexical string scanner for javascript
JavaScript
3
star
55

bindable-collection.js

JavaScript
2
star
56

rust-vdom

Rust vdom experiment
Rust
2
star
57

sysalert

alert when your system is down
JavaScript
2
star
58

beanpoll-mixpanel

mixpanel analytics library for beanpoll
JavaScript
2
star
59

beanpoll-growl

growl notification bean for beanpole
JavaScript
2
star
60

node-closest-ec2-region

Find the closest ec2 region based on a geoIP
JavaScript
2
star
61

cdelta.js

change delta
2
star
62

mesh-webrtc

JavaScript
2
star
63

node-fglob

JavaScript
2
star
64

asyngleton.js

asynchronously generate singletons
JavaScript
2
star
65

node-aster

Simplified AST handling
JavaScript
2
star
66

maprest.js

map objects to a restful interface
JavaScript
2
star
67

cortado

test runner for websites
CSS
2
star
68

eyebrowse

browser launcher
CoffeeScript
2
star
69

toarray.js

convert any item to an array if it's not an array
JavaScript
2
star
70

node-dirmr

platform bootstrap directory scanner
JavaScript
2
star
71

mojojs.com

mojo.js site
HTML
2
star
72

thyme

timing / queue management for node.js
JavaScript
2
star
73

browsertap

Remote browser testing
JavaScript
2
star
74

beanpoll-twilio

twilio plugin for beanpoll
JavaScript
2
star
75

crema.js

Syntactic sugar for middleware
JavaScript
2
star
76

beandocs

documentation engine for beanpole
JavaScript
2
star
77

beanpoll-store

JavaScript
2
star
78

mesh-pubnub

pubnub streams
JavaScript
2
star
79

vine.js

API builder
JavaScript
2
star
80

beanpole.as

AS3 version of beanpole
ActionScript
1
star
81

nofactor.js

node factory
JavaScript
1
star
82

node-awsm-cli

awsm command line interface
JavaScript
1
star
83

crowbar.js

HTTP routing for the browser, and Node.js
JavaScript
1
star
84

node-walkr

async file copy with middleware
JavaScript
1
star
85

mojo-starter

starter kit for mojo.js
JavaScript
1
star
86

dsync.js

synchronize dnode objects
JavaScript
1
star
87

node-auth

user authentication library for node.js
JavaScript
1
star
88

recap

JavaScript
1
star
89

capirona

Javascript Build System
JavaScript
1
star
90

mesh-local-storage

JavaScript
1
star
91

structr-step

JavaScript
1
star
92

beanie.js

haba + beanpoll
JavaScript
1
star
93

node-awsm-keypair-save

adds a chained command for saving keypair material to disc
JavaScript
1
star
94

node-yaconfig

JavaScript
1
star
95

disposable.js

Janitor / garbage collector for js
JavaScript
1
star
96

tq.js

tiny queue
JavaScript
1
star
97

dolce.js

Chained Collection
JavaScript
1
star
98

plugin-dnode

dnode plugin for haba
JavaScript
1
star
99

node-ectwo

EC2 library
CoffeeScript
1
star
100

beanpoll-connect

connect middleware for beanpoll
JavaScript
1
star