smbls 0.13.7 → 0.14.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 +1 -29
- package/src/DatePicker/index.js +137 -95
- package/src/DatePicker/style.js +0 -82
- package/src/Grid.js +1 -1
- package/src/Input.js +2 -4
- package/src/Media.js +15 -1
- package/src/Shape/index.js +5 -5
- package/src/Theme.js +12 -1
package/package.json
CHANGED
package/src/Block.js
CHANGED
|
@@ -1,34 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export const getSpacingBasedOnRatio = (props, propertyName, unit) => {
|
|
6
|
-
const { spacingRatio } = props
|
|
7
|
-
|
|
8
|
-
// if (spacingRatio) console.log(propertyName, props)
|
|
9
|
-
|
|
10
|
-
const val = props[propertyName]
|
|
11
|
-
// TODO: move this to getSpacingByKey
|
|
12
|
-
if (spacingRatio) {
|
|
13
|
-
let params = SPACING[spacingRatio]
|
|
14
|
-
|
|
15
|
-
if (!params) {
|
|
16
|
-
params = SPACING[spacingRatio] = {
|
|
17
|
-
base: props.base || SPACING.base,
|
|
18
|
-
type: SPACING.type + '-' + spacingRatio,
|
|
19
|
-
ratio: spacingRatio,
|
|
20
|
-
range: SPACING.range,
|
|
21
|
-
subSequence: SPACING.subSequence,
|
|
22
|
-
sequence: {},
|
|
23
|
-
scales: {},
|
|
24
|
-
vars: {}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
return getSpacingByKey(val, propertyName, params, unit, false)
|
|
29
|
-
}
|
|
30
|
-
return getSpacingByKey(val, propertyName, null, unit)
|
|
31
|
-
}
|
|
3
|
+
import { getSpacingBasedOnRatio, getSpacingByKey } from '@symbo.ls/scratch'
|
|
32
4
|
|
|
33
5
|
export const Block = {
|
|
34
6
|
class: {
|
package/src/DatePicker/index.js
CHANGED
|
@@ -2,111 +2,153 @@
|
|
|
2
2
|
|
|
3
3
|
import style from './style'
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { SquareButton, Flex, Button, Grid } from '../'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
const buttonProps = {
|
|
8
|
+
theme: 'transparent',
|
|
9
|
+
color: '--theme-quinary-dark-color',
|
|
10
|
+
':hover': {
|
|
11
|
+
theme: 'quinary .child'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
9
14
|
|
|
15
|
+
const aside = {
|
|
10
16
|
props: {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
17
|
+
gap: 'X2',
|
|
18
|
+
margin: '-Z - -Z -X2',
|
|
19
|
+
padding: 'Z - Z X2',
|
|
20
|
+
minHeight: '100%',
|
|
21
|
+
height: '100%',
|
|
22
|
+
width: '--spacing-D'
|
|
15
23
|
},
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{ text: '2026' }
|
|
29
|
-
]
|
|
30
|
-
},
|
|
25
|
+
cnt: {
|
|
26
|
+
extend: Flex,
|
|
27
|
+
props: {
|
|
28
|
+
flow: 'column',
|
|
29
|
+
overflow: 'hidden auto',
|
|
30
|
+
boxSize: '100% --spacing-D',
|
|
31
|
+
top: '0',
|
|
32
|
+
position: 'absolute',
|
|
33
|
+
maxHeight: '100%',
|
|
34
|
+
justifyContent: 'flex-end'
|
|
35
|
+
},
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
month: {
|
|
39
|
-
childExtend: { tag: 'span' },
|
|
40
|
-
...[
|
|
41
|
-
{ text: 'january' },
|
|
42
|
-
{ text: 'february' },
|
|
43
|
-
{ text: 'march' },
|
|
44
|
-
{ text: 'april' },
|
|
45
|
-
{ text: 'may' },
|
|
46
|
-
{ text: 'june' },
|
|
47
|
-
{ text: 'july' },
|
|
48
|
-
{ text: 'august' },
|
|
49
|
-
{ text: 'september' },
|
|
50
|
-
{ text: 'october' },
|
|
51
|
-
{ text: 'november' },
|
|
52
|
-
{ text: 'december' }
|
|
53
|
-
]
|
|
37
|
+
childExtend: {
|
|
38
|
+
extend: Button,
|
|
39
|
+
props: {
|
|
40
|
+
...buttonProps,
|
|
41
|
+
fontSize: 'Z1'
|
|
54
42
|
},
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
text: ({ state }) => state.value
|
|
44
|
+
},
|
|
45
|
+
$setCollection: () => {
|
|
46
|
+
return new Array(30).fill(undefined).map((_, i) => (2022 - i)).reverse()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const main = {
|
|
53
|
+
extend: Flex,
|
|
54
|
+
|
|
55
|
+
props: {
|
|
56
|
+
flex: 1,
|
|
57
|
+
gap: 'X2',
|
|
58
|
+
flow: 'column',
|
|
59
|
+
|
|
60
|
+
header: {
|
|
61
|
+
align: 'center space-between'
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
header: {
|
|
66
|
+
extend: Flex,
|
|
67
|
+
left: {
|
|
68
|
+
extend: SquareButton,
|
|
69
|
+
props: {
|
|
70
|
+
...buttonProps,
|
|
71
|
+
round: 'C',
|
|
72
|
+
icon: 'arrowAngleLeft'
|
|
58
73
|
}
|
|
59
74
|
},
|
|
60
|
-
|
|
61
|
-
tag: '
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
{ text: 'Sa' },
|
|
71
|
-
{ text: 'Su' }
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
content: {
|
|
75
|
-
childExtend: { tag: 'button' },
|
|
76
|
-
...[
|
|
77
|
-
{ text: '1' },
|
|
78
|
-
{ text: '2' },
|
|
79
|
-
{ text: '3' },
|
|
80
|
-
{ text: '4' },
|
|
81
|
-
{ text: '5' },
|
|
82
|
-
{ text: '6' },
|
|
83
|
-
{ text: '7' },
|
|
84
|
-
{ text: '8' },
|
|
85
|
-
{ text: '9' },
|
|
86
|
-
{ text: '10' },
|
|
87
|
-
{ text: '11' },
|
|
88
|
-
{ text: '12' },
|
|
89
|
-
{ text: '13' },
|
|
90
|
-
{ text: '14' },
|
|
91
|
-
{ text: '15' },
|
|
92
|
-
{ text: '16' },
|
|
93
|
-
{ text: '17' },
|
|
94
|
-
{ text: '18' },
|
|
95
|
-
{ text: '19' },
|
|
96
|
-
{ text: '20' },
|
|
97
|
-
{ text: '21' },
|
|
98
|
-
{ text: '22' },
|
|
99
|
-
{ text: '23' },
|
|
100
|
-
{ text: '24' },
|
|
101
|
-
{ text: '25' },
|
|
102
|
-
{ text: '26' },
|
|
103
|
-
{ text: '27' },
|
|
104
|
-
{ text: '28' },
|
|
105
|
-
{ text: '29' },
|
|
106
|
-
{ text: '30' },
|
|
107
|
-
{ text: '31' }
|
|
108
|
-
]
|
|
75
|
+
month: {
|
|
76
|
+
tag: 'span',
|
|
77
|
+
text: 'December'
|
|
78
|
+
},
|
|
79
|
+
right: {
|
|
80
|
+
extend: SquareButton,
|
|
81
|
+
props: {
|
|
82
|
+
...buttonProps,
|
|
83
|
+
round: 'C',
|
|
84
|
+
icon: 'arrowAngleRight'
|
|
109
85
|
}
|
|
110
86
|
}
|
|
87
|
+
},
|
|
88
|
+
days: {
|
|
89
|
+
extend: Flex,
|
|
90
|
+
props: {
|
|
91
|
+
flow: 'column',
|
|
92
|
+
gap: 'X2'
|
|
93
|
+
},
|
|
94
|
+
childExtend: {
|
|
95
|
+
extend: Grid,
|
|
96
|
+
props: {
|
|
97
|
+
columns: 'repeat(7, 1fr)',
|
|
98
|
+
gap: 'X2'
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
weekDays: {
|
|
102
|
+
childExtend: {
|
|
103
|
+
extend: Button,
|
|
104
|
+
props: {
|
|
105
|
+
...buttonProps,
|
|
106
|
+
fontSize: 'Z1',
|
|
107
|
+
padding: 'X2'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
...[
|
|
111
|
+
{ text: 'Mo' },
|
|
112
|
+
{ text: 'Tu' },
|
|
113
|
+
{ text: 'We' },
|
|
114
|
+
{ text: 'Th' },
|
|
115
|
+
{ text: 'Fr' },
|
|
116
|
+
{ text: 'Sa' },
|
|
117
|
+
{ text: 'Su' }
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
|
|
121
|
+
cnt: {
|
|
122
|
+
childExtend: {
|
|
123
|
+
extend: SquareButton,
|
|
124
|
+
props: {
|
|
125
|
+
...buttonProps,
|
|
126
|
+
theme: 'quinary'
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
// Generate days
|
|
131
|
+
...new Array(31).fill(undefined).map((_, i) => ({ text: i + 1 }))
|
|
132
|
+
}
|
|
111
133
|
}
|
|
112
134
|
}
|
|
135
|
+
|
|
136
|
+
export const DatePicker = {
|
|
137
|
+
style,
|
|
138
|
+
extend: Flex,
|
|
139
|
+
|
|
140
|
+
props: {
|
|
141
|
+
position: 'relative',
|
|
142
|
+
theme: 'quinary',
|
|
143
|
+
transition: 'A all',
|
|
144
|
+
round: 'Z',
|
|
145
|
+
padding: 'Z Z2 Z X2',
|
|
146
|
+
gap: 'X2',
|
|
147
|
+
depth: 16,
|
|
148
|
+
minHeight: '0',
|
|
149
|
+
align: 'stretch center'
|
|
150
|
+
},
|
|
151
|
+
|
|
152
|
+
aside,
|
|
153
|
+
main
|
|
154
|
+
}
|
package/src/DatePicker/style.js
CHANGED
|
@@ -1,95 +1,13 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
maxWidth: `${336 / 16}em`,
|
|
5
|
-
maxHeight: `${260 / 16}em`,
|
|
6
|
-
display: 'flex',
|
|
7
|
-
padding: '0 1em',
|
|
8
|
-
boxSizing: 'border-box',
|
|
9
|
-
borderRadius: '10px',
|
|
10
|
-
button: {
|
|
11
|
-
border: 'none',
|
|
12
|
-
outline: 'none',
|
|
13
|
-
background: 'transparent',
|
|
14
|
-
cursor: 'pointer'
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
aside: {
|
|
18
|
-
display: 'flex',
|
|
19
|
-
flexDirection: 'column',
|
|
20
|
-
overflowX: 'auto',
|
|
21
|
-
paddingRight: `${10 / 16}em`,
|
|
22
|
-
|
|
23
|
-
button: {
|
|
24
|
-
opacity: 0.5,
|
|
25
|
-
marginBottom: `${22 / 12}em`
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
|
|
29
4
|
main: {
|
|
30
|
-
flex: 1,
|
|
31
|
-
paddingTop: `${14 / 16}em`,
|
|
32
|
-
paddingBottom: `${10 / 16}em`,
|
|
33
|
-
overflow: 'hidden',
|
|
34
|
-
|
|
35
|
-
display: 'flex',
|
|
36
|
-
flexDirection: 'column',
|
|
37
|
-
|
|
38
|
-
'> header': {
|
|
39
|
-
display: 'flex',
|
|
40
|
-
alignItems: 'center',
|
|
41
|
-
height: 'auto',
|
|
42
|
-
overflow: 'hidden',
|
|
43
|
-
width: '100%',
|
|
44
|
-
padding: `0 ${8 / 16}em ${14 / 16}em ${8 / 16}em`,
|
|
45
|
-
boxSizing: 'border-box'
|
|
46
|
-
},
|
|
47
|
-
'> header > svg': {
|
|
48
|
-
cursor: 'pointer'
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
'> header > div': {
|
|
52
|
-
display: 'flex',
|
|
53
|
-
overflow: 'hidden',
|
|
54
|
-
flex: 1
|
|
55
|
-
},
|
|
56
|
-
'> header span': {
|
|
57
|
-
minWidth: '100%',
|
|
58
|
-
textTransform: 'capitalize',
|
|
59
|
-
textAlign: 'center',
|
|
60
|
-
fontWeight: 'bold'
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
section: {
|
|
64
|
-
flex: 1,
|
|
65
|
-
display: 'flex',
|
|
66
|
-
flexDirection: 'column'
|
|
67
|
-
},
|
|
68
|
-
'section > header': {
|
|
69
|
-
height: 'auto',
|
|
70
|
-
display: 'grid',
|
|
71
|
-
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
72
|
-
gap: '6px',
|
|
73
|
-
paddingBottom: `${2 / 16}em`
|
|
74
|
-
},
|
|
75
|
-
'section > header span': {
|
|
76
|
-
textAlign: 'center',
|
|
77
|
-
fontWeight: 'bold'
|
|
78
|
-
},
|
|
79
5
|
'section > header span:nth-child(6)': {
|
|
80
6
|
opacity: 0.5
|
|
81
7
|
},
|
|
82
8
|
'section > header span:nth-child(7)': {
|
|
83
9
|
opacity: 0.5
|
|
84
10
|
},
|
|
85
|
-
'section > div': {
|
|
86
|
-
flex: 1,
|
|
87
|
-
display: 'grid',
|
|
88
|
-
gridTemplateColumns: 'repeat(7, 1fr)',
|
|
89
|
-
gap: '6px'
|
|
90
|
-
},
|
|
91
|
-
'section > div button': {
|
|
92
|
-
},
|
|
93
11
|
'section > div button:nth-child(7n)': {
|
|
94
12
|
opacity: 0.5
|
|
95
13
|
},
|
package/src/Grid.js
CHANGED
package/src/Input.js
CHANGED
package/src/Media.js
CHANGED
|
@@ -106,6 +106,18 @@ const beforeClassAssign = (element, s) => {
|
|
|
106
106
|
export const initUpdate = element => {
|
|
107
107
|
const { props, class: className } = element
|
|
108
108
|
const rootState = element.__root ? element.__root.state : element.state
|
|
109
|
+
|
|
110
|
+
const parentProps = element.parent.props
|
|
111
|
+
if (parentProps?.spacingRatio && parentProps?.inheritSpacingRatio) {
|
|
112
|
+
element.setProps({
|
|
113
|
+
spacingRatio: parentProps.spacingRatio,
|
|
114
|
+
inheritSpacingRatio: true
|
|
115
|
+
}, {
|
|
116
|
+
preventRecursive: true,
|
|
117
|
+
ignoreInitUpdate: true
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
109
121
|
const { globalTheme } = rootState
|
|
110
122
|
|
|
111
123
|
if (!globalTheme) return
|
|
@@ -125,7 +137,9 @@ export const initUpdate = element => {
|
|
|
125
137
|
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
126
138
|
}
|
|
127
139
|
|
|
128
|
-
if (Object.keys(CLASS_NAMES.media).length)
|
|
140
|
+
if (Object.keys(CLASS_NAMES.media).length) {
|
|
141
|
+
className.media = CLASS_NAMES.media
|
|
142
|
+
}
|
|
129
143
|
className.selector = CLASS_NAMES.selector
|
|
130
144
|
className.case = CLASS_NAMES.case
|
|
131
145
|
}
|
package/src/Shape/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
import { exec, isString } from '@domql/utils'
|
|
4
4
|
import { SHAPES } from './style'
|
|
5
|
-
import {
|
|
5
|
+
import { getSpacingBasedOnRatio } from '@symbo.ls/scratch'
|
|
6
6
|
|
|
7
|
-
const transformBorderRadius = (radius, props) => {
|
|
7
|
+
const transformBorderRadius = (radius, props, propertyName) => {
|
|
8
8
|
if (!isString(radius)) return
|
|
9
9
|
return {
|
|
10
|
-
borderRadius: radius.split(' ').map((v, k) =>
|
|
10
|
+
borderRadius: radius.split(' ').map((v, k) => getSpacingBasedOnRatio(props, propertyName, v)[propertyName]).join(' ')
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
|
|
@@ -26,8 +26,8 @@ export const Shape = {
|
|
|
26
26
|
},
|
|
27
27
|
shapeDirectionColor: ({ props, ...el }) => props.shapeDirection ? { '&:before': { borderColor: el.class.backgroundColor } } : null,
|
|
28
28
|
|
|
29
|
-
round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props),
|
|
30
|
-
borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props)
|
|
29
|
+
round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props, 'round'),
|
|
30
|
+
borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props, 'borderRadius')
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
package/src/Theme.js
CHANGED
|
@@ -37,6 +37,16 @@ const transformShadow = shadow => ({
|
|
|
37
37
|
}).join(' ')
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
+
const transformBackgroundImage = (backgroundImage, ctx) => ({
|
|
41
|
+
backgroundImage: backgroundImage.split(', ').map(v => {
|
|
42
|
+
if (v.includes('url') || v.includes('gradient')) return v
|
|
43
|
+
else if (ctx.SYSTEM.GRADIENT[backgroundImage]) {
|
|
44
|
+
return getMediaColor(backgroundImage, 'backgroundImage')
|
|
45
|
+
}
|
|
46
|
+
return `url(${v})`
|
|
47
|
+
}).join(' ')
|
|
48
|
+
})
|
|
49
|
+
|
|
40
50
|
export const Theme = {
|
|
41
51
|
class: {
|
|
42
52
|
depth: ({ props }) => depth[props.depth],
|
|
@@ -49,8 +59,9 @@ export const Theme = {
|
|
|
49
59
|
color: ({ props }) => (props.color) && getMediaColor(props.color, 'color'),
|
|
50
60
|
background: ({ props }) => (props.background) && getMediaColor(props.background, 'background'),
|
|
51
61
|
backgroundColor: ({ props }) => (props.backgroundColor) && getMediaColor(props.backgroundColor, 'backgroundColor'),
|
|
52
|
-
backgroundImage: ({ props }) => (props.backgroundImage) &&
|
|
62
|
+
backgroundImage: ({ props, context }) => (props.backgroundImage) && transformBackgroundImage(props.backgroundImage, context),
|
|
53
63
|
backgroundSize: ({ props }) => props.backgroundSize ? ({ backgroundSize: props.backgroundSize }) : null,
|
|
64
|
+
backgroundPosition: ({ props }) => props.backgroundPosition ? ({ backgroundPosition: props.backgroundPosition }) : null,
|
|
54
65
|
|
|
55
66
|
textStroke: ({ props }) => props.textStroke ? transformTextStroke(props.textStroke) : null,
|
|
56
67
|
|