grid-area.js 891 B

12345678910111213141516171819202122232425262728293031323334
  1. let Declaration = require('../declaration')
  2. let utils = require('./grid-utils')
  3. class GridArea extends Declaration {
  4. /**
  5. * Translate grid-area to separate -ms- prefixed properties
  6. */
  7. insert(decl, prefix, prefixes, result) {
  8. if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes)
  9. let values = utils.parse(decl)
  10. let [rowStart, rowSpan] = utils.translate(values, 0, 2)
  11. let [columnStart, columnSpan] = utils.translate(values, 1, 3)
  12. ;[
  13. ['grid-row', rowStart],
  14. ['grid-row-span', rowSpan],
  15. ['grid-column', columnStart],
  16. ['grid-column-span', columnSpan]
  17. ].forEach(([prop, value]) => {
  18. utils.insertDecl(decl, prop, value)
  19. })
  20. utils.warnTemplateSelectorNotFound(decl, result)
  21. utils.warnIfGridRowColumnExists(decl, result)
  22. return undefined
  23. }
  24. }
  25. GridArea.names = ['grid-area']
  26. module.exports = GridArea