Skip to content

Commit

Permalink
Merge bb0e03b into babcef7
Browse files Browse the repository at this point in the history
  • Loading branch information
bartveneman committed Mar 3, 2019
2 parents babcef7 + bb0e03b commit a5b8c09
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 38 deletions.
27 changes: 13 additions & 14 deletions src/analyzer/values/font-families.js
Expand Up @@ -3,23 +3,22 @@ const uniquer = require('../../utils/uniquer')
const {KEYWORDS} = require('../../utils/css')

module.exports = declarations => {
const all = declarations
.reduce((prev, {property, value}) => {
if (property === 'font-family') {
prev = [...prev, value]
}
const all = declarations.reduce((prev, {property, value}) => {
if (KEYWORDS.includes(value)) {
return prev
}

if (property === 'font') {
const expanded = expand('font', value)
if (property === 'font-family') {
prev = [...prev, value]
}

if (expanded && expanded['font-family']) {
prev = [...prev, expanded['font-family']]
}
}
if (property === 'font') {
const {'font-family': family} = expand('font', value)
prev = [...prev, family]
}

return prev
}, [])
.filter(value => !KEYWORDS.includes(value))
return prev
}, [])

return {
total: all.length,
Expand Down
41 changes: 17 additions & 24 deletions src/analyzer/values/font-sizes.js
@@ -1,32 +1,25 @@
const expand = require('css-shorthand-expand')
const unitSort = require('css-unit-sort')
const uniquer = require('../../utils/uniquer')
const utils = require('../../utils/css')

const keywords = utils.KEYWORDS
const {KEYWORDS} = require('../../utils/css')

module.exports = declarations => {
const _all = (() => {
const tmp = []

declarations.forEach(declaration => {
if (declaration.property === 'font-size') {
return tmp.push(declaration.value)
}

if (declaration.property === 'font') {
const font = expand('font', declaration.value)

if (font && font['font-size']) {
return tmp.push(font['font-size'])
}
}
})

return tmp
})()

const all = _all.filter(v => !keywords.includes(v))
const all = declarations.reduce((prev, {property, value}) => {
if (KEYWORDS.includes(value)) {
return prev
}

if (property === 'font-size') {
prev = [...prev, value]
}

if (property === 'font') {
const {'font-size': size} = expand('font', value)
prev = [...prev, size]
}

return prev
}, [])

return {
total: all.length,
Expand Down

0 comments on commit a5b8c09

Please sign in to comment.