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 CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "UI Library built on Scratch and DOMQL",
4
4
  "private": false,
5
5
  "author": "symbo.ls",
6
- "version": "0.10.0",
6
+ "version": "0.11.0",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
package/src/Block.js CHANGED
@@ -1,29 +1,30 @@
1
1
  'use strict'
2
2
 
3
- import { SPACING, mapSpacing } from '@symbo.ls/scratch'
3
+ import { SPACING, getSpacingByKey } from '@symbo.ls/scratch'
4
4
 
5
- export const mapBasedOnRatio = (props, prop, unit) => {
5
+ export const getSpacingBasedOnRatio = (props, prop, unit) => {
6
6
  const { spacingRatio } = props
7
7
  const val = props[prop]
8
- // TODO: move this to mapSpacing
8
+ // TODO: move this to getSpacingByKey
9
9
  if (spacingRatio) {
10
- const params = SPACING[spacingRatio]
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: 'spacing',
15
+ type: SPACING.type,
16
16
  ratio: spacingRatio,
17
- range: [-5, +7],
18
- subSequence: true,
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 mapSpacing(val, prop, params, unit)
25
+ return getSpacingByKey(val, prop, params, unit)
25
26
  }
26
- return mapSpacing(val, prop, null, unit)
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 && mapBasedOnRatio(props, 'width'),
40
- height: ({ props }) => props.height && mapBasedOnRatio(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
- ...mapSpacing(height, 'height'),
46
- ...mapSpacing(width || height, 'width')
46
+ ...getSpacingByKey(height, 'height'),
47
+ ...getSpacingByKey(width || height, 'width')
47
48
  }
48
49
  },
49
50
 
50
- maxWidth: ({ props }) => props.maxWidth && mapBasedOnRatio(props, 'maxWidth'),
51
- minWidth: ({ props }) => props.minWidth && mapBasedOnRatio(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
- ...mapSpacing(minWidth, 'minWidth'),
57
- ...mapSpacing(maxWidth, 'maxWidth')
57
+ ...getSpacingByKey(minWidth, 'minWidth'),
58
+ ...getSpacingByKey(maxWidth, 'maxWidth')
58
59
  }
59
60
  },
60
61
 
61
- maxHeight: ({ props }) => props.maxHeight && mapBasedOnRatio(props, 'maxHeight'),
62
- minHeight: ({ props }) => props.minHeight && mapBasedOnRatio(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
- ...mapSpacing(minHeight, 'minHeight'),
68
- ...mapSpacing(maxHeight || minHeight, 'maxHeight')
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 ? mapBasedOnRatio(props, 'borderWidth') : null,
75
+ borderWidth: ({ props }) => props.borderWidth ? getSpacingBasedOnRatio(props, 'borderWidth') : null,
75
76
 
76
- padding: ({ props }) => props.padding ? mapBasedOnRatio(props, 'padding') : null,
77
- margin: ({ props }) => props.margin ? mapBasedOnRatio(props, 'margin') : null,
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 ? mapBasedOnRatio(props, 'gap') : null,
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
- ...mapSpacing(minHeight, 'minHeight'),
115
- ...mapSpacing(maxHeight || minHeight, 'maxHeight')
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 { mapBasedOnRatio } from './Block'
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 ? mapBasedOnRatio(props, 'columnGap') : null,
15
- rowGap: ({ props }) => props.rowGap ? mapBasedOnRatio(props, 'rowGap') : null
14
+ columnGap: ({ props }) => props.columnGap ? getSpacingBasedOnRatio(props, 'columnGap') : null,
15
+ rowGap: ({ props }) => props.rowGap ? getSpacingBasedOnRatio(props, 'rowGap') : null
16
16
  }
17
17
  }
@@ -22,11 +22,9 @@ export const Notification = {
22
22
  alignItems: 'flex-start'
23
23
  },
24
24
  caption: {
25
- extend: Text,
26
25
  text: 'Notification'
27
26
  },
28
27
  p: {
29
- extend: Text,
30
28
  props: {
31
29
  fontSize: 'Z',
32
30
  text: 'is not always a distraction'
package/src/Position.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { mapSpacing } from '@symbo.ls/scratch'
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 => mapSpacing(v,'k').k).join(' ') }
13
+ return { inset: inset.split(' ').map(v => getSpacingByKey(v,'k').k).join(' ') }
14
14
  },
15
15
 
16
- left: ({ props }) => mapSpacing(props.left, 'left'),
17
- top: ({ props }) => mapSpacing(props.top, 'top'),
18
- right: ({ props }) => mapSpacing(props.right, 'right'),
19
- bottom: ({ props }) => mapSpacing(props.bottom, 'bottom')
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 { mapFontSize, getFontFamily, FONT_FAMILY } from '@symbo.ls/scratch'
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 ? mapFontSize(props.fontSize) : null,
12
- fontFamily: ({ props }) => props.fontFamily && ({ fontFamily: getFontFamily(FONT_FAMILY, props.fontFamily) || props.fontFamily }),
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 && mapBasedOnRatio(props, 'lineHeight', null, ''),
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 { mapSpacing, getTheme, getColor } from '@symbo.ls/scratch'
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 => mapSpacing(v, 'shadow').shadow).join(' ')
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 ? (mapSpacing(props.round, 'borderRadius') || ({ borderRadius: props.round })) : null,
44
- borderRadius: ({ props, key, ...el }) => props.borderRadius ? (mapSpacing(props.borderRadius, 'borderRadius') || ({ borderRadius: props.borderRadius })) : null,
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 { mapTiming } from '@symbo.ls/scratch'
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 = mapTiming(v)
12
+ const mapWithSequence = getTimingByKey(v)
13
13
  return mapWithSequence.duration
14
14
  }
15
15
  return v