smbls 0.8.5 → 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.5",
6
+ "version": "0.8.6",
7
7
  "repository": "https://github.com/rackai/symbols",
8
8
  "main": "src/index.js",
9
9
  "files": [
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,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
  }