Skip to content

Commit c15f6ff

Browse files
committed
Fixed unitless @container queries
Fixes #6
1 parent ae21ae4 commit c15f6ff

6 files changed

+35
-15
lines changed

CHANGELOG.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# CHANGELOG
2+
3+
## 1.0.2 (2017-01-22)
4+
5+
- BUGFIX (#6): Fixed unitless @container queries
6+
- Upgraded Jest from v18 to v19
7+
8+
9+
## 1.0.1 (2017-01-21)
10+
11+
- Removed coverage/ and .babelrc from the installed package, hence making it a bit lighter.

README.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,16 @@ change at any time. (Including minor / patch releases.)
3232
- Example function to save all container configurations in separate JSON files in a dir
3333
- Gulp example
3434
- PostCSS example
35-
- SASS example
36-
- Less -> no-go
35+
- SASS example: works out of the box
36+
- Less -> separate pipeline
3737
- Containers can have more than one instance of their elements
3838
- The container units are relative to the container's "inner" height / width.
3939
(Without the borders.)
4040
- Note possible circular issues
4141
- A container should not use container units for properties that would affect
4242
its width / height. These situations are not currently handled, so try to
4343
avoid them.
44+
45+
##
46+
- To avoid circular deps, use overflow: hidden and avoid using container units on defined containers
47+
- Use native CSS techniques to achieve your goal whenever possible (css grid, flexbox)

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@zeecoder/container-query",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A PostCSS plugin and Javascript runtime combination, which allows you to write @container queries in your CSS the same way you would write @media queries.",
55
"main": "index.js",
66
"author": "Viktor Hubert <[email protected]>",
@@ -25,6 +25,7 @@
2525
],
2626
"license": "MIT",
2727
"dependencies": {
28+
"jest": "^19.0.1",
2829
"lodash.camelcase": "^4.3.0",
2930
"lodash.trim": "^4.5.1",
3031
"postcss": "^5.2.13"

src/postcss/containerQuery.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ test('proper json and css output', () => {
7676
line-height: 100${HEIGHT_UNIT}px;
7777
}
7878
79-
@container (height >= 100) and (width >= 100) {
79+
@container (height >= 100px) and (width >= 100px) {
8080
.container {
8181
font-size: 70${HEIGHT_UNIT}px;
8282
}
8383
}
8484
85-
@container (height >= 100) {
85+
@container (height >= 100px) {
8686
.container {
8787
background: none;
8888
}
@@ -151,8 +151,8 @@ test('proper json and css output', () => {
151151
},
152152
{
153153
"conditions": [
154-
[ "height", ">=", "100" ],
155-
[ "width", ">=", "100" ],
154+
[ "height", ">=", 100 ],
155+
[ "width", ">=", 100 ],
156156
],
157157
"elements": [
158158
{
@@ -165,7 +165,7 @@ test('proper json and css output', () => {
165165
},
166166
{
167167
"conditions": [
168-
[ "height", ">=", "100" ],
168+
[ "height", ">=", 100 ],
169169
],
170170
"elements": [
171171
{

src/postcss/getConditionsFromQueryParams.js

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,10 @@ export default function getConditionsFromQueryParams (params) {
1919

2020
conditionArr = conditionArr.map(trim);
2121

22+
if ([ 'landscape', 'portrait' ].indexOf(conditionArr[2]) === -1) {
23+
conditionArr[2] = parseInt(conditionArr[2]);
24+
}
25+
2226
return conditionArr;
2327
});
2428
}

src/postcss/getConditionsFromQueryParams.spec.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ import getConditionsFromQueryParams from './getConditionsFromQueryParams';
22

33
test('single condition should work with the "<", ">", "<=", ">=" and ":" operators', () => {
44
expect(getConditionsFromQueryParams('(width >= 42px)')).toEqual([
5-
[ 'width', '>=', '42px' ],
5+
[ 'width', '>=', 42 ],
66
]);
77
expect(getConditionsFromQueryParams('(width > 42px)')).toEqual([
8-
[ 'width', '>', '42px' ],
8+
[ 'width', '>', 42 ],
99
]);
1010
expect(getConditionsFromQueryParams('(width <= 42px)')).toEqual([
11-
[ 'width', '<=', '42px' ],
11+
[ 'width', '<=', 42 ],
1212
]);
1313
expect(getConditionsFromQueryParams('(width < 42px)')).toEqual([
14-
[ 'width', '<', '42px' ],
14+
[ 'width', '<', 42 ],
1515
]);
1616
expect(getConditionsFromQueryParams('(orientation: portrait)')).toEqual([
1717
[ 'orientation', ':', 'portrait' ],
@@ -24,10 +24,10 @@ test('single condition should work with the "<", ">", "<=", ">=" and ":" operato
2424
test('should handle multiple "and" conditions', () => {
2525
expect(getConditionsFromQueryParams('(orientation: landscape) and (width > 42px)')).toEqual([
2626
[ 'orientation', ':', 'landscape' ],
27-
[ 'width', '>', '42px' ],
27+
[ 'width', '>', 42 ],
2828
]);
2929
expect(getConditionsFromQueryParams('(width < 42px) and (height >= 42px)')).toEqual([
30-
[ 'width', '<', '42px' ],
31-
[ 'height', '>=', '42px' ],
30+
[ 'width', '<', 42 ],
31+
[ 'height', '>=', 42 ],
3232
]);
3333
});

0 commit comments

Comments
 (0)