smbls 0.8.3 → 0.8.6

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.3",
6
+ "version": "0.8.6",
7
7
  "repository": "https://github.com/rackai/symbols",
8
8
  "main": "src/index.js",
9
9
  "files": [
@@ -9,7 +9,11 @@ export const Button = {
9
9
  tag: 'button',
10
10
  style,
11
11
  props: {
12
- type: 'button'
12
+ type: 'button',
13
+ display: 'inline-flex',
14
+ alignItems: 'center',
15
+ justifyContent: 'center',
16
+ textDecoration: 'none'
13
17
  },
14
18
  attr: {
15
19
  type: ({ props }) => props.type
@@ -23,11 +27,11 @@ export const SquareButton = {
23
27
  width: 'A',
24
28
  padding: 'Z',
25
29
  aspectRatio: '1 / 1',
30
+ justifyContent: 'center',
26
31
  round: 'Z'
27
32
  },
28
33
  class: {
29
34
  squareButton: {
30
- justifyContent: 'center',
31
35
  boxSizing: 'content-box'
32
36
  }
33
37
  }
@@ -6,8 +6,4 @@ export default {
6
6
  outline: 0,
7
7
  cursor: 'pointer',
8
8
  fontFamily: 'inherit',
9
- display: 'inline-flex',
10
- alignItems: 'center',
11
- justifyContent: 'center',
12
- textDecoration: 'none'
13
9
  }
package/src/Flex/index.js CHANGED
@@ -14,6 +14,7 @@ export const Flex = {
14
14
  flow: ({ props }) => ({ flexFlow: props.flow }),
15
15
  flexDirection: ({ props }) => ({ flexDirection: props.flexDirection }),
16
16
  alignItems: ({ props }) => ({ alignItems: props.alignItems }),
17
+ alignContent: ({ props }) => ({ alignContent: props.alignContent }),
17
18
  justifyContent: ({ props }) => ({ justifyContent: props.justifyContent }),
18
19
  gap: ({ props }) => mapBasedOnRatio(props, 'gap')
19
20
  }
@@ -1,15 +1,14 @@
1
1
  'use strict'
2
2
 
3
- import style from './style'
4
-
5
- import { Icon, Text, Direction, Block } from '../'
6
- import { } from '../Flex'
3
+ import { Icon } from '../Icon'
7
4
 
8
5
  export const IconText = {
9
- style,
10
-
11
6
  props: {
12
- flexAlign: 'center flex-start'
7
+ flexAlign: 'center flex-start',
8
+ display: 'flex',
9
+ alignItems: 'center',
10
+ alignContent: 'center',
11
+ lineHeight: 1
13
12
  },
14
13
 
15
14
  icon: { proto: Icon, if: ({ parent }) => parent.props.icon, props: ({ parent }) => ({ icon: parent.props.icon }) },
@@ -1,11 +1,6 @@
1
1
  'use strict'
2
2
 
3
3
  export default {
4
- display: 'flex',
5
- alignItems: 'center',
6
- alignContent: 'center',
7
- lineHeight: 1,
8
-
9
4
  '> svg': {
10
5
  // marginInlineEnd: `${0.35}em`
11
6
  }
package/src/Link/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ import { exec } from '@domql/utils'
3
4
  import { Shape, Text } from '..'
4
5
 
5
6
  export const Link = {
@@ -12,7 +13,7 @@ export const Link = {
12
13
  aria: {}
13
14
  },
14
15
  attr: {
15
- href: ({ props }) => props.href,
16
+ href: element => exec(element.props.href, element),
16
17
  target: ({ props }) => props.target,
17
18
  'aria-label': ({ props }) => props.aria.label || props.text
18
19
  }
@@ -7,16 +7,10 @@ export const Position = {
7
7
 
8
8
  class: {
9
9
  position: ({ props }) => props.position && ({ position: props.position }),
10
- positionAxes: ({ props }) => {
11
- const { positionAxes } = props
12
- if (typeof positionAxes !== 'string') return
13
- const [left, top, right, bottom] = positionAxes.split(' ')
14
- return {
15
- left: mapSpacing(left, 'left'),
16
- top: mapSpacing(top, 'top'),
17
- right: mapSpacing(right, 'right'),
18
- bottom: mapSpacing(bottom, 'bottom')
19
- }
10
+ inset: ({ props }) => {
11
+ const { inset } = props
12
+ if (typeof inset !== 'string') return
13
+ return { inset: inset.split(' ').map(v => mapSpacing(v,'k').k).join(' ') }
20
14
  },
21
15
 
22
16
  left: ({ props }) => mapSpacing(props.left, 'left'),
@@ -7,14 +7,10 @@ export const Responsive = {
7
7
  init: (el, s) => {
8
8
  const { props } = el
9
9
 
10
- // Object.keys(props)
11
- // .filter(v => v.slice(0, 1) === '@')
12
- // .map()
13
-
14
10
  for (const screen in props) {
15
11
  if (screen.slice(0, 1) === '@') {
16
- const screenName = screen.slice(1)
17
- const responsiveKey = `@media screen and ${RESPONSIVE[screenName]}`
12
+ const mediaName = screen.slice(1)
13
+ const responsiveKey = `@media screen and ${RESPONSIVE[mediaName]}`
18
14
  const screenProps = props[screen]
19
15
  const calculatedScreenProps = {}
20
16
 
@@ -41,6 +37,33 @@ export const Responsive = {
41
37
  [responsiveKey]: calculatedScreenProps
42
38
  }
43
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 = `&${selectorName}`
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(underSelectorProps)) {
52
+ underSelectorProps = Object.assign({}, ...underSelectorProps)
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
+ }
44
67
  }
45
68
  }
46
69
  }