css-in-props 2.10.79 → 2.10.98

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,11 +2,12 @@
2
2
  "name": "css-in-props",
3
3
  "description": "Utilize props as CSS methods",
4
4
  "author": "symbo.ls",
5
- "version": "2.10.79",
5
+ "version": "2.10.98",
6
6
  "repository": "https://github.com/symbo-ls/smbls",
7
7
  "main": "src/index.js",
8
8
  "files": [
9
- "src"
9
+ "src",
10
+ "dist"
10
11
  ],
11
12
  "dependencies": {
12
13
  "@domql/utils": "latest",
@@ -14,5 +15,5 @@
14
15
  "@symbo.ls/emotion": "latest",
15
16
  "@symbo.ls/scratch": "latest"
16
17
  },
17
- "gitHead": "b6b0b03b2741e0f9085806cec874cea58aa9cae8"
18
+ "gitHead": "a2d105b6f070b784c511dbae1a88727debeedda6"
18
19
  }
@@ -1,10 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { isFunction } from '@domql/utils'
4
- import createEmotion from '@emotion/css/create-instance'
5
-
6
- const { css } = createEmotion({
7
- key: 'smbls'
8
- })
4
+ import { emotion } from '@symbo.ls/emotion'
5
+ const { css } = emotion
9
6
 
10
7
  export const transformEmotion = (props, callback) => isFunction(callback) ? callback(props) : css(props)
package/src/index.js CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  export * from './transform'
4
4
  export * from './set'
5
- export * as registry from './registry'
5
+ export * from './registry'
package/src/registry.js CHANGED
@@ -17,7 +17,6 @@ import {
17
17
  Animation
18
18
  } from '@symbo.ls/atoms'
19
19
 
20
-
21
20
  export const registry = mergeArray([
22
21
  Shape,
23
22
  Position,
package/src/set.js CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import { transformClassname, transformEmotion } from './transform'
3
+ import { transformClassname } from './transform'
4
+ import { transformEmotion } from './emotion'
4
5
 
5
6
  export const setClassname = (props, emotionCss) => {
6
7
  const transform = transformClassname(props)
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
3
  import { merge, isFunction, isObject, isArray } from '@domql/utils'
4
- import { keySetters } from './subProps'
4
+ import { keySetters } from '@symbo.ls/atoms'
5
5
 
6
- import { registry as reg } from '../registry'
6
+ import { registry as reg } from './registry'
7
7
 
8
8
  export const transformClassname = (props, registry = reg) => {
9
9
  const CLASS_NAMES = {}
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- export * from './classname'
4
- export * from './emotion'
5
- export * from './subProps'
@@ -1,68 +0,0 @@
1
-
2
- import { isArray, merge } from '@domql/utils'
3
- import { CASES as CONFIG_CASES, MEDIA as CONFIG_MEDIA } from '@symbo.ls/scratch'
4
- import { registry } from '../registry'
5
-
6
- const execClass = (key, props, result, rootProps) => {
7
- const className = registry[key]
8
-
9
- if (typeof className !== 'function') return
10
-
11
- let classExec = className(props)
12
- if (isArray(classExec)) {
13
- classExec = classExec.reduce((a, c) => merge(a, c), {})
14
- }
15
-
16
- for (const finalProp in classExec) {
17
- result[finalProp] = classExec[finalProp]
18
- }
19
- }
20
-
21
- export const transformProps = (props, result, rootProps) => {
22
- const propsClassObj = {}
23
-
24
- for (const key in props) {
25
- const setter = keySetters[key.slice(0, 1)]
26
- if (setter) {
27
- setter(key, props[key], propsClassObj, rootProps)
28
- continue
29
- } else {
30
- execClass(key, props, propsClassObj, rootProps)
31
- }
32
- }
33
-
34
- return propsClassObj
35
- }
36
-
37
- export const transformMedia = (key, props, result, rootProps) => {
38
- const mediaName = CONFIG_MEDIA[key.slice(1)]
39
- const mediaKey = `@media screen and ${mediaName}`
40
- // result[mediaKey] = transformProps(props, result, rootProps)
41
- const obj = { [mediaKey]: transformProps(props, result, rootProps) }
42
- merge(result, obj)
43
- }
44
-
45
- export const transformSelector = (key, props, result, rootProps) => {
46
- const selectorKey = `&${key}`
47
- const obj = { [selectorKey]: transformProps(props, result, rootProps) }
48
- merge(result, obj)
49
- }
50
-
51
- export const transformCases = (key, props, result, rootProps) => {
52
- const caseKey = key.slice(1)
53
- if (!CONFIG_CASES[caseKey]) return
54
- merge(result, transformProps(props, result, rootProps))
55
- }
56
-
57
- export const transformConditionalCases = (key, props, result, rootProps) => {
58
- const caseKey = key.slice(1)
59
- if (!rootProps[caseKey]) return // remove classname if not here
60
- merge(result, transformProps(props, result, rootProps))
61
- }
62
-
63
- export const keySetters = {
64
- '@': transformMedia,
65
- ':': transformSelector,
66
- $: transformCases,
67
- '.': transformConditionalCases
68
- }