Giter Club home page Giter Club logo

panix's Introduction

Panix.js

panix js

npm GitHub file size in bytes

Panix is a tiny weight Virtual Dom library .
Today's Virtual Doms have easy syntax but they are heavy , very heavy .
Panix is one of the most lightweight (~1kb) virtual DOM implementations, and is a learning resource more than a tool you should actually use in production.

Installation

Or if you want to use npm :

npm i panix

and simply

import {node, createElement, update} from "panix"

Note : always add type="module" to your script when you are importing

Hello World

let's make a simple example in panix :

let el = createElement(node("h1", { id: "hello" },"Hello World"));
render(el, document.body); // render the element to the body
let newNode= node("h1", { id: "hello" },"Bye World");
let el = update(el, newNode); // update the element
render(el, document.body) // re-render

Timer

let timer = 0
let el = createElement(node("p",{id:"time"},"hello world"))
render(el, document.body);
setInterval(() => {
  timer++;
  document.body.removeChild(el)
  let newNode = node("p",{id:"time"},`${timer}`)
   el =update(newNode,el)
   render(el,document.body)
}, 1000);

API

node(tagName:[String],props:[object,null],Children:[array,string]): makes a Panix node object and returns it.

createElement(node:[Panix node]): Creates a DOM element and returns it. If children is an array would make a element in parent element

render(container:[element],el:[element]): Add el to container

update(newNode:[Panix Node], oldElement:[element]): Checks all diffrences between this two, Then return a element that is new one. It doesn't just replace them, It checks for each props,children to be same or not.

Thank you

Thanks to all of the people who starred panix :

Stargazers repo roster for @mehanalavimajd/panix

License

See license in LICENSE file

panix's People

Contributors

adabadadudu avatar dependabot[bot] avatar depfu[bot] avatar mehanalavimajd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

panix's Issues

Style function

@PooiaFerdowsi I think we should make a style funcion that is like this :

{
fontWeight:600,
color:red
} 
// to this 
["fontStyle : 600 ;" , "color : red"]

cannot pass null as props

I usually pass {} for props but this time I used null and it didn't work . I will work on it today or tomorrow.
also @PooiaFerdowsi do you know any body who can contribute?

`createElement` is not making the correct props

In the unit testing with jasmine, I understood that CreateElement doesn't make the correct attributes.

let  el = createElement({
      tag: "h1",
      props: { id: "hello" },
      children: "Hello world",
    });

will produce:

<h1 i="d">Hello world</h1>

Panix needs a website

Panix needs a website!

you do NOT need to put website at a new repository.

make a directory called 'site' ( or anything you want )

  1. go to settings
  2. select pages from left sidebar
  3. set configuration in source section and choose you directory (site) and you branch.

notice a mit license clause

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or **(note here)sell**
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

at first glance it's is ordinary for MIT LICENSE but in a closer look a attracts attention.
sell
this means any one can sell it with out any difference!
so if you want prevent it remove self and add following clause in LICENSE file

mit license with a restriction:
you can't sell

Running mount function

our Syntax is this:

mount(node("div" , {id:"hello"} , "hello world"))

That's fine but if we want to assign a variable :

let a = mount(node("div" , {id:"hello"} , "hello world"))

it will run again !!!
my idea is this :

let a = mount(node("div" , {id:"hello"} , "hello world"))
a.run()

and if we want to run it without declare a variable

mount(node("div" , {id:"hello"} , "hello world")).run()

do you agree @pooiaFerdowsi and @amirghazi87

Unit testing

The project hasn't been maintaining for about a year and so it has a lots of bugs. I am writing unit tests to find them.

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.