Coder Social home page Coder Social logo

vanilla-components's Introduction

Vanilla JavaScript Components

Components:


Star Rating

Usage:

In the HTML, link the stylesheet:

<link rel="stylesheet" href="star-rating.css">

Also in the HTML, use the component like this:

<div class="star-rating" data-rating="0"></div>
<div class="star-rating" data-rating="1"></div>
<div class="star-rating" data-rating="1.2" rating-sticky></div>
<div class="star-rating" data-rating="2"></div>
<div class="star-rating" data-rating="2.9" rating-readonly></div>
<div class="star-rating" data-rating="3"></div>
<div class="star-rating" data-rating="4"></div>
<div class="star-rating" data-rating="4.4"></div>
<div class="star-rating" data-rating="4.6"></div>
<div class="star-rating" data-rating="5"></div>

In the JavaScript:

import initStarRatings from "./star-rating.js";
initStarRatings();

Modal

Usage:

In the HTML, link the stylesheet:

<link rel="stylesheet" href="modal.css">

Also in the HTML, use the component like this:

<div class="modalContainer">
    <div class="modalBody">
        <!-- This modalBody will completely move to the modalPlace once the modal is opened using the below modalOpener button -->
    </div>
    <button class="modalOpener">Open Modal</button>
</div>

Also in the HTML, this is required for displaying the modal ("modalBody"s are moved in it):

<div class="modalWrapper hidden">
    <div class="modalPlace"></div>
</div>

In the JavaScript:

import constructModal from "./modal.js";
const modalContainer = document.querySelector(".modalContainer");
constructModal(
    modalContainer,
    function onOpen(modalPlace, container) {},
    function onClose(modalPlace, container) {}
);

vanilla-components's People

Contributors

aderchox avatar

Stargazers

 avatar

Watchers

 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.