@symbo.ls/scratch 0.3.8 → 0.3.11

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": "Symbols",
5
- "version": "0.3.8",
5
+ "version": "0.3.11",
6
6
  "files": [
7
7
  "src"
8
8
  ],
@@ -11,6 +11,7 @@ var defaultFont = { // eslint-disable-line
11
11
  export const FONT_FAMILY = {}
12
12
  export const FONT_FAMILY_TYPES = {
13
13
  serif: 'Helvetica, Arial, sans-serif, --system-default',
14
- 'sans-serif': 'Times New Roman, Georgia, serif, --system-default'
14
+ 'sans-serif': 'Times New Roman, Georgia, serif, --system-default',
15
+ monospace: 'Courier New, monospace, --system-default'
15
16
  }
16
17
  export const FONT_FACE = getFontFace(FONT_FAMILY)
@@ -23,7 +23,7 @@ const getSequence = (props) => {
23
23
  return hasGenerated ? props : generateSequence(props)
24
24
  }
25
25
 
26
- export const mapSpacing = (val, property = 'padding', props) => {
26
+ export const mapSpacing = (val, property = 'padding', props, unit) => {
27
27
  const prefix = '--spacing-'
28
28
 
29
29
  const generatedSequence = getSequence(props)
@@ -38,7 +38,8 @@ export const mapSpacing = (val, property = 'padding', props) => {
38
38
  type,
39
39
  prop,
40
40
  val: stack[i],
41
- prefix
41
+ prefix,
42
+ unit
42
43
  })
43
44
 
44
45
  if (length === 2) {
@@ -21,29 +21,6 @@ import {
21
21
 
22
22
  const ENV = process.env.NODE_ENV
23
23
 
24
- const setColor = (val, key) => {
25
- const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
26
- const alpha = parseFloat(a.toFixed(2))
27
- const CSSVar = `--color-${key}`
28
- const rgb = `${r}, ${g}, ${b}`
29
- const value = `rgba(${rgb}, ${alpha})`
30
-
31
- return {
32
- var: CSSVar,
33
- rgb,
34
- alpha,
35
- value
36
- }
37
- }
38
-
39
- const setGradient = (val, key) => {
40
- const CSSVar = `--gradient-${key}`
41
- return {
42
- var: CSSVar,
43
- value: val.value || val
44
- }
45
- }
46
-
47
24
  export const getColor = value => {
48
25
  if (!isString(value)) {
49
26
  if (ENV === 'test' || ENV === 'development') console.warn(value, '- type for color is not valid')
@@ -84,6 +61,31 @@ export const getColor = value => {
84
61
  } else return val.value
85
62
  }
86
63
 
64
+ const setColor = (val, key) => {
65
+ if (val.slice(0, 2) === '--') val = getColor(val.slice(2))
66
+
67
+ const CSSVar = `--color-${key}`
68
+ const [r, g, b, a = 1] = colorStringToRgbaArray(val.value || val)
69
+ const alpha = parseFloat(a.toFixed(2))
70
+ const rgb = `${r}, ${g}, ${b}`
71
+ const value = `rgba(${rgb}, ${alpha})`
72
+
73
+ return {
74
+ var: CSSVar,
75
+ rgb,
76
+ alpha,
77
+ value
78
+ }
79
+ }
80
+
81
+ const setGradient = (val, key) => {
82
+ const CSSVar = `--gradient-${key}`
83
+ return {
84
+ var: CSSVar,
85
+ value: val.value || val
86
+ }
87
+ }
88
+
87
89
  const setThemeValue = theme => {
88
90
  const value = {}
89
91
  const { state, variants, helpers, ...rest } = theme
@@ -324,11 +324,11 @@ export const generateSequence = ({ type, base, ratio, range, subSequence, ...sta
324
324
  return state
325
325
  }
326
326
 
327
- export const fallBack = ({ type, prop, val = 'A', prefix = '--font-size-' }) => {
327
+ export const fallBack = ({ type, prop, val = 'A', prefix = '--font-size-', unit = UNIT.default }) => {
328
328
  if (typeof val !== 'string') console.warn(prop, val, 'is not a string')
329
329
 
330
330
  if (val === '-' || val === '') return ({ })
331
- if (val === 'auto') return ({ [prop]: val })
331
+ if (val === 'auto' || val === 'fit-content' || val === 'min-content' || val === 'max-content') return ({ [prop]: val })
332
332
 
333
333
  // const startsWithLetterRegex = /^[a-zA-Z]/i
334
334
  const startsWithLetterRegex = /^-?[a-zA-Z]/i
@@ -344,7 +344,7 @@ export const fallBack = ({ type, prop, val = 'A', prefix = '--font-size-' }) =>
344
344
  if (!value) return console.warn('can\'t find', type, prefix + simplyLetterVal, simplyLetterVal)
345
345
 
346
346
  return ({
347
- [prop]: isNegative + value.val + UNIT.default,
347
+ [prop]: isNegative + value.val + value.unit,
348
348
  [prop]: isNegative + value.scaling + 'em'
349
349
  })
350
350
  }