Coder Social home page Coder Social logo

doars / doars Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 1.0 11.13 MB

Build reactive web pages without leaving your HTML.

Home Page: http://doars.js.org/

License: MIT License

JavaScript 98.22% CSS 1.24% HTML 0.54%
front-end framework declarative reactive plugins html javascript js-framework

doars's Introduction

Project logo

Doars

Build reactive websites without leaving your HTML. Ditch the hassle with other frameworks. Doars is a declarative and light solution that scans the webpage then processes the instructions found as well as keep the state and content up-to-date.

You can write logic directly in your layout, as a result you have to simply look at the HTML to read what the elements do. You won't need to dig through other files because the functionality is written on the structure itself.

<!-- Add library to the document from a CDN. -->
<script src="https://cdn.jsdelivr.net/npm/@doars/doars@2/dst/doars.iife.js"></script>
<script>
  // Wait for the DOM to be interactive.
  document.addEventListener('DOMContentLoaded', () => {
    // Setup a library instance.
    const doars = new window.Doars()
    // Enable library.
    doars.enable()
  })
</script>

<!-- Define component with a list of messages. -->
<div d-state="{ messages: [ 'Hello there!', 'General Kenobi.' ] }">
  <!-- Create a list item for each message. -->
  <ol>
    <template d-for="message of messages">
      <li d-text="message"></li>
    </template>
  </ol>

  <!-- Store input as a reference. -->
  <input type="text" d-reference="input">

  <!-- On click add input value to the messages. -->
  <button d-on:click="messages.push($references.input.value); $references.input.value = ''">
    Add
  </button>
</div>

But don't worry, the markup is still yours! We promise we won't take it away. You can still modify the document directly in your own code and the library will do all the work to stay up to date.

Use as much or as little as you want. Doars can easily be added to an existing server side rendered or statically generated project because this solution doesn't force you to adopt an application wide architecture. You only need to load the library onto the page and add instructions in the form of attributes to your layouts.

Packages

This mono-repository includes the core library as well as several plugins. See the full list below or the packages directory.

Name Description
@doars/doars The core library, it manages the components and plugins as well as includes the basic contexts and directives.
@doars/doars-fetch Plugin that adds a fetch context that handles parsing the returned content.
@doars/doars-intersect Plugin that adds an intersect directive for reacting to intersection changes.
@doars/doars-navigate Plugin that adds a navigation directive that loads pages without unloading the current page by listening to anchor tags.
@doars/doars-persist Plugin that adds cookies, local storage, and sessions storage contexts to get and set persistent data.
@doars/doars-router Plugin that adds a router context with set of directives to control it.
@doars/doars-update Plugin that adds an update loop context and directive.

Contributing

If you are using the library and are running into an problem that you don't know how to solve, or would love to see a particular feature then feel free to create an issue. Or perhaps you want to make that cool feature, or help out in any other way. Then you are more then welcome! Read more about how to contribute.

In the wild

If you are using Doars then please let me know, I would love to hear about it!

Ideas

  • Input masking plugin for formatting dates, money et cetera.
  • Visibility directives similar to intersection plugin.
  • Sensor plugin for accessing the accelerometer, gyroscope et cetera.
  • Realtime shared state between clients using WebRTC.

doars's People

Contributors

redkenrok avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

fossabot

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.