smbls 0.15.20 → 0.15.21
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 +1 -1
- package/src/Icon.js +2 -3
- package/src/atoms/Animation.js +52 -0
- package/src/atoms/Interaction.js +13 -0
- package/src/atoms/Media.js +24 -23
- package/src/atoms/Timing.js +6 -3
package/package.json
CHANGED
package/src/Icon.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { SVG } from './atoms'
|
|
4
|
-
|
|
5
|
-
import { ICONS } from '@symbo.ls/scratch'
|
|
6
4
|
import { toCamelCase } from '@symbo.ls/utils'
|
|
7
5
|
|
|
8
6
|
export const Icon = {
|
|
9
7
|
extend: SVG,
|
|
10
|
-
props: ({ key, props, parent }) => {
|
|
8
|
+
props: ({ key, props, parent, context }) => {
|
|
9
|
+
const { ICONS } = context && context.SYSTEM
|
|
11
10
|
const iconName = props.inheritedString || props.name || props.icon || key
|
|
12
11
|
const camelCase = toCamelCase(iconName)
|
|
13
12
|
const isArray = camelCase.split(/([a-z])([A-Z])/g)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { merge } from '@domql/utils'
|
|
4
|
+
import { getTimingFunction } from '@symbo.ls/scratch'
|
|
5
|
+
import { convertPropsToClass } from './Media'
|
|
6
|
+
import { transformDuration } from './Timing'
|
|
7
|
+
|
|
8
|
+
const applyAnimationProps = (key, props, result, element) => {
|
|
9
|
+
const { ANIMATION } = element.context && element.context.SYSTEM
|
|
10
|
+
const mediaName = ANIMATION[key.slice(1)]
|
|
11
|
+
const generatedClass = convertPropsToClass(props, result, element)
|
|
12
|
+
|
|
13
|
+
const rootState = element.__root ? element.__root.state : element.state
|
|
14
|
+
const { globalTheme } = rootState
|
|
15
|
+
const name = key.slice(1)
|
|
16
|
+
const isTheme = ['dark', 'light'].includes(name)
|
|
17
|
+
const matchesGlobal = name === globalTheme
|
|
18
|
+
|
|
19
|
+
if (globalTheme && isTheme) {
|
|
20
|
+
if (matchesGlobal) return merge(result, generatedClass)
|
|
21
|
+
return
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const mediaKey = `@media screen and ${mediaName}`
|
|
25
|
+
result[mediaKey] = generatedClass
|
|
26
|
+
return result[mediaKey]
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const Animation = {
|
|
30
|
+
class: {
|
|
31
|
+
animation: ({ props }) => props.animation && ({
|
|
32
|
+
animation: applyAnimationProps(props.animation)
|
|
33
|
+
}),
|
|
34
|
+
|
|
35
|
+
animationDuration: ({ props }) => props.animationDuration && ({
|
|
36
|
+
animationDuration: transformDuration(props.animationDuration)
|
|
37
|
+
}),
|
|
38
|
+
animationDelay: ({ props }) => props.animationDelay && ({
|
|
39
|
+
animationDelay: transformDuration(props.animationDelay)
|
|
40
|
+
}),
|
|
41
|
+
animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
|
|
42
|
+
animationTimingFunction: getTimingFunction(props.animationTimingFunction)
|
|
43
|
+
}),
|
|
44
|
+
animationFillMode: ({ props }) => props.animationFillMode && ({
|
|
45
|
+
animationFillMode: props.animationFillMode
|
|
46
|
+
}),
|
|
47
|
+
animationProperty: ({ props }) => props.animationProperty && ({
|
|
48
|
+
animationProperty: props.animationProperty,
|
|
49
|
+
willChange: props.animationProperty
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
}
|
package/src/atoms/Interaction.js
CHANGED
|
@@ -27,6 +27,19 @@ export const Hoverable = {
|
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export const Clickable = {
|
|
31
|
+
extend: Hoverable,
|
|
32
|
+
props: {
|
|
33
|
+
':active': {
|
|
34
|
+
opacity: 1,
|
|
35
|
+
transform: 'scale(1.015)'
|
|
36
|
+
},
|
|
37
|
+
'.active': {
|
|
38
|
+
opacity: 1
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
30
43
|
export const Focusable = {
|
|
31
44
|
props: {
|
|
32
45
|
border: 'none',
|
package/src/atoms/Media.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { merge, isArray } from '@domql/utils'
|
|
4
|
-
import { CASES as CONFIG_CASES, MEDIA as CONFIG_MEDIA } from '@symbo.ls/scratch'
|
|
5
4
|
|
|
6
5
|
const keySetters = {
|
|
7
6
|
'@': (key, props, result, element, isSubtree) => applyMediaProps(key, props, isSubtree ? result : result.media, element),
|
|
@@ -46,7 +45,8 @@ const convertPropsToClass = (props, result, element) => {
|
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
const applyMediaProps = (key, props, result, element) => {
|
|
49
|
-
const
|
|
48
|
+
const { MEDIA } = element.context && element.context.SYSTEM
|
|
49
|
+
const mediaName = MEDIA[key.slice(1)]
|
|
50
50
|
const generatedClass = convertPropsToClass(props, result, element)
|
|
51
51
|
|
|
52
52
|
const rootState = element.__root ? element.__root.state : element.state
|
|
@@ -72,9 +72,10 @@ const applySelectorProps = (key, props, result, element) => {
|
|
|
72
72
|
}
|
|
73
73
|
|
|
74
74
|
const applyCaseProps = (key, props, result, element) => {
|
|
75
|
+
const { CASES } = element.context && element.context.SYSTEM
|
|
75
76
|
const caseKey = key.slice(1)
|
|
76
77
|
const isPropTrue = element.props[caseKey]
|
|
77
|
-
if (!
|
|
78
|
+
if (!CASES[caseKey] && !isPropTrue) return
|
|
78
79
|
return merge(result, convertPropsToClass(props, result, element))
|
|
79
80
|
}
|
|
80
81
|
|
|
@@ -127,30 +128,30 @@ export const initUpdate = element => {
|
|
|
127
128
|
|
|
128
129
|
const { globalTheme } = rootState
|
|
129
130
|
|
|
130
|
-
if (
|
|
131
|
+
if (globalTheme) {
|
|
132
|
+
const CLASS_NAMES = {
|
|
133
|
+
media: {},
|
|
134
|
+
selector: {},
|
|
135
|
+
case: {}
|
|
136
|
+
}
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
for (const key in props) {
|
|
139
|
+
const setter = keySetters[key.slice(0, 1)]
|
|
140
|
+
if (key === 'theme') {
|
|
141
|
+
props.update({
|
|
142
|
+
themeModifier: `@${globalTheme}`
|
|
143
|
+
}, { preventRecursive: true, ignoreInitUpdate: true })
|
|
144
|
+
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
137
145
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
if (key === 'theme') {
|
|
141
|
-
props.update({
|
|
142
|
-
themeModifier: `@${globalTheme}`
|
|
143
|
-
}, { preventRecursive: true, ignoreInitUpdate: true })
|
|
144
|
-
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
145
|
-
|
|
146
|
-
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
147
|
-
}
|
|
146
|
+
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
147
|
+
}
|
|
148
148
|
|
|
149
|
-
|
|
150
|
-
|
|
149
|
+
if (Object.keys(CLASS_NAMES.media).length) {
|
|
150
|
+
className.media = CLASS_NAMES.media
|
|
151
|
+
}
|
|
152
|
+
className.selector = CLASS_NAMES.selector
|
|
153
|
+
className.case = CLASS_NAMES.case
|
|
151
154
|
}
|
|
152
|
-
className.selector = CLASS_NAMES.selector
|
|
153
|
-
className.case = CLASS_NAMES.case
|
|
154
155
|
}
|
|
155
156
|
|
|
156
157
|
export const Media = {
|
package/src/atoms/Timing.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { isString } from '@domql/utils'
|
|
4
4
|
import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
|
|
5
5
|
|
|
6
|
-
const transformTransition = transition => {
|
|
6
|
+
export const transformTransition = transition => {
|
|
7
7
|
const arr = transition.split(' ')
|
|
8
8
|
|
|
9
9
|
if (!arr.length) return transition
|
|
@@ -18,12 +18,12 @@ const transformTransition = transition => {
|
|
|
18
18
|
}).join(' ')
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
const transformDuration = (duration, props, propertyName) => {
|
|
21
|
+
export const transformDuration = (duration, props, propertyName) => {
|
|
22
22
|
if (!isString(duration)) return
|
|
23
23
|
return duration.split(',').map(getTimingByKey).join(',')
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const splitTransition = transition => {
|
|
26
|
+
export const splitTransition = transition => {
|
|
27
27
|
const arr = transition.split(',')
|
|
28
28
|
if (!arr.length) return
|
|
29
29
|
return arr.map(transformTransition).join(',')
|
|
@@ -57,6 +57,9 @@ export const Timing = {
|
|
|
57
57
|
animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
|
|
58
58
|
animationTimingFunction: getTimingFunction(props.animationTimingFunction)
|
|
59
59
|
}),
|
|
60
|
+
animationFillMode: ({ props }) => props.animationFillMode && ({
|
|
61
|
+
animationFillMode: props.animationFillMode
|
|
62
|
+
}),
|
|
60
63
|
animationProperty: ({ props }) => props.animationProperty && ({
|
|
61
64
|
animationProperty: props.animationProperty,
|
|
62
65
|
willChange: props.animationProperty
|