@symbo.ls/atoms 2.11.257 → 2.11.262

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.
Files changed (2) hide show
  1. package/Block.js +129 -78
  2. package/package.json +2 -2
package/Block.js CHANGED
@@ -1,125 +1,160 @@
1
1
  'use strict'
2
2
 
3
- import { getSpacingBasedOnRatio, getSpacingByKey, transfromGap } from '@symbo.ls/scratch'
3
+ import { isUndefined } from '@domql/utils'
4
+
5
+ import {
6
+ getSpacingBasedOnRatio,
7
+ getSpacingByKey,
8
+ transformSize,
9
+ transformSizeRatio,
10
+ transfromGap
11
+ } from '@symbo.ls/scratch'
4
12
 
5
13
  export const Block = {
6
- deps: { getSpacingBasedOnRatio, getSpacingByKey, transfromGap },
14
+ deps: {
15
+ getSpacingBasedOnRatio,
16
+ getSpacingByKey,
17
+ transfromGap,
18
+ transformSizeRatio,
19
+ transformSize
20
+ },
7
21
 
8
22
  class: {
9
- boxSizing: ({ props }) => props.boxSizing
23
+ boxSizing: ({ props }) => !isUndefined(props.boxSizing)
10
24
  ? ({ boxSizing: props.boxSizing })
11
- : {
12
- boxSizing: 'border-box'
13
- },
25
+ : { boxSizing: 'border-box' },
26
+
27
+ display: ({ props }) => !isUndefined(props.display) && ({
28
+ display: props.display
29
+ }),
14
30
 
15
- display: ({ props }) => props.display && ({ display: props.display }),
31
+ hide: ({ props }) => props.hide && ({
32
+ display: 'none !important'
33
+ }),
16
34
 
17
- hide: ({ props }) => props.hide && ({ display: 'none !important' }),
35
+ width: ({ props, deps }) => deps.transformSizeRatio('width', props),
36
+ height: ({ props, deps }) => deps.transformSizeRatio('height', props),
18
37
 
19
- width: ({ props, deps }) => props.width && deps.getSpacingBasedOnRatio(props, 'width'),
20
- height: ({ props, deps }) => props.height && deps.getSpacingBasedOnRatio(props, 'height'),
21
38
  boxSize: ({ props, deps }) => {
22
39
  if (typeof props.boxSize !== 'string') return
23
40
  const [height, width] = props.boxSize.split(' ')
24
41
  return {
25
- ...deps.getSpacingByKey(height, 'height'),
26
- ...deps.getSpacingByKey(width || height, 'width')
42
+ ...deps.transformSize('height', height),
43
+ ...deps.transformSize('width', width || height)
27
44
  }
28
45
  },
29
46
 
30
- maxWidth: ({ props, deps }) => props.maxWidth && deps.getSpacingBasedOnRatio(props, 'maxWidth'),
31
- minWidth: ({ props, deps }) => props.minWidth && deps.getSpacingBasedOnRatio(props, 'minWidth'),
47
+ minWidth: ({ props, deps }) => deps.transformSizeRatio('minWidth', props),
48
+ maxWidth: ({ props, deps }) => deps.transformSizeRatio('maxWidth', props),
32
49
  widthRange: ({ props, deps }) => {
33
50
  if (typeof props.widthRange !== 'string') return
34
51
  const [minWidth, maxWidth] = props.widthRange.split(' ')
35
52
  return {
36
- ...deps.getSpacingByKey(minWidth, 'minWidth'),
37
- ...deps.getSpacingByKey(maxWidth || minWidth, 'maxWidth')
53
+ ...deps.transformSize('minWidth', minWidth),
54
+ ...deps.transformSize('maxWidth', maxWidth || minWidth)
38
55
  }
39
56
  },
40
57
 
41
- maxHeight: ({ props, deps }) => props.maxHeight && deps.getSpacingBasedOnRatio(props, 'maxHeight'),
42
- minHeight: ({ props, deps }) => props.minHeight && deps.getSpacingBasedOnRatio(props, 'minHeight'),
58
+ minHeight: ({ props, deps }) => deps.transformSizeRatio('minHeight', props),
59
+ maxHeight: ({ props, deps }) => deps.transformSizeRatio('maxHeight', props),
43
60
  heightRange: ({ props, deps }) => {
44
- if (typeof props.heightRange !== 'string') return
45
- const [minHeight, maxHeight] = props.heightRange.split(' ')
61
+ if (typeof props.widthRange !== 'string') return
62
+ const [minHeight, maxHeight] = props.widthRange.split(' ')
46
63
  return {
47
- ...deps.getSpacingByKey(minHeight, 'minHeight'),
48
- ...deps.getSpacingByKey(maxHeight || minHeight, 'maxHeight')
64
+ ...deps.transformSize('minHeight', minHeight),
65
+ ...deps.transformSize('maxHeight', maxHeight || minHeight)
49
66
  }
50
67
  },
51
68
 
52
- direction: ({ props }) => props.direction && ({ direction: props.direction }),
69
+ direction: ({ props }) => !isUndefined(props.direction) && ({
70
+ direction: props.direction
71
+ }),
53
72
 
54
- aspectRatio: ({ props }) => props.aspectRatio && ({ aspectRatio: props.aspectRatio }),
73
+ aspectRatio: ({ props }) => !isUndefined(props.aspectRatio) && ({
74
+ aspectRatio: props.aspectRatio
75
+ }),
55
76
 
56
- borderWidth: ({ props, deps }) => props.borderWidth ? deps.getSpacingBasedOnRatio(props, 'borderWidth') : null,
77
+ borderWidth: ({ props, deps }) => deps.transformSizeRatio('borderWidth', props),
57
78
 
58
- padding: ({ props, deps }) => props.padding ? deps.getSpacingBasedOnRatio(props, 'padding') : null,
79
+ padding: ({ props, deps }) => deps.transformSizeRatio('padding', props),
59
80
  paddingInline: ({ props, deps }) => {
60
81
  if (typeof props.paddingInline !== 'string') return
61
82
  const [paddingInlineStart, paddingInlineEnd] = props.paddingInline.split(' ')
62
83
  return {
63
- ...deps.getSpacingByKey(paddingInlineStart, 'paddingInlineStart'),
64
- ...deps.getSpacingByKey(paddingInlineEnd || paddingInlineStart, 'paddingInlineEnd')
84
+ ...deps.transformSize('paddingInlineStart', paddingInlineStart),
85
+ ...deps.transformSize('paddingInlineEnd', paddingInlineEnd || paddingInlineStart)
65
86
  }
66
87
  },
67
88
  paddingBlock: ({ props, deps }) => {
68
89
  if (typeof props.paddingBlock !== 'string') return
69
90
  const [paddingBlockStart, paddingBlockEnd] = props.paddingBlock.split(' ')
70
91
  return {
71
- ...deps.getSpacingByKey(paddingBlockStart, 'paddingBlockStart'),
72
- ...deps.getSpacingByKey(paddingBlockEnd || paddingBlockStart, 'paddingBlockEnd')
92
+ ...deps.transformSize('paddingBlockStart', paddingBlockStart),
93
+ ...deps.transformSize('paddingBlockEnd', paddingBlockEnd || paddingBlockStart)
73
94
  }
74
95
  },
75
- paddingInlineStart: ({ props, deps }) => props.paddingInlineStart ? deps.getSpacingBasedOnRatio(props, 'paddingInlineStart') : null,
76
- paddingInlineEnd: ({ props, deps }) => props.paddingInlineEnd ? deps.getSpacingBasedOnRatio(props, 'paddingInlineEnd') : null,
77
- paddingBlockStart: ({ props, deps }) => props.paddingBlockStart ? deps.getSpacingBasedOnRatio(props, 'paddingBlockStart') : null,
78
- paddingBlockEnd: ({ props, deps }) => props.paddingBlockEnd ? deps.getSpacingBasedOnRatio(props, 'paddingBlockEnd') : null,
96
+ paddingInlineStart: ({ props, deps }) => deps.transformSizeRatio('paddingInlineStart', props),
97
+ paddingInlineEnd: ({ props, deps }) => deps.transformSizeRatio('paddingInlineEnd', props),
98
+ paddingBlockStart: ({ props, deps }) => deps.transformSizeRatio('paddingBlockStart', props),
99
+ paddingBlockEnd: ({ props, deps }) => deps.transformSizeRatio('paddingBlockEnd', props),
79
100
 
80
- margin: ({ props, deps }) => props.margin ? deps.getSpacingBasedOnRatio(props, 'margin') : null,
101
+ margin: ({ props, deps }) => deps.transformSizeRatio('margin', props),
81
102
  marginInline: ({ props, deps }) => {
82
103
  if (typeof props.marginInline !== 'string') return
83
104
  const [marginInlineStart, marginInlineEnd] = props.marginInline.split(' ')
84
105
  return {
85
- ...deps.getSpacingByKey(marginInlineStart, 'marginInlineStart'),
86
- ...deps.getSpacingByKey(marginInlineEnd || marginInlineStart, 'marginInlineEnd')
106
+ ...deps.getSpacingByKey('marginInlineStart', marginInlineStart),
107
+ ...deps.getSpacingByKey('marginInlineEnd', marginInlineEnd || marginInlineStart)
87
108
  }
88
109
  },
89
110
  marginBlock: ({ props, deps }) => {
90
111
  if (typeof props.marginBlock !== 'string') return
91
112
  const [marginBlockStart, marginBlockEnd] = props.marginBlock.split(' ')
92
113
  return {
93
- ...deps.getSpacingByKey(marginBlockStart, 'marginBlockStart'),
94
- ...deps.getSpacingByKey(marginBlockEnd || marginBlockStart, 'marginBlockEnd')
114
+ ...deps.getSpacingByKey('marginBlockStart', marginBlockStart),
115
+ ...deps.getSpacingByKey('marginBlockEnd', marginBlockEnd || marginBlockStart)
95
116
  }
96
117
  },
97
- marginInlineStart: ({ props, deps }) => props.marginInlineStart ? deps.getSpacingBasedOnRatio(props, 'marginInlineStart') : null,
98
- marginInlineEnd: ({ props, deps }) => props.marginInlineEnd ? deps.getSpacingBasedOnRatio(props, 'marginInlineEnd') : null,
99
- marginBlockStart: ({ props, deps }) => props.marginBlockStart ? deps.getSpacingBasedOnRatio(props, 'marginBlockStart') : null,
100
- marginBlockEnd: ({ props, deps }) => props.marginBlockEnd ? deps.getSpacingBasedOnRatio(props, 'marginBlockEnd') : null,
101
-
102
- gap: ({ props }) => props.gap
103
- ? ({
104
- gap: transfromGap(props.gap)
105
- })
106
- : null,
118
+ marginInlineStart: ({ props, deps }) => deps.transformSizeRatio('marginInlineStart', props),
119
+ marginInlineEnd: ({ props, deps }) => deps.transformSizeRatio('marginInlineEnd', props),
120
+ marginBlockStart: ({ props, deps }) => deps.transformSizeRatio('marginBlockStart', props),
121
+ marginBlockEnd: ({ props, deps }) => deps.transformSizeRatio('marginBlockEnd', props),
122
+
123
+ gap: ({ props }) => !isUndefined(props.gap) && ({
124
+ gap: transfromGap(props.gap)
125
+ }),
107
126
  gridArea: ({ props, deps }) => props.gridArea && ({ gridArea: props.gridArea }),
108
127
 
109
- flex: ({ props }) => props.flex && ({ flex: props.flex }),
110
- flexDirection: ({ props }) => props.flexDirection && ({ flexDirection: props.flexDirection }),
111
- alignItems: ({ props }) => props.alignItems && ({ alignItems: props.alignItems }),
112
- alignContent: ({ props }) => props.alignContent && ({ alignContent: props.alignContent }),
113
- justifyContent: ({ props }) => props.justifyContent && ({ justifyContent: props.justifyContent }),
114
- justifyItems: ({ props }) => props.justifyItems && ({ justifyItems: props.justifyItems }),
115
- alignSelf: ({ props }) => props.alignSelf && ({ alignSelf: props.alignSelf }),
116
- order: ({ props }) => props.order && ({ order: props.order }),
128
+ flex: ({ props }) => props.flex && ({
129
+ flex: props.flex
130
+ }),
131
+ flexDirection: ({ props }) => !isUndefined(props.flexDirection) && ({
132
+ flexDirection: props.flexDirection
133
+ }),
134
+ alignItems: ({ props }) => !isUndefined(props.alignItems) && ({
135
+ alignItems: props.alignItems
136
+ }),
137
+ alignContent: ({ props }) => !isUndefined(props.alignContent) && ({
138
+ alignContent: props.alignContent
139
+ }),
140
+ justifyContent: ({ props }) => !isUndefined(props.justifyContent) && ({
141
+ justifyContent: props.justifyContent
142
+ }),
143
+ justifyItems: ({ props }) => !isUndefined(props.justifyItems) && ({
144
+ justifyItems: props.justifyItems
145
+ }),
146
+ alignSelf: ({ props }) => !isUndefined(props.alignSelf) && ({
147
+ alignSelf: props.alignSelf
148
+ }),
149
+ order: ({ props }) => props.order && ({
150
+ order: props.order
151
+ }),
117
152
 
118
- flexWrap: ({ props }) => props.flexWrap && ({
153
+ flexWrap: ({ props }) => !isUndefined(props.flexWrap) && ({
119
154
  display: 'flex',
120
155
  flexFlow: props.flexWrap
121
156
  }),
122
- flexFlow: ({ props }) => props.flexFlow && ({
157
+ flexFlow: ({ props }) => !isUndefined(props.flexFlow) && ({
123
158
  display: 'flex',
124
159
  flexFlow: props.flexFlow + (props.reverse ? '-reverse' : '')
125
160
  }),
@@ -133,31 +168,47 @@ export const Block = {
133
168
  }
134
169
  },
135
170
 
136
- gridColumn: ({ props }) => props.gridColumn && ({ gridColumn: props.gridColumn }),
137
- gridColumnStart: ({ props }) => props.gridColumnStart
138
- ? ({
139
- gridColumnStart: props.gridColumnStart
140
- })
141
- : null,
142
- gridRow: ({ props }) => props.gridRow && ({ gridRow: props.gridRow }),
143
- gridRowStart: ({ props }) => props.gridRowStart ? ({ gridRowStart: props.gridRowStart }) : null,
171
+ gridColumn: ({ props }) => !isUndefined(props.gridColumn) && ({
172
+ gridColumn: props.gridColumn
173
+ }),
174
+ gridColumnStart: ({ props }) => !isUndefined(props.gridColumnStart) && ({
175
+ gridColumnStart: props.gridColumnStart
176
+ }),
177
+ gridRow: ({ props }) => !isUndefined(props.gridRow) && ({
178
+ gridRow: props.gridRow
179
+ }),
180
+ gridRowStart: ({ props }) => !isUndefined(props.gridRowStart) && ({
181
+ gridRowStart: props.gridRowStart
182
+ }),
144
183
 
145
184
  size: ({ props, deps }) => {
146
185
  if (typeof props.heightRange !== 'string') return
147
186
  const [minHeight, maxHeight] = props.heightRange.split(' ')
148
187
  return {
149
- ...deps.getSpacingByKey(minHeight, 'minHeight'),
150
- ...deps.getSpacingByKey(maxHeight || minHeight, 'maxHeight')
188
+ ...deps.transformSizeRatio('minHeight', minHeight),
189
+ ...deps.transformSizeRatio('maxHeight', maxHeight || minHeight)
151
190
  }
152
191
  },
153
192
 
154
- columns: ({ props }) => props.columns && ({ columns: props.columns }),
155
- columnRule: ({ props }) => props.columnRule && ({ columnRule: props.columnRule }),
156
- columnWidth: ({ props }) => props.columnWidth && ({ columnWidth: props.columnWidth }),
157
- columnGap: ({ props, deps }) => props.columnGap ? deps.getSpacingBasedOnRatio(props, 'columnGap') : null,
158
- columnSpan: ({ props }) => props.columnSpan && ({ columnSpan: props.columnSpan }),
159
- columnFill: ({ props }) => props.columnFill && ({ columnFill: props.columnFill }),
160
- columnCount: ({ props }) => props.columnCount && ({ columnCount: props.columnCount })
193
+ columns: ({ props }) => !isUndefined(props.columns) && ({
194
+ columns: props.columns
195
+ }),
196
+ columnRule: ({ props }) => !isUndefined(props.columnRule) && ({
197
+ columnRule: props.columnRule
198
+ }),
199
+ columnWidth: ({ props }) => !isUndefined(props.columnWidth) && ({
200
+ columnWidth: props.columnWidth
201
+ }),
202
+ columnGap: ({ props, deps }) => deps.transformSizeRatio('columnGap', props),
203
+ columnSpan: ({ props }) => !isUndefined(props.columnSpan) && ({
204
+ columnSpan: props.columnSpan
205
+ }),
206
+ columnFill: ({ props }) => !isUndefined(props.columnFill) && ({
207
+ columnFill: props.columnFill
208
+ }),
209
+ columnCount: ({ props }) => !isUndefined(props.columnCount) && ({
210
+ columnCount: props.columnCount
211
+ })
161
212
  }
162
213
  }
163
214
 
@@ -183,8 +234,8 @@ export const Gutter = {
183
234
  if (typeof props.size !== 'string') return
184
235
  const [height, width] = props.size.split(' ')
185
236
  return {
186
- ...deps.getSpacingByKey(height, 'height'),
187
- ...deps.getSpacingByKey(width || height, 'width')
237
+ ...deps.getSpacingByKey('height', height),
238
+ ...deps.getSpacingByKey('width', width || height)
188
239
  }
189
240
  }
190
241
  }
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@symbo.ls/atoms",
3
- "version": "2.11.257",
3
+ "version": "2.11.262",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
- "gitHead": "fee03ced348ded2839443d9636f6da28d9952465",
6
+ "gitHead": "f5fc1f8eb0fde32e726a8f46a1c8d2c7c588a8e5",
7
7
  "dependencies": {
8
8
  "@domql/state": "latest",
9
9
  "@domql/utils": "latest",