smbls 0.13.8 → 0.14.1

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.8",
6
+ "version": "0.14.1",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
package/src/Block.js CHANGED
@@ -1,34 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { SPACING, getSpacingByKey } from '@symbo.ls/scratch'
4
-
5
- export const getSpacingBasedOnRatio = (props, propertyName, unit) => {
6
- const { spacingRatio } = props
7
-
8
- // if (spacingRatio) console.log(propertyName, props)
9
-
10
- const val = props[propertyName]
11
- // TODO: move this to getSpacingByKey
12
- if (spacingRatio) {
13
- let params = SPACING[spacingRatio]
14
-
15
- if (!params) {
16
- params = SPACING[spacingRatio] = {
17
- base: props.base || SPACING.base,
18
- type: SPACING.type + '-' + spacingRatio,
19
- ratio: spacingRatio,
20
- range: SPACING.range,
21
- subSequence: SPACING.subSequence,
22
- sequence: {},
23
- scales: {},
24
- vars: {}
25
- }
26
- }
27
-
28
- return getSpacingByKey(val, propertyName, params, unit, false)
29
- }
30
- return getSpacingByKey(val, propertyName, null, unit)
31
- }
3
+ import { getSpacingBasedOnRatio, getSpacingByKey } from '@symbo.ls/scratch'
32
4
 
