• Stars
    star
    102
  • Rank 335,584 (Top 7 %)
  • Language
    JavaScript
  • Created about 9 years ago
  • Updated almost 9 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Let the classes on DOM elements generate the CSS for you.

Furnish JS

Let the classes on DOM elements generate the CSS for you.

Furnish JS is simple lightweight, ~2KB when minified, utility that turns the classes applied upon the DOM elements to CSS. So that you don't have to manually write the CSS for those minor UI enhancements like increasing the padding, adding a little margin, changing the font size, applying a border radius, pumping up the line-height a bit etc. All you have to do is specify the CSS class on an element at any point of timea i.e. either dynamically or statically, it will be furnished.

How to Install?

  • You can install the utility via Bower:

    bower install idnan/furnish-js
    

    Or directly download the repository and place the content of dist wherever you can access them.

  • Include the dom-funish.min.js or dom-furnish.js and you are ready to use the magic of it.

How to Use

In order to use it, all you have to specify from the set of classes in a specific format i.e. in the form of

[formula][value][unit] # If you donot provide the unit, `px` will be used.

And run

// Furnish all the elements in div#some-elem
var domElem = document.getElementById('some-elem')
Funish.apply(domElem)

or if you want to run it over the whole document

Furnish.apply()

domElem specifies the container whose children are to be furnished, passing nothing will furnish the whole document.

For example you can specify mt25 to apply top margin of 25px, fs14px to apply font size of 14 px etc. Also you can combine these formulas on an element as well for example an element may have class="mb20 pt10 pl15 lh20" etc.

Currently supported styles are as follows:

Formula CSS Property Example Usage
p padding p10 will translate to padding: 10px
pt padding-top pt20 will translate to padding-top: 20px;
pb padding-bottom pb10 will translate to padding-bottom: 10px;
pr padding-right pr20 will translate to padding-right: 20px;
pl padding-left pl23 will translate to padding-left: 23px;
m margin m20 will translate to margin: 20px
mt margin-top mt20 will translate to margin-top: 20px;
mb margin-bottom mb20 will translate to margin-bottom: 20px;
ml margin-left ml50 will translate to margin-left: 50px;
mr margin-right mr30 will translate to margin-right: 30px;
w width w200 will translate to width: 200px
h height h60 will translate to height: 60px;
br border-radius br5 will translate to border-radius: 5px;
fs font-size fs15 will translate to font-size: 15px
fw font-weight fw400 will translate to font-weight: 400px
lh line-height lh20em will translate to line-height: 20em
t top t6 will translate to top: 6px;
l left l30 will translate to left: 30px
b bottom b20em will translate to bottom: 20em;
r right r20em will translate to right: 20em;

Quick Usage Examples

Let's say that you have a heading and you want to apply bottom margin of 10px, you will do

<h1 class="mb10">Furnish JS</h1>
<p>Turn your classes to CSS</p>

Changing the font size to 15px

<p class="fs14px mt25 mb0 ml2em br30%">You can combine formulas as well</p>

Contributing

You can contribute to this project by

  • Adding the support for other CSS attributes. (Fork it, add your feature, create the pull request)
  • Pointing out any bugs or issues

More Repositories

1

bash-guide

A guide to learn bash
11,268
star
2

like-on-github

Chrome extension - Link a repository with the extension and automatically save the links to content you like
JavaScript
230
star
3

soundcloud-waveform-generator

Generates waveform like soundcloud.
JavaScript
127
star
4

trending-guides

List of trending guides on github curated over time
116
star
5

git-random

Chrome extension - Replaces new tab with random github user's profile
HTML
78
star
6

mjml-cms

Extended version of the MJML editor with support for dynamic templating.
TypeScript
40
star
7

github-pr

CLI tool to automatically create pull request on Github
Shell
36
star
8

go-mongo-indexer

CLI tool to manage mongo database collection indexes through json files
Go
26
star
9

tweet-cli

🐦 Tweet directly from your cli without any hassle
PHP
24
star
10

ts-grpc-example

gRPC example with typescript and nodejs
JavaScript
20
star
11

mysql-migrate

Version control your database with tiny one migration script
PHP
14
star
12

cut-url

Chrome Extension - To shorten your URLs in a Shortcut.
JavaScript
12
star
13

tevo

A jenkins tool to run jobs from command line
PHP
10
star
14

idnan.github.io

The code behind
CSS
9
star
15

docker-elk

The ELK stack powered by Docker and Compose
8
star
16

Easy-Tabs

Allows you to easily manage your tabs. Now you can easly pin/unpin, reload and hide/unhide with single clicks
JavaScript
6
star
17

docker-mmonit

MMonit docker
Dockerfile
6
star
18

composer-permission

Composer script handling directories permissions by making them writable
PHP
6
star
19

PHP-URLShortener

A basic URL shortener developed in PHP
PHP
5
star
20

raycast-utc-time

A simple raycast extension to quickly display and copy the current UTC time to the clipboard
Shell
4
star
21

jsLog

Displays logs in an overlay on top of your site. Useful for web development.
JavaScript
3
star
22

pong

A javascript version of the classic 1972 arcade game Pong!
JavaScript
3
star
23

jenkins-deploy

A jenkins tool to run jobs from command line
PHP
3
star
24

instanttag

HTML
2
star
25

vagrant-shell-provision

Script to provision Vagrant with shell
Shell
1
star