smbls 0.13.2 → 0.13.3

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.13.2",
6
+ "version": "0.13.3",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
@@ -26,9 +26,12 @@
26
26
  "@symbo.ls/scratch": "latest"
27
27
  },
28
28
  "devDependencies": {
29
- "@babel/core": "^7.18.10",
30
- "@babel/preset-env": "^7.18.10",
31
- "babel-eslint": "^10.1.0",
29
+ "@babel/core": "^7.11.5",
30
+ "@emotion/css": "^11.5.0",
31
+ "babel-eslint": "^10.0.3",
32
+ "eslint": "^6.1.0",
33
+ "parcel-bundler": "^1.12.4",
34
+ "parcel-plugin-svg-sprite": "^1.4.1",
32
35
  "standard": "^13.1.0"
33
36
  },
34
37
  "standard": {
package/src/Block.js CHANGED
@@ -2,17 +2,20 @@
2
2
 
3
3
  import { SPACING, getSpacingByKey } from '@symbo.ls/scratch'
4
4
 
5
- export const getSpacingBasedOnRatio = (props, prop, unit) => {
5
+ export const getSpacingBasedOnRatio = (props, propertyName, unit) => {
6
6
  const { spacingRatio } = props
7
- const val = props[prop]
7
+
8
+ // if (spacingRatio) console.log(propertyName, props)
9
+
10
+ const val = props[propertyName]
8
11
  // TODO: move this to getSpacingByKey
9
12
  if (spacingRatio) {
10
13
  let params = SPACING[spacingRatio]
11
14
 
12
15
  if (!params) {
13
16
  params = SPACING[spacingRatio] = {
14
- base: SPACING.base,
15
- type: SPACING.type,
17
+ base: props.base || SPACING.base,
18
+ type: SPACING.type + '-' + spacingRatio,
16
19
  ratio: spacingRatio,
17
20
  range: SPACING.range,
18
21
  subSequence: SPACING.subSequence,
@@ -22,9 +25,9 @@ export const getSpacingBasedOnRatio = (props, prop, unit) => {
22
25
  }
23
26
  }
24
27
 
25
- return getSpacingByKey(val, prop, params, unit)
28
+ return getSpacingByKey(val, propertyName, params, unit, false)
26
29
  }
27
- return getSpacingByKey(val, prop, null, unit)
30
+ return getSpacingByKey(val, propertyName, null, unit)
28
31
  }
29
32
 
30
33
  export const Block = {
package/src/Icon.js CHANGED
@@ -4,16 +4,20 @@ import { SVG } from '.'
4
4
 
5
5
  import { ICONS } from '@symbo.ls/scratch'
6
6
 
7
+ function camelize (str) {
8
+ return str.replace(/(?:^\w|[A-Z]|\b\w)/g, function (word, index) {
9
+ return index === 0 ? word.toLowerCase() : word.toUpperCase()
10
+ }).replace(/\s+/g, '')
11
+ }
12
+
7
13
  export const Icon = {
8
14
  extend: SVG,
9
15
  props: ({ key, props, parent }) => {
10
- let iconName = props.inheritedString || props.name || props.icon || key
11
-
12
- const isArray = iconName.split(' ')
13
- const secondArg = props.iconModifier || isArray[1]
16
+ const iconName = props.inheritedString || props.name || props.icon || key
17
+ const camelCase = camelize(iconName)
18
+ const isArray = camelCase.replace(/([a-z])([A-Z])/g, '$1 $2')
14
19
 
15
- if (secondArg) iconName = isArray[0] + secondArg.slice(0, 1).toUpperCase() + secondArg.slice(1)
16
- const iconFromLibrary = ICONS[iconName] || ICONS[isArray[0]] || ICONS['noIcon']
20
+ const iconFromLibrary = ICONS[camelCase] || ICONS[isArray[0] + isArray[1]] || ICONS[isArray[0]] || ICONS['noIcon']
17
21
 
18
22
  return {
19
23
  width: 'A',
@@ -1,35 +1,43 @@
1
1
  'use strict'
2
2
 
3
- import { Shape, Block, IconText, Direction, Flex, Text } from '.'
3
+ import { IconText, Flex } from '.'
4
4
 
5
5
  export const Notification = {
6
- style: { cursor: 'pointer' },
7
- extend: [Shape, Block, Direction, Flex],
6
+ extend: Flex,
7
+
8
+ props: {
9
+ padding: 'Z1 B Z1 A1',
10
+ round: 'A',
11
+ gap: 'X2',
12
+ style: { cursor: 'pointer' },
13
+
14
+ article: {
15
+ gap: 'X2',
16
+ title: {
17
+ fontWeight: '600',
18
+ lineHeight: '1em'
19
+ },
20
+ p: {
21
+ fontSize: 'Z',
22
+ margin: '0'
23
+ }
24
+ }
25
+ },
26
+
8
27
  icon: {
9
28
  extend: [IconText],
10
29
  props: {
11
- icon: 'info'
12
- },
13
- style: {
14
- width: 'fit-content',
15
- height: 'fit-content'
30
+ icon: 'info outline'
16
31
  }
17
32
  },
33
+
18
34
  article: {
19
- extend: [Flex],
20
- style: {
21
- flexDirection: 'column',
22
- alignItems: 'flex-start'
23
- },
24
- caption: {
25
- text: 'Notification'
35
+ extend: Flex,
36
+ props: {
37
+ flow: 'column',
38
+ align: 'flex-start'
26
39
  },
27
- p: {
28
- props: {
29
- fontSize: 'Z',
30
- text: 'is not always a distraction'
31
- },
32
- style: { margin: 0 }
33
- }
40
+ title: { text: 'Notification' },
41
+ p: { text: 'is not always a distraction' }
34
42
  }
35
43
  }
@@ -1,7 +1,15 @@
1
1
  'use strict'
2
2
 
3
- import { exec } from '@domql/utils'
3
+ import { exec, isString } from '@domql/utils'
4
4
  import { SHAPES } from './style'
5
+ import { getSpacingByKey } from '@symbo.ls/scratch'
6
+
7
+ const transformBorderRadius = (radius, props) => {
8
+ if (!isString(radius)) return
9
+ return {
10
+ borderRadius: radius.split(' ').map((v, k) => getSpacingByKey(v, 'radius').radius).join(' ')
11
+ }
12
+ }
5
13
 
6
14
  export const Shape = {
7
15
  class: {
@@ -16,7 +24,10 @@ export const Shape = {
16
24
  const shapeDir = SHAPES[shape + 'Direction']
17
25
  return shape ? shapeDir[shapeDirection || 'top'] : null
18
26
  },
19
- shapeDirectionColor: ({ props, ...el }) => props.shapeDirection ? { '&:before': { borderColor: el.class.backgroundColor } } : null
27
+ shapeDirectionColor: ({ props, ...el }) => props.shapeDirection ? { '&:before': { borderColor: el.class.backgroundColor } } : null,
28
+
29
+ round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props),
30
+ borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props)
20
31
  }
21
32
  }
22
33
 
package/src/Theme.js CHANGED
@@ -12,7 +12,7 @@ const transformBorder = (border, key = 'border') => {
12
12
  const obj = {}
13
13
  const arr = isObject(border) ? Object.values(border) : isArray(border) ? border : border.split(', ')
14
14
  arr.map(v => {
15
- if (v.includes('px')) obj[`${key}Width`] = v // TODO: add map spacing
15
+ if (v.slice(-2) === 'px' || v.slice(-2) === 'em') obj[`${key}Width`] = v // TODO: add map spacing
16
16
  else if (isBorderStyle(v)) obj[`${key}Style`] = v || 'solid'
17
17
  else if (getColor(v)) obj[`${key}Color`] = getColor(v)
18
18
  })
@@ -40,8 +40,6 @@ const transformShadow = shadow => ({
40
40
  export const Theme = {
41
41
  class: {
42
42
  depth: ({ props }) => depth[props.depth],
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
43
 
46
44
  theme: ({ props, key }) => {
47
45
  if (!props.theme) return
package/src/Transition.js CHANGED
@@ -27,6 +27,8 @@ const splitTransition = transition => {
27
27
  export const Transition = {
28
28
  class: {
29
29
  transition: ({ props }) => props.transition && splitTransition(props.transition),
30
+ transitionEasing: ({ props }) => props.transitionEasing && ({ transitionEasing: props.transitionEasing }),
31
+ transitionTimingFunction: ({ props }) => props.transitionTimingFunction && ({ transitionTimingFunction: props.transitionTimingFunction }),
30
32
  transitionProperty: ({ props }) => props.transitionProperty && ({
31
33
  transitionProperty: props.transitionProperty,
32
34
  willChange: props.transitionProperty
package/src/User.js ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict'
2
+
3
+ import { Img, Flex } from '.'
4
+
5
+ export const User = {
6
+ extend: Img,
7
+ props: {
8
+ borderRadius: '100%',
9
+ boxSize: 'B',
10
+ src: 'https://p194.p3.n0.cdn.getcloudapp.com/items/yAubz2KN/IMG_2375.jpg?v=c59a92ea47a959e386e952c3d84c08e5',
11
+ style: {
12
+ cursor: 'pointer'
13
+ }
14
+ }
15
+ }
16
+
17
+ export const UserBundle = {
18
+ extend: Flex,
19
+ childExtend: {
20
+ extend: User,
21
+ props: {
22
+ boxSize: 'B1',
23
+ border: '0.1312em, black .85, solid',
24
+ ':not(:last-child)': {
25
+ margin: '0 -Y2 0 0'
26
+ }
27
+ }
28
+ }
29
+ }
package/src/User/index.js DELETED
@@ -1,25 +0,0 @@
1
- 'use strict'
2
-
3
- import { Shape, Block } from '..'
4
- import { styleUser, styleUserBundle } from './style'
5
-
6
- export const User = {
7
- extend: [Shape, Block],
8
- props: { boxSize: 'B B' },
9
- style: styleUser,
10
- tag: 'img',
11
- attr: {
12
- src: 'https://p194.p3.n0.cdn.getcloudapp.com/items/yAubz2KN/IMG_2375.jpg?v=c59a92ea47a959e386e952c3d84c08e5'
13
- }
14
- }
15
-
16
- export const UserBundle = {
17
- style: styleUserBundle,
18
- users: {
19
- childExtend: User,
20
- ...[{}]
21
- },
22
- span: 'join classroom'
23
- }
24
-
25
- export default User
package/src/User/style.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict'
2
-
3
- export const styleUser = {
4
- cursor: 'pointer',
5
- borderRadius: '100%'
6
- }
7
-
8
- export const styleUserBundle = {
9
- display: 'flex',
10
- alignItems: 'center',
11
- textTransform: 'capitalize',
12
- '> div': {
13
- display: 'flex',
14
- marginRight: '1em',
15
- '> img': {
16
- marginRight: '-0.5em'
17
- }
18
- }
19
- }