Git Product home page Git Product logo

progre-c-ss's Introduction

#progre(c)ss

###Pure CSS progress bars with minimal effort

alt tag

Usage

  1. Include the stylesheet.
  2. Add the class progrecss to your element (any existing element)
  3. Add a data attribute data-progrecss defining the completion percentage (1 to 100) and any optional helper data attributes and classes for your desired behaviour/position/appearance* see helpers
  4. Update progre(c)ss value if necessary using simple vanilla js or whatever suits you best!

That's it!

    <div class="progrecss" data-progrecss="77">
		My first progre(c)ss!
	</div>
Browser Support

From what I can gather having a look at caniuse, progre(c)ss should be fully supported from IE10 up. This is purely because of transition, but if I remember rightly this can be shimmed.

Mocking progre(c)ss

You can easily mock progress by using the helper attributes and classes. Refer here.

Hooking into AJAX requests with progre(c)ss

A first attempt at hooking progre(c)ss into a simple AJAX request has been made and you can read about it here and see it here. Any help with this feature of progre(c)ss would be really appreciated.

Update: I came across this article on codersgrid.com which shows also a way of hooking into AJAX requests.

Helpers

There are some helper classes and attributes you can add to help you out!

######positioning classes

  • top(default) The default positioning for a progrecss bar is at the top of an element.
  • bottom Positions the progrecss bar at the bottom of the element.
  • fixed Gives a fixed position of 0,0 relative to the container of the element.

######color classes

  • blue(default)
  • green
  • red
  • purple
  • orange
  • yellow

######mocking attribute

  • data-progrecss-mock - takes a number value that defines duration of how long the mocked progress should take in seconds (up to 120).

######mocking classes

  • mock - required in order to initiate a mock.
  • staggered - will stagger the mock halting at different percentages (can be customised by altering source files).

######javascript helper At the request of some people I have added a small javascript helper to the repo.

It's real simple to use. Here is an example piece of code for using it.

var myProgrecss = new progrecss (document.body, {
	color: 'red',
	percent: 0,
	position: 'fixed',
	mock: {
		staggered: true,
		startMockOnCreate: false,
		mockDuration: 5
	}
})

The following options are available;

  • color - string - 'green', 'red', 'blue', 'purple', 'orange', 'yellow'.
  • percent - number - 0 to 100.
  • position - string - 'fixed', 'top', 'bottom'.
  • mock - object consisting of mock, mockDuration, and staggered
  • staggered - string - defines whether the mock will stagger.
  • mockDuration - number - defines how long the mock will take in seconds.
  • startMockOnCreate - bool - defines whether the progre(c)ss bar will mock straight away.

And the following methods;

  • setProgrecss(number percent) - sets percentage that progre(c)ss is complete.
  • startMock() - will initiate a progre(c)ss bar mock based on the options passed in.

How does this work?

Not surprisingly it's real simple! :)

progre(c)ss takes advantage of CSS pseudo elements and preprocessing tools such as less and sass.

making use of pseudo elements means that we can add progre(c)ss bars to any existing element on our page without being intrusive just by adding some attributes and classes as long as the elements pseudo elements aren't currently in use.

preprocessing tools such as less and sass mean we can write minimal code making use of looping in order to sit back and reap the benefits and drink a coffee!

Development/Customisation

progre(c)ss is developed with less/sass /scss making the actual amount of code written minimal in order to generate the stylesheet by making use of looping.

When using the less/sass/scss file there are already some variables in place so you can roll out a new theme easily.

Those variables are:

  • color
  • height
  • box-shadow
  • opacity
  • border-radius
  • transition(-webkit-transition)

Also to edit things like the way in which a staggered mock progress behaves you can modify the existing keyframes in place.

Contributing

Any suggestions, improvements or issues are welcome. :)

@jh3y

License

MIT

Copyright (c) 2014 @jh3y

progre-c-ss's People

Contributors

jh3y avatar pducks32 avatar ybur-yug avatar

Watchers

 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.