smbls 0.15.22 → 0.15.23

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.22",
6
+ "version": "0.15.23",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
package/src/Box.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { Shape, Position, Theme, Block, Text, Overflow, Timing, Transform, Media, Interaction, XYZ } from './atoms'
3
+ import { Shape, Position, Theme, Block, Text, Overflow, Timing, Transform, Media, Interaction, XYZ, Animation } from './atoms'
4
4
 
5
5
  const PropsCSS = {
6
6
  class: {
@@ -9,5 +9,5 @@ const PropsCSS = {
9
9
  }
10
10
 
11
11
  export const Box = {
12
- extend: [Shape, Position, Theme, Block, Text, Overflow, Timing, Transform, Media, PropsCSS, Interaction, XYZ]
12
+ extend: [Shape, Position, Theme, Block, Text, Overflow, Timing, Transform, Media, PropsCSS, Interaction, XYZ, Animation]
13
13
  }
@@ -1,52 +1,53 @@
1
1
  'use strict'
2
2
 
3
- import { merge } from '@domql/utils'
4
- import { getTimingFunction } from '@symbo.ls/scratch'
5
- import { convertPropsToClass } from './Media'
6
- import { transformDuration } from './Timing'
3
+ import { getTimingByKey, getTimingFunction } from '@symbo.ls/scratch'
4
+ import { isObject } from '@domql/utils'
5
+ import { convertPropsToClass } from './Media' // eslint-disable-line no-unused-vars
6
+ import createEmotion from '@symbo.ls/create-emotion'
7
+ const { keyframes } = createEmotion
7
8
 
8
- const applyAnimationProps = (key, props, result, element) => {
9
+ const applyAnimationProps = (animation, element) => {
10
+ if (isObject(animation)) return { animationName: keyframes(animation) }
9
11
  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]
12
+ const record = ANIMATION[animation]
13
+ return keyframes(record)
27
14
  }
28
15
 
29
16
  export const Animation = {
30
17
  class: {
31
- animation: ({ props }) => props.animation && ({
32
- animation: applyAnimationProps(props.animation)
33
- }),
18
+ animation: (el) => el.props.animation && {
19
+ animationName: applyAnimationProps(el.props.animation, el),
20
+ animationDuration: getTimingByKey(el.props.animationDuration || 'A').timing,
21
+ animationDelay: getTimingByKey(el.props.animationDelay).timing || '0s',
22
+ animationTimingFunction: getTimingFunction(el.props.animationTimingFunction || 'ease'),
23
+ animationFillMode: el.props.animationFillMode || 'both',
24
+ animationPlayState: el.props.animationPlayState,
25
+ animationDirection: el.props.animationDirection
26
+ },
27
+ animationName: (el) => el.props.animationName && {
28
+ animationName: applyAnimationProps(el.props.animationName, el)
29
+ },
34
30
 
35
31
  animationDuration: ({ props }) => props.animationDuration && ({
36
- animationDuration: transformDuration(props.animationDuration)
32
+ animationDuration: getTimingByKey(props.animationDuration || 'A').timing
37
33
  }),
38
34
  animationDelay: ({ props }) => props.animationDelay && ({
39
- animationDelay: transformDuration(props.animationDelay)
35
+ animationDelay: getTimingByKey(props.animationDelay).timing || '0s'
40
36
  }),
41
37
  animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
42
- animationTimingFunction: getTimingFunction(props.animationTimingFunction)
38
+ animationTimingFunction: getTimingFunction(props.animationTimingFunction || 'ease')
43
39
  }),
44
40
  animationFillMode: ({ props }) => props.animationFillMode && ({
45
- animationFillMode: props.animationFillMode
41
+ animationFillMode: props.animationFillMode || 'both'
42
+ }),
43
+ animationPlayState: ({ props }) => props.animationPlayState && ({
44
+ animationPlayState: props.animationPlayState
45
+ }),
46
+ animationIterationCount: ({ props }) => props.animationIterationCount && ({
47
+ animationIterationCount: props.animationIterationCount || 1
46
48
  }),
47
- animationProperty: ({ props }) => props.animationProperty && ({
48
- animationProperty: props.animationProperty,
49
- willChange: props.animationProperty
49
+ animationDirection: ({ props }) => props.animationDirection && ({
50
+ animationDirection: props.animationDirection
50
51
  })
51
52
  }
52
53
  }
@@ -51,6 +51,7 @@ export const Focusable = {
51
51
  },
52
52
 
53
53
  attr: {
54
- placeholder: ({ props }) => props.placeholder
54
+ placeholder: ({ props }) => props.placeholder,
55
+ tabIndex: ({ props }) => props.tabIndex
55
56
  }
56
57
  }
@@ -34,6 +34,9 @@ export const Timing = {
34
34
  transition: ({ props }) => props.transition && ({
35
35
  transition: splitTransition(props.transition)
36
36
  }),
37
+ willChange: ({ props }) => props.willChange && ({
38
+ willChange: props.willChange
39
+ }),
37
40
  transitionDuration: ({ props }) => props.transitionDuration && ({
38
41
  transitionDuration: transformDuration(props.transitionDuration)
39
42
  }),
@@ -46,23 +49,6 @@ export const Timing = {
46
49
  transitionProperty: ({ props }) => props.transitionProperty && ({
47
50
  transitionProperty: props.transitionProperty,
48
51
  willChange: props.transitionProperty
49
- }),
50
-
51
- animationDuration: ({ props }) => props.animationDuration && ({
52
- animationDuration: transformDuration(props.animationDuration)
53
- }),
54
- animationDelay: ({ props }) => props.animationDelay && ({
55
- animationDelay: transformDuration(props.animationDelay)
56
- }),
57
- animationTimingFunction: ({ props }) => props.animationTimingFunction && ({
58
- animationTimingFunction: getTimingFunction(props.animationTimingFunction)
59
- }),
60
- animationFillMode: ({ props }) => props.animationFillMode && ({
61
- animationFillMode: props.animationFillMode
62
- }),
63
- animationProperty: ({ props }) => props.animationProperty && ({
64
- animationProperty: props.animationProperty,
65
- willChange: props.animationProperty
66
52
  })
67
53
  }
68
54
  }
@@ -2,8 +2,7 @@
2
2
 
3
3
  export const Transform = {
4
4
  class: {
5
- transform: ({ props }) => props.transform && ({
6
- transform: props.transform
7
- })
5
+ transform: ({ props }) => props.transform && ({ transform: props.transform }),
6
+ transformOrigin: ({ props }) => props.transformOrigin && ({ transformOrigin: props.transformOrigin })
8
7
  }
9
8
  }
@@ -18,3 +18,4 @@ export * from './Text'
18
18
  export * from './Timing'
19
19
  export * from './Transform'
20
20
  export * from './XYZ'
21
+ export * from './Animation'