Skip to content

Commit affc2d6

Browse files
committed
Initial release.
0 parents  commit affc2d6

File tree

5 files changed

+212
-0
lines changed

5 files changed

+212
-0
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ratio Changelog
2+
3+
## [0.1.0] - 2015-03-31
4+
5+
* Initial release.

README.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Ratio
2+
3+
The `ratio` object simply causes media embeds – such as videos, slideshows, or
4+
even images to retain a specific aspect ratio.
5+
6+
## Dependencies
7+
8+
The `ratio` object depends on one other module:
9+
10+
* [settings.defaults](https://github.com/treeframework/settings.defaults)
11+
12+
If you install the `ratio` object using Bower, you will get these dependencies at
13+
the same time. If not using Bower, please be sure to install and `@import` these
14+
dependencies in the relevant way.
15+
16+
## Installation
17+
18+
You can install `ratio` object via npm, Git Submodule, or copy and paste.
19+
20+
### Install using Bower:
21+
22+
```sh
23+
$ bower install tree-ratio --save
24+
```
25+
26+
Once installed, `@import` into your project in its Object layer:
27+
28+
```scss
29+
@import "bower_components/tree-ratio/object.ratio";
30+
```
31+
32+
### Install using npm:
33+
34+
```sh
35+
$ npm install tree-ratio --save
36+
```
37+
38+
### Install as a Git Submodule:
39+
40+
```sh
41+
$ git submodule add [email protected]:treeframework/object.ratio.git
42+
```
43+
44+
Once installed, `@import` into your project in its Object layer:
45+
46+
```scss
47+
@import "trump.ratio/trump.ratio";
48+
```
49+
50+
### Install via file download
51+
52+
The least recommended option dor installation is to simply download
53+
`_object.ratio.scss` into your project and `@import` it into your project in its
54+
Objects layer.
55+
56+
## Usage
57+
58+
Basic usage of the `ratio` object uses the required classes:
59+
60+
```html
61+
<div class="ratio">
62+
<iframe class="ratio__item" src="..."></iframe>
63+
</div>
64+
```
65+
66+
## Options
67+
68+
Other, optional classes can supplement the required base classes:
69+
70+
* `.ratio--[3by1|2by1|16by9|4by3]`: alter aspect ratio.
71+
72+
For example:
73+
74+
```html
75+
<figure class="ratio ratio--4by3">
76+
<img class="ratio__item" src="path/to/image.jpg" alt="">
77+
</figure>
78+
```
79+
80+
## Credits
81+
82+
* **[inuitcss](https://github.com/inuitcss)** Powerful, Sass-based, OOCSS
83+
framework designed with scalability and performance in mind.
84+
85+
* **[SUIT CSS link utilities](https://github.com/suitcss/utils-link/)** SUIT
86+
CSS is a reliable and testable styling methodology for component-based UI
87+
development.

_object.ratio.scss

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
// *************************************
2+
//
3+
// #RATIO
4+
//
5+
// *************************************
6+
7+
// For use with media embeds – such as videos, slideshows, or even images –
8+
// * that need to retain a specific aspect ratio.
9+
10+
// Predefine the variables below in order to alter and enable specific features.
11+
$tree-ratio-namespace: $tree-namespace !default;
12+
13+
$tree-enable-ratio--3by1: false !default;
14+
$tree-enable-ratio--2by1: false !default;
15+
$tree-enable-ratio--16by9: false !default;
16+
$tree-enable-ratio--4by3: false !default;
17+
18+
19+
20+
21+
// 1. Default aspect ratio is 1:1.
22+
.#{$tree-ratio-namespace}ratio {
23+
position: relative;
24+
display: block;
25+
height: 0;
26+
padding-bottom: 100%; // [1]
27+
overflow: hidden;
28+
}
29+
30+
.#{$tree-ratio-namespace}ratio__item {
31+
position: absolute;
32+
top: 0;
33+
left: 0;
34+
bottom: 0;
35+
height: 100%;
36+
width: 100%;
37+
}
38+
39+
40+
41+
42+
43+
@if ($tree-enable-ratio--3by1 == true) {
44+
45+
// Ratio 3:1
46+
47+
.#{$tree-ratio-namespace}ratio--3by1 {
48+
padding-bottom: 33.33333%;
49+
}
50+
51+
}
52+
53+
@if ($tree-enable-ratio--2by1 == true) {
54+
55+
// Ratio 2:1
56+
57+
.#{$tree-ratio-namespace}ratio--2by1 {
58+
padding-bottom: 50%;
59+
}
60+
61+
}
62+
63+
@if ($tree-enable-ratio--16by9 == true) {
64+
65+
// Ratio 16:9
66+
67+
.#{$tree-ratio-namespace}ratio--16by9 {
68+
padding-bottom: 56.25%;
69+
}
70+
71+
}
72+
73+
@if ($tree-enable-ratio--4by3 == true) {
74+
75+
// Ratio 4:3
76+
77+
.#{$tree-ratio-namespace}ratio--4by3 {
78+
padding-bottom: 75%;
79+
}
80+
81+
}

bower.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"name": "tree-ratio",
3+
"version": "0.1.0",
4+
"homepage": "https://github.com/treeframework/object.ratio",
5+
"author": "Ilia Kolev <[email protected]>",
6+
"description": "For use with media embeds – such as videos, slideshows, or even images – * that need to retain a specific aspect ratio.",
7+
"main": "_object.ratio.scss",
8+
"keywords": [
9+
"oocss",
10+
"css"
11+
],
12+
"license": "MIT",
13+
"dependencies": {
14+
"tree-defaults": "~0.2.5",
15+
}
16+
}

package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "tree-ratio",
3+
"description": "For use with media embeds – such as videos, slideshows, or even images – * that need to retain a specific aspect ratio.",
4+
"version": "0.1.0",
5+
"author": "Ilia Kolev <[email protected]>",
6+
"bugs": {
7+
"url": "https://github.com/treeframework/object.ratio/issues"
8+
},
9+
"dependencies": {
10+
"tree-defaults": "~0.2.5",
11+
},
12+
"homepage": "https://github.com/treeframework/object.ratio",
13+
"keywords": [
14+
"oocss",
15+
"css"
16+
],
17+
"license": "MIT",
18+
"main": "_object.ratio.scss",
19+
"repository": {
20+
"type": "git",
21+
"url": "https://github.com/treeframework/object.ratio.git"
22+
}
23+
}

0 commit comments

Comments
 (0)