@symbo.ls/scratch 0.7.21 → 0.7.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/scratch",
3
3
  "description": "Φ / CSS framework and methodology.",
4
4
  "author": "symbo.ls",
5
- "version": "0.7.21",
5
+ "version": "0.7.22",
6
6
  "files": [
7
7
  "src"
8
8
  ],
@@ -1,17 +1,21 @@
1
1
  'use strict'
2
2
 
3
+ import { isObject } from '@domql/utils'
3
4
  import { CONFIG, CSS_VARS } from '../factory' // eslint-disable-line
4
5
 
5
6
  import {
6
7
  getDefaultOrFirstKey,
7
- getFontFaceEach
8
+ getFontFaceEach,
9
+ setCustomFontMedia
8
10
  } from '../utils'
9
11
 
10
12
  // const ENV = process.env.NODE_ENV
11
13
 
12
14
  export const setFont = (val, key) => {
13
15
  const CSSvar = `--font-${key}`
14
- const fontFace = getFontFaceEach(key, val)
16
+ const fontFace = isObject(val)
17
+ ? setCustomFontMedia(key, val.url)
18
+ : getFontFaceEach(key, val)
15
19
  return { var: CSSvar, value: val, fontFace }
16
20
  }
17
21
 
package/src/utils/font.js CHANGED
@@ -1,5 +1,7 @@
1
1
  'use strict'
2
2
 
3
+ import { isObject } from '@domql/utils'
4
+
3
5
  export const getDefaultOrFirstKey = (LIBRARY, key) => {
4
6
  if (LIBRARY[key]) return LIBRARY[key].value
5
7
  if (LIBRARY.default) return LIBRARY[LIBRARY.default].value
@@ -11,22 +13,22 @@ export const getFontFormat = url => url.split(/[#?]/)[0].split('.').pop().trim()
11
13
 
12
14
  export const setInCustomFontMedia = str => `@font-face { ${str} }`
13
15
 
14
- export const setCustomFont = (name, weight, url) => `
16
+ export const setCustomFont = (name, url, weight) => `
15
17
  font-family: '${name}';
16
18
  font-style: normal;
17
- font-weight: ${weight};
19
+ ${weight && `font-weight: ${weight};`}
18
20
  src: url('${url}') format('${getFontFormat(url)}');`
19
21
 
20
- export const setCustomFontMedia = (name, weight, url) => `@font-face {
21
- ${setCustomFont((name, weight, url))}
22
+ export const setCustomFontMedia = (name, url, weight) => `@font-face {
23
+ ${setCustomFont(name, url, weight)}
22
24
  }`
23
25
  // src: url('${url}') format('${getFontFormat(url)}');
24
26
 
25
- export const getFontFaceEach = (name, weightsObject) => {
26
- const keys = Object.keys(weightsObject)
27
+ export const getFontFaceEach = (name, weights) => {
28
+ const keys = Object.keys(weights)
27
29
  return keys.map(key => {
28
- const { fontWeight, url } = weightsObject[key]
29
- return setCustomFont(name, fontWeight, url)
30
+ const { url, fontWeight } = weights[key]
31
+ return setCustomFont(name, url, fontWeight)
30
32
  })
31
33
  }
32
34
 
@@ -35,8 +37,10 @@ export const getFontFace = LIBRARY => {
35
37
  return keys.map(key => getFontFaceEach(key, LIBRARY[key].value))
36
38
  }
37
39
 
38
- export const getFontFaceEachString = (name, weightsObject) => {
39
- return getFontFaceEach(name, weightsObject).map(setInCustomFontMedia)
40
+ export const getFontFaceEachString = (name, weights) => {
41
+ const isObj = isObject(weights)
42
+ if (isObj) return setCustomFontMedia(name, weights.url)
43
+ return getFontFaceEach(name, weights).map(setInCustomFontMedia)
40
44
  }
41
45
 
42
46
  export const getFontFaceString = LIBRARY => {