Giter VIP home page Giter VIP logo

tent's Introduction

⛺ Tent

A jsx-free, super-lightweight and zero-dependency library to add reactivity to the web — without all the nonsense.

Important

Tent is currently in early development. It can be used in production, but there might be breaking changes in future versions. If you're interested in contributing, please submit a PR or report an issue. Keep track of the changes in the CHANGELOG.

⚙️ Installation

npm install @tentjs/tent

⚡ Quickstart

Getting started is very easy. Here's a simple example component that increments a number when the button is clicked. This example demonstrates creating a stateful component, updating the state, and mounting it to the DOM.

import { type Component, mount, tags } from '@tentjs/tent';

// Tags are used to create elements - like `div`, `button`, `span`, etc.
const { button } = tags;

type State = { count: number };

const Counter: Component<State> = {
  // Initial state
  state: { count: 0 },
  // Define the view
  view({ state }) {
    return button(
      `You clicked ${state.count} times`,
      // Add attributes to the button
      { onclick: () => state.count++ },
    );
  },
};

// Append the component to an element in the DOM
mount(document.querySelector('.counter'), Counter);

💡 Examples

You can find examples for building a simple counter, todo list, a form and more in the examples repository.

👍🏻 Contribute

If you want to support the active development of Tent, there are a few ways you can help:

  1. Give a ⭐ — bring attention to the project.
  2. Tweet about it — share your excitement.
  3. Get involved — join the discussions.
  4. Contribute — submit a pull request.
  5. Buy me a ☕ — thank you for your support!

tent's People

Contributors

sebkolind avatar

Stargazers

Greg DeCarlo avatar Tanmay Agrawal avatar omar avatar Jatin avatar Ikechukwu Charles avatar Bluzzi avatar Luiz Felipe avatar Jakob Gaard Andersen avatar Carlos Vieira avatar Florian avatar Hamada Fadil Mahdi avatar Emil Godsk avatar  avatar

Watchers

 avatar

tent's Issues

Require setting `state` if given to the `Component` generic

When using the Component generic and setting type for the state, the state property of the component should be required.

type State = { count: number }

// Should give you a type error
const Counter: Component = {
  view: ({ state }) => p(`Count: ${state.count}`)
}

// Should be OK!
const Counter: Component<{ count: number }> = {
  state: { count: 0 },
  view: ({ state }) => p(`Count: ${state.count}`)
}

Add examples to `README.md`

It would be nice to add some examples to the readme file. This gives a quick way to see what the library can do.

`release.yml` using node 16

GitHub gives a warning regarding the release ci script is using node 16. It should be upgraded to use node 20 instead.

It might be the release action that needs to be updated.

Up test coverage on `walker.ts`

There are a couple of sections of the walker.ts file that are not covered by tests. It would be nice to handle that with some simple tests.

Should be done in the src/__tests__/walker.test.ts file.

image.png

Changing root node to different tag fails

When the root node goes from one tag to another an error occurs.

Example: When div becomes p.

I believe the entire node should be replaced, since it's not possible to diff on the view any longer - until next iteration, that is.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.