Code Monkey home page Code Monkey logo

doz's Introduction







Almost like writing in VanillaJS. For modern browser.



Documentation | API | Demo | Browse example code

๐Ÿ‘‰ SEE A PROJECT BUILT WITH DOZ ๐Ÿ‘ˆ


Look at the code on Codepen

Why

  • ๐ŸŽผ Works with tagged template literals
  • ๐ŸŽณ Component based
  • ๐Ÿงฉ WebComponent ready
  • ๐Ÿช Global stores
  • ๐Ÿ˜† Global components
  • ๐Ÿ”ซ Fast performance
  • ๐Ÿ’… Scoped style
  • ๐Ÿ“ก Uses ES6 proxy to observe changes
  • ๐Ÿ˜ Simple and familiar API
  • ๐Ÿ˜ฑโ€ No extra syntax like JSX
  • ๐Ÿ’ฃ No confusion with props and state
  • โ› Extensible through: plugins, mixin, components
  • ๐Ÿ“ฝ CSS animation support

Get started

$ npx doz-cli app my-app
$ cd my-app
$ npm start

Example

<div id="app"></div>

Component definition

ButtonCounter.js

import {Component} from 'doz'

export default class ButtonCounter extends Component {
    
    constructor(o) {
        super(o);
        this.props = {
            counter: 0
        };
    }

    template(h) {
        return h`
            <style>
                button {
                    font-size: 16px;
                    padding: 20px;
                }
            </style>

            <button onclick="${this.increase}">
                count ${this.props.counter}
            </button>
        `
    }
    
    increase() {
        this.props.counter++;
    }

};

Make an app with the component defined above

app.js

import {appCreate} from 'doz'
import ButtonCounter from './ButtonCounter'

appCreate('#app', ButtonCounter);

Doz ecosystem

  • ๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป doz-cli provides a boilerplate to creating app and component
  • ๐Ÿ‘จ๐Ÿผโ€๐ŸŽจ doz-ssr server side rendering
  • ๐Ÿคณ๐Ÿผ doz-snap transforms app to static HTML
  • ๐Ÿ‘ฉ๐Ÿผโ€๐Ÿš€ doz-router a complete component for routing
  • โœ๐Ÿผ doz-metatag a plugin for managing basic OG meta tag in your app (perfect with doz-ssr)

CDN unpkg

<script type="module">
    import {Component} from 'https://unpkg.com/doz/dist/doz.min.js'
    //...
</script>

Changelog

You can view the changelog here

License

Doz is open-sourced software licensed under the MIT license

Author

Fabio Ricali

doz's People

Contributors

dependabot[bot] avatar fabioricali avatar plembo90 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

doz's Issues

Spaces inside loop

if there are spaces characters after the wrapper tag of the loop, the loop fails and it returns a string like this "[object Object],[object Object],[object Object]...".

sitemap

Is there a sitemap plugin already?

Transform props to attributes

Sometimes it could be useful.
Like so:

    propsToAttributes() {
        let out = '';
        Object.keys(this.props).forEach(name => {
            out += `${name}="${this.decode(this.props[name])}" `;
        });
        return out;
    }
<img ${this.propsToAttributes()} 

I need to decode HTML entities

    decode(str) {
        decoder = decoder || document.createElement('textarea');
        decoder.innerHTML = str;
        return decoder.value;
    }

Bind bug

When set a props with 0 number, the bind don't work.

Please fix it

dynamic select field fail

Update for a select bind to a prop fails with dynamic options.
Maybe it happens with numeric values...

Passing props object as argument

It might be useful to pass the props object as an argument to the template function.
Like:

template(h, props)  {
    return h`
          <div>${props.name}</div>
    `
} 

scoped style and comment

The comments are not considered.

This
/*.grid-row img { }*/
is converted to

[data-uid=...] /*.grid-row img { }*/

animation in css

The component style does not support the short definition like:

<style>
.my-class {
    animation: 1s blink ease infinite;
}
</style>

this works:

<style>
.my-class {
    animation-name: blink;
    animation-duration: 1s;
    animation-timing-function: ease;
    animation-iteration-count: infinite;
}
</style>

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.