Skip to content

Commit 3d9018d

Browse files
authored
Merge pull request #9 from oscmedgon/development
Fixed bug where the content can resize the size of a column
2 parents ddf9667 + e1a9efd commit 3d9018d

File tree

8 files changed

+14
-9
lines changed

8 files changed

+14
-9
lines changed

build/index.js

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

build/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/components/Grid.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/main.css.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-grid-easy",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "A react grid system using css grid",
55
"main": "lib/index.js",
66
"repository": {

sass/_cssGrid.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@
3030
& > :not([class*="col"]) {
3131
grid-column: span $cols
3232
}
33-
grid-template-columns: repeat($cols, 1fr);
33+
--template-col: calc(var(--column) - var(--gap));
34+
grid-template-columns: repeat($cols, var(--template-col));
3435
&.vertical-grid {
3536
grid-template-rows: repeat($cols, 1fr);
3637
}
3738
& .row {
38-
grid-template-columns: repeat($cols, 1fr);
39+
grid-template-columns: repeat($cols, var(--template-col));
3940
& > :not([class*="col"]) {
4041
grid-column: span $cols
4142
}

src/components/Grid.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,16 @@ export default class Grid extends Component {
1919
className: 'grid-parent'
2020
}
2121
};
22+
let columnGap;
23+
params.grid.style['--column'] = `${100 / divisions}%`;
2224
if (['string', 'number'].includes(typeof gap)) {
2325
params.grid.style.gridGap = gap;
26+
params.grid.style['--gap'] = `${((divisions - 1) * gap) / divisions}px`;
2427
} else if (typeof gap === 'object' && gap && !Array.isArray(gap)) {
2528
const {column = 21, row = 21} = gap;
2629
params.grid.style.rowGap = row;
2730
params.grid.style.columnGap = column;
31+
params.grid.style['--gap'] = `${((divisions - 1) * column) / divisions}px`;
2832
} else {
2933
const error = new Error('Expected gap to be string, number or object.');
3034
console.error(error.stack)
@@ -39,7 +43,7 @@ export default class Grid extends Component {
3943
}
4044
return (
4145
<section {...params.parent}>
42-
<section {...params.grid}>
46+
<section {...params.grid} data-gap={columnGap}>
4347
{children}
4448
</section>
4549
</section>

0 commit comments

Comments
 (0)