GithubHelp home page GithubHelp logo

davidvujic / vanillajs-components Goto Github PK

View Code? Open in Web Editor NEW
40.0 3.0 6.0 516 KB

You might (not) need a JavaScript framework

Home Page: https://davidvujic.github.io/vanillajs-components/

HTML 14.71% JavaScript 63.51% CSS 21.79%

vanillajs-components's Introduction

You might (not) need a JavaScript framework

In this repo, you will find examples on how to create a web site with reusable building blocks (aka components). When learning about React and components, I started thinking about how this could be done without using React, ES 2016, Webpack or any other framework out there. Is that even possible?

Okay, but why?

I want to understand the problems that are solved using React, ES 201x, Webpack & friends. I guess one way is to experience it the hard way - to feel the pain - by writing code with plain old vanilla JavaScript, html and css.

The source code in the main branch of this repo is written with Old School vanilla JavaScript, without any frameworks, without a build system and without a transpiler.

Blog post

There is also a blog post related to this repo: http://davidvujic.blogspot.se/2017/01/you-might-not-need-a-javascript-library.html

Examples

The listItem.js component

vanilla.listItem = (function (templates) {

    function render(props, done) {

        // load the html using a template helper
        templates.load('/src/listItem/listItem.html', function (el) {

            // set data
            el.textContent = props.data;
            el.addEventListener('click', props.onClick);

            if (done) {
                // pass the node to be rendered to the DOM
                done(el);
            }
        });
    }

    return {
        render: render
    };

}(templates));

The listItem.html template

<li class="listItem" title="the listItem component"></li>

Here's an example web page with vanilla components:

https://davidvujic.github.io/vanillajs-components/

Setup

Clone this repo and start experimenting! To browse the example web page, run these commands:

npm install
npm start

When switching between the branches (see below), you might need to run the npm install command again (because of the different dependencies used).

What next?

To step by step add tools & frameworks, that will solve current issues and improve the quality & readability of the code base.

Something like this (each one in a separate branch):

vanillajs-components's People

Contributors

davidvujic avatar dependabot[bot] avatar

Stargazers

detpik avatar  avatar Anny Fan avatar  avatar Yair Tavizon avatar sarath avatar Salvatore Tosti avatar Michael Salihi avatar Oleksii Tsyliuryk avatar Csaba Szilveszter-Berei avatar  avatar Derek Martin avatar 김동하 avatar Future Infinity avatar J.D avatar Yosef Enmanuel Blandin Rios avatar Abdessalam Benharira avatar  avatar Jin Yao avatar Suhyun Jeon avatar Hallison Batista avatar  avatar Sarfraz Ahmed avatar Vu Tran avatar Ian DesJardins avatar Neeraj Kanhere avatar Nikita Pilgrim avatar Watermelon Puppet avatar Akhil avatar  avatar Dalton Jorge avatar Stephen Griffiths avatar Hector Romo avatar Dennis avatar Anix avatar Axel Möllerberg avatar Johan Martin avatar Amit Erandole avatar Ed Gim avatar Baki Goxhaj avatar

Watchers

 avatar James Cloos avatar  avatar

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.