@fullstackunicorn/style 1.0.9 → 1.0.12

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/index.cmd.js CHANGED
@@ -1,4 +1,6 @@
1
1
  #!/usr/bin/env node
2
+ import '@fullstackunicorn/initialize'
3
+ F3.service = '@fullstackunicorn/style'
2
4
  import { fss, path} from '#@/index.dep.js'
3
5
  import { run } from '#@/index.js'
4
6
 
package/index.dep.js CHANGED
@@ -1,8 +1,8 @@
1
- // NODE BUILT IN
2
- export { default as path } from 'path'
3
-
4
1
  // @FULLSTACKUNICORN
5
2
  export { fss, fsa } from '@fullstackunicorn/filesystem'
6
3
 
4
+ // NODE BUILT IN
5
+ export { default as path } from 'path'
6
+
7
7
  // PACKAGES
8
8
  export { glob } from 'glob'
package/index.js CHANGED
@@ -1,3 +1 @@
1
- import '@fullstackunicorn/initialize'
2
- F3.service = '@fullstackunicorn/style'
3
1
  export { run } from '#@/modules/run.js'
@@ -2,46 +2,126 @@ import { styles } from '#@/modules/styles/index.js'
2
2
 
3
3
  class Style {
4
4
 
5
- getList = (list) => {
5
+ unitless = new Set(['flex', 'G', 'shrink', 'order', 'Z', 'opacity', 'scale'])
6
+
7
+ removed = new Set([
8
+ 'X',
9
+ 'Xx',
10
+ 'Y',
11
+ 'Yy',
12
+ 'XY',
13
+ 'flex',
14
+ 'absolute',
15
+ 'relative',
16
+ 'fixed',
17
+ 'overflowXh',
18
+ 'overflowYh',
19
+ 'overflowXs',
20
+ 'overflowYs',
21
+ 'overflowXYh',
22
+ 'overflowXYs',
23
+ 'noPointer',
24
+ 'flexWrap',
25
+ 'cover',
26
+ 'ellipsis',
27
+ ])
28
+
29
+ isRemoved = item => {
30
+ if (this.removed.has(item)) return true
31
+ if (/^Zm\d+$/.test(item)) return true
32
+ if (/^order\d+m$/.test(item)) return true
33
+ if (/^orderm\d+$/.test(item)) return true
34
+ if (/^ratio_X\d+Y\d+$/.test(item)) return true
35
+ return false
36
+ }
6
37
 
7
- const result = []
38
+ getKeyword = value => value ? value.charAt(0).toLowerCase()+value.slice(1) : value
39
+
40
+ getValue = ({ raw, key, suffix, match, keyword }) => {
41
+
42
+ if (keyword) {
43
+ const value = this.getKeyword(keyword)
44
+ return {
45
+ isStyleValue: true,
46
+ raw,
47
+ key,
48
+ suffix,
49
+ value,
50
+ valueKind: 'keyword',
51
+ keyword: value,
52
+ web: value,
53
+ native: `'${value}'`,
54
+ toString() { return this.suffix },
55
+ [Symbol.toPrimitive]() { return this.suffix },
56
+ }
57
+ }
58
+
59
+ const integer = match[1]
60
+ const negative = !!match[2]
61
+ const percent = !!match[3]
62
+ const decimal = match[4] ?? ''
63
+ const number = Number(`${integer}${decimal?`.${decimal}`:''}`)
64
+ const value = negative ? -number : number
65
+ const display = `${negative?'-':''}${integer}${decimal?`.${decimal}`:''}`
66
+ const variable = `$px${integer}${decimal?`d${decimal}`:''}`
67
+ const webVariable = `n.${variable}`
68
+
69
+ return {
70
+ isStyleValue: true,
71
+ raw,
72
+ key,
73
+ suffix,
74
+ value,
75
+ valueKind: percent ? 'percent' : 'number',
76
+ unit: percent ? '%' : null,
77
+ suffixData: { negative, percent, decimal },
78
+ variable,
79
+ web: percent ? `${display}%` : negative ? `calc(-1 * ${webVariable})` : webVariable,
80
+ native: percent ? `'${display}%'` : `${value}`,
81
+ toString() { return this.suffix },
82
+ [Symbol.toPrimitive]() { return this.suffix },
83
+ }
84
+ }
8
85
 
9
- const numericSuffix = /\d+$/
10
- const twoLetterTwoNumber = /^([A-Za-z])(\d+)([A-Za-z])(\d+)$/
86
+ parseItem = (item) => {
11
87
 
12
- for (const item of list) {
88
+ if (this.isRemoved(item)) return { name: item, key: `__removed_${item}` }
13
89
 
14
- // 1. If underscores exist, handle carefully
15
- if (item.includes('_')) {
16
- const [prefix, tail] = item.split('_')
17
-
18
- // 1A. MULTI-NUMBER PATTERN (e.g. X16Y9)
19
- const m = tail.match(twoLetterTwoNumber)
20
- if (m) {
21
- const A = m[1], nA = Number(m[2])
22
- const B = m[3], nB = Number(m[4])
23
- const finalKey = `${prefix}${A}${B}`
24
- result.push({ name: item, key: finalKey, params: { [A]: nA, [B]: nB } })
25
- continue
26
- }
90
+ const ratio = item.match(/^ratio(\d+)x(\d+)$/)
91
+ if (ratio) return { name: item, key: 'ratioXY', params: { X: Number(ratio[1]), Y: Number(ratio[2]), name: item } }
27
92
 
28
- if (!/\d/.test(item)) {
29
- result.push({ name: item, key: item })
30
- continue
31
- }
93
+ if (styles[item]) return { name: item, key: item }
94
+
95
+ const keys = Object.keys(styles).sort((a, b) => b.length - a.length)
96
+ const numberValue = /^(\d+)(n?)(p?)(?:d(\d+))?$/
97
+ const keywordValue = /^[A-Z][A-Za-z0-9]*$/
98
+
99
+ for (const key of keys) {
100
+ if (!item.startsWith(key)) continue
101
+
102
+ const suffix = item.slice(key.length)
103
+ if (!suffix) continue
104
+
105
+ const match = suffix.match(numberValue)
106
+ if (match) {
107
+ if (!match[2] && !match[3] && !match[4]) return { name: item, key, number: Number(match[1]) }
108
+ return { name: item, key, value: this.getValue({ raw: item, key, suffix, match }) }
32
109
  }
33
110
 
34
- // 2. NUMERIC-SUFFIX PATTERN (margin64 etc)
35
- const nmatch = item.match(numericSuffix)
36
- if (nmatch) {
37
- const num = Number(nmatch[0])
38
- const key = item.slice(0, -nmatch[0].length)
39
- result.push({ name: item, key, number: num })
40
- continue
111
+ if (keywordValue.test(suffix)) {
112
+ return { name: item, key, value: this.getValue({ raw: item, key, suffix, keyword: suffix }) }
41
113
  }
114
+ }
115
+
116
+ return { name: item, key: item }
117
+ }
118
+
119
+ getList = (list) => {
42
120
 
43
- // 3. DEFAULT: no underscore, no numeric suffix
44
- result.push({ name: item, key: item })
121
+ const result = []
122
+
123
+ for (const item of list) {
124
+ result.push(this.parseItem(item))
45
125
  }
46
126
 
47
127
  return result
@@ -89,9 +169,9 @@ class Style {
89
169
 
90
170
  for (const item of list) {
91
171
 
92
- const { name, key, number, params } = item
93
- const arg = params ?? number
94
- const is0 = number === 0
172
+ const { name, key, number, value, params } = item
173
+ const arg = params ?? value ?? number
174
+ const is0 = number === 0 || value?.value === 0
95
175
 
96
176
  const noStyle = !styles?.[key]?.write(arg)
97
177
  if (noStyle) {
@@ -100,8 +180,9 @@ class Style {
100
180
  }
101
181
 
102
182
  const { target, write, webClasses, webStyle, nativeClasses, nativeStyle } = styles[key]
183
+ const writeList = write(arg)
103
184
 
104
- const isDone = this.exists(done, write(arg))
185
+ const isDone = this.exists(done, writeList)
105
186
  if (isDone) continue
106
187
 
107
188
  if (isWeb) {
@@ -125,6 +206,13 @@ class Style {
125
206
  if (num2 && !web.numbers.includes(num2String)) web.numbers.push(num2String)
126
207
  }
127
208
  }
209
+
210
+ if (value?.isStyleValue && value.valueKind === 'number' && !this.unitless.has(key)) {
211
+ const numString = `${value.variable} : ${is0 ? 0 : Math.abs(value.value) / 16}rem;`
212
+ if (is0 || (value.value && !web.numbers.includes(numString))) {
213
+ web.numbers.push(numString)
214
+ }
215
+ }
128
216
  }
129
217
 
130
218
  if (isNative) {
@@ -132,8 +220,8 @@ class Style {
132
220
  native.style.push(...nativeStyle(arg, fonts))
133
221
  }
134
222
 
135
- present.push(...this.getPresent(list, write(arg)))
136
- done.push(...write(arg))
223
+ present.push(...this.getPresent(list, writeList))
224
+ done.push(...writeList)
137
225
  }
138
226
 
139
227
  const response = { missing, present, done }
@@ -143,4 +231,4 @@ class Style {
143
231
  }
144
232
  }
145
233
 
146
- export const style = new Style()
234
+ export const style = new Style()
@@ -1,15 +1,33 @@
1
- const f_position = (position) => ({
1
+ const f_position = (name, position, native = true) => ({
2
2
  target: `fixed`,
3
- write: () => ([position]),
4
- webClasses: () => ([`${position}: '${position}'`]),
5
- webStyle: () => ([`.${position} { position:${position} }`]),
6
- nativeClasses: () => ([`${position}: style['${position}']`]),
7
- nativeStyle: () => ([`${position}: { position:'${position}' }`])
3
+ write: () => ([name]),
4
+ webClasses: () => ([`${name}: '${name}'`]),
5
+ webStyle: () => ([`.${name} { position:${position} }`]),
6
+ nativeClasses: () => ([`${name}: style['${name}']`]),
7
+ nativeStyle: () => ([`${name}: { ${native ? `position:'${position}'` : ``} }`])
8
+ })
9
+
10
+ export const fixed = f_position('fixed', 'fixed', false)
11
+ export const absolute = f_position('absolute', 'absolute')
12
+ export const relative = f_position('relative', 'relative')
13
+
14
+ export const positionFixedWeb = f_position('positionFixedWeb', 'fixed', false)
15
+ export const positionAbsolute = f_position('positionAbsolute', 'absolute')
16
+ export const positionRelative = f_position('positionRelative', 'relative')
17
+ export const positionStatic = f_position('positionStatic', 'static')
18
+
19
+ const f_display = (name, display, direction = '') => ({
20
+ target: `fixed`,
21
+ write: () => ([name]),
22
+ webClasses: () => ([`${name}: '${name}'`]),
23
+ webStyle: () => ([`.${name} { display:${display}${direction?`; flex-direction:${direction}`:''} }`]),
24
+ nativeClasses: () => ([`${name}: style['${name}']`]),
25
+ nativeStyle: () => ([`${name}: { display:'${display}'${direction?`, flexDirection:'${direction}'`:''} }`])
8
26
  })
9
27
 
10
- export const fixed = f_position('fixed')
11
- export const absolute = f_position('absolute')
12
- export const relative = f_position('relative')
28
+ export const displayFlex = f_display('displayFlex', 'flex', 'row')
29
+ export const displayNone = f_display('displayNone', 'none')
30
+ export const displayContents = f_display('displayContents', 'contents')
13
31
 
14
32
  const f_overflow = (name, type, axis) => ({
15
33
  target: `fixed`,
@@ -17,7 +35,7 @@ const f_overflow = (name, type, axis) => ({
17
35
  webClasses: () => ([`${name}: '${name}'`]),
18
36
  webStyle: () => ([`.${name} { overflow${axis?`-${axis}`:''}:${type} }`]),
19
37
  nativeClasses: () => ([`${name}: style['${name}']`]),
20
- nativeStyle: () => ([`${name}: { overflow${axis?axis.toUpperCase():''}:'${type}' }`])
38
+ nativeStyle: () => ([`${name}: { ${axis ? `` : `overflow:'${type}'`} }`])
21
39
  })
22
40
 
23
41
  export const overflowXh = f_overflow('overflowXh','hidden','x')
@@ -26,7 +44,14 @@ export const overflowYh = f_overflow('overflowYh','hidden','y')
26
44
  export const overflowXs = f_overflow('overflowXs','scroll','x')
27
45
  export const overflowYs = f_overflow('overflowYs','scroll','y')
28
46
 
47
+ export const overflowXHidden = f_overflow('overflowXHidden','hidden','x')
48
+ export const overflowYHidden = f_overflow('overflowYHidden','hidden','y')
49
+ export const overflowXScroll = f_overflow('overflowXScroll','scroll','x')
50
+ export const overflowYScroll = f_overflow('overflowYScroll','scroll','y')
51
+
52
+ export const overflowHidden = f_overflow('overflowHidden','hidden')
29
53
  export const overflowXYh = f_overflow('overflowXYh','hidden')
54
+ export const overflowScroll = f_overflow('overflowScroll','scroll')
30
55
  export const overflowXYs = f_overflow('overflowXYs','scroll')
31
56
 
32
57
  export const flip = {
@@ -70,11 +95,11 @@ export const ratio = {
70
95
 
71
96
  export const ratioXY = {
72
97
  target: 'fixed',
73
- write: ({ X, Y }) => ([ `ratioXY_${X}_${Y}` ]),
74
- webClasses: ({ X, Y }) => ([`ratioXY_${X}_${Y}: 'ratioXY_${X}_${Y}'`]),
75
- webStyle: ({ X, Y }) => ([`.ratioXY_${X}_${Y} { aspect-ratio: ${X} / ${Y} }`]),
76
- nativeClasses: ({ X, Y }) => ([`ratioXY_${X}_${Y}: style['ratioXY_${X}_${Y}']`]),
77
- nativeStyle: ({ X, Y }) => ([`ratioXY_${X}_${Y}: { aspectRatio: ${X / Y} }`]),
98
+ write: ({ X, Y, name }) => ([ name ?? `ratioXY_${X}_${Y}` ]),
99
+ webClasses: ({ X, Y, name }) => ([`${name ?? `ratioXY_${X}_${Y}`}: '${name ?? `ratioXY_${X}_${Y}`}'`]),
100
+ webStyle: ({ X, Y, name }) => ([`.${name ?? `ratioXY_${X}_${Y}`} { aspect-ratio: ${X} / ${Y} }`]),
101
+ nativeClasses: ({ X, Y, name }) => ([`${name ?? `ratioXY_${X}_${Y}`}: style['${name ?? `ratioXY_${X}_${Y}`}']`]),
102
+ nativeStyle: ({ X, Y, name }) => ([`${name ?? `ratioXY_${X}_${Y}`}: { aspectRatio: ${X / Y} }`]),
78
103
  }
79
104
 
80
105
  export const cover = {
@@ -86,6 +111,15 @@ export const cover = {
86
111
  nativeStyle: () => ([`cover: { width: '100%', height: '100%', resizeMode: 'cover' }`])
87
112
  }
88
113
 
114
+ export const objectCover = {
115
+ target: `fixed`,
116
+ write: () => ([`objectCover`]),
117
+ webClasses: () => ([`objectCover: 'objectCover'`]),
118
+ webStyle: () => ([`.objectCover { width: 100%; height: 100%; object-fit: cover; object-position: center; display: block }`]),
119
+ nativeClasses: () => ([`objectCover: style['objectCover']`]),
120
+ nativeStyle: () => ([`objectCover: { width: '100%', height: '100%', resizeMode: 'cover' }`])
121
+ }
122
+
89
123
  export const noPointer = {
90
124
  target: `fixed`,
91
125
  write: (n='') => ([`noPointer`]),
@@ -93,4 +127,4 @@ export const noPointer = {
93
127
  webStyle: (n) => ([`.noPointer { pointer-events: none }`]),
94
128
  nativeClasses: (n) => ([`noPointer: style['noPointer']`]),
95
129
  nativeStyle: (n) => ([`noPointer: { pointerEvents: 'none' }`])
96
- }
130
+ }
@@ -1,3 +1,5 @@
1
+ import { nameOf, nativeLength, nativeNumber, webLength, webNumber } from './value.js'
2
+
1
3
  const f_row = ({name, name_r, dir, dir_r}) => ({
2
4
  target: `directional`,
3
5
  write: () => ([
@@ -214,74 +216,77 @@ export const row_bX_r = row_bX
214
216
 
215
217
  export const flex = {
216
218
  target: `fixed`,
217
- write: (n='') => ([`flex${n}`]),
218
- webClasses: (n) => ([`flex${n}: 'flex${n}'`]),
219
- webStyle: (n) => ([`.flex${n} { flex:${n} }`]),
220
- nativeClasses: (n) => ([`flex${n}: style['flex${n}']`]),
221
- nativeStyle: (n) => ([`flex${n}: { flex:${n} }`])
219
+ write: (n='') => ([`flex${nameOf(n)}`]),
220
+ webClasses: (n) => ([`flex${nameOf(n)}: 'flex${nameOf(n)}'`]),
221
+ webStyle: (n) => ([`.flex${nameOf(n)} { flex:${webNumber(n)} }`]),
222
+ nativeClasses: (n) => ([`flex${nameOf(n)}: style['flex${nameOf(n)}']`]),
223
+ nativeStyle: (n) => ([`flex${nameOf(n)}: { flex:${nativeNumber(n)} }`])
222
224
  }
223
225
 
224
- export const flexWrap = {
226
+ const f_wrap = name => ({
225
227
  target: `fixed`,
226
- write: () => ([`flexWrap`]),
227
- webClasses: () => ([`flexWrap: 'flexWrap'`]),
228
- webStyle: () => ([`.flexWrap { flex-wrap:wrap }`]),
229
- nativeClasses: () => ([`flexWrap: style['flexWrap']`]),
230
- nativeStyle: () => ([`flexWrap: { flexWrap:'wrap' }`])
231
- }
228
+ write: () => ([name]),
229
+ webClasses: () => ([`${name}: '${name}'`]),
230
+ webStyle: () => ([`.${name} { flex-wrap:wrap }`]),
231
+ nativeClasses: () => ([`${name}: style['${name}']`]),
232
+ nativeStyle: () => ([`${name}: { flexWrap:'wrap' }`])
233
+ })
234
+
235
+ export const flexWrap = f_wrap('flexWrap')
236
+ export const wrap = f_wrap('wrap')
232
237
 
233
238
  export const start = {
234
239
  target: `directional`,
235
240
  write: (n='') => ([
236
- `start${n}`,
237
- `end${n}`
241
+ `start${nameOf(n)}`,
242
+ `end${nameOf(n)}`
238
243
  ]),
239
244
  webClasses: (n) => ([
240
- `start${n}: isRTL ? 'right${n}' : 'left${n}'`,
241
- `end${n}: isRTL ? 'left${n}' : 'right${n}'`
245
+ `start${nameOf(n)}: isRTL ? 'right${nameOf(n)}' : 'left${nameOf(n)}'`,
246
+ `end${nameOf(n)}: isRTL ? 'left${nameOf(n)}' : 'right${nameOf(n)}'`
242
247
  ]),
243
248
  webStyle: (n) => ([
244
- `.right${n} { right:n.$px${n} }`,
245
- `.left${n} { left:n.$px${n} }`
249
+ `.right${nameOf(n)} { right:${webLength(n)} }`,
250
+ `.left${nameOf(n)} { left:${webLength(n)} }`
246
251
  ]),
247
252
  nativeClasses: (n) => ([
248
- `start${n}: style[ isRTL ? 'right${n}' : 'left${n}']`,
249
- `end${n}: style[ isRTL ? 'left${n}' : 'right${n}']`
253
+ `start${nameOf(n)}: style[ isRTL ? 'right${nameOf(n)}' : 'left${nameOf(n)}']`,
254
+ `end${nameOf(n)}: style[ isRTL ? 'left${nameOf(n)}' : 'right${nameOf(n)}']`
250
255
  ]),
251
256
  nativeStyle: (n) => ([
252
- `right${n}: { right:${n} }`,
253
- `left${n}: { left:${n} }`
257
+ `right${nameOf(n)}: { right:${nativeLength(n)} }`,
258
+ `left${nameOf(n)}: { left:${nativeLength(n)} }`
254
259
  ])
255
260
  }
256
261
  export const end = start
257
262
 
258
263
  export const top = {
259
264
  target: `fixed`,
260
- write: (n='') => ([`top${n}`]),
261
- webClasses: (n) => ([`top${n}: 'top${n}'`]),
262
- webStyle: (n) => ([`.top${n} { top:n.$px${n} }`]),
263
- nativeClasses: (n) => ([`top${n}: style['top${n}']`]),
264
- nativeStyle: (n) => ([`top${n}: { top:${n} }`])
265
+ write: (n='') => ([`top${nameOf(n)}`]),
266
+ webClasses: (n) => ([`top${nameOf(n)}: 'top${nameOf(n)}'`]),
267
+ webStyle: (n) => ([`.top${nameOf(n)} { top:${webLength(n)} }`]),
268
+ nativeClasses: (n) => ([`top${nameOf(n)}: style['top${nameOf(n)}']`]),
269
+ nativeStyle: (n) => ([`top${nameOf(n)}: { top:${nativeLength(n)} }`])
265
270
  }
266
271
 
267
272
  export const bottom = {
268
273
  target: `fixed`,
269
- write: (n='') => ([`bottom${n}`]),
270
- webClasses: (n) => ([`bottom${n}: 'bottom${n}'`]),
271
- webStyle: (n) => ([`.bottom${n} { bottom:n.$px${n} }`]),
272
- nativeClasses: (n) => ([`bottom${n}: style['bottom${n}']`]),
273
- nativeStyle: (n) => ([`bottom${n}: { bottom:${n} }`])
274
+ write: (n='') => ([`bottom${nameOf(n)}`]),
275
+ webClasses: (n) => ([`bottom${nameOf(n)}: 'bottom${nameOf(n)}'`]),
276
+ webStyle: (n) => ([`.bottom${nameOf(n)} { bottom:${webLength(n)} }`]),
277
+ nativeClasses: (n) => ([`bottom${nameOf(n)}: style['bottom${nameOf(n)}']`]),
278
+ nativeStyle: (n) => ([`bottom${nameOf(n)}: { bottom:${nativeLength(n)} }`])
274
279
  }
275
280
 
276
281
  // to be tested
277
282
 
278
283
  const f_gap = (web, native, prefix) => ({
279
284
  target: 'fixed',
280
- write: (n = '') => ([`${prefix}${n}`]),
281
- webClasses: (n) => ([`${prefix}${n}: '${prefix}${n}'`]),
282
- webStyle: (n) => ([`.${prefix}${n} { ${web}: n.$px${n} }`]),
283
- nativeClasses: (n) => ([`${prefix}${n}: style['${prefix}${n}']`]),
284
- nativeStyle: (n) => ([`${prefix}${n}: { ${native}: ${n} }`]),
285
+ write: (n = '') => ([`${prefix}${nameOf(n)}`]),
286
+ webClasses: (n) => ([`${prefix}${nameOf(n)}: '${prefix}${nameOf(n)}'`]),
287
+ webStyle: (n) => ([`.${prefix}${nameOf(n)} { ${web}: ${webLength(n)} }`]),
288
+ nativeClasses: (n) => ([`${prefix}${nameOf(n)}: style['${prefix}${nameOf(n)}']`]),
289
+ nativeStyle: (n) => ([`${prefix}${nameOf(n)}: { ${native}: ${nativeLength(n)} }`]),
285
290
  })
286
291
 
287
292
  export const gap = f_gap('gap', 'gap', 'gap')
@@ -290,20 +295,20 @@ export const gapCol = f_gap('column-gap', 'columnGap', 'gapCol')
290
295
 
291
296
  export const shrink = {
292
297
  target: 'fixed',
293
- write: (n = '') => ([`shrink${n}`]),
294
- webClasses: (n) => ([`shrink${n}: 'shrink${n}'`]),
295
- webStyle: (n) => ([`.shrink${n} { flex-shrink: ${n || 1} }`]),
296
- nativeClasses: (n) => ([`shrink${n}: style['shrink${n}']`]),
297
- nativeStyle: (n) => ([`shrink${n}: { flexShrink: ${n || 1} }`]),
298
+ write: (n = '') => ([`shrink${nameOf(n)}`]),
299
+ webClasses: (n) => ([`shrink${nameOf(n)}: 'shrink${nameOf(n)}'`]),
300
+ webStyle: (n) => ([`.shrink${nameOf(n)} { flex-shrink: ${webNumber(n) || 1} }`]),
301
+ nativeClasses: (n) => ([`shrink${nameOf(n)}: style['shrink${nameOf(n)}']`]),
302
+ nativeStyle: (n) => ([`shrink${nameOf(n)}: { flexShrink: ${nativeNumber(n) || 1} }`]),
298
303
  }
299
304
 
300
305
  export const order = {
301
306
  target: 'fixed',
302
- write: (n = '') => ([`order${n}`]),
303
- webClasses: (n) => ([`order${n}: 'order${n}'`]),
304
- webStyle: (n) => ([`.order${n} { order: ${n} }`]),
305
- nativeClasses: (n) => ([`order${n}: style['order${n}']`]),
306
- nativeStyle: (n) => ([`order${n}: { order: ${n} }`]),
307
+ write: (n = '') => ([`order${nameOf(n)}`]),
308
+ webClasses: (n) => ([`order${nameOf(n)}: 'order${nameOf(n)}'`]),
309
+ webStyle: (n) => ([`.order${nameOf(n)} { order: ${webNumber(n)} }`]),
310
+ nativeClasses: (n) => ([`order${nameOf(n)}: style['order${nameOf(n)}']`]),
311
+ nativeStyle: (n) => ([`order${nameOf(n)}: { order: ${nativeNumber(n)} }`]),
307
312
  }
308
313
 
309
314
  export const orderm = {
@@ -313,4 +318,4 @@ export const orderm = {
313
318
  webStyle: (n) => ([`.order${n}m { order: -${n} }`]),
314
319
  nativeClasses: (n) => ([`order${n}m: style['order${n}m']`]),
315
320
  nativeStyle: (n) => ([`order${n}m: { order: -${n} }`]),
316
- }
321
+ }
@@ -1,8 +1,10 @@
1
+ import { nameOf, nativeNumber, webNumber } from './value.js'
2
+
1
3
  export const opacity = {
2
4
  target: `fixed`,
3
- write: (n='') => ([`opacity${n}`]),
4
- webClasses: (n) => ([`opacity${n}: 'opacity${n}'`]),
5
- webStyle: (n) => ([`.opacity${n} { opacity:${n/100} }`]),
6
- nativeClasses: (n) => ([`opacity${n}: style['opacity${n}']`]),
7
- nativeStyle: (n) => ([`opacity${n}: { opacity:${n/100} }`])
5
+ write: (n='') => ([`opacity${nameOf(n)}`]),
6
+ webClasses: (n) => ([`opacity${nameOf(n)}: 'opacity${nameOf(n)}'`]),
7
+ webStyle: (n) => ([`.opacity${nameOf(n)} { opacity:${webNumber(n)/100} }`]),
8
+ nativeClasses: (n) => ([`opacity${nameOf(n)}: style['opacity${nameOf(n)}']`]),
9
+ nativeStyle: (n) => ([`opacity${nameOf(n)}: { opacity:${nativeNumber(n)/100} }`])
8
10
  }
@@ -1,35 +1,51 @@
1
+ import { nameOf, nativeLength, webLength } from './value.js'
2
+
1
3
  export const radiusRound = {
2
4
  target: `fixed`,
3
5
  write: () => ([`radiusRound`]),
4
6
  webClasses: () => ([`radiusRound: 'radiusRound'`]),
5
- webStyle: () => ([`.radiusRound { border-radius:100% }`]),
7
+ webStyle: () => ([`.radiusRound { border-radius:9999px }`]),
6
8
  nativeClasses: () => ([`radiusRound: style['radiusRound']`]),
7
- nativeStyle: () => ([`radiusRound: { borderRadius:'100%' }`])
9
+ nativeStyle: () => ([`radiusRound: { borderRadius:9999 }`])
8
10
  }
9
11
 
10
12
  export const radius = {
11
13
  target: `fixed`,
12
- write: (n='') => ([`radius${n}`]),
13
- webClasses: (n) => ([`radius${n}: 'radius${n}'`]),
14
- webStyle: (n) => ([`.radius${n} { border-radius:n.$px${n} }`]),
15
- nativeClasses: (n) => ([`radius${n}: style['radius${n}']`]),
16
- nativeStyle: (n) => ([`radius${n}: { borderRadius:${n} }`])
14
+ write: (n='') => ([`radius${nameOf(n)}`]),
15
+ webClasses: (n) => ([`radius${nameOf(n)}: 'radius${nameOf(n)}'`]),
16
+ webStyle: (n) => ([`.radius${nameOf(n)} { border-radius:${webLength(n)} }`]),
17
+ nativeClasses: (n) => ([`radius${nameOf(n)}: style['radius${nameOf(n)}']`]),
18
+ nativeStyle: (n) => ([`radius${nameOf(n)}: { borderRadius:${nativeLength(n)} }`])
17
19
  }
18
20
 
19
21
  export const radiusT = {
20
22
  target: `fixed`,
21
- write: (n='') => ([`radiusT${n}`]),
22
- webClasses: (n) => ([`radiusT${n}: 'radiusT${n}'`]),
23
- webStyle: (n) => ([`.radiusT${n} { border-top-left-radius:n.$px${n}; border-top-right-radius:n.$px${n} }`]),
24
- nativeClasses: (n) => ([`radiusT${n}: style['radiusT${n}']`]),
25
- nativeStyle: (n) => ([`radiusT${n}: { borderTopLeftRadius:${n}, borderTopRightRadius:${n} }`])
23
+ write: (n='') => ([`radiusT${nameOf(n)}`]),
24
+ webClasses: (n) => ([`radiusT${nameOf(n)}: 'radiusT${nameOf(n)}'`]),
25
+ webStyle: (n) => ([`.radiusT${nameOf(n)} { border-top-left-radius:${webLength(n)}; border-top-right-radius:${webLength(n)} }`]),
26
+ nativeClasses: (n) => ([`radiusT${nameOf(n)}: style['radiusT${nameOf(n)}']`]),
27
+ nativeStyle: (n) => ([`radiusT${nameOf(n)}: { borderTopLeftRadius:${nativeLength(n)}, borderTopRightRadius:${nativeLength(n)} }`])
26
28
  }
27
29
 
28
30
  export const radiusB = {
29
31
  target: `fixed`,
30
- write: (n='') => ([`radiusB${n}`]),
31
- webClasses: (n) => ([`radiusB${n}: 'radiusB${n}'`]),
32
- webStyle: (n) => ([`.radiusB${n} { border-bottom-left-radius:n.$px${n}; border-bottom-right-radius:n.$px${n} }`]),
33
- nativeClasses: (n) => ([`radiusB${n}: style['radiusB${n}']`]),
34
- nativeStyle: (n) => ([`radiusB${n}: { borderBottomLeftRadius:${n}, borderBottomRightRadius:${n} }`])
35
- }
32
+ write: (n='') => ([`radiusB${nameOf(n)}`]),
33
+ webClasses: (n) => ([`radiusB${nameOf(n)}: 'radiusB${nameOf(n)}'`]),
34
+ webStyle: (n) => ([`.radiusB${nameOf(n)} { border-bottom-left-radius:${webLength(n)}; border-bottom-right-radius:${webLength(n)} }`]),
35
+ nativeClasses: (n) => ([`radiusB${nameOf(n)}: style['radiusB${nameOf(n)}']`]),
36
+ nativeStyle: (n) => ([`radiusB${nameOf(n)}: { borderBottomLeftRadius:${nativeLength(n)}, borderBottomRightRadius:${nativeLength(n)} }`])
37
+ }
38
+
39
+ const f_radius = (prefix, web, native) => ({
40
+ target: `fixed`,
41
+ write: (n='') => ([`${prefix}${nameOf(n)}`]),
42
+ webClasses: (n) => ([`${prefix}${nameOf(n)}: '${prefix}${nameOf(n)}'`]),
43
+ webStyle: (n) => ([`.${prefix}${nameOf(n)} { ${web}:${webLength(n)} }`]),
44
+ nativeClasses: (n) => ([`${prefix}${nameOf(n)}: style['${prefix}${nameOf(n)}']`]),
45
+ nativeStyle: (n) => ([`${prefix}${nameOf(n)}: { ${native}:${nativeLength(n)} }`])
46
+ })
47
+
48
+ export const radiusTS = f_radius('radiusTS', 'border-start-start-radius', 'borderTopStartRadius')
49
+ export const radiusTE = f_radius('radiusTE', 'border-start-end-radius', 'borderTopEndRadius')
50
+ export const radiusBS = f_radius('radiusBS', 'border-end-start-radius', 'borderBottomStartRadius')
51
+ export const radiusBE = f_radius('radiusBE', 'border-end-end-radius', 'borderBottomEndRadius')
@@ -1,54 +1,56 @@
1
+ import { nameOf, nativeLength, nativeNumber, webLength, webNumber } from './value.js'
2
+
1
3
  export const X = {
2
4
  target: `fixed`,
3
- write: (n='') => ([`X${n}`]),
4
- webClasses: (n='') => ([`X${n}: 'X${n}'`]),
5
- webStyle: (n='') => ([`.X${n} { width:${n?`n.$px${n}`:`100%`}; max-width:${n?`n.$px${n}`:`100%`}; min-width:${n?`n.$px${n}`:`100%`} }`]),
6
- nativeClasses: (n='') => ([`X${n}: style['X${n}']`]),
7
- nativeStyle: (n='') => ([`X${n}: { width:${n?n:`'100%'`}, maxWidth:${n?n:`'100%'`}, minWidth:${n?n:`'100%'`} }`])
5
+ write: (n='') => ([`X${nameOf(n)}`]),
6
+ webClasses: (n='') => ([`X${nameOf(n)}: 'X${nameOf(n)}'`]),
7
+ webStyle: (n='') => ([`.X${nameOf(n)} { width:${webLength(n)}; max-width:${webLength(n)}; min-width:${webLength(n)} }`]),
8
+ nativeClasses: (n='') => ([`X${nameOf(n)}: style['X${nameOf(n)}']`]),
9
+ nativeStyle: (n='') => ([`X${nameOf(n)}: { width:${nativeLength(n)}, maxWidth:${nativeLength(n)}, minWidth:${nativeLength(n)} }`])
8
10
  }
9
11
  export const Xx = {
10
12
  target: `fixed`,
11
- write: (n='') => ([`Xx${n}`]),
12
- webClasses: (n='') => ([`Xx${n}: 'Xx${n}'`]),
13
- webStyle: (n='') => ([`.Xx${n} { width:${n?`n.$px${n}`:`100%`} }`]),
14
- nativeClasses: (n='') => ([`Xx${n}: style['Xx${n}']`]),
15
- nativeStyle: (n='') => ([`Xx${n}: { width:${n?n:`'100%'`} }`])
13
+ write: (n='') => ([`Xx${nameOf(n)}`]),
14
+ webClasses: (n='') => ([`Xx${nameOf(n)}: 'Xx${nameOf(n)}'`]),
15
+ webStyle: (n='') => ([`.Xx${nameOf(n)} { width:${webLength(n)} }`]),
16
+ nativeClasses: (n='') => ([`Xx${nameOf(n)}: style['Xx${nameOf(n)}']`]),
17
+ nativeStyle: (n='') => ([`Xx${nameOf(n)}: { width:${nativeLength(n)} }`])
16
18
  }
17
19
 
18
20
 
19
21
  export const Y = {
20
22
  target: `fixed`,
21
- write: (n='') => ([`Y${n}`]),
22
- webClasses: (n='') => ([`Y${n}: 'Y${n}'`]),
23
- webStyle: (n='') => ([`.Y${n} { height:${n?`n.$px${n}`:`100%`}; max-height:${n?`n.$px${n}`:`100%`}; min-height:${n?`n.$px${n}`:`100%`} }`]),
24
- nativeClasses: (n='') => ([`Y${n}: style['Y${n}']`]),
25
- nativeStyle: (n='') => ([`Y${n}: { height:${n?n:`'100%'`}, maxHeight:${n?n:`'100%'`}, minHeight:${n?n:`'100%'`} }`])
23
+ write: (n='') => ([`Y${nameOf(n)}`]),
24
+ webClasses: (n='') => ([`Y${nameOf(n)}: 'Y${nameOf(n)}'`]),
25
+ webStyle: (n='') => ([`.Y${nameOf(n)} { height:${webLength(n)}; max-height:${webLength(n)}; min-height:${webLength(n)} }`]),
26
+ nativeClasses: (n='') => ([`Y${nameOf(n)}: style['Y${nameOf(n)}']`]),
27
+ nativeStyle: (n='') => ([`Y${nameOf(n)}: { height:${nativeLength(n)}, maxHeight:${nativeLength(n)}, minHeight:${nativeLength(n)} }`])
26
28
  }
27
29
  export const Yy = {
28
30
  target: `fixed`,
29
- write: (n='') => ([`Yy${n}`]),
30
- webClasses: (n='') => ([`Yy${n}: 'Yy${n}'`]),
31
- webStyle: (n='') => ([`.Yy${n} { height:${n?`n.$px${n}`:`100%`} }`]),
32
- nativeClasses: (n='') => ([`Yy${n}: style['Yy${n}']`]),
33
- nativeStyle: (n='') => ([`Yy${n}: { height:${n?n:`'100%'`} }`])
31
+ write: (n='') => ([`Yy${nameOf(n)}`]),
32
+ webClasses: (n='') => ([`Yy${nameOf(n)}: 'Yy${nameOf(n)}'`]),
33
+ webStyle: (n='') => ([`.Yy${nameOf(n)} { height:${webLength(n)} }`]),
34
+ nativeClasses: (n='') => ([`Yy${nameOf(n)}: style['Yy${nameOf(n)}']`]),
35
+ nativeStyle: (n='') => ([`Yy${nameOf(n)}: { height:${nativeLength(n)} }`])
34
36
  }
35
37
 
36
38
  export const XY = {
37
39
  target: `fixed`,
38
- write: (n='') => ([`XY${n}`]),
39
- webClasses: (n='') => ([`XY${n}: 'XY${n}'`]),
40
- webStyle: (n='') => ([`.XY${n} { width:${n?`n.$px${n}`:`100%`}; max-width:${n?`n.$px${n}`:`100%`}; min-width:${n?`n.$px${n}`:`100%`}; height:${n?`n.$px${n}`:`100%`}; max-height:${n?`n.$px${n}`:`100%`}; min-height:${n?`n.$px${n}`:`100%`} }`]),
41
- nativeClasses: (n='') => ([`XY${n}: style['XY${n}']`]),
42
- nativeStyle: (n='') => ([`XY${n}: { width:${n?n:`'100%'`}, maxWidth:${n?n:`'100%'`}, minWidth:${n?n:`'100%'`}, height:${n?n:`'100%'`}, maxHeight:${n?n:`'100%'`}, minHeight:${n?n:`'100%'`} }`])
40
+ write: (n='') => ([`XY${nameOf(n)}`]),
41
+ webClasses: (n='') => ([`XY${nameOf(n)}: 'XY${nameOf(n)}'`]),
42
+ webStyle: (n='') => ([`.XY${nameOf(n)} { width:${webLength(n)}; max-width:${webLength(n)}; min-width:${webLength(n)}; height:${webLength(n)}; max-height:${webLength(n)}; min-height:${webLength(n)} }`]),
43
+ nativeClasses: (n='') => ([`XY${nameOf(n)}: style['XY${nameOf(n)}']`]),
44
+ nativeStyle: (n='') => ([`XY${nameOf(n)}: { width:${nativeLength(n)}, maxWidth:${nativeLength(n)}, minWidth:${nativeLength(n)}, height:${nativeLength(n)}, maxHeight:${nativeLength(n)}, minHeight:${nativeLength(n)} }`])
43
45
  }
44
46
 
45
47
  export const Z = {
46
48
  target: `fixed`,
47
- write: (n='') => ([`Z${n}`]),
48
- webClasses: (n) => ([`Z${n}: 'Z${n}'`]),
49
- webStyle: (n) => ([`.Z${n} { z-index:${n} }`]),
50
- nativeClasses: (n) => ([`Z${n}: style['Z${n}']`]),
51
- nativeStyle: (n) => ([`Z${n}: { zIndex:${n} }`])
49
+ write: (n='') => ([`Z${nameOf(n)}`]),
50
+ webClasses: (n) => ([`Z${nameOf(n)}: 'Z${nameOf(n)}'`]),
51
+ webStyle: (n) => ([`.Z${nameOf(n)} { z-index:${webNumber(n)} }`]),
52
+ nativeClasses: (n) => ([`Z${nameOf(n)}: style['Z${nameOf(n)}']`]),
53
+ nativeStyle: (n) => ([`Z${nameOf(n)}: { zIndex:${nativeNumber(n)} }`])
52
54
  }
53
55
  export const Zm = {
54
56
  target: `fixed`,
@@ -61,36 +63,36 @@ export const Zm = {
61
63
 
62
64
  export const Xmin = {
63
65
  target: `fixed`,
64
- write: (n='') => ([`Xmin${n}`]),
65
- webClasses: (n='') => ([`Xmin${n}: 'Xmin${n}'`]),
66
- webStyle: (n='') => ([`.Xmin${n} { min-width:n.$px${n} }`]),
67
- nativeClasses: (n='') => ([`Xmin${n}: style['Xmin${n}']`]),
68
- nativeStyle: (n='') => ([`Xmin${n}: { minWidth:${n} }`])
66
+ write: (n='') => ([`Xmin${nameOf(n)}`]),
67
+ webClasses: (n='') => ([`Xmin${nameOf(n)}: 'Xmin${nameOf(n)}'`]),
68
+ webStyle: (n='') => ([`.Xmin${nameOf(n)} { min-width:${webLength(n)} }`]),
69
+ nativeClasses: (n='') => ([`Xmin${nameOf(n)}: style['Xmin${nameOf(n)}']`]),
70
+ nativeStyle: (n='') => ([`Xmin${nameOf(n)}: { minWidth:${nativeLength(n)} }`])
69
71
  }
70
72
  export const Xmax = {
71
73
  target: `fixed`,
72
- write: (n='') => ([`Xmax${n}`]),
73
- webClasses: (n='') => ([`Xmax${n}: 'Xmax${n}'`]),
74
- webStyle: (n='') => ([`.Xmax${n} { max-width:n.$px${n} }`]),
75
- nativeClasses: (n='') => ([`Xmax${n}: style['Xmax${n}']`]),
76
- nativeStyle: (n='') => ([`Xmax${n}: { maxWidth:${n} }`])
74
+ write: (n='') => ([`Xmax${nameOf(n)}`]),
75
+ webClasses: (n='') => ([`Xmax${nameOf(n)}: 'Xmax${nameOf(n)}'`]),
76
+ webStyle: (n='') => ([`.Xmax${nameOf(n)} { max-width:${webLength(n)} }`]),
77
+ nativeClasses: (n='') => ([`Xmax${nameOf(n)}: style['Xmax${nameOf(n)}']`]),
78
+ nativeStyle: (n='') => ([`Xmax${nameOf(n)}: { maxWidth:${nativeLength(n)} }`])
77
79
  }
78
80
 
79
81
  export const Ymin = {
80
82
  target: `fixed`,
81
- write: (n='') => ([`Ymin${n}`]),
82
- webClasses: (n='') => ([`Ymin${n}: 'Ymin${n}'`]),
83
- webStyle: (n='') => ([`.Ymin${n} { min-height:n.$px${n} }`]),
84
- nativeClasses: (n='') => ([`Ymin${n}: style['Ymin${n}']`]),
85
- nativeStyle: (n='') => ([`Ymin${n}: { minHeight:${n} }`])
83
+ write: (n='') => ([`Ymin${nameOf(n)}`]),
84
+ webClasses: (n='') => ([`Ymin${nameOf(n)}: 'Ymin${nameOf(n)}'`]),
85
+ webStyle: (n='') => ([`.Ymin${nameOf(n)} { min-height:${webLength(n)} }`]),
86
+ nativeClasses: (n='') => ([`Ymin${nameOf(n)}: style['Ymin${nameOf(n)}']`]),
87
+ nativeStyle: (n='') => ([`Ymin${nameOf(n)}: { minHeight:${nativeLength(n)} }`])
86
88
  }
87
89
  export const Ymax = {
88
90
  target: `fixed`,
89
- write: (n='') => ([`Ymax${n}`]),
90
- webClasses: (n='') => ([`Ymax${n}: 'Ymax${n}'`]),
91
- webStyle: (n='') => ([`.Ymax${n} { max-height:n.$px${n} }`]),
92
- nativeClasses: (n='') => ([`Ymax${n}: style['Ymax${n}']`]),
93
- nativeStyle: (n='') => ([`Ymax${n}: { maxHeight:${n} }`])
91
+ write: (n='') => ([`Ymax${nameOf(n)}`]),
92
+ webClasses: (n='') => ([`Ymax${nameOf(n)}: 'Ymax${nameOf(n)}'`]),
93
+ webStyle: (n='') => ([`.Ymax${nameOf(n)} { max-height:${webLength(n)} }`]),
94
+ nativeClasses: (n='') => ([`Ymax${nameOf(n)}: style['Ymax${nameOf(n)}']`]),
95
+ nativeStyle: (n='') => ([`Ymax${nameOf(n)}: { maxHeight:${nativeLength(n)} }`])
94
96
  }
95
97
 
96
98
  export const Xr = {
@@ -161,4 +163,3 @@ export const XG = {
161
163
  nativeClasses: (n) => ([`XG${n}: style['XG${n}']`]),
162
164
  nativeStyle: (n) => ([`XG${n}: { flexGrow:${n}, width:1 }`])
163
165
  }
164
-
@@ -1,69 +1,71 @@
1
+ import { nameOf, nativeLength, webLength } from './value.js'
2
+
1
3
  export const margin = {
2
4
  target: `fixed`,
3
- write: (n='') => ([`margin${n}`]),
4
- webClasses: (n) => ([`margin${n}: 'margin${n}'`]),
5
- webStyle: (n) => ([`.margin${n} { margin:n.$px${n} }`]),
6
- nativeClasses: (n) => ([`margin${n}: style['margin${n}']`]),
7
- nativeStyle: (n) => ([`margin${n}: { margin:${n} }`])
5
+ write: (n='') => ([`margin${nameOf(n)}`]),
6
+ webClasses: (n) => ([`margin${nameOf(n)}: 'margin${nameOf(n)}'`]),
7
+ webStyle: (n) => ([`.margin${nameOf(n)} { margin:${webLength(n)} }`]),
8
+ nativeClasses: (n) => ([`margin${nameOf(n)}: style['margin${nameOf(n)}']`]),
9
+ nativeStyle: (n) => ([`margin${nameOf(n)}: { margin:${nativeLength(n)} }`])
8
10
  }
9
11
 
10
12
  export const marginX = {
11
13
  target: `fixed`,
12
- write: (n='') => ([`marginX${n}`]),
13
- webClasses: (n) => ([`marginX${n}: 'marginX${n}'`]),
14
- webStyle: (n) => ([`.marginX${n} { margin-left:n.$px${n}; margin-right:n.$px${n} }`]),
15
- nativeClasses: (n) => ([`marginX${n}: style['marginX${n}']`]),
16
- nativeStyle: (n) => ([`marginX${n}: { marginLeft:${n}, marginRight:${n}}`])
14
+ write: (n='') => ([`marginX${nameOf(n)}`]),
15
+ webClasses: (n) => ([`marginX${nameOf(n)}: 'marginX${nameOf(n)}'`]),
16
+ webStyle: (n) => ([`.marginX${nameOf(n)} { margin-left:${webLength(n)}; margin-right:${webLength(n)} }`]),
17
+ nativeClasses: (n) => ([`marginX${nameOf(n)}: style['marginX${nameOf(n)}']`]),
18
+ nativeStyle: (n) => ([`marginX${nameOf(n)}: { marginLeft:${nativeLength(n)}, marginRight:${nativeLength(n)}}`])
17
19
  }
18
20
 
19
21
  export const marginY = {
20
22
  target: `fixed`,
21
- write: (n='') => ([`marginY${n}`]),
22
- webClasses: (n) => ([`marginY${n}: 'marginY${n}'`]),
23
- webStyle: (n) => ([`.marginY${n} { margin-top:n.$px${n}; margin-bottom:n.$px${n} }`]),
24
- nativeClasses: (n) => ([`marginY${n}: style['marginY${n}']`]),
25
- nativeStyle: (n) => ([`marginY${n}: { marginTop:${n}, marginBottom:${n}}`])
23
+ write: (n='') => ([`marginY${nameOf(n)}`]),
24
+ webClasses: (n) => ([`marginY${nameOf(n)}: 'marginY${nameOf(n)}'`]),
25
+ webStyle: (n) => ([`.marginY${nameOf(n)} { margin-top:${webLength(n)}; margin-bottom:${webLength(n)} }`]),
26
+ nativeClasses: (n) => ([`marginY${nameOf(n)}: style['marginY${nameOf(n)}']`]),
27
+ nativeStyle: (n) => ([`marginY${nameOf(n)}: { marginTop:${nativeLength(n)}, marginBottom:${nativeLength(n)}}`])
26
28
  }
27
29
 
28
30
  export const marginT = {
29
31
  target: `fixed`,
30
- write: (n='') => ([`marginT${n}`]),
31
- webClasses: (n) => ([`marginT${n}: 'marginT${n}'`]),
32
- webStyle: (n) => ([`.marginT${n} { margin-top:n.$px${n} }`]),
33
- nativeClasses: (n) => ([`marginT${n}: style['marginT${n}']`]),
34
- nativeStyle: (n) => ([`marginT${n}: { marginTop:${n} }`])
32
+ write: (n='') => ([`marginT${nameOf(n)}`]),
33
+ webClasses: (n) => ([`marginT${nameOf(n)}: 'marginT${nameOf(n)}'`]),
34
+ webStyle: (n) => ([`.marginT${nameOf(n)} { margin-top:${webLength(n)} }`]),
35
+ nativeClasses: (n) => ([`marginT${nameOf(n)}: style['marginT${nameOf(n)}']`]),
36
+ nativeStyle: (n) => ([`marginT${nameOf(n)}: { marginTop:${nativeLength(n)} }`])
35
37
  }
36
38
 
37
39
  export const marginB = {
38
40
  target: `fixed`,
39
- write: (n='') => ([`marginB${n}`]),
40
- webClasses: (n) => ([`marginB${n}: 'marginB${n}'`]),
41
- webStyle: (n) => ([`.marginB${n} { margin-bottom:n.$px${n} }`]),
42
- nativeClasses: (n) => ([`marginB${n}: style['marginB${n}']`]),
43
- nativeStyle: (n) => ([`marginB${n}: { marginBottom:${n}}`])
41
+ write: (n='') => ([`marginB${nameOf(n)}`]),
42
+ webClasses: (n) => ([`marginB${nameOf(n)}: 'marginB${nameOf(n)}'`]),
43
+ webStyle: (n) => ([`.marginB${nameOf(n)} { margin-bottom:${webLength(n)} }`]),
44
+ nativeClasses: (n) => ([`marginB${nameOf(n)}: style['marginB${nameOf(n)}']`]),
45
+ nativeStyle: (n) => ([`marginB${nameOf(n)}: { marginBottom:${nativeLength(n)}}`])
44
46
  }
45
47
 
46
48
  export const marginS = {
47
- target: `directional`,
49
+ target: `fixed`,
48
50
  write: (n='') => ([
49
- `marginS${n}`,
50
- `marginE${n}`
51
+ `marginS${nameOf(n)}`,
52
+ `marginE${nameOf(n)}`
51
53
  ]),
52
54
  webClasses: (n) => ([
53
- `marginS${n}: isRTL ? 'marginR${n}' : 'marginL${n}'`,
54
- `marginE${n}: isRTL ? 'marginL${n}' : 'marginR${n}'`
55
+ `marginS${nameOf(n)}: 'marginS${nameOf(n)}'`,
56
+ `marginE${nameOf(n)}: 'marginE${nameOf(n)}'`
55
57
  ]),
56
58
  webStyle: (n) => ([
57
- `.marginL${n} { margin-left:n.$px${n} }`,
58
- `.marginR${n} { margin-right:n.$px${n} }`
59
+ `.marginS${nameOf(n)} { margin-inline-start:${webLength(n)} }`,
60
+ `.marginE${nameOf(n)} { margin-inline-end:${webLength(n)} }`
59
61
  ]),
60
62
  nativeClasses: (n) => ([
61
- `marginS${n}: style[isRTL ? 'marginR${n}' : 'marginL${n}']`,
62
- `marginE${n}: style[isRTL ? 'marginL${n}' : 'marginR${n}']`
63
+ `marginS${nameOf(n)}: style['marginS${nameOf(n)}']`,
64
+ `marginE${nameOf(n)}: style['marginE${nameOf(n)}']`
63
65
  ]),
64
66
  nativeStyle: (n) => ([
65
- `marginL${n}: { marginLeft:${n} }`,
66
- `marginR${n}: { marginRight:${n} }`
67
+ `marginS${nameOf(n)}: { marginStart:${nativeLength(n)} }`,
68
+ `marginE${nameOf(n)}: { marginEnd:${nativeLength(n)} }`
67
69
  ])
68
70
  }
69
71
  export const marginE = marginS
@@ -71,70 +73,70 @@ export const marginE = marginS
71
73
 
72
74
  export const padding = {
73
75
  target: `fixed`,
74
- write: (n='') => ([`padding${n}`]),
75
- webClasses: (n) => ([`padding${n}: 'padding${n}'`]),
76
- webStyle: (n) => ([`.padding${n} { padding:n.$px${n} }`]),
77
- nativeClasses: (n) => ([`padding${n}: style['padding${n}']`]),
78
- nativeStyle: (n) => ([`padding${n}: { padding:${n} }`])
76
+ write: (n='') => ([`padding${nameOf(n)}`]),
77
+ webClasses: (n) => ([`padding${nameOf(n)}: 'padding${nameOf(n)}'`]),
78
+ webStyle: (n) => ([`.padding${nameOf(n)} { padding:${webLength(n)} }`]),
79
+ nativeClasses: (n) => ([`padding${nameOf(n)}: style['padding${nameOf(n)}']`]),
80
+ nativeStyle: (n) => ([`padding${nameOf(n)}: { padding:${nativeLength(n)} }`])
79
81
  }
80
82
 
81
83
  export const paddingX = {
82
84
  target: `fixed`,
83
- write: (n='') => ([`paddingX${n}`]),
84
- webClasses: (n) => ([`paddingX${n}: 'paddingX${n}'`]),
85
- webStyle: (n) => ([`.paddingX${n} { padding-left:n.$px${n}; padding-right:n.$px${n} }`]),
86
- nativeClasses: (n) => ([`paddingX${n}: style['paddingX${n}']`]),
87
- nativeStyle: (n) => ([`paddingX${n}: { paddingLeft:${n}, paddingRight:${n}}`])
85
+ write: (n='') => ([`paddingX${nameOf(n)}`]),
86
+ webClasses: (n) => ([`paddingX${nameOf(n)}: 'paddingX${nameOf(n)}'`]),
87
+ webStyle: (n) => ([`.paddingX${nameOf(n)} { padding-left:${webLength(n)}; padding-right:${webLength(n)} }`]),
88
+ nativeClasses: (n) => ([`paddingX${nameOf(n)}: style['paddingX${nameOf(n)}']`]),
89
+ nativeStyle: (n) => ([`paddingX${nameOf(n)}: { paddingLeft:${nativeLength(n)}, paddingRight:${nativeLength(n)}}`])
88
90
  }
89
91
 
90
92
  export const paddingY = {
91
93
  target: `fixed`,
92
- write: (n='') => ([`paddingY${n}`]),
93
- webClasses: (n) => ([`paddingY${n}: 'paddingY${n}'`]),
94
- webStyle: (n) => ([`.paddingY${n} { padding-top:n.$px${n}; padding-bottom:n.$px${n} }`]),
95
- nativeClasses: (n) => ([`paddingY${n}: style['paddingY${n}']`]),
96
- nativeStyle: (n) => ([`paddingY${n}: { paddingTop:${n}, paddingBottom:${n}}`])
94
+ write: (n='') => ([`paddingY${nameOf(n)}`]),
95
+ webClasses: (n) => ([`paddingY${nameOf(n)}: 'paddingY${nameOf(n)}'`]),
96
+ webStyle: (n) => ([`.paddingY${nameOf(n)} { padding-top:${webLength(n)}; padding-bottom:${webLength(n)} }`]),
97
+ nativeClasses: (n) => ([`paddingY${nameOf(n)}: style['paddingY${nameOf(n)}']`]),
98
+ nativeStyle: (n) => ([`paddingY${nameOf(n)}: { paddingTop:${nativeLength(n)}, paddingBottom:${nativeLength(n)}}`])
97
99
  }
98
100
 
99
101
  export const paddingT = {
100
102
  target: `fixed`,
101
- write: (n='') => ([`paddingT${n}`]),
102
- webClasses: (n) => ([`paddingT${n}: 'paddingT${n}'`]),
103
- webStyle: (n) => ([`.paddingT${n} { padding-top:n.$px${n} }`]),
104
- nativeClasses: (n) => ([`paddingT${n}: style['paddingT${n}']`]),
105
- nativeStyle: (n) => ([`paddingT${n}: { paddingTop:${n} }`])
103
+ write: (n='') => ([`paddingT${nameOf(n)}`]),
104
+ webClasses: (n) => ([`paddingT${nameOf(n)}: 'paddingT${nameOf(n)}'`]),
105
+ webStyle: (n) => ([`.paddingT${nameOf(n)} { padding-top:${webLength(n)} }`]),
106
+ nativeClasses: (n) => ([`paddingT${nameOf(n)}: style['paddingT${nameOf(n)}']`]),
107
+ nativeStyle: (n) => ([`paddingT${nameOf(n)}: { paddingTop:${nativeLength(n)} }`])
106
108
  }
107
109
 
108
110
  export const paddingB = {
109
111
  target: `fixed`,
110
- write: (n='') => ([`paddingB${n}`]),
111
- webClasses: (n) => ([`paddingB${n}: 'paddingB${n}'`]),
112
- webStyle: (n) => ([`.paddingB${n} { padding-bottom:n.$px${n} }`]),
113
- nativeClasses: (n) => ([`paddingB${n}: style['paddingB${n}']`]),
114
- nativeStyle: (n) => ([`paddingB${n}: { paddingBottom:${n}}`])
112
+ write: (n='') => ([`paddingB${nameOf(n)}`]),
113
+ webClasses: (n) => ([`paddingB${nameOf(n)}: 'paddingB${nameOf(n)}'`]),
114
+ webStyle: (n) => ([`.paddingB${nameOf(n)} { padding-bottom:${webLength(n)} }`]),
115
+ nativeClasses: (n) => ([`paddingB${nameOf(n)}: style['paddingB${nameOf(n)}']`]),
116
+ nativeStyle: (n) => ([`paddingB${nameOf(n)}: { paddingBottom:${nativeLength(n)}}`])
115
117
  }
116
118
 
117
119
  export const paddingS = {
118
- target: `directional`,
120
+ target: `fixed`,
119
121
  write: (n='') => ([
120
- `paddingS${n}`,
121
- `paddingE${n}`
122
+ `paddingS${nameOf(n)}`,
123
+ `paddingE${nameOf(n)}`
122
124
  ]),
123
125
  webClasses: (n) => ([
124
- `paddingS${n}: isRTL ? 'paddingR${n}' : 'paddingL${n}'`,
125
- `paddingE${n}: isRTL ? 'paddingL${n}' : 'paddingR${n}'`
126
+ `paddingS${nameOf(n)}: 'paddingS${nameOf(n)}'`,
127
+ `paddingE${nameOf(n)}: 'paddingE${nameOf(n)}'`
126
128
  ]),
127
129
  webStyle: (n) => ([
128
- `.paddingL${n} { padding-left:n.$px${n} }`,
129
- `.paddingR${n} { padding-right:n.$px${n} }`
130
+ `.paddingS${nameOf(n)} { padding-inline-start:${webLength(n)} }`,
131
+ `.paddingE${nameOf(n)} { padding-inline-end:${webLength(n)} }`
130
132
  ]),
131
133
  nativeClasses: (n) => ([
132
- `paddingS${n}: style[isRTL ? 'paddingR${n}' : 'paddingL${n}']`,
133
- `paddingE${n}: style[isRTL ? 'paddingL${n}' : 'paddingR${n}']`
134
+ `paddingS${nameOf(n)}: style['paddingS${nameOf(n)}']`,
135
+ `paddingE${nameOf(n)}: style['paddingE${nameOf(n)}']`
134
136
  ]),
135
137
  nativeStyle: (n) => ([
136
- `paddingL${n}: { paddingLeft:${n} }`,
137
- `paddingR${n}: { paddingRight:${n} }`
138
+ `paddingS${nameOf(n)}: { paddingStart:${nativeLength(n)} }`,
139
+ `paddingE${nameOf(n)}: { paddingEnd:${nativeLength(n)} }`
138
140
  ])
139
141
  }
140
- export const paddingE = paddingS
142
+ export const paddingE = paddingS
@@ -1,3 +1,5 @@
1
+ import { nameOf, nativeNumber, webNumber } from './value.js'
2
+
1
3
  export const textC = {
2
4
  target: `fixed`,
3
5
  write: (n='') => ([`textC`]),
@@ -34,11 +36,11 @@ export const textE = textS
34
36
 
35
37
  export const fw = {
36
38
  target: `fixed`,
37
- write: (n='') => ([`fw${n}`]),
38
- webClasses: (n) => ([`fw${n}: 'fw${n}'`]),
39
- webStyle: (n) => ([`.fw${n} { font-weight:${n} }`]),
40
- nativeClasses: (n) => ([`fw${n}: style['fw${n}']`]),
41
- nativeStyle: (n) => ([`fw${n}: { fontWeight:${n} }`])
39
+ write: (n='') => ([`fw${nameOf(n)}`]),
40
+ webClasses: (n) => ([`fw${nameOf(n)}: 'fw${nameOf(n)}'`]),
41
+ webStyle: (n) => ([`.fw${nameOf(n)} { font-weight:${webNumber(n)} }`]),
42
+ nativeClasses: (n) => ([`fw${nameOf(n)}: style['fw${nameOf(n)}']`]),
43
+ nativeStyle: (n) => ([`fw${nameOf(n)}: { fontWeight:'${nativeNumber(n)}' }`])
42
44
  }
43
45
 
44
46
  export const lh = {
@@ -159,4 +161,4 @@ export const textline = {
159
161
  nativeClasses: (n) => ([`textline: style['textline']`]),
160
162
  nativeStyle: (n) => ([`textline: { overflow: 'hidden' }`])
161
163
  //need to add props numberOfLines={1} ellipsizeMode="tail"
162
- }
164
+ }
@@ -0,0 +1,27 @@
1
+ export const isValue = value => value && typeof value === 'object' && value.isStyleValue
2
+
3
+ export const nameOf = value => isValue(value) ? value.suffix : (value ?? '')
4
+
5
+ export const webLength = value => {
6
+ if (isValue(value)) return value.web
7
+ if (value === 0) return 0
8
+ if (value) return `n.$px${value}`
9
+ return `100%`
10
+ }
11
+
12
+ export const nativeLength = value => {
13
+ if (isValue(value)) return value.native
14
+ if (value === 0) return 0
15
+ if (value) return value
16
+ return `'100%'`
17
+ }
18
+
19
+ export const webNumber = value => {
20
+ if (isValue(value)) return value.value
21
+ return value
22
+ }
23
+
24
+ export const nativeNumber = value => {
25
+ if (isValue(value)) return value.value
26
+ return value
27
+ }
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
- "version": "1.0.9",
2
+ "version": "1.0.12",
3
3
  "name": "@fullstackunicorn/style",
4
4
  "author": "lucanigido (https://fullstackunicorn.dev/author/lucanigido)",
5
5
  "description": "A development utility for generating responsive web and native styles (CSS, SCSS, JS, RN) from a declarative style.config.js file.",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "private": false,
9
- "readme": "package.readme.md",
9
+ "readme": "package.md",
10
10
  "main": "index.js",
11
11
  "files": [
12
12
  "index.js",
@@ -38,8 +38,8 @@
38
38
  "#@/*": "./*"
39
39
  },
40
40
  "scripts": {
41
- "test": "exit 1",
42
- "run": "chmod +x ./config.run.sh && ./config.run.sh"
41
+ "cmd": "chmod +x ./config.cmd.sh && ./config.cmd.sh",
42
+ "test": "exit 1"
43
43
  },
44
44
  "dependencies": {
45
45
  "@fullstackunicorn/filesystem": "^1.0.4",