Skip to content

Commit

Permalink
refactor: stop vendoring signal
Browse files Browse the repository at this point in the history
  • Loading branch information
kt3k committed Aug 17, 2024
1 parent 109180d commit 9e17fcd
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 202 deletions.
52 changes: 24 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@

# Cell v0.2.1

> Event-driven DOM programming in a new style
> frontend tool for local event handlers and signals
## Features

- Cell encourages **event-driven** DOM programming in a new way
- Supports **event delegation**
- **Lightweight** library (**< 1.5 kiB** gzipped)
- ⭐️ **No dependencies**
- 🌱 **No build** step required
- Uses **No special syntax**. Uses **plain JavaScript** and **plain HTML**
- Cell encourages **local event handlers**
- Cell provides **signals** for remote effects
- **Lightweight** (**< 1.5 kiB** gzipped)
- **TypeScript** friendly
- Use **signal** when you need remote effect

## Live examples

Expand Down Expand Up @@ -54,26 +50,6 @@ register(MyComponent, "js-hello");
<div class="js-hello">Click</div>
```

Vanilla js (ES Module):

```html
<script type="module">
import { register } from "https://kt3k.github.io/cell/dist.min.js";
function Mirroring({ on, query }) {
on.input = () => {
query(".dest").textContent = query(".src").value;
};
}
register(Mirroring, "js-mirroring");
</script>
<div class="js-mirroring">
<input class="src" placeholder="Type something" />
<p class="dest"></p>
</div>
```

## More examples

Mirrors input value of `<input>` element to another dom.
Expand Down Expand Up @@ -175,6 +151,26 @@ $(document).read(() => {
`cell` can be seen as a syntax sugar for the above pattern (with a few more
utilities).

## Using Cell directly from the browser

```html
<script type="module">
import { register } from "https://kt3k.github.io/cell/dist.min.js";
function Mirroring({ on, query }) {
on.input = () => {
query(".dest").textContent = query(".src").value;
};
}
register(Mirroring, "js-mirroring");
</script>
<div class="js-mirroring">
<input class="src" placeholder="Type something" />
<p class="dest"></p>
</div>
```

## Motivation

Virtual DOM frameworks are good for many use cases, but sometimes they are
Expand Down
1 change: 1 addition & 0 deletions deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
},
"imports": {
"@b-fuze/deno-dom": "jsr:@b-fuze/deno-dom@^0.1.47",
"@kt3k/signal": "jsr:@kt3k/signal@^0.1.6",
"@std/assert": "jsr:@std/assert@^1.0.0",
"@std/async": "jsr:@std/async@^1.0.0",
"@std/testing": "jsr:@std/testing@^1.0.0"
Expand Down
5 changes: 5 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function logEvent({
console.groupEnd();
}

// signal.ts
// https://jsr.io/@kt3k/signal/0.1.6/mod.ts
var Signal = class {
#val;
#handlers = [];
Expand Down Expand Up @@ -288,4 +288,4 @@ export {
signal,
unmount
};
/*! Cell v0.2.0 | Copyright 2024 Yoshiya Hinosawa and Capsule contributors | MIT license */
/*! Cell v0.2.1 | Copyright 2024 Yoshiya Hinosawa and Capsule contributors | MIT license */
2 changes: 1 addition & 1 deletion docs/dist.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*! Cell v0.2.1 | Copyright 2024 Yoshiya Hinosawa and Capsule contributors | MIT license */
import { documentReady, logEvent } from "./util.ts";
export { signal } from "./signal.ts";
export { signal } from "@kt3k/signal";

interface Initializer {
// deno-lint-ignore no-explicit-any
Expand Down
105 changes: 0 additions & 105 deletions signal.ts

This file was deleted.

65 changes: 0 additions & 65 deletions signal_test.ts

This file was deleted.

0 comments on commit 9e17fcd

Please sign in to comment.