@symbo.ls/atoms 2.11.81 → 2.11.94
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/Block.js +5 -0
- package/Media.js +26 -39
- package/package.json +2 -2
package/Block.js
CHANGED
package/Media.js
CHANGED
|
@@ -13,7 +13,7 @@ export const keySetters = {
|
|
|
13
13
|
'[': (key, props, result, element, isSubtree) => applySelectorProps(
|
|
14
14
|
key, props, isSubtree ? result : (result && result.selector), element
|
|
15
15
|
),
|
|
16
|
-
'&': (key, props, result, element, isSubtree) =>
|
|
16
|
+
'&': (key, props, result, element, isSubtree) => applyEndProps(
|
|
17
17
|
key, props, isSubtree ? result : (result && result.selector), element
|
|
18
18
|
),
|
|
19
19
|
$: (key, props, result, element, isSubtree) => applyCaseProps(
|
|
@@ -82,11 +82,16 @@ const applyMediaProps = (key, props, result, element) => {
|
|
|
82
82
|
return
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
const mediaKey = `@media screen and ${mediaName}`
|
|
85
|
+
const mediaKey = mediaName ? `@media screen and ${mediaName}` : key
|
|
86
86
|
result[mediaKey] = generatedClass
|
|
87
87
|
return result[mediaKey]
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
const applyEndProps = (key, props, result, element) => {
|
|
91
|
+
result[key] = convertPropsToClass(props, result, element)
|
|
92
|
+
return result[key]
|
|
93
|
+
}
|
|
94
|
+
|
|
90
95
|
const applySelectorProps = (key, props, result, element) => {
|
|
91
96
|
const selectorKey = `&${key}`
|
|
92
97
|
result[selectorKey] = convertPropsToClass(props, result, element)
|
|
@@ -117,7 +122,7 @@ const applyConditionalFalsyProps = (key, props, result, element) => {
|
|
|
117
122
|
const applyTrueProps = (props, result, element) => merge(result, convertPropsToClass(props, result, element))
|
|
118
123
|
|
|
119
124
|
const beforeClassAssign = (element, s) => {
|
|
120
|
-
const { props, class: className } = element
|
|
125
|
+
const { props, class: className, context } = element
|
|
121
126
|
|
|
122
127
|
const CLASS_NAMES = {
|
|
123
128
|
media: {},
|
|
@@ -125,18 +130,25 @@ const beforeClassAssign = (element, s) => {
|
|
|
125
130
|
case: {}
|
|
126
131
|
}
|
|
127
132
|
|
|
133
|
+
if (!context) return
|
|
134
|
+
const globalTheme = context.designSystem.globalTheme
|
|
135
|
+
|
|
128
136
|
for (const key in props) {
|
|
129
137
|
const setter = keySetters[key.slice(0, 1)]
|
|
138
|
+
if (globalTheme) {
|
|
139
|
+
if (key === 'theme') {
|
|
140
|
+
props.update({
|
|
141
|
+
themeModifier: globalTheme
|
|
142
|
+
}, {
|
|
143
|
+
preventRecursive: true,
|
|
144
|
+
isForced: true,
|
|
145
|
+
preventDefineUpdate: true
|
|
146
|
+
})
|
|
147
|
+
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
148
|
+
}
|
|
130
149
|
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
131
150
|
}
|
|
132
151
|
|
|
133
|
-
overwriteShallow(className, CLASS_NAMES)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const initUpdate = (changes, element) => {
|
|
137
|
-
const { props, context, class: className } = element
|
|
138
|
-
if (!context) return
|
|
139
|
-
const globalTheme = context.designSystem.globalTheme
|
|
140
152
|
|
|
141
153
|
const parentProps = element.parent.props
|
|
142
154
|
if (parentProps && parentProps.spacingRatio && parentProps.inheritSpacingRatio) {
|
|
@@ -145,37 +157,12 @@ const initUpdate = (changes, element) => {
|
|
|
145
157
|
inheritSpacingRatio: true
|
|
146
158
|
}, {
|
|
147
159
|
preventRecursive: true,
|
|
148
|
-
|
|
160
|
+
isForced: true,
|
|
161
|
+
preventDefineUpdate: true
|
|
149
162
|
})
|
|
150
163
|
}
|
|
151
164
|
|
|
152
|
-
|
|
153
|
-
const CLASS_NAMES = {
|
|
154
|
-
media: {},
|
|
155
|
-
selector: {},
|
|
156
|
-
case: {}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
for (const key in props) {
|
|
160
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
161
|
-
if (key === 'theme') {
|
|
162
|
-
props.update({
|
|
163
|
-
themeModifier: globalTheme
|
|
164
|
-
}, {
|
|
165
|
-
preventRecursive: true,
|
|
166
|
-
preventInitUpdateListener: true,
|
|
167
|
-
preventDefineUpdate: true
|
|
168
|
-
})
|
|
169
|
-
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
170
|
-
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (Object.keys(CLASS_NAMES.media).length) {
|
|
174
|
-
className.media = CLASS_NAMES.media
|
|
175
|
-
}
|
|
176
|
-
className.selector = CLASS_NAMES.selector
|
|
177
|
-
className.case = CLASS_NAMES.case
|
|
178
|
-
}
|
|
165
|
+
overwriteShallow(className, CLASS_NAMES)
|
|
179
166
|
}
|
|
180
167
|
|
|
181
168
|
export const Media = {
|
|
@@ -186,5 +173,5 @@ export const Media = {
|
|
|
186
173
|
}
|
|
187
174
|
}
|
|
188
175
|
},
|
|
189
|
-
on: { beforeClassAssign
|
|
176
|
+
on: { beforeClassAssign }
|
|
190
177
|
}
|
package/package.json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@symbo.ls/atoms",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.94",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"gitHead": "
|
|
6
|
+
"gitHead": "80354d405a3dd6085ee93472538ebef687c97764",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@domql/state": "latest",
|
|
9
9
|
"@domql/utils": "latest",
|