33
5
  export const Block = {
34
6
  class: {
@@ -2,111 +2,153 @@
2
2
 
3
3
  import style from './style'
4
4
 
5
- import { Icon } from '../Icon'
5
+ import { SquareButton, Flex, Button, Grid } from '../'
6
6
 
7
- export const DatePicker = {
8
- style,
7
+ const buttonProps = {
8
+ theme: 'transparent',
9
+ color: '--theme-quinary-dark-color',
10
+ ':hover': {
11
+ theme: 'quinary .child'
12
+ }
13
+ }
9
14
 
15
+ const aside = {
10
16
  props: {
11
- theme: 'lightDark',
12
- padding: 'A',
13
- round: 'Z',
14
- depth: 16
17
+ gap: 'X2',
18
+ margin: '-Z - -Z -X2',
19
+ padding: 'Z - Z X2',
20
+ minHeight: '100%',
21
+ height: '100%',
22
+ width: '--spacing-D'
15
23
  },
16
24
 
17
- aside: {
18
- childExtend: { tag: 'button' },
19
- ...[
20
- { text: '2020' },
21
- { text: '2021' },
22
- { text: '2022' },
23
- { text: '2023' },
24
- { text: '2024' },
25
- { text: '2025' },
26
- { text: '2026' },
27
- { text: '2026' },
28
- { text: '2026' }
29
- ]
30
- },
25
+ cnt: {
26
+ extend: Flex,
27
+ props: {
28
+ flow: 'column',
29
+ overflow: 'hidden auto',
30
+ boxSize: '100% --spacing-D',
31
+ top: '0',
32
+ position: 'absolute',
33
+ maxHeight: '100%',
34
+ justifyContent: 'flex-end'
35
+ },
31
36
 
32
- main: {
33
- header: {
34
- icon: {
35
- extend: Icon,
36
- props: { icon: 'arrowMediumLeft' }
37
- },
38
- month: {
39
- childExtend: { tag: 'span' },
40
- ...[
41
- { text: 'january' },
42
- { text: 'february' },
43
- { text: 'march' },
44
- { text: 'april' },
45
- { text: 'may' },
46
- { text: 'june' },
47
- { text: 'july' },
48
- { text: 'august' },
49
- { text: 'september' },
50
- { text: 'october' },
51
- { text: 'november' },
52
- { text: 'december' }
53
- ]
37
+ childExtend: {
38
+ extend: Button,
39
+ props: {
40
+ ...buttonProps,
41
+ fontSize: 'Z1'
54
42
  },
55
- icon2: {
56
- extend: Icon,
57
- props: { icon: 'arrowMediumRight' }
43
+ text: ({ state }) => state.value
44
+ },
45
+ $setCollection: () => {
46
+ return new Array(30).fill(undefined).map((_, i) => (2022 - i)).reverse()
47
+ }
48
+ }
49
+
50
+ }
51
+
52
+ const main = {
53
+ extend: Flex,
54
+
55
+ props: {
56
+ flex: 1,
57
+ gap: 'X2',
58
+ flow: 'column',
59
+
60
+ header: {
61
+ align: 'center space-between'
62
+ }
63
+ },
64
+
65
+ header: {
66
+ extend: Flex,
67
+ left: {
68
+ extend: SquareButton,
69
+ props: {
70
+ ...buttonProps,
71
+ round: 'C',
72
+ icon: 'arrowAngleLeft'
58
73
  }
59
74
  },
60
- days: {
61
- tag: 'section',
62
- header: {
63
- childExtend: { tag: 'span' },
64
- ...[
65
- { text: 'Mo' },
66
- { text: 'Tu' },
67
- { text: 'We' },
68
- { text: 'Th' },
69
- { text: 'Fr' },
70
- { text: 'Sa' },
71
- { text: 'Su' }
72
- ]
73
- },
74
- content: {
75
- childExtend: { tag: 'button' },
76
- ...[
77
- { text: '1' },
78
- { text: '2' },
79
- { text: '3' },
80
- { text: '4' },
81
- { text: '5' },
82
- { text: '6' },
83
- { text: '7' },
84
- { text: '8' },
85
- { text: '9' },
86
- { text: '10' },
87
- { text: '11' },
88
- { text: '12' },
89
- { text: '13' },
90
- { text: '14' },
91
- { text: '15' },
92
- { text: '16' },
93
- { text: '17' },
94
- { text: '18' },
95
- { text: '19' },
96
- { text: '20' },
97
- { text: '21' },
98
- { text: '22' },
99
- { text: '23' },
100
- { text: '24' },
101
- { text: '25' },
102
- { text: '26' },
103
- { text: '27' },
104
- { text: '28' },
105
- { text: '29' },
106
- { text: '30' },
107
- { text: '31' }
108
- ]
75
+ month: {
76
+ tag: 'span',
77
+ text: 'December'
78
+ },
79
+ right: {
80
+ extend: SquareButton,
81
+ props: {
82
+ ...buttonProps,
83
+ round: 'C',
84
+ icon: 'arrowAngleRight'
109
85
  }
110
86
  }
87
+ },
88
+ days: {
89
+ extend: Flex,
90
+ props: {
91
+ flow: 'column',
92
+ gap: 'X2'
93
+ },
94
+ childExtend: {
95
+ extend: Grid,
96
+ props: {
97
+ columns: 'repeat(7, 1fr)',
98
+ gap: 'X2'
99
+ }
100
+ },
101
+ weekDays: {
102
+ childExtend: {
103
+ extend: Button,
104
+ props: {
105
+ ...buttonProps,
106
+ fontSize: 'Z1',
107
+ padding: 'X2'
108
+ }
109
+ },
110
+ ...[
111
+ { text: 'Mo' },
112
+ { text: 'Tu' },
113
+ { text: 'We' },
114
+ { text: 'Th' },
115
+ { text: 'Fr' },
116
+ { text: 'Sa' },
117
+ { text: 'Su' }
118
+ ]
119
+ },
120
+
121
+ cnt: {
122
+ childExtend: {
123
+ extend: SquareButton,
124
+ props: {
125
+ ...buttonProps,
126
+ theme: 'quinary'
127
+ }
128
+ },
129
+
130
+ // Generate days
131
+ ...new Array(31).fill(undefined).map((_, i) => ({ text: i + 1 }))
132
+ }
111
133
  }
112
134
  }
135
+
136
+ export const DatePicker = {
137
+ style,
138
+ extend: Flex,
139
+
140
+ props: {
141
+ position: 'relative',
142
+ theme: 'quinary',
143
+ transition: 'A all',
144
+ round: 'Z',
145
+ padding: 'Z Z2 Z X2',
146
+ gap: 'X2',
147
+ depth: 16,
148
+ minHeight: '0',
149
+ align: 'stretch center'
150
+ },
151
+
152
+ aside,
153
+ main
154
+ }
@@ -1,95 +1,13 @@
1
1
  'use strict'
2
2
 
3
3
  export default {
4
- maxWidth: `${336 / 16}em`,
5
- maxHeight: `${260 / 16}em`,
6
- display: 'flex',
7
- padding: '0 1em',
8
- boxSizing: 'border-box',
9
- borderRadius: '10px',
10
- button: {
11
- border: 'none',
12
- outline: 'none',
13
- background: 'transparent',
14
- cursor: 'pointer'
15
- },
16
-
17
- aside: {
18
- display: 'flex',
19
- flexDirection: 'column',
20
- overflowX: 'auto',
21
- paddingRight: `${10 / 16}em`,
22
-
23
- button: {
24
- opacity: 0.5,
25
- marginBottom: `${22 / 12}em`
26
- }
27
- },
28
-
29
4
  main: {
30
- flex: 1,
31
- paddingTop: `${14 / 16}em`,
32
- paddingBottom: `${10 / 16}em`,
33
- overflow: 'hidden',
34
-
35
- display: 'flex',
36
- flexDirection: 'column',
37
-
38
- '> header': {
39
- display: 'flex',
40
- alignItems: 'center',
41
- height: 'auto',
42
- overflow: 'hidden',
43
- width: '100%',
44
- padding: `0 ${8 / 16}em ${14 / 16}em ${8 / 16}em`,
45
- boxSizing: 'border-box'
46
- },
47
- '> header > svg': {
48
- cursor: 'pointer'
49
- },
50
-
51
- '> header > div': {
52
- display: 'flex',
53
- overflow: 'hidden',
54
- flex: 1
55
- },
56
- '> header span': {
57
- minWidth: '100%',
58
- textTransform: 'capitalize',
59
- textAlign: 'center',
60
- fontWeight: 'bold'
61
- },
62
-
63
- section: {
64
- flex: 1,
65
- display: 'flex',
66
- flexDirection: 'column'
67
- },
68
- 'section > header': {
69
- height: 'auto',
70
- display: 'grid',
71
- gridTemplateColumns: 'repeat(7, 1fr)',
72
- gap: '6px',
73
- paddingBottom: `${2 / 16}em`
74
- },
75
- 'section > header span': {
76
- textAlign: 'center',
77
- fontWeight: 'bold'
78
- },
79
5
  'section > header span:nth-child(6)': {
80
6
  opacity: 0.5
81
7
  },
82
8
  'section > header span:nth-child(7)': {
83
9
  opacity: 0.5
84
10
  },
85
- 'section > div': {
86
- flex: 1,
87
- display: 'grid',
88
- gridTemplateColumns: 'repeat(7, 1fr)',
89
- gap: '6px'
90
- },
91
- 'section > div button': {
92
- },
93
11
  'section > div button:nth-child(7n)': {
94
12
  opacity: 0.5
95
13
  },
package/src/Grid.js CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { getSpacingBasedOnRatio } from './Block'
3
+ import { getSpacingBasedOnRatio } from '@symbo.ls/scratch'
4
4
 
5
5
  export const Grid = {
6
6
  props: { display: 'grid' },
package/src/Media.js CHANGED
@@ -106,6 +106,18 @@ const beforeClassAssign = (element, s) => {
106
106
  export const initUpdate = element => {
107
107
  const { props, class: className } = element
108
108
  const rootState = element.__root ? element.__root.state : element.state
109
+
110
+ const parentProps = element.parent.props
111
+ if (parentProps?.spacingRatio && parentProps?.inheritSpacingRatio) {
112
+ element.setProps({
113
+ spacingRatio: parentProps.spacingRatio,
114
+ inheritSpacingRatio: true
115
+ }, {
116
+ preventRecursive: true,
117
+ ignoreInitUpdate: true
118
+ })
119
+ }
120
+
109
121
  const { globalTheme } = rootState
110
122
 
111
123
  if (!globalTheme) return
@@ -125,7 +137,9 @@ export const initUpdate = element => {
125
137
  if (setter) setter(key, props[key], CLASS_NAMES, element)
126
138
  }
127
139
 
128
- if (Object.keys(CLASS_NAMES.media).length) className.media = CLASS_NAMES.media
140
+ if (Object.keys(CLASS_NAMES.media).length) {
141
+ className.media = CLASS_NAMES.media
142
+ }
129
143
  className.selector = CLASS_NAMES.selector
130
144
  className.case = CLASS_NAMES.case
131
145
  }
@@ -2,16 +2,19 @@
2
2
 
3
3
  import { exec, isString } from '@domql/utils'
4
4
  import { SHAPES } from './style'
5
- import { getSpacingByKey } from '@symbo.ls/scratch'
5
+ import { getSpacingBasedOnRatio, getMediaColor } from '@symbo.ls/scratch'
6
+ import { Pseudo } from '../Pseudo'
6
7
 
7
- const transformBorderRadius = (radius, props) => {
8
+ const transformBorderRadius = (radius, props, propertyName) => {
8
9
  if (!isString(radius)) return
9
10
  return {
10
- borderRadius: radius.split(' ').map((v, k) => getSpacingByKey(v, 'radius').radius).join(' ')
11
+ borderRadius: radius.split(' ').map((v, k) => getSpacingBasedOnRatio(props, propertyName, v)[propertyName]).join(' ')
11
12
  }
12
13
  }
13
14
 
14
15
  export const Shape = {
16
+ extend: Pseudo,
17
+
15
18
  class: {
16
19
  shape: (element) => {
17
20
  const { props } = element
@@ -24,10 +27,15 @@ export const Shape = {
24
27
  const shapeDir = SHAPES[shape + 'Direction']
25
28
  return shape ? shapeDir[shapeDirection || 'top'] : null
26
29
  },
27
- shapeDirectionColor: ({ props, ...el }) => props.shapeDirection ? { '&:before': { borderColor: el.class.backgroundColor } } : null,
30
+ shapeDirectionColor: el => {
31
+ const { props } = el
32
+ const { background, backgroundColor } = props
33
+ const borderColor = getMediaColor(background || backgroundColor, 'borderColor')
34
+ return props.shapeDirection ? borderColor : null
35
+ },
28
36
 
29
- round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props),
30
- borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props)
37
+ round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props, 'round'),
38
+ borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props, 'borderRadius')
31
39
  }
32
40
  }
33
41
 
@@ -18,14 +18,14 @@ export const SHAPES = {
18
18
 
19
19
  tooltip: ({ props }) => ({
20
20
  position: props.position || 'relative',
21
- '&:before': {
21
+ ':before': {
22
22
  content: '""',
23
23
  display: 'block',
24
24
  width: '0px',
25
25
  height: '0px',
26
- border: `6px solid ${getColor(props.background) || (props.theme && getTheme(props.theme).background)}`,
26
+ border: `6px, solid`,
27
27
  position: 'absolute',
28
- borderRadius: '2px'
28
+ borderRadius: 'X2'
29
29
  }
30
30
  }),
31
31