@symbo.ls/scratch 2.11.212 → 2.11.216

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.
@@ -30,9 +30,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
30
30
  ));
31
31
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
32
32
 
33
- // ../../../domql/packages/utils/dist/cjs/key.js
33
+ // ../../node_modules/@domql/utils/dist/cjs/key.js
34
34
  var require_key = __commonJS({
35
- "../../../domql/packages/utils/dist/cjs/key.js"(exports, module2) {
35
+ "../../node_modules/@domql/utils/dist/cjs/key.js"(exports, module2) {
36
36
  "use strict";
37
37
  var __defProp2 = Object.defineProperty;
38
38
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -69,9 +69,9 @@ var require_key = __commonJS({
69
69
  }
70
70
  });
71
71
 
72
- // ../../../domql/packages/utils/dist/cjs/env.js
72
+ // ../../node_modules/@domql/utils/dist/cjs/env.js
73
73
  var require_env = __commonJS({
74
- "../../../domql/packages/utils/dist/cjs/env.js"(exports, module2) {
74
+ "../../node_modules/@domql/utils/dist/cjs/env.js"(exports, module2) {
75
75
  "use strict";
76
76
  var __defProp2 = Object.defineProperty;
77
77
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -107,9 +107,9 @@ var require_env = __commonJS({
107
107
  }
108
108
  });
109
109
 
110
- // ../../../domql/packages/utils/dist/cjs/globals.js
110
+ // ../../node_modules/@domql/utils/dist/cjs/globals.js
111
111
  var require_globals = __commonJS({
112
- "../../../domql/packages/utils/dist/cjs/globals.js"(exports, module2) {
112
+ "../../node_modules/@domql/utils/dist/cjs/globals.js"(exports, module2) {
113
113
  "use strict";
114
114
  var __defProp2 = Object.defineProperty;
115
115
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -143,9 +143,9 @@ var require_globals = __commonJS({
143
143
  }
144
144
  });
145
145
 
146
- // ../../../domql/packages/utils/dist/cjs/node.js
146
+ // ../../node_modules/@domql/utils/dist/cjs/node.js
147
147
  var require_node = __commonJS({
148
- "../../../domql/packages/utils/dist/cjs/node.js"(exports, module2) {
148
+ "../../node_modules/@domql/utils/dist/cjs/node.js"(exports, module2) {
149
149
  "use strict";
150
150
  var __defProp2 = Object.defineProperty;
151
151
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -180,9 +180,9 @@ var require_node = __commonJS({
180
180
  }
181
181
  });
182
182
 
183
- // ../../../domql/packages/utils/dist/cjs/types.js
183
+ // ../../node_modules/@domql/utils/dist/cjs/types.js
184
184
  var require_types = __commonJS({
185
- "../../../domql/packages/utils/dist/cjs/types.js"(exports, module2) {
185
+ "../../node_modules/@domql/utils/dist/cjs/types.js"(exports, module2) {
186
186
  "use strict";
187
187
  var __defProp2 = Object.defineProperty;
188
188
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -267,9 +267,9 @@ var require_types = __commonJS({
267
267
  }
268
268
  });
269
269
 
270
- // ../../../domql/packages/utils/dist/cjs/array.js
270
+ // ../../node_modules/@domql/utils/dist/cjs/array.js
271
271
  var require_array = __commonJS({
272
- "../../../domql/packages/utils/dist/cjs/array.js"(exports, module2) {
272
+ "../../node_modules/@domql/utils/dist/cjs/array.js"(exports, module2) {
273
273
  "use strict";
274
274
  var __defProp2 = Object.defineProperty;
275
275
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -366,9 +366,9 @@ var require_array = __commonJS({
366
366
  }
367
367
  });
368
368
 
369
- // ../../../domql/packages/utils/dist/cjs/string.js
369
+ // ../../node_modules/@domql/utils/dist/cjs/string.js
370
370
  var require_string = __commonJS({
371
- "../../../domql/packages/utils/dist/cjs/string.js"(exports, module2) {
371
+ "../../node_modules/@domql/utils/dist/cjs/string.js"(exports, module2) {
372
372
  "use strict";
373
373
  var __defProp2 = Object.defineProperty;
374
374
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -426,9 +426,9 @@ var require_string = __commonJS({
426
426
  }
427
427
  });
428
428
 
429
- // ../../../domql/packages/utils/dist/cjs/object.js
429
+ // ../../node_modules/@domql/utils/dist/cjs/object.js
430
430
  var require_object = __commonJS({
431
- "../../../domql/packages/utils/dist/cjs/object.js"(exports, module2) {
431
+ "../../node_modules/@domql/utils/dist/cjs/object.js"(exports, module2) {
432
432
  "use strict";
433
433
  var __defProp2 = Object.defineProperty;
434
434
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -878,9 +878,9 @@ var require_object = __commonJS({
878
878
  }
879
879
  });
880
880
 
881
- // ../../../domql/packages/utils/dist/cjs/function.js
881
+ // ../../node_modules/@domql/utils/dist/cjs/function.js
882
882
  var require_function = __commonJS({
883
- "../../../domql/packages/utils/dist/cjs/function.js"(exports, module2) {
883
+ "../../node_modules/@domql/utils/dist/cjs/function.js"(exports, module2) {
884
884
  "use strict";
885
885
  var __defProp2 = Object.defineProperty;
886
886
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -953,9 +953,9 @@ var require_function = __commonJS({
953
953
  }
954
954
  });
955
955
 
956
- // ../../../domql/packages/utils/dist/cjs/log.js
956
+ // ../../node_modules/@domql/utils/dist/cjs/log.js
957
957
  var require_log = __commonJS({
958
- "../../../domql/packages/utils/dist/cjs/log.js"(exports, module2) {
958
+ "../../node_modules/@domql/utils/dist/cjs/log.js"(exports, module2) {
959
959
  "use strict";
960
960
  var __defProp2 = Object.defineProperty;
961
961
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -994,9 +994,9 @@ var require_log = __commonJS({
994
994
  }
995
995
  });
996
996
 
997
- // ../../../domql/packages/utils/dist/cjs/cookie.js
997
+ // ../../node_modules/@domql/utils/dist/cjs/cookie.js
998
998
  var require_cookie = __commonJS({
999
- "../../../domql/packages/utils/dist/cjs/cookie.js"(exports, module2) {
999
+ "../../node_modules/@domql/utils/dist/cjs/cookie.js"(exports, module2) {
1000
1000
  "use strict";
1001
1001
  var __defProp2 = Object.defineProperty;
1002
1002
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1050,9 +1050,9 @@ var require_cookie = __commonJS({
1050
1050
  }
1051
1051
  });
1052
1052
 
1053
- // ../../../domql/packages/utils/dist/cjs/tags.js
1053
+ // ../../node_modules/@domql/utils/dist/cjs/tags.js
1054
1054
  var require_tags = __commonJS({
1055
- "../../../domql/packages/utils/dist/cjs/tags.js"(exports, module2) {
1055
+ "../../node_modules/@domql/utils/dist/cjs/tags.js"(exports, module2) {
1056
1056
  "use strict";
1057
1057
  var __defProp2 = Object.defineProperty;
1058
1058
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1215,9 +1215,9 @@ var require_tags = __commonJS({
1215
1215
  }
1216
1216
  });
1217
1217
 
1218
- // ../../../domql/packages/utils/dist/cjs/index.js
1218
+ // ../../node_modules/@domql/utils/dist/cjs/index.js
1219
1219
  var require_cjs = __commonJS({
1220
- "../../../domql/packages/utils/dist/cjs/index.js"(exports, module2) {
1220
+ "../../node_modules/@domql/utils/dist/cjs/index.js"(exports, module2) {
1221
1221
  "use strict";
1222
1222
  var __defProp2 = Object.defineProperty;
1223
1223
  var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
@@ -1280,6 +1280,7 @@ __export(defaultConfig_exports, {
1280
1280
  MEDIA: () => MEDIA,
1281
1281
  RESET: () => RESET,
1282
1282
  SEQUENCE: () => SEQUENCE,
1283
+ SHADOW: () => SHADOW,
1283
1284
  SPACING: () => SPACING,
1284
1285
  SVG: () => SVG,
1285
1286
  SVG_DATA: () => SVG_DATA,
@@ -1402,6 +1403,9 @@ var GRADIENT = {};
1402
1403
  // src/defaultConfig/theme.js
1403
1404
  var THEME = {};
1404
1405
 
1406
+ // src/defaultConfig/shadow.js
1407
+ var SHADOW = {};
1408
+
1405
1409
  // src/defaultConfig/icons.js
1406
1410
  var ICONS = {};
1407
1411
 
@@ -1508,14 +1512,14 @@ var applySequenceVars = (props, mediaName, options = {}) => {
1508
1512
  let underMediaQuery = CSS_VARS2[`@media ${query}`];
1509
1513
  if (!underMediaQuery)
1510
1514
  underMediaQuery = CSS_VARS2[`@media ${query}`] = {};
1511
- underMediaQuery[item.variable] = `var(${item.variable + "-" + mediaName})`;
1512
- CSS_VARS2[item.variable + "-" + mediaName] = value;
1515
+ underMediaQuery[item.variable] = `var(${item.variable + "_" + mediaName})`;
1516
+ CSS_VARS2[item.variable + "_" + mediaName] = value;
1513
1517
  } else {
1514
1518
  if (options.useDefault === false) {
1515
1519
  CSS_VARS2[item.variable] = value;
1516
1520
  } else {
1517
- CSS_VARS2[item.variable + "-default"] = value;
1518
- CSS_VARS2[item.variable] = `var(${item.variable + "-default"})`;
1521
+ CSS_VARS2[item.variable + "_default"] = value;
1522
+ CSS_VARS2[item.variable] = `var(${item.variable + "_default"})`;
1519
1523
  }
1520
1524
  }
1521
1525
  }
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": "2.11.212",
5
+ "version": "2.11.216",
6
6
  "files": [
7
7
  "src",
8
8
  "dist"
@@ -29,5 +29,5 @@
29
29
  "@symbo.ls/utils": "latest",
30
30
  "color-contrast-checker": "^1.5.0"
31
31
  },
32
- "gitHead": "12914eac8527ac1df36183098bbf3dfcfaa2e027"
32
+ "gitHead": "23694218fd8511bd183cb4ca1ed0493e3dbcc704"
33
33
  }
@@ -2,8 +2,7 @@
2
2
 
3
3
  var proto = { // eslint-disable-line
4
4
  name: '',
5
- value: '',
6
- themes: {}
5
+ value: ''
7
6
  }
8
7
 
9
8
  export const COLOR = {}
@@ -9,6 +9,7 @@ export * from './media.js'
9
9
  export * from './spacing.js'
10
10
  export * from './color.js'
11
11
  export * from './theme.js'
12
+ export * from './shadow.js'
12
13
  export * from './icons.js'
13
14
  export * from './timing.js'
14
15
  export * from './document.js'
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+
3
+ const shadow = { // eslint-disable-line
4
+ name: 'primaryShadow',
5
+ boxShadow: 'gray12, 0 0px 50px 50px'
6
+ }
7
+
8
+ export const SHADOW = {}
package/src/set.js CHANGED
@@ -13,7 +13,8 @@ import {
13
13
  applySpacingSequence,
14
14
  applyReset,
15
15
  applyTimingSequence,
16
- applyDocument
16
+ applyDocument,
17
+ setShadow
17
18
  } from './system'
18
19
 
19
20
  import { isFunction } from '@domql/utils'
@@ -36,6 +37,7 @@ export const VALUE_TRANSFORMERS = {
36
37
  svg_data: setSameValue,
37
38
  typography: setSameValue,
38
39
  cases: setCases,
40
+ shadow: setShadow,
39
41
  spacing: setSameValue,
40
42
  media: setSameValue,
41
43
  timing: setSameValue,
@@ -98,7 +98,13 @@ export const setColor = (val, key, suffix) => {
98
98
 
99
99
  if (isObject(val)) {
100
100
  const obj = {}
101
- for (const variant in val) obj[variant] = setColor(val[variant], key, variant.slice(0, 1) === '@' ? variant.slice(1) : variant)
101
+ for (const variant in val) {
102
+ obj[variant] = setColor(
103
+ val[variant],
104
+ key,
105
+ variant.slice(0, 1) === '@' ? variant.slice(1) : variant
106
+ )
107
+ }
102
108
  return obj
103
109
  }
104
110
 
@@ -5,6 +5,7 @@ export * from './theme.js'
5
5
  export * from './font.js'
6
6
  export * from './typography.js'
7
7
  export * from './spacing.js'
8
+ export * from './shadow.js'
8
9
  export * from './timing.js'
9
10
  export * from './document.js'
10
11
  export * from './svg.js'
@@ -0,0 +1,99 @@
1
+ 'use strict'
2
+
3
+ import { getActiveConfig } from '../factory.js'
4
+ import { getColor } from './color.js'
5
+ import { getSpacingByKey } from './spacing.js'
6
+
7
+ import {
8
+ isObject,
9
+ isString,
10
+ isArray
11
+ } from '@domql/utils'
12
+
13
+ export const setShadow = (value, key, suffix, prefers) => {
14
+ const CONFIG = getActiveConfig()
15
+ // const { CSS_VARS } = CONFIG
16
+ // const theme = { valueue: value }
17
+
18
+ if (isArray(value)) {
19
+ return {
20
+ '@light': setShadow(value[0], key, 'light'),
21
+ '@dark': setShadow(value[1], key, 'dark')
22
+ }
23
+ }
24
+
25
+ if (isObject(value)) {
26
+ const obj = {}
27
+ for (const variant in value) {
28
+ obj[variant] = setShadow(
29
+ value[variant],
30
+ key,
31
+ variant.startsWith('@') ? variant.slice(1) : variant
32
+ )
33
+ }
34
+ return obj
35
+ }
36
+
37
+ if (isString(value) && value.includes(',')) {
38
+ value = value.split(',').map(v => {
39
+ v = v.trim()
40
+ if (v.startsWith('--')) return `var(${v})`
41
+ if (getColor(v).length > 2) return getColor(v)
42
+ if (v.includes('px') || v.slice(-2) === 'em') return v
43
+ const arr = v.split(' ')
44
+ if (!arr.length) return v
45
+ return arr.map(v => getSpacingByKey(v, 'shadow').shadow).join(' ')
46
+ }).join(' ')
47
+ }
48
+
49
+ const CSSVar = `--shadow-${key}` + (suffix ? `-${suffix}` : '')
50
+
51
+ if (CONFIG.useVariable) { CONFIG.CSS_VARS[CSSVar] = value }
52
+
53
+ return {
54
+ var: CSSVar,
55
+ value
56
+ }
57
+ }
58
+
59
+ export const getShadow = (value, globalTheme) => {
60
+ const CONFIG = getActiveConfig()
61
+ if (!globalTheme) globalTheme = CONFIG.globalTheme
62
+ if (!isString(value)) {
63
+ if (CONFIG.verbose) console.warn(value, '- type for color is not valid')
64
+ return
65
+ }
66
+
67
+ if (value.slice(0, 2) === '--') return `var(${value})`
68
+
69
+ const [name] = isArray(value) ? value : value.split(' ')
70
+
71
+ const { SHADOW } = CONFIG
72
+ const val = SHADOW[name]
73
+ const isObj = isObject(val)
74
+
75
+ if (!val) {
76
+ if (CONFIG.verbose) console.warn('Can\'t find color ', name)
77
+ return value
78
+ }
79
+
80
+ if (globalTheme) {
81
+ if (val[globalTheme]) return val[globalTheme].value
82
+ else if (CONFIG.verbose) console.warn(value, ' - does not have ', globalTheme)
83
+ }
84
+
85
+ if (isObj && val.value) return val.value
86
+
87
+ if (isObj) {
88
+ const obj = {}
89
+ for (const mediaName in val) {
90
+ const query = CONFIG.MEDIA[mediaName.slice(1)]
91
+ const media = `@media screen and ${query}`
92
+ obj[media] = val.value
93
+ }
94
+ return obj
95
+ }
96
+
97
+ if (CONFIG.verbose) console.warn('Can\'t find color', value)
98
+ return value
99
+ }
@@ -5,6 +5,7 @@ import { getActiveConfig } from '../factory'
5
5
  import {
6
6
  getSpacingByKey,
7
7
  getColor,
8
+ getShadow,
8
9
  getMediaColor,
9
10
  getTimingByKey,
10
11
  getTimingFunction
@@ -45,17 +46,11 @@ export const transformTextStroke = stroke => {
45
46
  }).join(' ')
46
47
  }
47
48
 
48
- export const transformShadow = shadows => shadows.split('|').map(shadow => {
49
- return shadow.split(', ').map(v => {
50
- v = v.trim()
51
- if (v.slice(0, 2) === '--') return `var(${v})`
52
- if (getColor(v).length > 2) return getColor(v)
53
- if (v.includes('px') || v.slice(-2) === 'em') return v
54
- const arr = v.split(' ')
55
- if (!arr.length) return v
56
- return arr.map(v => getSpacingByKey(v, 'shadow').shadow).join(' ')
57
- }).join(' ')
58
- }).join(',')
49
+ export const transformShadow = (sh, globalTheme) => {
50
+ return sh.split(',').map(shadow => getShadow(shadow, globalTheme)).join(',')
51
+ }
52
+
53
+ export const transformBoxShadow = (sh, globalTheme) => getShadow(sh, globalTheme)
59
54
 
60
55
  export const transformBackgroundImage = (backgroundImage, globalTheme) => {
61
56
  const CONFIG = getActiveConfig()
@@ -158,20 +158,24 @@ export const getSequenceValue = (value = 'A', sequenceProps) => {
158
158
  let absValue = isNegative ? letterVal.slice(1) : letterVal
159
159
 
160
160
  let mediaName = ''
161
- if (absValue.includes('-')) {
162
- mediaName = '-' + absValue.split('-')[1].toLowerCase()
163
- absValue = absValue.split('-')[0]
161
+ if (absValue.includes('_')) {
162
+ mediaName = '_' + absValue.split('_')[1].toLowerCase()
163
+ absValue = absValue.split('_')[0]
164
164
  }
165
165
 
166
- const varValue = v => `var(${prefix}${v}${mediaName})`
166
+ const varValue = v => startsWithDashOrLetterRegex.test(v) ? `var(${prefix}${v}${mediaName})` : v
167
167
  if (absValue.includes('+')) {
168
- const args = absValue.split('+')
169
- const [first, second] = args
168
+ const [first, second] = absValue.split('+')
170
169
  const joint = `${varValue(first)} + ${varValue(second)}`
171
170
  return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`
171
+ } else if (absValue.includes('*')) {
172
+ const [first, second] = absValue.split('*')
173
+ const joint = `${varValue(first)} * ${varValue(second)}`
174
+ return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`
172
175
  } else if (absValue.includes('-')) {
173
- const args = absValue.split('-')
174
- const [first, second] = args
176
+ // TODO: check this
177
+ // check for the first char
178
+ const [first, second] = absValue.split('-')
175
179
  const joint = `${varValue(first)} - ${varValue(second)}`
176
180
  return isNegative ? `calc((${joint}) * -1)` : `calc(${joint})`
177
181
  }
package/src/utils/var.js CHANGED
@@ -32,14 +32,14 @@ export const applySequenceVars = (props, mediaName, options = {}) => {
32
32
  }
33
33
  let underMediaQuery = CSS_VARS[`@media ${query}`]
34
34
  if (!underMediaQuery) underMediaQuery = CSS_VARS[`@media ${query}`] = {}
35
- underMediaQuery[item.variable] = `var(${item.variable + '-' + mediaName})`
36
- CSS_VARS[item.variable + '-' + mediaName] = value
35
+ underMediaQuery[item.variable] = `var(${item.variable + '_' + mediaName})`
36
+ CSS_VARS[item.variable + '_' + mediaName] = value
37
37
  } else {
38
38
  if (options.useDefault === false) {
39
39
  CSS_VARS[item.variable] = value
40
40
  } else {
41
- CSS_VARS[item.variable + '-default'] = value
42
- CSS_VARS[item.variable] = `var(${item.variable + '-default'})`
41
+ CSS_VARS[item.variable + '_default'] = value
42
+ CSS_VARS[item.variable] = `var(${item.variable + '_default'})`
43
43
  }
44
44
  }
45
45
  }