smbls 0.8.27 → 0.8.30

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.27",
6
+ "version": "0.8.30",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
@@ -38,10 +38,10 @@ export const Block = {
38
38
  height: ({ props }) => props.height && mapBasedOnRatio(props, 'height'),
39
39
  boxSize: ({ props }) => {
40
40
  if (typeof props.boxSize !== 'string') return
41
- const [width, height] = props.boxSize.split(' ')
41
+ const [height, width] = props.boxSize.split(' ')
42
42
  return {
43
- ...mapSpacing(width, 'width'),
44
- ...mapSpacing(height, 'height')
43
+ ...mapSpacing(height, 'height'),
44
+ ...mapSpacing(width, 'width')
45
45
  }
46
46
  },
47
47
 
@@ -1,9 +1,11 @@
1
1
  'use strict'
2
2
 
3
- import { Shape, Position, Block, Text, Overflow, Transition, Transform, Responsive } from '..'
3
+ import { Shape, Position, Block, Text, Overflow, Transition, Transform, Responsive } from '.'
4
4
 
5
5
  const PropsCSS = {
6
- class: { propsCSS: ({ props }) => props && props.css }
6
+ class: {
7
+ propsCSS: ({ props }) => props && props.css
8
+ }
7
9
  }
8
10
 
9
11
  export const Box = {
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { IconText } from '../'
3
+ import { IconText } from '.'
4
4
 
5
5
  const css = {
6
6
  appearance: 'none',
@@ -0,0 +1,10 @@
1
+ 'use strict'
2
+
3
+ import { SquareButton } from './Button'
4
+ import { Flex } from './Flex'
5
+
6
+ export const ButtonSet = {
7
+ tag: 'nav',
8
+ proto: Flex,
9
+ childProto: SquareButton
10
+ }
@@ -3,13 +3,10 @@
3
3
  import style from './style'
4
4
 
5
5
  import Icon from '../Icon'
6
- import Shape from '../Shape'
7
- import { Block } from '../Block'
8
6
 
9
7
  export const DatePicker = {
10
8
  style,
11
9
 
12
- proto: [Shape, Block],
13
10
  props: {
14
11
  theme: 'lightDark',
15
12
  padding: 'A',
File without changes
@@ -1,12 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import style from './style'
4
- import { mapBasedOnRatio } from '../Block'
3
+ import { mapBasedOnRatio } from './Block'
5
4
 
6
5
  export const Flex = {
7
- style,
8
-
9
6
  props: {
7
+ display: 'flex',
10
8
  flow: 'row'
11
9
  },
12
10
 
@@ -1,12 +1,9 @@
1
1
  'use strict'
2
2
 
3
- import style from './style'
4
- import { mapBasedOnRatio } from '../Block'
3
+ import { mapBasedOnRatio } from './Block'
5
4
 
6
5
  export const Grid = {
7
- style,
8
-
9
- props: {},
6
+ props: { display: 'grid' },
10
7
 
11
8
  class: {
12
9
  columns: ({ props }) => props.columns ? ({ gridTemplateColumns: props.columns }) : null,
File without changes
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
- import { Block } from '../Block'
3
- import { Shape } from '../Shape'
4
- import { Text } from '../Text'
2
+ import { Block } from './Block'
3
+ import { Shape } from './Shape'
4
+ import { Text } from './Text'
5
5
 
6
6
  export const Label = {
7
7
  proto: [Shape, Block, Text],
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { exec } from '@domql/utils'
4
- import { Shape, Text } from '..'
4
+ import { Shape, Text } from '.'
5
5
 
6
6
  export const Link = {
7
7
  proto: [Shape, Text],
package/src/Media.js ADDED
@@ -0,0 +1,96 @@
1
+ 'use strict'
2
+
3
+ import { merge, isArray } from '@domql/utils'
4
+ import { CASES as CONFIG_CASES, MEDIA as CONFIG_MEDIA, getTheme } from '@symbo.ls/scratch'
5
+
6
+ const convertToClass = (subProps, element) => {
7
+ const { class: className } = element
8
+ const subPropsClassname = {}
9
+ for (const prop in subProps) {
10
+ const classnameExec = className[prop]
11
+ if (typeof classnameExec !== 'function') continue
12
+
13
+ let contertedToClass = classnameExec({ props: subProps })
14
+ if (isArray(contertedToClass)) {
15
+ contertedToClass = contertedToClass.reduce((a, c) => merge(a, c), {})
16
+ }
17
+
18
+ for (const finalProp in contertedToClass) subPropsClassname[finalProp] = contertedToClass[finalProp]
19
+ }
20
+ return subPropsClassname
21
+ }
22
+
23
+ const init = (el, s) => {
24
+ const { props, class: className } = el
25
+
26
+ for (const screen in props) {
27
+ if (screen.slice(0, 1) === '@') {
28
+ const mediaName = CONFIG_MEDIA[screen.slice(1)]
29
+ const mediaKey = `@media screen and ${mediaName}`
30
+ const screenProps = props[screen]
31
+
32
+ const { MEDIA } = className
33
+ if (!MEDIA) className.MEDIA = {}
34
+ className.MEDIA[mediaKey] = convertToClass(screenProps, el)
35
+ } else if (screen.slice(0, 1) === ':') {
36
+ const selectorProps = props[screen]
37
+ const selectorKey = `&${screen}`
38
+
39
+ const { SELECTORS } = className
40
+ if (!SELECTORS) className.SELECTORS = {}
41
+ className.SELECTORS[selectorKey] = convertToClass(selectorProps, el)
42
+ } else if (screen.slice(0, 1) === '$') {
43
+ const caseKey = screen.slice(1)
44
+ if (!CONFIG_CASES[caseKey]) continue
45
+ const caseProps = props[screen]
46
+ const { CASE } = className
47
+ if (!CASE) className.CASE = {}
48
+ merge(className.CASE, convertToClass(caseProps, el))
49
+ }
50
+ }
51
+ }
52
+
53
+ export const Responsive = {
54
+ on: {
55
+ init,
56
+ initUpdate: el => {
57
+ // FORCE STATE UPDATE:
58
+ const { props, class: className } = el
59
+ const rootState = el.__root ? el.__root.state : el.state
60
+ // console.log(props)
61
+ if (el.key !== 'app') return
62
+
63
+ if (props.theme) {
64
+ const { theme } = props
65
+ // console.group(props.theme)
66
+
67
+ const convertTheme = getTheme(theme)
68
+
69
+ for (const key in convertTheme) {
70
+ if (key.includes('dark') || key.includes('light')) {
71
+ const parse = key.split(': ')[1].split(')')[0]
72
+ if (rootState.globalTheme === parse) {
73
+ props.theme = getTheme(theme[key])
74
+ } else props.theme = theme
75
+ className.MEDIA_FORCED_BY_STATE = props.theme
76
+ }
77
+ }
78
+ // console.groupEnd(props.theme)
79
+ }
80
+
81
+ for (const screen in props) {
82
+ if (screen.slice(0, 1) === '@') {
83
+ const mediaName = screen.slice(1)
84
+ const mediaKey = `@media screen and ${CONFIG_MEDIA[mediaName]}`
85
+ if (mediaName === 'dark' || mediaName === 'light') {
86
+ const { MEDIA_FORCE } = className
87
+ if (!MEDIA_FORCE) className.media = {}
88
+ if (rootState.globalTheme === mediaName) {
89
+ className.MEDIA_FORCED = className.MEDIA[mediaKey]
90
+ } else className.MEDIA_FORCED = {}
91
+ }
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { Shape, Block, IconText, Direction, Flex, Text } from '../'
3
+ import { Shape, Block, IconText, Direction, Flex, Text } from '.'
4
4
 
5
5
  export const Notification = {
6
6
  style: { cursor: 'pointer' },
@@ -2,6 +2,6 @@
2
2
 
3
3
  export const Overflow = {
4
4
  class: {
5
- overflow: ({ props }) => props.overflow && ({ overflow: props.overflow }),
5
+ overflow: ({ props }) => props.overflow && ({ overflow: props.overflow })
6
6
  }
7
7
  }
@@ -1,5 +1,4 @@
1
1
  'use strict'
2
- import Shape from '../Shape'
3
2
 
4
3
  export const Pills = {
5
4
  style: {
@@ -18,13 +17,10 @@ export const Pills = {
18
17
  },
19
18
  childProto: {
20
19
  tag: 'div',
21
- proto: Shape,
22
20
  props: {
23
21
  round: 42,
24
22
  theme: 'White'
25
23
  }
26
24
  },
27
- ...[
28
- {}, {}, {}
29
- ]
25
+ ...[{}, {}, {}]
30
26
  }
File without changes
File without changes
@@ -45,10 +45,14 @@ export const Shape = {
45
45
  depth: ({ props }) => depth[props.depth],
46
46
  round: ({ props, key, ...el }) => props.round ? (mapSpacing(props.round, 'borderRadius') || ({ borderRadius: props.round })) : null,
47
47
  borderRadius: ({ props, key, ...el }) => props.borderRadius ? (mapSpacing(props.borderRadius, 'borderRadius') || ({ borderRadius: props.borderRadius })) : null,
48
- theme: ({ props }) => props.theme ? getTheme(props.theme) : null,
48
+
49
+ theme: ({ props }) => {
50
+ if (!props.theme) return
51
+ return getTheme(props.theme)
52
+ },
53
+
49
54
  color: ({ props }) => props.color ? ({ color: getColor(props.color) }) : null,
50
55
  background: ({ props }) => props.background ? ({ backgroundColor: getColor(props.background) }) : null,
51
- // border: ({ props }) => props.border ? ({ borderColor: getColor(props.border) }) : null,
52
56
 
53
57
  textStroke: ({ props }) => props.textStroke ? diffStroke(props.textStroke) : null,
54
58
 
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { UNIT, getColor } from '@symbo.ls/scratch'
3
+ import { UNIT, getColor, getTheme } from '@symbo.ls/scratch'
4
4
 
5
5
  export default {
6
6
  boxSizing: 'border-box'
@@ -27,7 +27,7 @@ export const SHAPES = {
27
27
  display: 'block',
28
28
  width: '0px',
29
29
  height: '0px',
30
- border: `6px solid ${getColor(props.background)}`,
30
+ border: `6px solid ${getColor(props.background) || (props.theme && getTheme(props.theme).backgroundColor)}`,
31
31
  position: 'absolute',
32
32
  borderRadius: '2px'
33
33
  }
@@ -71,10 +71,10 @@ export const SHAPES = {
71
71
  display: 'block',
72
72
  width: '0',
73
73
  height: '0',
74
- border: `16px solid ${getColor(props.background)}`,
74
+ border: `16px solid ${getColor(props.background) || (props.theme && getTheme(props.theme).backgroundColor)}`,
75
75
  borderRadius: '6px',
76
76
  position: 'absolute'
77
- },
77
+ }
78
78
  }),
79
79
 
80
80
  tagDirection: {
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
- import { Icon, Link } from '../'
2
+
3
+ import { Icon, Link } from '.'
3
4
 
4
5
  const MenuItem = {
5
6
  proto: Link,
File without changes
@@ -4,6 +4,6 @@ export const Transform = {
4
4
  class: {
5
5
  transform: ({ props }) => props.transform && ({
6
6
  transform: props.transform
7
- }),
7
+ })
8
8
  }
9
9
  }
File without changes
@@ -1 +0,0 @@
1
- 'use strict'
@@ -1,4 +0,0 @@
1
- 'use strict'
2
-
3
- export default {
4
- }
@@ -1,14 +0,0 @@
1
- 'use strict'
2
-
3
- import { SquareButton } from '../Button'
4
- import { Shape } from '../Shape'
5
- import { Flex } from '../Flex'
6
- import { Block } from '../Block'
7
-
8
- export const ButtonSet = {
9
- tag: 'nav',
10
- proto: [Shape, Flex, Block],
11
- childProto: {
12
- proto: [SquareButton]
13
- }
14
- }
package/src/Flex/style.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- export default {
4
- display: 'flex'
5
- }
package/src/Grid/style.js DELETED
@@ -1,5 +0,0 @@
1
- 'use strict'
2
-
3
- export default {
4
- display: 'grid'
5
- }
@@ -1,71 +0,0 @@
1
- 'use strict'
2
-
3
- import { MEDIA as BREAKPOINTS } from '@symbo.ls/scratch'
4
-
5
- export const Responsive = {
6
- on: {
7
- init: (el, s) => {
8
- const { props } = el
9
-
10
- for (const screen in props) {
11
- if (screen.slice(0, 1) === '@') {
12
- const mediaName = screen.slice(1)
13
- const responsiveKey = `@media screen and ${BREAKPOINTS[mediaName]}`
14
- const screenProps = props[screen]
15
- const calculatedScreenProps = {}
16
-
17
- for (const prop in screenProps) {
18
- // if (!el.class || !el.class[prop]) return
19
- // const classProp = el.class[prop]
20
- const classProp = el.class[prop]
21
- if (typeof classProp !== 'function') continue
22
- let calculatedProp = classProp({ props: screenProps })
23
-
24
- if (Array.isArray(calculatedProp)) {
25
- calculatedProp = Object.assign({}, ...calculatedProp)
26
- }
27
-
28
- for (const finalProp in calculatedProp) {
29
- calculatedScreenProps[finalProp] = calculatedProp[finalProp]
30
- }
31
- }
32
-
33
- const { MEDIA } = el.class
34
- if (MEDIA) MEDIA[responsiveKey] = calculatedScreenProps
35
- else {
36
- el.class.MEDIA = {
37
- [responsiveKey]: calculatedScreenProps
38
- }
39
- }
40
- } else if (screen.slice(0, 1) === ':') {
41
- const selectorProps = {}
42
- // const selectorName = screen.slice(1)
43
- const underSelectorProps = props[screen]
44
- const selectorKey = `&${screen}`
45
-
46
- for (const prop in underSelectorProps) {
47
- const classProp = el.class[prop]
48
- if (typeof classProp !== 'function') continue
49
- let calculatedProp = classProp({ props: underSelectorProps })
50
-
51
- if (Array.isArray(calculatedProp)) {
52
- calculatedProp = Object.assign({}, ...calculatedProp)
53
- }
54
-
55
- for (const finalProp in calculatedProp) {
56
- selectorProps[finalProp] = calculatedProp[finalProp]
57
- }
58
- }
59
-
60
- const { SELECTORS } = el.class
61
- if (SELECTORS) SELECTORS[selectorKey] = selectorProps
62
- else {
63
- el.class.SELECTORS = {
64
- [selectorKey]: selectorProps
65
- }
66
- }
67
- }
68
- }
69
- }
70
- }
71
- }
package/src/Text/style.js DELETED
@@ -1,2 +0,0 @@
1
- 'use strict'
2
-
@@ -1,2 +0,0 @@
1
- 'use strict'
2
-