smbls 0.15.19 → 0.15.21

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.15.19",
6
+ "version": "0.15.21",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
package/src/Icon.js CHANGED
@@ -1,13 +1,12 @@
1
1
  'use strict'
2
2
 
3
3
  import { SVG } from './atoms'
4
-
5
- import { ICONS } from '@symbo.ls/scratch'
6
4
  import { toCamelCase } from '@symbo.ls/utils'
7
5
 
8
6
  export const Icon = {
9
7
  extend: SVG,
10
- props: ({ key, props, parent }) => {
8
+ props: ({ key, props, parent, context }) => {
9
+ const { ICONS } = context && context.SYSTEM
11
10
  const iconName = props.inheritedString || props.name || props.icon || key
12
11
  const camelCase = toCamelCase(iconName)
13
12
  const isArray = camelCase.split(/([a-z])([A-Z])/g)
@@ -0,0 +1,52 @@
1
+ 'use strict'
2
+
3
+ import { merge } from '@domql/utils'
4
+ import { getTimingFunction } from '@symbo.ls/scratch'
5
+ import { convertPropsToClass } from './Media'
6
+ import { transformDuration } from './Timing'
7
+
8
+ const applyAnimationProps = (key, props, result, element) => {
9
+ const { ANIMATION } = element.context && element.context.SYSTEM
10
+ const mediaName = ANIMATION[key.slice(1)]
11
+ const generatedClass = convertPropsToClass(props, result, element)
12
+
13
+ const rootState = element.__root ? element.__root.state : element.state
14
+ const { globalTheme } = rootState
15
+ const name = key.slice(1)
16
+ const isTheme = ['dark', 'light'].includes(name)
17
+ const matchesGlobal = name === globalTheme
18
+
19
+ if (globalTheme && isTheme) {
20
+ if (matchesGlobal) return merge(result, generatedClass)
21
+ return
22
+ }
23
+
24
+ const mediaKey = `@media screen and ${mediaName}`
25
+ result[mediaKey] = generatedClass
26
+ return result[mediaKey]
27
+ }
28
+
29
+ export const Animation = {
30
+ class: {
31
+ animation: ({ props }) => props.animation && ({
32
+ animation: applyAnimationProps(props.animation)
33
+ }),
34
+
35
+ animationDuration: ({ props }) => props.animationDuration && ({
36
+ animationDuration: transformDuration(props.animationDuration)
37
+ }),
38
+ animationDelay: ({ props }) => props.animationDelay && ({
39
+ animationDelay: transformDuration(props.animationDelay)
40
+ }),
41
+ animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
42
+ animationTimingFunction: getTimingFunction(props.animationTimingFunction)
43
+ }),
44
+ animationFillMode: ({ props }) => props.animationFillMode && ({
45
+ animationFillMode: props.animationFillMode
46
+ }),
47
+ animationProperty: ({ props }) => props.animationProperty && ({
48
+ animationProperty: props.animationProperty,
49
+ willChange: props.animationProperty
50
+ })
51
+ }
52
+ }
@@ -99,10 +99,11 @@ export const Block = {
99
99
  gridArea: ({ props }) => props.gridArea && ({ gridArea: props.gridArea }),
100
100
 
101
101
  flex: ({ props }) => props.flex && ({ flex: props.flex }),
102
+ flexDirection: ({ props }) => props.flexDirection && ({ flexDirection: props.flexDirection }),
102
103
  alignItems: ({ props }) => props.alignItems && ({ alignItems: props.alignItems }),
103
104
  alignContent: ({ props }) => props.alignContent && ({ alignContent: props.alignContent }),
104
105
  justifyContent: ({ props }) => props.justifyContent && ({ justifyContent: props.justifyContent }),
105
- flexDirection: ({ props }) => props.flexDirection && ({ flexDirection: props.flexDirection }),
106
+ justifyItems: ({ props }) => props.justifyItems && ({ justifyItems: props.justifyItems }),
106
107
  alignSelf: ({ props }) => props.alignSelf && ({ alignSelf: props.alignSelf }),
107
108
  order: ({ props }) => props.order && ({ order: props.order }),
108
109
 
package/src/atoms/Grid.js CHANGED
@@ -6,11 +6,20 @@ export const Grid = {
6
6
  props: { display: 'grid' },
7
7
 
8
8
  class: {
9
- columns: ({ props }) => props.columns ? ({ gridTemplateColumns: props.columns }) : null,
10
- rows: ({ props }) => props.rows ? ({ gridTemplateRows: props.rows }) : null,
11
9
  area: ({ props }) => props.area ? ({ gridArea: props.area }) : null,
12
10
  template: ({ props }) => props.template ? ({ gridTemplate: props.template }) : null,
13
11
  templateAreas: ({ props }) => props.templateAreas ? ({ gridTemplateAreas: props.templateAreas }) : null,
12
+
13
+ columns: ({ props }) => props.columns ? ({ gridTemplateColumns: props.columns }) : null,
14
+ templateColumns: ({ props }) => props.templateColumns ? ({ gridTemplateColumns: props.templateColumns }) : null,
15
+ autoColumns: ({ props }) => props.autoColumns ? ({ gridAutoColumns: props.autoColumns }) : null,
16
+
17
+ rows: ({ props }) => props.rows ? ({ gridTemplateRows: props.rows }) : null,
18
+ templateRows: ({ props }) => props.templateRows ? ({ gridTemplateRows: props.templateRows }) : null,
19
+ autoRows: ({ props }) => props.autoRows ? ({ gridAutoRows: props.autoRows }) : null,
20
+
21
+ autoFlow: ({ props }) => props.autoFlow ? ({ gridAutoFlow: props.autoFlow }) : null,
22
+
14
23
  columnGap: ({ props }) => props.columnGap ? getSpacingBasedOnRatio(props, 'columnGap') : null,
15
24
  rowGap: ({ props }) => props.rowGap ? getSpacingBasedOnRatio(props, 'rowGap') : null
16
25
  }
@@ -27,6 +27,19 @@ export const Hoverable = {
27
27
  }
28
28
  }
29
29
 
30
+ export const Clickable = {
31
+ extend: Hoverable,
32
+ props: {
33
+ ':active': {
34
+ opacity: 1,
35
+ transform: 'scale(1.015)'
36
+ },
37
+ '.active': {
38
+ opacity: 1
39
+ }
40
+ }
41
+ }
42
+
30
43
  export const Focusable = {
31
44
  props: {
32
45
  border: 'none',
@@ -1,7 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  import { merge, isArray } from '@domql/utils'
4
- import { CASES as CONFIG_CASES, MEDIA as CONFIG_MEDIA } from '@symbo.ls/scratch'
5
4
 
6
5
  const keySetters = {
7
6
  '@': (key, props, result, element, isSubtree) => applyMediaProps(key, props, isSubtree ? result : result.media, element),
@@ -46,7 +45,8 @@ const convertPropsToClass = (props, result, element) => {
46
45
  }
47
46
 
48
47
  const applyMediaProps = (key, props, result, element) => {
49
- const mediaName = CONFIG_MEDIA[key.slice(1)]
48
+ const { MEDIA } = element.context && element.context.SYSTEM
49
+ const mediaName = MEDIA[key.slice(1)]
50
50
  const generatedClass = convertPropsToClass(props, result, element)
51
51
 
52
52
  const rootState = element.__root ? element.__root.state : element.state
@@ -72,9 +72,10 @@ const applySelectorProps = (key, props, result, element) => {
72
72
  }
73
73
 
74
74
  const applyCaseProps = (key, props, result, element) => {
75
+ const { CASES } = element.context && element.context.SYSTEM
75
76
  const caseKey = key.slice(1)
76
77
  const isPropTrue = element.props[caseKey]
77
- if (!CONFIG_CASES[caseKey] && !isPropTrue) return
78
+ if (!CASES[caseKey] && !isPropTrue) return
78
79
  return merge(result, convertPropsToClass(props, result, element))
79
80
  }
80
81
 
@@ -127,30 +128,30 @@ export const initUpdate = element => {
127
128
 
128
129
  const { globalTheme } = rootState
129
130
 
130
- if (!globalTheme) return
131
+ if (globalTheme) {
132
+ const CLASS_NAMES = {
133
+ media: {},
134
+ selector: {},
135
+ case: {}
136
+ }
131
137
 
132
- const CLASS_NAMES = {
133
- media: {},
134
- selector: {},
135
- case: {}
136
- }
138
+ for (const key in props) {
139
+ const setter = keySetters[key.slice(0, 1)]
140
+ if (key === 'theme') {
141
+ props.update({
142
+ themeModifier: `@${globalTheme}`
143
+ }, { preventRecursive: true, ignoreInitUpdate: true })
144
+ } else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
137
145
 
138
- for (const key in props) {
139
- const setter = keySetters[key.slice(0, 1)]
140
- if (key === 'theme') {
141
- props.update({
142
- themeModifier: `@${globalTheme}`
143
- }, { preventRecursive: true, ignoreInitUpdate: true })
144
- } else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
145
-
146
- if (setter) setter(key, props[key], CLASS_NAMES, element)
147
- }
146
+ if (setter) setter(key, props[key], CLASS_NAMES, element)
147
+ }
148
148
 
149
- if (Object.keys(CLASS_NAMES.media).length) {
150
- className.media = CLASS_NAMES.media
149
+ if (Object.keys(CLASS_NAMES.media).length) {
150
+ className.media = CLASS_NAMES.media
151
+ }
152
+ className.selector = CLASS_NAMES.selector
153
+ className.case = CLASS_NAMES.case
151
154
  }
152
- className.selector = CLASS_NAMES.selector
153
- className.case = CLASS_NAMES.case
154
155
  }
155
156
 
156
157
  export const Media = {
@@ -3,7 +3,7 @@
3
3
  import { isString } from '@domql/utils'
4
4
  import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
5
5
 
6
- const transformTransition = transition => {
6
+ export const transformTransition = transition => {
7
7
  const arr = transition.split(' ')
8
8
 
9
9
  if (!arr.length) return transition
@@ -18,12 +18,12 @@ const transformTransition = transition => {
18
18
  }).join(' ')
19
19
  }
20
20
 
21
- const transformDuration = (duration, props, propertyName) => {
21
+ export const transformDuration = (duration, props, propertyName) => {
22
22
  if (!isString(duration)) return
23
23
  return duration.split(',').map(getTimingByKey).join(',')
24
24
  }
25
25
 
26
- const splitTransition = transition => {
26
+ export const splitTransition = transition => {
27
27
  const arr = transition.split(',')
28
28
  if (!arr.length) return
29
29
  return arr.map(transformTransition).join(',')
@@ -57,6 +57,9 @@ export const Timing = {
57
57
  animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
58
58
  animationTimingFunction: getTimingFunction(props.animationTimingFunction)
59
59
  }),
60
+ animationFillMode: ({ props }) => props.animationFillMode && ({
61
+ animationFillMode: props.animationFillMode
62
+ }),
60
63
  animationProperty: ({ props }) => props.animationProperty && ({
61
64
  animationProperty: props.animationProperty,
62
65
  willChange: props.animationProperty