# craydom

> craydom = pure views + (minimal diffs) - (virtual DOM)

Latest version **2.3.6** (published 2020-01-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install craydom
pnpm add craydom
yarn add craydom
bun add craydom
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.3.6 |
| Published | 2020-01-03 |
| First published | 2020-01-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 68.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | @dosy |
| Maintainers | dosy |
| Keywords | javascript, view, framework |

## Links

- npm: https://www.npmjs.com/package/craydom
- Repository: https://github.com/dosyago/craydom
- Homepage: https://github.com/dosyago/craydom#readme
- Issues: https://github.com/dosyago/craydom/issues
- npm.io page: https://npm.io/package/craydom

## Dependencies (2)

- [esm](https://npm.io/package/esm.md) ^3.0.74
- [jtype-system](https://npm.io/package/jtype-system.md) ^1.1.1

## Alternatives

- [@sveltejs/kit](https://npm.io/package/@sveltejs/kit.md) — 2.2M weekly downloads
- [@tangle-network/brand](https://npm.io/package/@tangle-network/brand.md) — 10.0K weekly downloads
- [seneca](https://npm.io/package/seneca.md) — 7.4K weekly downloads
- [@bsb/base](https://npm.io/package/@bsb/base.md) — 7.2K weekly downloads
- [@modern-js/plugin-swc](https://npm.io/package/@modern-js/plugin-swc.md) — 3.4K weekly downloads

## Recent versions

- 2.3.6 (latest) — 2020-01-03

## README

# craydom (2.3.4)

Minimalist view framework for building JS apps. Aims to be more efficient than React, Vue or Angular, both for rendering and development.

## Features

- Minimal DOM updates without "Virtual DOM" overhead
- Keyed, singleton (from `R` tag), and clone (from `X` tag) components
- Pinned DOM locations
- Uses native JS features and requires no transpilation or build step.
- Fully isomorphic, running browser-side or server-side (with builtin hydration).
- Use normal HTML conventions (omit some end tags, omit quotes, lowercase attr names ~ unlike JSX).
- Concise, declarative, literate syntax using tagged template literals.
- Add event listeners inline using the lowercased event name, like `click`, `keydown`, etc.
- Small, fast and XSS safe. 
- Can be used in place of Deku, lit-html, AppRun or React.
- Namespaced event attributes add flags to addEventListener like `capture`, `passive` and `once`.

## Examples

### Real world example

This is [the core interactive image canvas from this project](https://github.com/dosyago/supreme-architect). 

```javascript
R`
  <canvas
    click=${e => {
      if ( viewState.shouldHaveFocus && document.activeElement != viewState.shouldHaveFocus ) {
        viewState.shouldHaveFocus.focus(); 
      }
    }}
    bond=${[saveCanvas, asyncSizeBrowserToBounds, emulateNavigator, ...canvasBondTasks]}
    touchstart=${retargetTouchScroll}
    touchmove=${[
      e => e.preventDefault(), 
      throttle(retargetTouchScroll, state.EVENT_THROTTLE_MS)
    ]}
    wheel:passive=${throttle(H, state.EVENT_THROTTLE_MS)}
    mousemove=${throttle(H, state.EVENT_THROTTLE_MS)}         
    mousedown=${H}         
    mouseup=${H}         
    pointermove=${throttle(H, state.EVENT_THROTTLE_MS)}         
    pointerdown=${H}         
    pointerup=${H}         
    contextmenu=${subviews.makeContextMenuHandler(state)}
  ></canvas>
`
 ```

## Installing

From NPM:

```shell
$ npm i --save craydom
```

Then using on server with CJS:

```JavaScript
  import {R,X} from 'craydom';
```

Using on client with the Unpkg CDN:

```HTML
  <script type=module src=https://unpkg.com/craydom/r.js></script>
```

## Simple Example

This is craydom:

```JavaScript
function ButtonWidget({name}) {
  return R`
    <button click=${() => showModal(name)}>
      Show ${name} Modal
    </button>
  `;
}
```

### Other similar/related projects

- [lit-html](https://github.com/Polymer/lit-html)

---
_Source: https://npm.io/package/craydom · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
