smbls 0.15.32 → 0.15.33
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/atoms/Media.js +7 -8
- package/src/atoms/Theme.js +10 -5
package/package.json
CHANGED
package/src/atoms/Media.js
CHANGED
|
@@ -16,7 +16,7 @@ const execClass = (key, props, result, element) => {
|
|
|
16
16
|
|
|
17
17
|
if (typeof classnameExec !== 'function') return
|
|
18
18
|
|
|
19
|
-
let classExec = classnameExec({ props })
|
|
19
|
+
let classExec = classnameExec({ props, context: element.context })
|
|
20
20
|
if (isArray(classExec)) {
|
|
21
21
|
classExec = classExec.reduce((a, c) => merge(a, c), {})
|
|
22
22
|
}
|
|
@@ -45,13 +45,13 @@ const convertPropsToClass = (props, result, element) => {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
const applyMediaProps = (key, props, result, element) => {
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
const { context } = element
|
|
49
|
+
console.log(context, element)
|
|
50
|
+
if (!context.SYSTEM || !context.SYSTEM.MEDIA) return
|
|
51
|
+
const { globalTheme, MEDIA } = context.SYSTEM
|
|
50
52
|
const mediaName = MEDIA[key.slice(1)]
|
|
51
53
|
const generatedClass = convertPropsToClass(props, result, element)
|
|
52
54
|
|
|
53
|
-
const rootState = element.__root ? element.__root.state : element.state
|
|
54
|
-
const { globalTheme } = rootState
|
|
55
55
|
const name = key.slice(1)
|
|
56
56
|
const isTheme = ['dark', 'light'].includes(name)
|
|
57
57
|
const matchesGlobal = name === globalTheme
|
|
@@ -113,8 +113,7 @@ const beforeClassAssign = (element, s) => {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
export const initUpdate = element => {
|
|
116
|
-
const { props, class: className } = element
|
|
117
|
-
const rootState = element.__root ? element.__root.state : element.state
|
|
116
|
+
const { props, context, class: className } = element
|
|
118
117
|
|
|
119
118
|
const parentProps = element.parent.props
|
|
120
119
|
if (parentProps && parentProps.spacingRatio && parentProps.inheritSpacingRatio) {
|
|
@@ -127,7 +126,7 @@ export const initUpdate = element => {
|
|
|
127
126
|
})
|
|
128
127
|
}
|
|
129
128
|
|
|
130
|
-
const { globalTheme } =
|
|
129
|
+
const { globalTheme } = context.SYSTEM
|
|
131
130
|
|
|
132
131
|
if (globalTheme) {
|
|
133
132
|
const CLASS_NAMES = {
|
package/src/atoms/Theme.js
CHANGED
|
@@ -50,14 +50,19 @@ export const Theme = {
|
|
|
50
50
|
class: {
|
|
51
51
|
depth: ({ props }) => depth[props.depth],
|
|
52
52
|
|
|
53
|
-
theme: ({ props,
|
|
53
|
+
theme: ({ props, context }) => {
|
|
54
54
|
if (!props.theme) return
|
|
55
|
-
return getMediaTheme(props.theme, props.themeModifier)
|
|
55
|
+
return getMediaTheme(props.theme, props.themeModifier || context.SYSTEM.globalTheme)
|
|
56
56
|
},
|
|
57
57
|
|
|
58
|
-
color: ({ props }) =>
|
|
59
|
-
|
|
60
|
-
|
|
58
|
+
color: ({ props, context }) => props.color && (
|
|
59
|
+
getMediaColor(props.color, 'color', context.SYSTEM.globalTheme)
|
|
60
|
+
),
|
|
61
|
+
background: ({ props, context }) => {
|
|
62
|
+
if (!props.background) return
|
|
63
|
+
return getMediaColor(props.background, 'background', context.SYSTEM.globalTheme)
|
|
64
|
+
},
|
|
65
|
+
backgroundColor: ({ props, context }) => (props.backgroundColor) && getMediaColor(props.backgroundColor, 'backgroundColor', context.SYSTEM.globalTheme),
|
|
61
66
|
backgroundImage: ({ props, context }) => (props.backgroundImage) && transformBackgroundImage(props.backgroundImage, context),
|
|
62
67
|
backgroundSize: ({ props }) => props.backgroundSize ? ({ backgroundSize: props.backgroundSize }) : null,
|
|
63
68
|
backgroundPosition: ({ props }) => props.backgroundPosition ? ({ backgroundPosition: props.backgroundPosition }) : null,
|