Git Product home page Git Product logo

tab-component's Introduction

A tab component which creates all of HTML, takes all data from JSON object and where a user can create new tabs. It can display large amount of tabs, when there is not enough space, a user can scroll through tabs. It's made in JavaScript only so it doesn't have any dependencies.

How it looks like:

Without styling:

  • Just add (or copy) styles.css file Image of unstyled tab component

With styling:

  • Add (or copy) both styles.css file and pretty-styles.css. Form styling is also in this file. Image of styled tab component

How to use:

For tab:

The component needs just an element with id of "tabs" for basic tabs without styling. Rest of HTML will be generated by the component. For tab with styling you need to wrap tabs element by another element with "tab-wrapper" class:

<div class="tab-wrapper">
  <div id="tabs">
    <img class="unicorn" src="unicorn-head-silhouette.svg">
  </div>
</div>

For form:

You need to push form values to tabData. Each tab should have tabButton, tabTitle and tabText. Also call unicornTabs.newTab(); to print it and let unicornTabs = new UnicornTabs(); to instantiate it.

Example of form needed:

let unicornTabs = new UnicornTabs();

    function newTabFormData(e) {
        e.preventDefault();

        let newTabButtonValue = document.getElementById('newTabButton').value;
        let newTabTitleValue = document.getElementById('newTabTitle').value;
        let newTabTextValue = document.getElementById('newTabText').value;
		
        var addNewTab = {"tabButton":newTabButtonValue, "tabTitle":newTabTitleValue, "tabText":newTabTextValue}
        tabData.push(addNewTab);


        unicornTabs.newTab();
        alert("New tab have been added");
    }

    form.addEventListener('submit', newTabFormData);

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.