smbls 0.10.0 → 0.11.0
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/Block.js +30 -29
- package/src/Grid.js +3 -3
- package/src/Notification.js +0 -2
- package/src/Position.js +6 -6
- package/src/Text.js +4 -4
- package/src/Theme.js +4 -4
- package/src/Transition.js +2 -2
package/package.json
CHANGED
package/src/Block.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import { SPACING,
|
|
3
|
+
import { SPACING, getSpacingByKey } from '@symbo.ls/scratch'
|
|
4
4
|
|
|
5
|
-
export const
|
|
5
|
+
export const getSpacingBasedOnRatio = (props, prop, unit) => {
|
|
6
6
|
const { spacingRatio } = props
|
|
7
7
|
const val = props[prop]
|
|
8
|
-
// TODO: move this to
|
|
8
|
+
// TODO: move this to getSpacingByKey
|
|
9
9
|
if (spacingRatio) {
|
|
10
|
-
|
|
10
|
+
let params = SPACING[spacingRatio]
|
|
11
11
|
|
|
12
12
|
if (!params) {
|
|
13
|
-
SPACING[spacingRatio] = {
|
|
13
|
+
params = SPACING[spacingRatio] = {
|
|
14
14
|
base: SPACING.base,
|
|
15
|
-
type:
|
|
15
|
+
type: SPACING.type,
|
|
16
16
|
ratio: spacingRatio,
|
|
17
|
-
range:
|
|
18
|
-
subSequence:
|
|
17
|
+
range: SPACING.range,
|
|
18
|
+
subSequence: SPACING.subSequence,
|
|
19
19
|
sequence: {},
|
|
20
|
-
scales: {}
|
|
20
|
+
scales: {},
|
|
21
|
+
vars: {}
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
24
|
-
return
|
|
25
|
+
return getSpacingByKey(val, prop, params, unit)
|
|
25
26
|
}
|
|
26
|
-
return
|
|
27
|
+
return getSpacingByKey(val, prop, null, unit)
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
export const Block = {
|
|
@@ -36,47 +37,47 @@ export const Block = {
|
|
|
36
37
|
|
|
37
38
|
hide: ({ props }) => props.hide && ({ display: 'none' }),
|
|
38
39
|
|
|
39
|
-
width: ({ props }) => props.width &&
|
|
40
|
-
height: ({ props }) => props.height &&
|
|
40
|
+
width: ({ props }) => props.width && getSpacingBasedOnRatio(props, 'width'),
|
|
41
|
+
height: ({ props }) => props.height && getSpacingBasedOnRatio(props, 'height'),
|
|
41
42
|
boxSize: ({ props }) => {
|
|
42
43
|
if (typeof props.boxSize !== 'string') return
|
|
43
44
|
const [height, width] = props.boxSize.split(' ')
|
|
44
45
|
return {
|
|
45
|
-
...
|
|
46
|
-
...
|
|
46
|
+
...getSpacingByKey(height, 'height'),
|
|
47
|
+
...getSpacingByKey(width || height, 'width')
|
|
47
48
|
}
|
|
48
49
|
},
|
|
49
50
|
|
|
50
|
-
maxWidth: ({ props }) => props.maxWidth &&
|
|
51
|
-
minWidth: ({ props }) => props.minWidth &&
|
|
51
|
+
maxWidth: ({ props }) => props.maxWidth && getSpacingBasedOnRatio(props, 'maxWidth'),
|
|
52
|
+
minWidth: ({ props }) => props.minWidth && getSpacingBasedOnRatio(props, 'minWidth'),
|
|
52
53
|
widthRange: ({ props }) => {
|
|
53
54
|
if (typeof props.widthRange !== 'string') return
|
|
54
55
|
const [minWidth, maxWidth] = props.widthRange.split(' ')
|
|
55
56
|
return {
|
|
56
|
-
...
|
|
57
|
-
...
|
|
57
|
+
...getSpacingByKey(minWidth, 'minWidth'),
|
|
58
|
+
...getSpacingByKey(maxWidth, 'maxWidth')
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
61
|
|
|
61
|
-
maxHeight: ({ props }) => props.maxHeight &&
|
|
62
|
-
minHeight: ({ props }) => props.minHeight &&
|
|
62
|
+
maxHeight: ({ props }) => props.maxHeight && getSpacingBasedOnRatio(props, 'maxHeight'),
|
|
63
|
+
minHeight: ({ props }) => props.minHeight && getSpacingBasedOnRatio(props, 'minHeight'),
|
|
63
64
|
heightRange: ({ props }) => {
|
|
64
65
|
if (typeof props.heightRange !== 'string') return
|
|
65
66
|
const [minHeight, maxHeight] = props.heightRange.split(' ')
|
|
66
67
|
return {
|
|
67
|
-
...
|
|
68
|
-
...
|
|
68
|
+
...getSpacingByKey(minHeight, 'minHeight'),
|
|
69
|
+
...getSpacingByKey(maxHeight || minHeight, 'maxHeight')
|
|
69
70
|
}
|
|
70
71
|
},
|
|
71
72
|
|
|
72
73
|
aspectRatio: ({ props }) => props.aspectRatio && ({ aspectRatio: props.aspectRatio }),
|
|
73
74
|
|
|
74
|
-
borderWidth: ({ props }) => props.borderWidth ?
|
|
75
|
+
borderWidth: ({ props }) => props.borderWidth ? getSpacingBasedOnRatio(props, 'borderWidth') : null,
|
|
75
76
|
|
|
76
|
-
padding: ({ props }) => props.padding ?
|
|
77
|
-
margin: ({ props }) => props.margin ?
|
|
77
|
+
padding: ({ props }) => props.padding ? getSpacingBasedOnRatio(props, 'padding') : null,
|
|
78
|
+
margin: ({ props }) => props.margin ? getSpacingBasedOnRatio(props, 'margin') : null,
|
|
78
79
|
|
|
79
|
-
gap: ({ props }) => props.gap ?
|
|
80
|
+
gap: ({ props }) => props.gap ? getSpacingBasedOnRatio(props, 'gap') : null,
|
|
80
81
|
gridArea: ({ props }) => props.gridArea && ({ gridArea: props.gridArea }),
|
|
81
82
|
|
|
82
83
|
flex: ({ props }) => props.flex && ({ flex: props.flex }),
|
|
@@ -111,8 +112,8 @@ export const Block = {
|
|
|
111
112
|
if (typeof props.heightRange !== 'string') return
|
|
112
113
|
const [minHeight, maxHeight] = props.heightRange.split(' ')
|
|
113
114
|
return {
|
|
114
|
-
...
|
|
115
|
-
...
|
|
115
|
+
...getSpacingByKey(minHeight, 'minHeight'),
|
|
116
|
+
...getSpacingByKey(maxHeight || minHeight, 'maxHeight')
|
|
116
117
|
}
|
|
117
118
|
}
|
|
118
119
|
}
|
package/src/Grid.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getSpacingBasedOnRatio } from './Block'
|
|
4
4
|
|
|
5
5
|
export const Grid = {
|
|
6
6
|
props: { display: 'grid' },
|
|
@@ -11,7 +11,7 @@ export const Grid = {
|
|
|
11
11
|
area: ({ props }) => props.area ? ({ gridArea: props.area }) : null,
|
|
12
12
|
template: ({ props }) => props.template ? ({ gridTemplate: props.template }) : null,
|
|
13
13
|
templateAreas: ({ props }) => props.templateAreas ? ({ gridTemplateAreas: props.templateAreas }) : null,
|
|
14
|
-
columnGap: ({ props }) => props.columnGap ?
|
|
15
|
-
rowGap: ({ props }) => props.rowGap ?
|
|
14
|
+
columnGap: ({ props }) => props.columnGap ? getSpacingBasedOnRatio(props, 'columnGap') : null,
|
|
15
|
+
rowGap: ({ props }) => props.rowGap ? getSpacingBasedOnRatio(props, 'rowGap') : null
|
|
16
16
|
}
|
|
17
17
|
}
|
package/src/Notification.js
CHANGED
package/src/Position.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getSpacingByKey } from '@symbo.ls/scratch'
|
|
4
4
|
|
|
5
5
|
export const Position = {
|
|
6
6
|
props: {},
|
|
@@ -10,12 +10,12 @@ export const Position = {
|
|
|
10
10
|
inset: ({ props }) => {
|
|
11
11
|
const { inset } = props
|
|
12
12
|
if (typeof inset !== 'string') return
|
|
13
|
-
return { inset: inset.split(' ').map(v =>
|
|
13
|
+
return { inset: inset.split(' ').map(v => getSpacingByKey(v,'k').k).join(' ') }
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
-
left: ({ props }) =>
|
|
17
|
-
top: ({ props }) =>
|
|
18
|
-
right: ({ props }) =>
|
|
19
|
-
bottom: ({ props }) =>
|
|
16
|
+
left: ({ props }) => getSpacingByKey(props.left, 'left'),
|
|
17
|
+
top: ({ props }) => getSpacingByKey(props.top, 'top'),
|
|
18
|
+
right: ({ props }) => getSpacingByKey(props.right, 'right'),
|
|
19
|
+
bottom: ({ props }) => getSpacingByKey(props.bottom, 'bottom')
|
|
20
20
|
}
|
|
21
21
|
}
|
package/src/Text.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getFontSizeByKey, getFontFamily } from '@symbo.ls/scratch'
|
|
4
4
|
|
|
5
5
|
export const Text = {
|
|
6
6
|
props: {},
|
|
@@ -8,10 +8,10 @@ export const Text = {
|
|
|
8
8
|
text: ({ props }) => props.text,
|
|
9
9
|
|
|
10
10
|
class: {
|
|
11
|
-
fontSize: ({ props }) => props.fontSize ?
|
|
12
|
-
fontFamily: ({ props }) => props.fontFamily && ({ fontFamily: getFontFamily(
|
|
11
|
+
fontSize: ({ props }) => props.fontSize ? getFontSizeByKey(props.fontSize) : null,
|
|
12
|
+
fontFamily: ({ props }) => props.fontFamily && ({ fontFamily: getFontFamily(props.fontFamily) || props.fontFamily }),
|
|
13
13
|
lineHeight: ({ props }) => props.lineHeight && ({ lineHeight: props.lineHeight }),
|
|
14
|
-
// lineHeight: ({ props }) => props.lineHeight &&
|
|
14
|
+
// lineHeight: ({ props }) => props.lineHeight && getSpacingBasedOnRatio(props, 'lineHeight', null, ''),
|
|
15
15
|
textDecoration: ({ props }) => props.textDecoration && ({ textDecoration: props.textDecoration }),
|
|
16
16
|
textTransform: ({ props }) => props.textTransform && ({ textTransform: props.textTransform }),
|
|
17
17
|
whiteSpace: ({ props }) => props.whiteSpace && ({ whiteSpace: props.whiteSpace }),
|
package/src/Theme.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
import { isArray, isObject } from '@domql/utils'
|
|
4
|
-
import {
|
|
4
|
+
import { getSpacingByKey, getTheme, getColor } from '@symbo.ls/scratch'
|
|
5
5
|
|
|
6
6
|
import { depth } from './Shape/style'
|
|
7
7
|
|
|
@@ -33,15 +33,15 @@ const transformShadow = shadow => ({
|
|
|
33
33
|
|
|
34
34
|
const arr = v.split(' ')
|
|
35
35
|
if (!arr.length) return v
|
|
36
|
-
return arr.map(v =>
|
|
36
|
+
return arr.map(v => getSpacingByKey(v, 'shadow').shadow).join(' ')
|
|
37
37
|
}).join(' ')
|
|
38
38
|
})
|
|
39
39
|
|
|
40
40
|
export const Theme = {
|
|
41
41
|
class: {
|
|
42
42
|
depth: ({ props }) => depth[props.depth],
|
|
43
|
-
round: ({ props, key, ...el }) => props.round ? (
|
|
44
|
-
borderRadius: ({ props, key, ...el }) => props.borderRadius ? (
|
|
43
|
+
round: ({ props, key, ...el }) => props.round ? (getSpacingByKey(props.round, 'borderRadius') || ({ borderRadius: props.round })) : null,
|
|
44
|
+
borderRadius: ({ props, key, ...el }) => props.borderRadius ? (getSpacingByKey(props.borderRadius, 'borderRadius') || ({ borderRadius: props.borderRadius })) : null,
|
|
45
45
|
|
|
46
46
|
theme: ({ props, key }) => {
|
|
47
47
|
if (!props.theme) return
|
package/src/Transition.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { getTimingByKey } from '@symbo.ls/scratch'
|
|
4
4
|
|
|
5
5
|
const transformTransition = transition => {
|
|
6
6
|
const arr = transition.split(' ')
|
|
@@ -9,7 +9,7 @@ const transformTransition = transition => {
|
|
|
9
9
|
|
|
10
10
|
return arr.map(v => {
|
|
11
11
|
if (v.length < 3 || v.includes('ms')) {
|
|
12
|
-
const mapWithSequence =
|
|
12
|
+
const mapWithSequence = getTimingByKey(v)
|
|
13
13
|
return mapWithSequence.duration
|
|
14
14
|
}
|
|
15
15
|
return v
|