Last active
February 24, 2019 11:21
-
-
Save ianmcnally/3bc8fa64dc1fb35e47deeb7e449265ce to your computer and use it in GitHub Desktop.
Revisions
-
ianmcnally revised this gist
Oct 19, 2017 . No changes.There are no files selected for viewing
-
ianmcnally renamed this gist
Oct 19, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ianmcnally renamed this gist
Oct 19, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ianmcnally renamed this gist
Oct 19, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 10 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,7 +46,13 @@ const runPolyfill = () => { toArray(grids).forEach(placeItemsOnGrid) } const supportsGrid = typeof CSS !== 'undefined' && typeof CSS.supports !== 'undefined' && CSS.supports('display', 'grid') if (!supportsGrid) { // covers dynamic and static pages, at the cost of multiple DOM traversals window.addEventListener('popstate', runPolyfill) document.addEventListener('DOMContentLoaded', runPolyfill) document.body.addEventListener('DOMSubtreeModified', runPolyfill) } -
ianmcnally renamed this gist
Oct 19, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ .auto { -ms-grid-rows: auto; grid-template-rows: auto; } -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ .grid { display: -ms-grid; display: grid; } -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ .of12 { -ms-grid-columns: (1fr)[12]; grid-template-columns: repeat(12, 1fr); } -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,5 @@ import { columns, display, gridSpans, margin } from './css-modules-styles' const COLUMNS = 12 const toArray = arrayLike => Array.prototype.slice.call(arrayLike) -
ianmcnally revised this gist
Oct 19, 2017 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -45,8 +45,7 @@ const runPolyfill = () => { toArray(grids).forEach(placeItemsOnGrid) } // covers dynamic and static pages, at the cost of multiple DOM traversals window.addEventListener('popstate', runPolyfill) document.addEventListener('DOMContentLoaded', runPolyfill) document.body.addEventListener('DOMSubtreeModified', runPolyfill) -
ianmcnally created this gist
Oct 19, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ import { columns, display, gridSpans, margin } from 'design-system-styles' const COLUMNS = 12 const toArray = arrayLike => Array.prototype.slice.call(arrayLike) const placeItemsOnGrid = grid => { const withGutters = grid.classList.contains(columns.withGutters) let currentColumnSpansInRow = 0 let currentRow = 1 let currentColumn = 1 toArray(grid.children).forEach(row => { let columnSpan for (let i = 0; i <= COLUMNS; i++) { if (row.classList.contains(gridSpans[`column${i}`])) { columnSpan = i break } } const wouldNextSpansExceedColumnCount = currentColumnSpansInRow + Number(columnSpan) > COLUMNS if (wouldNextSpansExceedColumnCount) { currentRow += 1 currentColumnSpansInRow = 0 currentColumn = 1 } currentColumnSpansInRow = currentColumnSpansInRow + Number(columnSpan) row.style['-ms-grid-column-span'] = columnSpan row.style['-ms-grid-column'] = currentColumn row.style['-ms-grid-row'] = currentRow if (withGutters) { row.classList.add(margin.leftOne) } currentColumn += columnSpan }) } const runPolyfill = () => { const grids = document.getElementsByClassName(display.grid) toArray(grids).forEach(placeItemsOnGrid) } setTimeout(runPolyfill, 10000) window.addEventListener('popstate', runPolyfill) document.addEventListener('DOMContentLoaded', runPolyfill) document.body.addEventListener('DOMSubtreeModified', runPolyfill)