2023-08-17 09:47:40 +00:00
|
|
|
let Declaration = require('../declaration')
|
|
|
|
let utils = require('./grid-utils')
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
class GridArea extends Declaration {
|
|
|
|
/**
|
|
|
|
* Translate grid-area to separate -ms- prefixed properties
|
|
|
|
*/
|
|
|
|
insert(decl, prefix, prefixes, result) {
|
|
|
|
if (prefix !== '-ms-') return super.insert(decl, prefix, prefixes)
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
let values = utils.parse(decl)
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
let [rowStart, rowSpan] = utils.translate(values, 0, 2)
|
|
|
|
let [columnStart, columnSpan] = utils.translate(values, 1, 3)
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
;[
|
|
|
|
['grid-row', rowStart],
|
|
|
|
['grid-row-span', rowSpan],
|
|
|
|
['grid-column', columnStart],
|
|
|
|
['grid-column-span', columnSpan]
|
|
|
|
].forEach(([prop, value]) => {
|
|
|
|
utils.insertDecl(decl, prop, value)
|
|
|
|
})
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
utils.warnTemplateSelectorNotFound(decl, result)
|
|
|
|
utils.warnIfGridRowColumnExists(decl, result)
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
return undefined
|
2022-01-21 08:28:41 +00:00
|
|
|
}
|
2023-08-17 09:47:40 +00:00
|
|
|
}
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
GridArea.names = ['grid-area']
|
2022-01-21 08:28:41 +00:00
|
|
|
|
2023-08-17 09:47:40 +00:00
|
|
|
module.exports = GridArea
|