Skip to content

Commit a683c71

Browse files
committed
Merge pull request #9 from cssrecipes/feat.flexbox
Added: flexbox Grid
2 parents 7d853cc + 43a0bfe commit a683c71

File tree

6 files changed

+51
-19
lines changed

6 files changed

+51
-19
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# 1.0.0 - 2015-05-30
2+
3+
- added flexbox grid
4+
15
# 0.4.0 - 2014-11-08
26

37
- update org prefix to `r`

README.md

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,20 @@
88
$ npm install cssrecipes-grid
99
```
1010

11+
Default grid implementation is using inline-block+font-size 0 method:
12+
1113
```css
1214
@import "./node_modules/cssrecipes-grid/index.css";
1315
```
1416

17+
If you want, an alternative grid based on flexbox is available in cssrecipes-grid/flex.
18+
19+
```css
20+
@import "./node_modules/cssrecipes-grid/flex.css";
21+
```
22+
23+
Both rely on same classes, so generic documentation below should works both implementations"
24+
1525
_Advice: you can use size utilities from [`cssrecipes-utils`](http://github.com/cssrecipes/utils) for convenience.
1626
It includes `.r-(all|min|max)*` classes used in the examples below to define grid cells width._
1727

@@ -42,7 +52,6 @@ First of all, you can override all these custom properties according to your nee
4252
```css
4353
:root {
4454
--r-Grid-baseFontSize: 1rem;
45-
--r-Grid-baseFontSizeFallback: 16px;
4655
--r-Grid-gutter: 1rem; /* used for .r-Grid--withGutter */
4756
}
4857
```

flex.css

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@import "./lib/base.css";
2+
3+
.r-Grid {
4+
display: flex;
5+
}
6+
.r-Grid-cell {
7+
display: block;
8+
font-size: var(--r-Grid-baseFontSize);
9+
}
10+
11+
.r-Grid-cell--alignTop {margin-bottom: auto }
12+
.r-Grid-cell--alignMiddle {margin-top: auto; margin-bottom: auto }
13+
.r-Grid-cell--alignBottom {margin-top: auto }

index.css

+1-15
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,12 @@
1-
:root {
2-
--r-Grid-baseFontSize: 1rem;
3-
--r-Grid-baseFontSizeFallback: 16px;
4-
--r-Grid-gutter: 1rem;
5-
}
1+
@import "./lib/base.css";
62

73
.r-Grid {
84
display: block;
95
font-size: 0; /* whitespace control */
10-
padding: 0;
11-
margin: 0;
126
}
13-
/* Modifier --withGutter */
14-
.r-Grid--withGutter { margin: 0 calc(-0.5 * var(--r-Grid-gutter)) }
15-
16-
.r-Grid--withGutter > .r-Grid-cell { padding: 0 calc(0.5 * var(--r-Grid-gutter)) }
17-
187
.r-Grid-cell {
198
display: inline-block;
209
vertical-align: top;
21-
font-size: var(--r-Grid-baseFontSize, var(--r-Grid-baseFontSizeFallback));
22-
width: 100%;
23-
padding: 0;
2410
}
2511

2612

lib/base.css

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
:root {
2+
--r-Grid-baseFontSize: 1rem;
3+
--r-Grid-gutter: 1rem;
4+
}
5+
6+
.r-Grid {
7+
padding: 0;
8+
margin: 0;
9+
}
10+
/* Modifier --withGutter */
11+
.r-Grid--withGutter { margin: 0 calc(-0.5 * var(--r-Grid-gutter)) }
12+
13+
.r-Grid--withGutter > .r-Grid-cell { padding: 0 calc(0.5 * var(--r-Grid-gutter)) }
14+
15+
.r-Grid-cell {
16+
font-size: var(--r-Grid-baseFontSize);
17+
width: 100%;
18+
padding: 0;
19+
}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cssrecipes-grid",
3-
"version": "0.4.0",
3+
"version": "1.0.0",
44
"description": "BEMish grid component",
55
"keywords": [
66
"browser",
@@ -27,14 +27,15 @@
2727
"CHANGELOG.md",
2828
"LICENSE",
2929
"lib",
30-
"index.css"
30+
"index.css",
31+
"flex.css"
3132
],
3233
"devDependencies": {
3334
"cssnext": "^0.4.0"
3435
},
3536
"scripts": {
3637
"setup": "npm install && mkdir -p build",
37-
"preprocess": "cssnext index.css build/index.css",
38+
"preprocess": "cssnext index.css build/index.css && cssnext flex.css build/flex.css",
3839
"build": "npm run setup && npm run preprocess",
3940
"preprocess-test": "cssnext test/test.css build/test.css",
4041
"build-test": "npm run setup && npm run preprocess-test",

0 commit comments

Comments
 (0)