smbls 0.8.8 → 0.8.11

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.8.8",
6
+ "version": "0.8.11",
7
7
  "repository": "https://github.com/rackai/symbols",
8
8
  "main": "src/index.js",
9
9
  "files": [
@@ -2,9 +2,10 @@
2
2
 
3
3
  import { SPACING, mapSpacing } from '@symbo.ls/scratch'
4
4
 
5
- export const mapBasedOnRatio = (props, prop) => {
5
+ export const mapBasedOnRatio = (props, prop, unit) => {
6
6
  const { spacingRatio } = props
7
7
  const val = props[prop]
8
+ // TODO: move this to mapSpacing
8
9
  if (spacingRatio) {
9
10
  const params = SPACING[spacingRatio]
10
11
 
@@ -20,18 +21,18 @@ export const mapBasedOnRatio = (props, prop) => {
20
21
  }
21
22
  }
22
23
 
23
- const result = mapSpacing(val, prop, params)
24
-
25
- return result
24
+ return mapSpacing(val, prop, params, unit)
26
25
  }
27
- return mapSpacing(val, prop)
26
+ return mapSpacing(val, prop, null, unit)
28
27
  }
29
28
 
30
29
  export const Block = {
31
30
  props: {},
32
31
 
33
32
  class: {
34
- display: ({ props }) => ({ display: props.display }),
33
+ display: ({ props }) => props.display && ({ display: props.display }),
34
+
35
+ hide: ({ props }) => props.hide && ({ display: 'none' }),
35
36
 
36
37
  width: ({ props }) => props.width && mapBasedOnRatio(props, 'width'),
37
38
  height: ({ props }) => props.height && mapBasedOnRatio(props, 'height'),
@@ -66,7 +67,7 @@ export const Block = {
66
67
  }
67
68
  },
68
69
 
69
- aspectRatio: ({ props }) => ({ aspectRatio: props.aspectRatio }),
70
+ aspectRatio: ({ props }) => props.aspectRatio && ({ aspectRatio: props.aspectRatio }),
70
71
 
71
72
  padding: ({ props }) => mapBasedOnRatio(props, 'padding'),
72
73
  margin: ({ props }) => mapBasedOnRatio(props, 'margin'),
@@ -87,6 +88,9 @@ export const Block = {
87
88
  },
88
89
  flex: ({ props }) => props.flex && ({ flex: props.flex }),
89
90
 
91
+ gridColumn: ({ props }) => props.gridColumn && ({ gridColumn: props.gridColumn }),
92
+ gridRow: ({ props }) => props.gridRow && ({ gridRow: props.gridRow }),
93
+
90
94
  size: ({ props }) => {
91
95
  // if (typeof props.size !== 'string') return
92
96
  // const [fontSize, padding, margin] = props.size.split(' ')
package/src/Box/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import { Shape, Position, Block, Text, Overflow, Transition, Responsive } from '..'
3
+ import { Shape, Position, Block, Text, Overflow, Transition, Transform, Responsive } from '..'
4
4
 
5
5
  export const Box = {
6
- proto: [Shape, Position, Block, Text, Overflow, Transition, Responsive],
6
+ proto: [Shape, Position, Block, Text, Overflow, Transition, Transform, Responsive],
7
7
  class: {
8
8
  fromProps: ({ props }) => props && props.css
9
9
  }
package/src/Flex/index.js CHANGED
@@ -11,11 +11,11 @@ export const Flex = {
11
11
  },
12
12
 
13
13
  class: {
14
- flow: ({ props }) => ({ flexFlow: props.flow }),
15
- flexDirection: ({ props }) => ({ flexDirection: props.flexDirection }),
16
- alignItems: ({ props }) => ({ alignItems: props.alignItems }),
17
- alignContent: ({ props }) => ({ alignContent: props.alignContent }),
18
- justifyContent: ({ props }) => ({ justifyContent: props.justifyContent }),
19
- gap: ({ props }) => mapBasedOnRatio(props, 'gap')
14
+ flow: ({ props }) => props.flow && ({ flexFlow: props.flow }),
15
+ flexDirection: ({ props }) => props.flexDirection && ({ flexDirection: props.flexDirection }),
16
+ alignItems: ({ props }) => props.alignItems && ({ alignItems: props.alignItems }),
17
+ alignContent: ({ props }) => props.alignContent && ({ alignContent: props.alignContent }),
18
+ justifyContent: ({ props }) => props.justifyContent && ({ justifyContent: props.justifyContent }),
19
+ gap: ({ props }) => props.gap && mapBasedOnRatio(props, 'gap')
20
20
  }
21
21
  }
@@ -2,6 +2,6 @@
2
2
 
3
3
  export const Overflow = {
4
4
  class: {
5
- overflow: ({ props }) => ({ overflow: props.overflow }),
5
+ overflow: ({ props }) => props.overflow && ({ overflow: props.overflow }),
6
6
  }
7
7
  }
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ import { isArray, isObject } from '@domql/utils'
3
4
  import { mapSpacing, getTheme, getColor } from '@symbo.ls/scratch'
4
5
 
5
6
  import style, { shape, depth } from './style'
@@ -9,7 +10,7 @@ const isBorderStyle = str =>
9
10
 
10
11
  const diffBorder = (border, key = 'border') => {
11
12
  const obj = {}
12
- const arr = border.split(' ')
13
+ const arr = isObject(border) ? Object.values(border) : isArray(border) ? border : border.split(', ')
13
14
  arr.map(v => {
14
15
  if (v.includes('px')) obj[`${key}Width`] = v
15
16
  else if (isBorderStyle(v)) obj[`${key}Style`] = v || 'solid'
package/src/Text/index.js CHANGED
@@ -10,10 +10,11 @@ export const Text = {
10
10
  class: {
11
11
  fontSize: ({ props }) => props.fontSize ? mapFontSize(props.fontSize) : null,
12
12
  fontFamily: ({ props }) => props.fontFamily && ({ fontFamily: getFontFamily(FONT_FAMILY, props.fontFamily) || props.fontFamily }),
13
- lineHeight: ({ props }) => ({ lineHeight: props.lineHeight }),
14
- textDecoration: ({ props }) => ({ textDecoration: props.textDecoration }),
15
- textTransform: ({ props }) => ({ textTransform: props.textTransform }),
16
- textAlign: ({ props }) => ({ textAlign: props.textAlign }),
17
- fontWeight: ({ props }) => ({ fontWeight: props.fontWeight })
13
+ lineHeight: ({ props }) => props.lineHeight && ({ lineHeight: props.lineHeight }),
14
+ // lineHeight: ({ props }) => props.lineHeight && mapBasedOnRatio(props, 'lineHeight', null, ''),
15
+ textDecoration: ({ props }) => props.textDecoration && ({ textDecoration: props.textDecoration }),
16
+ textTransform: ({ props }) => props.textTransform && ({ textTransform: props.textTransform }),
17
+ textAlign: ({ props }) => props.textAlign && ({ textAlign: props.textAlign }),
18
+ fontWeight: ({ props }) => props.fontWeight && ({ fontWeight: props.fontWeight })
18
19
  }
19
20
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  export const Transform = {
4
4
  class: {
5
- transform: ({ props }) => ({
5
+ transform: ({ props }) => props.transform && ({
6
6
  transform: props.transform
7
7
  }),
8
8
  }
@@ -2,7 +2,10 @@
2
2
 
3
3
  export const Transition = {
4
4
  class: {
5
- transition: ({ props }) => ({ transition: props.transition }),
6
- transitionProperty: ({ props }) => ({ transitionProperty: props.transitionProperty })
5
+ transition: ({ props }) => props.transition && ({ transition: props.transition }),
6
+ transitionProperty: ({ props }) => props.transitionProperty && ({
7
+ transitionProperty: props.transitionProperty,
8
+ willChange: props.transitionProperty
9
+ })
7
10
  }
8
11
  }