Giter Club home page Giter Club logo

cssstate's Introduction

cssState

Description

Libary to Manage States (like "LogedIn", "Public") of SinglePage HTML Sites using automated generated CSS classes.

You should use this cause

  • You can Hide or Show Menu Elements based on defined states
  • The result ist human readable as text
  • Show or hide Informations, Animations ect. based on global switches (expert mode / junior mode)

Installation

bower install cssState

You need to reference the css and js inside HTML site

<link href="css/cssState.css" rel="stylesheet">
<script src="js/cssState.js"></script>

During page onload you

  • define states
  • set start states
  • Activate Libary
cssState.add('login',['on','off']);
cssState.add('user',['public','admin','expert']);
cssState.login('off');
cssState.user('public');
cssState.init();

Requirements

JQuery is required

Classes

cssStateMain

Defines scope for cssState (body as default)

cssStateShowWhen {statename}_is_{value}

Show the element, if the state {statename} has the specific value {value}

cssStateHideWhen {statename}_is_{value}

Hide the element, if the state {statename} has the specific value {value}

cssStateController

Defines a place where the libary creates a debug control to change all states interactiv

Javascript Object

cssState.add({statename},[{value1},{value2},...]);

Add a state {statename} with possible values

cssState.init();

Definition is finished, compile states and add the result as local css style.

cssState.{statename}({value});

Activate a value {value} for state {statename}.
Can also be used to define start values for states before cssState.init()

Sample (--> sample.html)

<!DOCTYPE html>
<html lang="en">
<head>
    <link href="css/cssState.css" rel="stylesheet">
</head>
<body class="cssStateMain">
    <div class="cssStateShowWhen login_is_off">
        User is Loged out <button type="button" onclick="cssState.login('on')">Login...</button>
    </div>
    <div class="cssStateShowWhen login_is_on">
        User is Loged in<button type="button" onclick="cssState.login('off')">Logout...</button>
    </div>
    <div class="cssStateShowWhen user_is_admin" >I'm visible for Admins</div>
    <div class="cssStateHideWhen user_is_public" >Not Visible to Public</div>
    <div class="cssStateController">
        <!-- 
            a HTML Form to select the different state interactively is
            created inside this TAG
        -->
    </div>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>    
    <script src="js/cssState.js"></script>
    <script>
        /* Config states on Startup*/

        cssState.add('login',['on','off']);
        cssState.add('user',['public','admin','expert']);

        /* Set States on Startup */

        cssState.login('off');
        cssState.user('public');

        /* Startup using states currently set (compile CSS and add to Header Section) */
        cssState.init();

        /* 
            Form This point you can set the States using
             cssState.{statename}({state});
        */
    </script>
</body>
</html>

cssstate's People

Contributors

haeferer 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.