smbls 0.8.25 → 0.8.28
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 +2 -2
- package/src/Box/index.js +3 -1
- package/src/Icon.js +2 -3
- package/src/Media.js +130 -0
- package/src/SVG/index.js +2 -3
- package/src/Shape/index.js +6 -1
- package/src/Media/index.js +0 -71
package/package.json
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
"description": "UI Library built on Scratch and DOMQL",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "symbo.ls",
|
|
6
|
-
"version": "0.8.
|
|
7
|
-
"repository": "https://github.com/
|
|
6
|
+
"version": "0.8.28",
|
|
7
|
+
"repository": "https://github.com/symbo-ls/smbls",
|
|
8
8
|
"main": "src/index.js",
|
|
9
9
|
"files": [
|
|
10
10
|
"src"
|
package/src/Box/index.js
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
import { Shape, Position, Block, Text, Overflow, Transition, Transform, Responsive } from '..'
|
|
4
4
|
|
|
5
5
|
const PropsCSS = {
|
|
6
|
-
class: {
|
|
6
|
+
class: {
|
|
7
|
+
propsCSS: ({ props }) => props && props.css
|
|
8
|
+
}
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const Box = {
|
package/src/Icon.js
CHANGED
|
@@ -7,14 +7,13 @@ import { ICONS } from '@symbo.ls/scratch'
|
|
|
7
7
|
export const Icon = {
|
|
8
8
|
proto: SVG,
|
|
9
9
|
props: ({ key, props, parent }) => {
|
|
10
|
-
let iconName = props.inheritedString || props.name || props.icon || key
|
|
10
|
+
let iconName = props.inheritedString || props.name || props.icon || key
|
|
11
11
|
|
|
12
12
|
const isArray = iconName.split(' ')
|
|
13
13
|
const secondArg = props.iconModifier || isArray[1]
|
|
14
14
|
|
|
15
15
|
if (secondArg) iconName = isArray[0] + secondArg.slice(0, 1).toUpperCase() + secondArg.slice(1)
|
|
16
|
-
|
|
17
|
-
const iconFromLibrary = ICONS[iconName]
|
|
16
|
+
const iconFromLibrary = ICONS[iconName] || ICONS[isArray[0]] || ICONS['noIcon']
|
|
18
17
|
|
|
19
18
|
return {
|
|
20
19
|
width: 'A',
|
package/src/Media.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { getTheme, CASES, MEDIA as BREAKPOINTS } from '@symbo.ls/scratch'
|
|
4
|
+
|
|
5
|
+
const init = (el, s) => {
|
|
6
|
+
const { props, class: className } = el
|
|
7
|
+
|
|
8
|
+
for (const screen in props) {
|
|
9
|
+
if (screen.slice(0, 1) === '@') {
|
|
10
|
+
const mediaName = screen.slice(1)
|
|
11
|
+
const responsiveKey = `@media screen and ${BREAKPOINTS[mediaName]}`
|
|
12
|
+
const screenProps = props[screen]
|
|
13
|
+
const calculatedScreenProps = {}
|
|
14
|
+
|
|
15
|
+
for (const prop in screenProps) {
|
|
16
|
+
// if (!className || !className[prop]) return
|
|
17
|
+
// const classProp = className[prop]
|
|
18
|
+
const classProp = className[prop]
|
|
19
|
+
if (typeof classProp !== 'function') continue
|
|
20
|
+
let calculatedProp = classProp({ props: screenProps })
|
|
21
|
+
|
|
22
|
+
if (Array.isArray(calculatedProp)) {
|
|
23
|
+
calculatedProp = Object.assign({}, ...calculatedProp)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const finalProp in calculatedProp) {
|
|
27
|
+
calculatedScreenProps[finalProp] = calculatedProp[finalProp]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const { MEDIA } = className
|
|
32
|
+
if (!MEDIA) className.MEDIA = {}
|
|
33
|
+
className.MEDIA[responsiveKey] = calculatedScreenProps
|
|
34
|
+
} else if (screen.slice(0, 1) === ':') {
|
|
35
|
+
const selectorProps = {}
|
|
36
|
+
// const selectorName = screen.slice(1)
|
|
37
|
+
const underSelectorProps = props[screen]
|
|
38
|
+
const selectorKey = `&${screen}`
|
|
39
|
+
|
|
40
|
+
for (const prop in underSelectorProps) {
|
|
41
|
+
const classProp = className[prop]
|
|
42
|
+
if (typeof classProp !== 'function') continue
|
|
43
|
+
let calculatedProp = classProp({ props: underSelectorProps })
|
|
44
|
+
|
|
45
|
+
if (Array.isArray(calculatedProp)) {
|
|
46
|
+
calculatedProp = Object.assign({}, ...calculatedProp)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
for (const finalProp in calculatedProp) {
|
|
50
|
+
selectorProps[finalProp] = calculatedProp[finalProp]
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const { SELECTORS } = className
|
|
55
|
+
if (SELECTORS) SELECTORS[selectorKey] = selectorProps
|
|
56
|
+
else {
|
|
57
|
+
className.SELECTORS = {
|
|
58
|
+
[selectorKey]: selectorProps
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
} else if (screen.slice(0, 1) === '$') {
|
|
62
|
+
const caseKey = screen.slice(1)
|
|
63
|
+
const caseProps = props[screen]
|
|
64
|
+
const calculatedCaseProps = {}
|
|
65
|
+
|
|
66
|
+
if (!CASES[caseKey]) return
|
|
67
|
+
|
|
68
|
+
for (const prop in caseProps) {
|
|
69
|
+
// if (!className || !className[prop]) return
|
|
70
|
+
// const classProp = className[prop]
|
|
71
|
+
const classProp = className[prop]
|
|
72
|
+
if (typeof classProp !== 'function') continue
|
|
73
|
+
let calculatedProp = classProp({ props: caseProps })
|
|
74
|
+
|
|
75
|
+
if (Array.isArray(calculatedProp)) {
|
|
76
|
+
calculatedProp = Object.assign({}, ...calculatedProp)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
for (const finalProp in calculatedProp) {
|
|
80
|
+
calculatedCaseProps[finalProp] = calculatedProp[finalProp]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const { CASE } = className
|
|
85
|
+
if (!CASE) className.CASE = {}
|
|
86
|
+
className.CASE[caseKey] = calculatedCaseProps
|
|
87
|
+
// Object.assign(className.CASE[caseKey], calculatedCaseProps)
|
|
88
|
+
// console.log(className.CASE)
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export const Responsive = {
|
|
94
|
+
on: {
|
|
95
|
+
init,
|
|
96
|
+
initUpdate: el => {
|
|
97
|
+
const { props, class: className } = el
|
|
98
|
+
const rootState = el.__root ? el.__root.state : el.state
|
|
99
|
+
|
|
100
|
+
if (props.theme) {
|
|
101
|
+
props.returnGeneratedTheme = getTheme(props.theme)
|
|
102
|
+
const { returnGeneratedTheme } = props
|
|
103
|
+
|
|
104
|
+
for (const key in returnGeneratedTheme) {
|
|
105
|
+
if (key.includes('dark') || key.includes('light')) {
|
|
106
|
+
const parse = key.split(': ')[1].split(')')[0]
|
|
107
|
+
if (rootState.globalTheme === parse) {
|
|
108
|
+
props.returnGeneratedTheme = getTheme(returnGeneratedTheme[key])
|
|
109
|
+
} else props.returnGeneratedTheme = returnGeneratedTheme
|
|
110
|
+
className.MEDIA_FORCED_BY_STATE = props.returnGeneratedTheme
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
for (const screen in props) {
|
|
116
|
+
if (screen.slice(0, 1) === '@') {
|
|
117
|
+
const mediaName = screen.slice(1)
|
|
118
|
+
const responsiveKey = `@media screen and ${BREAKPOINTS[mediaName]}`
|
|
119
|
+
if (mediaName === 'dark' || mediaName === 'light') {
|
|
120
|
+
const { MEDIA_FORCE } = className
|
|
121
|
+
if (!MEDIA_FORCE) className.media = {}
|
|
122
|
+
if (rootState.globalTheme === mediaName) {
|
|
123
|
+
className.MEDIA_FORCED = className.MEDIA[responsiveKey]
|
|
124
|
+
} else className.MEDIA_FORCED = {}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
package/src/SVG/index.js
CHANGED
|
@@ -2,13 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
const useSVGSymbol = file => `<use xlink:href="${file}" />`
|
|
4
4
|
|
|
5
|
-
// create
|
|
5
|
+
// create SVG symbol
|
|
6
6
|
export const SVG = {
|
|
7
7
|
tag: 'svg',
|
|
8
8
|
attr: {
|
|
9
9
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
10
10
|
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
|
|
11
11
|
},
|
|
12
|
-
|
|
13
|
-
html: ({ key, props }) => useSVGSymbol(props.src || key)
|
|
12
|
+
html: ({ key, props }) => useSVGSymbol(props.src)
|
|
14
13
|
}
|
package/src/Shape/index.js
CHANGED
|
@@ -45,7 +45,12 @@ export const Shape = {
|
|
|
45
45
|
depth: ({ props }) => depth[props.depth],
|
|
46
46
|
round: ({ props, key, ...el }) => props.round ? (mapSpacing(props.round, 'borderRadius') || ({ borderRadius: props.round })) : null,
|
|
47
47
|
borderRadius: ({ props, key, ...el }) => props.borderRadius ? (mapSpacing(props.borderRadius, 'borderRadius') || ({ borderRadius: props.borderRadius })) : null,
|
|
48
|
-
|
|
48
|
+
|
|
49
|
+
theme: ({ props }) => {
|
|
50
|
+
if (!props.theme) return
|
|
51
|
+
return props.returnGeneratedTheme || getTheme(props.theme)
|
|
52
|
+
},
|
|
53
|
+
|
|
49
54
|
color: ({ props }) => props.color ? ({ color: getColor(props.color) }) : null,
|
|
50
55
|
background: ({ props }) => props.background ? ({ backgroundColor: getColor(props.background) }) : null,
|
|
51
56
|
// border: ({ props }) => props.border ? ({ borderColor: getColor(props.border) }) : null,
|
package/src/Media/index.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { MEDIA as BREAKPOINTS } from '@symbo.ls/scratch'
|
|
4
|
-
|
|
5
|
-
export const Responsive = {
|
|
6
|
-
on: {
|
|
7
|
-
init: (el, s) => {
|
|
8
|
-
const { props } = el
|
|
9
|
-
|
|
10
|
-
for (const screen in props) {
|
|
11
|
-
if (screen.slice(0, 1) === '@') {
|
|
12
|
-
const mediaName = screen.slice(1)
|
|
13
|
-
const responsiveKey = `@media screen and ${BREAKPOINTS[mediaName]}`
|
|
14
|
-
const screenProps = props[screen]
|
|
15
|
-
const calculatedScreenProps = {}
|
|
16
|
-
|
|
17
|
-
for (const prop in screenProps) {
|
|
18
|
-
// if (!el.class || !el.class[prop]) return
|
|
19
|
-
// const classProp = el.class[prop]
|
|
20
|
-
const classProp = el.class[prop]
|
|
21
|
-
if (typeof classProp !== 'function') continue
|
|
22
|
-
let calculatedProp = classProp({ props: screenProps })
|
|
23
|
-
|
|
24
|
-
if (Array.isArray(calculatedProp)) {
|
|
25
|
-
calculatedProp = Object.assign({}, ...calculatedProp)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
for (const finalProp in calculatedProp) {
|
|
29
|
-
calculatedScreenProps[finalProp] = calculatedProp[finalProp]
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const { MEDIA } = el.class
|
|
34
|
-
if (MEDIA) MEDIA[responsiveKey] = calculatedScreenProps
|
|
35
|
-
else {
|
|
36
|
-
el.class.MEDIA = {
|
|
37
|
-
[responsiveKey]: calculatedScreenProps
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
} else if (screen.slice(0, 1) === ':') {
|
|
41
|
-
const selectorProps = {}
|
|
42
|
-
// const selectorName = screen.slice(1)
|
|
43
|
-
const underSelectorProps = props[screen]
|
|
44
|
-
const selectorKey = `&${screen}`
|
|
45
|
-
|
|
46
|
-
for (const prop in underSelectorProps) {
|
|
47
|
-
const classProp = el.class[prop]
|
|
48
|
-
if (typeof classProp !== 'function') continue
|
|
49
|
-
let calculatedProp = classProp({ props: underSelectorProps })
|
|
50
|
-
|
|
51
|
-
if (Array.isArray(calculatedProp)) {
|
|
52
|
-
calculatedProp = Object.assign({}, ...calculatedProp)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
for (const finalProp in calculatedProp) {
|
|
56
|
-
selectorProps[finalProp] = calculatedProp[finalProp]
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const { SELECTORS } = el.class
|
|
61
|
-
if (SELECTORS) SELECTORS[selectorKey] = selectorProps
|
|
62
|
-
else {
|
|
63
|
-
el.class.SELECTORS = {
|
|
64
|
-
[selectorKey]: selectorProps
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|