Skip to content

Commit

Permalink
Merge pull request #9 from joaocunha/HouseKeeping
Browse files Browse the repository at this point in the history
House keeping
  • Loading branch information
joaocunha committed Oct 28, 2015
2 parents 1e407d6 + 09d6fdd commit 3096e62
Show file tree
Hide file tree
Showing 11 changed files with 732 additions and 869 deletions.
15 changes: 15 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# EditorConfig
# http://editorconfig.org

root = true

[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tabs
insert_final_newline = true
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*.sublime*
.DS_Store
59 changes: 35 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,42 @@ vUnit is a vanilla JS microlib (~600 bytes after gzip) that allows you to size e
**Second:** add the script to the `<head>` tag and instantiate `vUnit` passing a `CSSMap` object:
```html
<head>
<script src="vunit.js"></script>
<script>
new vUnit({
CSSMap: {
// The selector (VUnit will create rules ranging from .selector1 to .selector100)
'.vh_height': {
// The CSS property (any CSS property that accepts px as units)
property: 'height',
// What to base the value on (vh, vw, vmin or vmax)
reference: 'vh'
},
// Wanted to have a font-size based on the viewport width? You got it.
'.vw_font-size': {
property: 'font-size',
reference: 'vw'
},
// vmin and vmax can be used as well.
'.vmin_margin-top': {
property: 'margin-top',
reference: 'vmin'
}
}
}).init(); // call the public init() method
</script>
<!-- Add vUnit.js to the head to avoid FOUC -->
<script src="path/to/vunit.js"></script>

<!-- Instantiate vUnit.js passing a CSSMap with properties you want to play with -->
<script>
new vUnit({
CSSMap: {
// The selector (VUnit will create rules ranging from .selector1 to .selector100)
'.vh_height': {
// The CSS property (any CSS property that accepts px as units)
property: 'height',
// What to base the value on (vh, vw, vmin or vmax)
reference: 'vh'
},
// Wanted to have a font-size based on the viewport width? You got it.
'.vw_font-size': {
property: 'font-size',
reference: 'vw'
},
// vmin and vmax can be used as well.
'.vmin_margin-top': {
property: 'margin-top',
reference: 'vmin'
}
},
onResize: function() {
console.log('A screen resize just happened, yo.');
}
}).init(); // call the public init() method
</script>
</head>
<body>
<h1 class="vw_font-size15">This title font-size is 15% of the viewport width.</h1>
<p class="vh_height50">This p's height is 50% of the viewport height.</p>
<p class="vmin_margin-top5">This p has some margin-top<p>
</body>
```

**Third:** Add the generated classes to your HTML elements:
Expand Down
45 changes: 25 additions & 20 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{
"name": "vunit",
"description": "A vanilla JS alternative to vh/vw and vmin/vmax CSS units.",
"license": "MIT",
"version": "v0.1.0",
"main": "vunit.js",
"author": "João Cunha <[email protected]> (http://twitter.com/joaocunha)",
"homepage": "http://joaocunha.github.io/vunit/",
"keywords": [
"js",
"viewport",
"css",
"vh",
"vw",
"vmin",
"vmax"
],
"ignore": [
"*.md",
"example"
]
"name": "vunit",
"description": "A vanilla JS alternative to vh/vw and vmin/vmax CSS units.",
"license": "MIT",
"main": "src/vunit.js",
"author": "João Cunha <[email protected]> (http://twitter.com/joaocunha)",
"homepage": "http://joaocunha.github.io/vunit/",
"moduleType": "globals",
"keywords": [
"js",
"javascript",
"viewport",
"css",
"vh",
"vw",
"vmin",
"vmax"
],
"ignore": [
"*.md",
"example"
],
"repository": {
"type": "git",
"url": "[email protected]:joaocunha/vunit.git"
}
}
12 changes: 12 additions & 0 deletions dist/vunit-0.2.0.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3096e62

Please sign in to comment.