@symbo.ls/atoms 2.29.5 → 2.29.7
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/Box.js +1147 -0
- package/Media.js +141 -79
- package/Picture.js +4 -3
- package/{Shape/style.js → Shape.js} +29 -11
- package/index.js +1 -12
- package/package.json +6 -6
- package/Animation.js +0 -57
- package/Block.js +0 -388
- package/Collection.js +0 -234
- package/Direction.js +0 -10
- package/Interaction.js +0 -17
- package/Overflow.js +0 -19
- package/Position.js +0 -42
- package/Pseudo.js +0 -7
- package/Shape/index.js +0 -43
- package/Theme.js +0 -204
- package/Timing.js +0 -39
- package/Transform.js +0 -12
- package/XYZ.js +0 -11
package/Media.js
CHANGED
|
@@ -1,45 +1,93 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { merge, isArray, overwriteDeep, overwriteShallow } from '@domql/utils'
|
|
4
|
-
import { getSystemGlobalTheme } from './
|
|
4
|
+
import { getSystemGlobalTheme } from './Box'
|
|
5
5
|
|
|
6
6
|
export const keySetters = {
|
|
7
|
-
'@': (key, props, result, element, isSubtree) =>
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
)
|
|
7
|
+
'@': (key, props, result, element, isSubtree) =>
|
|
8
|
+
applyMediaProps(
|
|
9
|
+
key,
|
|
10
|
+
props,
|
|
11
|
+
isSubtree ? result : result && result.media,
|
|
12
|
+
element
|
|
13
|
+
),
|
|
14
|
+
':': (key, props, result, element, isSubtree) =>
|
|
15
|
+
applySelectorProps(
|
|
16
|
+
key,
|
|
17
|
+
props,
|
|
18
|
+
isSubtree ? result : result && result.selector,
|
|
19
|
+
element
|
|
20
|
+
),
|
|
21
|
+
'[': (key, props, result, element, isSubtree) =>
|
|
22
|
+
applySelectorProps(
|
|
23
|
+
key,
|
|
24
|
+
props,
|
|
25
|
+
isSubtree ? result : result && result.selector,
|
|
26
|
+
element
|
|
27
|
+
),
|
|
28
|
+
'*': (key, props, result, element, isSubtree) =>
|
|
29
|
+
applySelectorProps(
|
|
30
|
+
key,
|
|
31
|
+
props,
|
|
32
|
+
isSubtree ? result : result && result.selector,
|
|
33
|
+
element
|
|
34
|
+
),
|
|
35
|
+
'+': (key, props, result, element, isSubtree) =>
|
|
36
|
+
applySelectorProps(
|
|
37
|
+
key,
|
|
38
|
+
props,
|
|
39
|
+
isSubtree ? result : result && result.selector,
|
|
40
|
+
element
|
|
41
|
+
),
|
|
42
|
+
'~': (key, props, result, element, isSubtree) =>
|
|
43
|
+
applySelectorProps(
|
|
44
|
+
key,
|
|
45
|
+
props,
|
|
46
|
+
isSubtree ? result : result && result.selector,
|
|
47
|
+
element
|
|
48
|
+
),
|
|
49
|
+
'&': (key, props, result, element, isSubtree) =>
|
|
50
|
+
applyAndProps(
|
|
51
|
+
key,
|
|
52
|
+
props,
|
|
53
|
+
isSubtree ? result : result && result.selector,
|
|
54
|
+
element
|
|
55
|
+
),
|
|
56
|
+
'>': (key, props, result, element, isSubtree) =>
|
|
57
|
+
applyAndProps(
|
|
58
|
+
key,
|
|
59
|
+
props,
|
|
60
|
+
isSubtree ? result : result && result.selector,
|
|
61
|
+
element
|
|
62
|
+
),
|
|
63
|
+
$: (key, props, result, element, isSubtree) =>
|
|
64
|
+
applyCaseProps(
|
|
65
|
+
key,
|
|
66
|
+
props,
|
|
67
|
+
isSubtree ? result : result && result.case,
|
|
68
|
+
element
|
|
69
|
+
),
|
|
70
|
+
'-': (key, props, result, element, isSubtree) =>
|
|
71
|
+
applyVariableProps(
|
|
72
|
+
key,
|
|
73
|
+
props,
|
|
74
|
+
isSubtree ? result : result && result.variable,
|
|
75
|
+
element
|
|
76
|
+
),
|
|
77
|
+
'.': (key, props, result, element, isSubtree) =>
|
|
78
|
+
applyConditionalCaseProps(
|
|
79
|
+
key,
|
|
80
|
+
props,
|
|
81
|
+
isSubtree ? result : result && result.case,
|
|
82
|
+
element
|
|
83
|
+
),
|
|
84
|
+
'!': (key, props, result, element, isSubtree) =>
|
|
85
|
+
applyConditionalFalsyProps(
|
|
86
|
+
key,
|
|
87
|
+
props,
|
|
88
|
+
isSubtree ? result : result && result.case,
|
|
89
|
+
element
|
|
90
|
+
)
|
|
43
91
|
}
|
|
44
92
|
|
|
45
93
|
const execClass = (key, props, result, element) => {
|
|
@@ -48,14 +96,19 @@ const execClass = (key, props, result, element) => {
|
|
|
48
96
|
|
|
49
97
|
if (typeof classnameExec !== 'function') return
|
|
50
98
|
|
|
51
|
-
let classExec = classnameExec(
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
99
|
+
let classExec = classnameExec(
|
|
100
|
+
{
|
|
101
|
+
props,
|
|
102
|
+
context: element.context,
|
|
103
|
+
state: element.state,
|
|
104
|
+
deps: element.deps
|
|
105
|
+
},
|
|
106
|
+
element.state,
|
|
107
|
+
element.context
|
|
108
|
+
)
|
|
57
109
|
|
|
58
|
-
if (isArray(classExec))
|
|
110
|
+
if (isArray(classExec))
|
|
111
|
+
classExec = classExec.reduce((a, c) => merge(a, c), {})
|
|
59
112
|
|
|
60
113
|
for (const finalProp in classExec) {
|
|
61
114
|
result[finalProp] = classExec[finalProp]
|
|
@@ -97,7 +150,9 @@ const applyMediaProps = (key, props, result, element) => {
|
|
|
97
150
|
return
|
|
98
151
|
}
|
|
99
152
|
|
|
100
|
-
const printValue =
|
|
153
|
+
const printValue =
|
|
154
|
+
'@media ' +
|
|
155
|
+
(mediaValue === 'print' ? `${mediaValue}` : `screen and ${mediaValue}`)
|
|
101
156
|
const mediaKey = mediaValue ? printValue : key
|
|
102
157
|
result[mediaKey] = generatedClass
|
|
103
158
|
return result[mediaKey]
|
|
@@ -129,20 +184,28 @@ const applyVariableProps = (key, props, result, element) => {
|
|
|
129
184
|
|
|
130
185
|
const applyConditionalCaseProps = (key, props, result, element) => {
|
|
131
186
|
const caseKey = key.slice(1)
|
|
132
|
-
const isPropTrue =
|
|
187
|
+
const isPropTrue =
|
|
188
|
+
element.props[caseKey] === true ||
|
|
189
|
+
element.state[caseKey] ||
|
|
190
|
+
element[caseKey]
|
|
133
191
|
if (!isPropTrue) return // remove classname if not here
|
|
134
192
|
return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
135
193
|
}
|
|
136
194
|
|
|
137
195
|
const applyConditionalFalsyProps = (key, props, result, element) => {
|
|
138
196
|
const caseKey = key.slice(1)
|
|
139
|
-
const isPropTrue =
|
|
140
|
-
|
|
197
|
+
const isPropTrue =
|
|
198
|
+
element.props[caseKey] === true ||
|
|
199
|
+
element.state[caseKey] ||
|
|
200
|
+
element[caseKey]
|
|
201
|
+
if (!isPropTrue)
|
|
202
|
+
return overwriteDeep(result, convertPropsToClass(props, result, element))
|
|
141
203
|
}
|
|
142
204
|
|
|
143
|
-
const applyTrueProps = (props, result, element) =>
|
|
205
|
+
const applyTrueProps = (props, result, element) =>
|
|
206
|
+
merge(result, convertPropsToClass(props, result, element))
|
|
144
207
|
|
|
145
|
-
const beforeClassAssign = (element, s, ctx) => {
|
|
208
|
+
export const beforeClassAssign = (element, s, ctx) => {
|
|
146
209
|
const { props, class: className, context } = element
|
|
147
210
|
|
|
148
211
|
const CLASS_NAMES = {
|
|
@@ -159,14 +222,17 @@ const beforeClassAssign = (element, s, ctx) => {
|
|
|
159
222
|
const setter = keySetters[key.slice(0, 1)]
|
|
160
223
|
if (globalTheme) {
|
|
161
224
|
if (key === 'theme' && !props.themeModifier) {
|
|
162
|
-
props.update(
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
225
|
+
props.update(
|
|
226
|
+
{
|
|
227
|
+
themeModifier: globalTheme
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
preventListeners: true,
|
|
231
|
+
preventRecursive: true,
|
|
232
|
+
isForced: true,
|
|
233
|
+
preventDefineUpdate: true
|
|
234
|
+
}
|
|
235
|
+
)
|
|
170
236
|
}
|
|
171
237
|
}
|
|
172
238
|
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
@@ -190,28 +256,24 @@ const beforeClassAssign = (element, s, ctx) => {
|
|
|
190
256
|
// }
|
|
191
257
|
|
|
192
258
|
const parentProps = element.parent && element.parent.props
|
|
193
|
-
if (
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
259
|
+
if (
|
|
260
|
+
parentProps &&
|
|
261
|
+
parentProps.spacingRatio &&
|
|
262
|
+
parentProps.inheritSpacingRatio
|
|
263
|
+
) {
|
|
264
|
+
element.setProps(
|
|
265
|
+
{
|
|
266
|
+
spacingRatio: parentProps.spacingRatio,
|
|
267
|
+
inheritSpacingRatio: true
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
preventListeners: true,
|
|
271
|
+
preventRecursive: true,
|
|
272
|
+
isForced: true,
|
|
273
|
+
preventDefineUpdate: true
|
|
274
|
+
}
|
|
275
|
+
)
|
|
203
276
|
}
|
|
204
277
|
|
|
205
278
|
overwriteShallow(className, CLASS_NAMES)
|
|
206
279
|
}
|
|
207
|
-
|
|
208
|
-
export const Media = {
|
|
209
|
-
class: {
|
|
210
|
-
case: (el, s) => {
|
|
211
|
-
return {
|
|
212
|
-
//
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
},
|
|
216
|
-
on: { beforeClassAssign }
|
|
217
|
-
}
|
package/Picture.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { getSystemGlobalTheme } from './
|
|
3
|
+
import { getSystemGlobalTheme } from './Box'
|
|
4
4
|
|
|
5
5
|
export const Picture = {
|
|
6
6
|
deps: { getSystemGlobalTheme },
|
|
@@ -9,14 +9,15 @@ export const Picture = {
|
|
|
9
9
|
childExtend: {
|
|
10
10
|
tag: 'source',
|
|
11
11
|
attr: {
|
|
12
|
-
media:
|
|
12
|
+
media: element => {
|
|
13
13
|
const { props, key, context, deps } = element
|
|
14
14
|
const { MEDIA } = context.designSystem
|
|
15
15
|
const globalTheme = deps.getSystemGlobalTheme(element)
|
|
16
16
|
const mediaName = (props.media || key).slice(1)
|
|
17
17
|
|
|
18
18
|
if (mediaName === globalTheme) return '(min-width: 0px)'
|
|
19
|
-
else if (mediaName === 'dark' || mediaName === 'light')
|
|
19
|
+
else if (mediaName === 'dark' || mediaName === 'light')
|
|
20
|
+
return '(max-width: 0px)'
|
|
20
21
|
|
|
21
22
|
return MEDIA[mediaName]
|
|
22
23
|
},
|
|
@@ -1,28 +1,42 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { getActiveConfig, getColor } from '@symbo.ls/scratch' // eslint-disable-line no-unused-vars
|
|
4
|
-
import {
|
|
4
|
+
import { Box } from './Box'
|
|
5
5
|
|
|
6
6
|
const CONFIG = getActiveConfig()
|
|
7
7
|
|
|
8
8
|
export const depth = {
|
|
9
|
-
4: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
4: {
|
|
10
|
+
boxShadow: `rgba(0,0,0,.10) 0 2${CONFIG.UNIT.default} 4${CONFIG.UNIT.default}`
|
|
11
|
+
},
|
|
12
|
+
6: {
|
|
13
|
+
boxShadow: `rgba(0,0,0,.10) 0 3${CONFIG.UNIT.default} 6${CONFIG.UNIT.default}`
|
|
14
|
+
},
|
|
15
|
+
10: {
|
|
16
|
+
boxShadow: `rgba(0,0,0,.10) 0 4${CONFIG.UNIT.default} 10${CONFIG.UNIT.default}`
|
|
17
|
+
},
|
|
18
|
+
16: {
|
|
19
|
+
boxShadow: `rgba(0,0,0,.10) 0 8${CONFIG.UNIT.default} 16${CONFIG.UNIT.default}`
|
|
20
|
+
},
|
|
21
|
+
26: {
|
|
22
|
+
boxShadow: `rgba(0,0,0,.10) 0 14${CONFIG.UNIT.default} 26${CONFIG.UNIT.default}`
|
|
23
|
+
},
|
|
24
|
+
42: {
|
|
25
|
+
boxShadow: `rgba(0,0,0,.10) 0 20${CONFIG.UNIT.default} 42${CONFIG.UNIT.default}`
|
|
26
|
+
}
|
|
15
27
|
}
|
|
16
28
|
|
|
17
29
|
const getComputedBackgroundColor = ({ props }) => {
|
|
18
|
-
return
|
|
30
|
+
return (
|
|
31
|
+
getColor(props.shapeDirectionColor) ||
|
|
19
32
|
getColor(props.borderColor) ||
|
|
20
33
|
getColor(props.backgroundColor) ||
|
|
21
34
|
getColor(props.background)
|
|
35
|
+
)
|
|
22
36
|
}
|
|
23
37
|
|
|
24
38
|
const inheritTransition = ({ props, deps }) => {
|
|
25
|
-
const exec =
|
|
39
|
+
const exec = Box.class.transition({ props, deps })
|
|
26
40
|
return exec && exec.transition
|
|
27
41
|
}
|
|
28
42
|
|
|
@@ -168,10 +182,14 @@ export const SHAPES = {
|
|
|
168
182
|
transformOrigin: '50% 50%',
|
|
169
183
|
transition: inheritTransition({ props, deps }),
|
|
170
184
|
transitionProperty: 'background'
|
|
171
|
-
|
|
172
185
|
},
|
|
173
186
|
'&:before': {
|
|
174
|
-
background: `linear-gradient(225deg, ${getComputedBackgroundColor({
|
|
187
|
+
background: `linear-gradient(225deg, ${getComputedBackgroundColor({
|
|
188
|
+
props,
|
|
189
|
+
deps
|
|
190
|
+
})} 25%, transparent 25%), linear-gradient(315deg, ${getComputedBackgroundColor(
|
|
191
|
+
{ props, deps }
|
|
192
|
+
)} 25%, transparent 25%)`
|
|
175
193
|
},
|
|
176
194
|
'&:after': {
|
|
177
195
|
background: getComputedBackgroundColor({ props, deps }),
|
package/index.js
CHANGED
|
@@ -1,27 +1,16 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './Direction'
|
|
3
|
+
export * from './Box'
|
|
5
4
|
export * from './Flex'
|
|
6
5
|
export * from './Grid'
|
|
7
6
|
export * from './Img'
|
|
8
7
|
export * from './Form'
|
|
9
8
|
export * from './Media'
|
|
10
9
|
export * from './Iframe'
|
|
11
|
-
export * from './Interaction'
|
|
12
10
|
export * from './InteractiveComponent'
|
|
13
|
-
export * from './Overflow'
|
|
14
|
-
export * from './Collection'
|
|
15
|
-
export * from './Position'
|
|
16
11
|
export * from './Picture'
|
|
17
|
-
export * from './Pseudo'
|
|
18
12
|
export * from './Svg'
|
|
19
13
|
export * from './Shape'
|
|
20
14
|
export * from './Video'
|
|
21
|
-
export * from './Theme'
|
|
22
15
|
export * from './Text'
|
|
23
|
-
export * from './Timing'
|
|
24
16
|
export * from './Hgroup'
|
|
25
|
-
export * from './Transform'
|
|
26
|
-
export * from './XYZ'
|
|
27
|
-
export * from './Animation'
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/atoms",
|
|
3
|
-
"version": "2.29.
|
|
3
|
+
"version": "2.29.7",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "c74c4ee77eaebbd1a58ce94b258175f59b7572f4",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@domql/state": "^2.29.
|
|
9
|
-
"@domql/utils": "^2.29.
|
|
10
|
-
"@symbo.ls/emotion": "^2.29.
|
|
11
|
-
"@symbo.ls/scratch": "^2.29.
|
|
8
|
+
"@domql/state": "^2.29.7",
|
|
9
|
+
"@domql/utils": "^2.29.7",
|
|
10
|
+
"@symbo.ls/emotion": "^2.29.7",
|
|
11
|
+
"@symbo.ls/scratch": "^2.29.7"
|
|
12
12
|
},
|
|
13
13
|
"source": "src/index.js",
|
|
14
14
|
"devDependencies": {
|
package/Animation.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
|
|
4
|
-
import { isObject } from '@domql/utils'
|
|
5
|
-
import { emotion } from '@symbo.ls/emotion'
|
|
6
|
-
|
|
7
|
-
const applyAnimationProps = (animation, element) => {
|
|
8
|
-
const { emotion: ctxEmotion } = element.context
|
|
9
|
-
const { keyframes } = ctxEmotion || emotion
|
|
10
|
-
if (isObject(animation)) return { animationName: keyframes(animation) }
|
|
11
|
-
const { ANIMATION } = element.context && element.context.designSystem
|
|
12
|
-
const record = ANIMATION[animation]
|
|
13
|
-
return keyframes(record)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const props = {
|
|
17
|
-
animation: (el) => el.props.animation && {
|
|
18
|
-
animationName: el.deps.applyAnimationProps(el.props.animation, el),
|
|
19
|
-
animationDuration: el.deps.getTimingByKey(el.props.animationDuration || 'A').timing,
|
|
20
|
-
animationDelay: el.deps.getTimingByKey(el.props.animationDelay || '0s').timing,
|
|
21
|
-
animationTimingFunction: el.deps.getTimingFunction(el.props.animationTimingFunction || 'ease'),
|
|
22
|
-
animationFillMode: el.props.animationFillMode || 'both',
|
|
23
|
-
animationPlayState: el.props.animationPlayState,
|
|
24
|
-
animationDirection: el.props.animationDirection
|
|
25
|
-
},
|
|
26
|
-
animationName: (el) => el.props.animationName && {
|
|
27
|
-
animationName: el.deps.applyAnimationProps(el.props.animationName, el)
|
|
28
|
-
},
|
|
29
|
-
animationDuration: ({ props, deps }) => props.animationDuration && ({
|
|
30
|
-
animationDuration: deps.getTimingByKey(props.animationDuration).timing
|
|
31
|
-
}),
|
|
32
|
-
animationDelay: ({ props, deps }) => props.animationDelay && ({
|
|
33
|
-
animationDelay: deps.getTimingByKey(props.animationDelay).timing
|
|
34
|
-
}),
|
|
35
|
-
animationTimingFunction: ({ props, deps }) => props.animationTimingFunction && ({
|
|
36
|
-
animationTimingFunction: deps.getTimingFunction(props.animationTimingFunction)
|
|
37
|
-
})
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export const Animation = {
|
|
41
|
-
deps: { isObject, getTimingByKey, getTimingFunction, applyAnimationProps },
|
|
42
|
-
class: {
|
|
43
|
-
...props,
|
|
44
|
-
animationFillMode: ({ props }) => props.animationFillMode && ({
|
|
45
|
-
animationFillMode: props.animationFillMode
|
|
46
|
-
}),
|
|
47
|
-
animationPlayState: ({ props }) => props.animationPlayState && ({
|
|
48
|
-
animationPlayState: props.animationPlayState
|
|
49
|
-
}),
|
|
50
|
-
animationIterationCount: ({ props }) => props.animationIterationCount && ({
|
|
51
|
-
animationIterationCount: props.animationIterationCount || 1
|
|
52
|
-
}),
|
|
53
|
-
animationDirection: ({ props }) => props.animationDirection && ({
|
|
54
|
-
animationDirection: props.animationDirection
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
}
|