smbls 0.14.4 → 0.14.5

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.14.4",
6
+ "version": "0.14.5",
7
7
  "repository": "https://github.com/symbo-ls/smbls",
8
8
  "main": "src/index.js",
9
9
  "files": [
package/src/Button.js CHANGED
@@ -1,11 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { IconText } from '.'
3
+ import { IconText, Focusable } from '.'
4
4
 
5
5
  const style = {
6
6
  appearance: 'none',
7
7
  border: 'none',
8
- outline: 0,
9
8
  cursor: 'pointer',
10
9
  fontFamily: 'inherit',
11
10
  '& > *': {
@@ -14,7 +13,7 @@ const style = {
14
13
  }
15
14
 
16
15
  export const Button = {
17
- extend: IconText,
16
+ extend: [Focusable, IconText],
18
17
  tag: 'button',
19
18
  props: {
20
19
  fontSize: 'A',
package/src/Input.js CHANGED
@@ -1,6 +1,9 @@
1
1
  'use strict'
2
2
 
3
+ import { Focusable } from './Interaction'
4
+
3
5
  export const Input = {
6
+ extend: [Focusable],
4
7
  tag: 'input',
5
8
 
6
9
  props: {
@@ -6,3 +6,37 @@ export const Interaction = {
6
6
  cursor: ({ props }) => props.cursor && ({ cursor: props.cursor })
7
7
  }
8
8
  }
9
+
10
+ export const Hoverable = {
11
+ props: {
12
+ transition: 'B',
13
+ transitionProperty: 'opacity, transform',
14
+ opacity: 0.85,
15
+
16
+ ':hover': {
17
+ opacity: 0.9,
18
+ transform: 'scale(1.015)'
19
+ },
20
+ ':active': {
21
+ opacity: 1,
22
+ transform: 'scale(1.015)'
23
+ },
24
+ '.active': {
25
+ opacity: 1
26
+ }
27
+ }
28
+ }
29
+
30
+ export const Focusable = {
31
+ props: {
32
+ outline: 'none',
33
+ ':focus-visible': {
34
+ opacity: 1,
35
+ outline: 'solid, X, blue .3'
36
+ }
37
+ },
38
+
39
+ attr: {
40
+ placeholder: ({ props }) => props.placeholder
41
+ }
42
+ }
package/src/Label.js CHANGED
@@ -1,20 +1,25 @@
1
1
  'use strict'
2
- import { Block } from './Block'
3
- import { Shape } from './Shape'
4
- import { Text } from './Text'
5
2
 
6
- export const Label = {
7
- extend: [Shape, Block, Text],
3
+ import { Button } from '.'
8
4
 
9
- style: { lineHeight: 1 },
5
+ export const Label = {
6
+ extend: Button,
10
7
 
11
8
  props: {
9
+ fontSize: 'Z',
12
10
  emoji: '👍',
13
11
  text: '3',
14
12
  padding: 'X2 Z',
15
13
  round: 'C',
16
- depth: 16
14
+ lineHeight: 1,
15
+ gap: 'X2',
16
+ depth: 16,
17
+ fontWeight: '500',
18
+ background: 'blue .3',
19
+ color: 'white'
17
20
  },
18
21
 
19
- emoji: ({ props }) => props.emoji
22
+ emoji: {
23
+ props: ({ parent }) => ({ text: parent.props.emoji })
24
+ }
20
25
  }
package/src/Link.js CHANGED
@@ -1,8 +1,10 @@
1
1
  'use strict'
2
2
 
3
3
  import { exec } from '@domql/utils'
4
+ import { Focusable } from './Interaction'
4
5
 
5
6
  export const Link = {
7
+ extend: [Focusable],
6
8
  tag: 'a',
7
9
  props: {
8
10
  aria: {},
package/src/Theme.js CHANGED
@@ -1,6 +1,5 @@
1
1
  'use strict'
2
2
 
3
- import { isArray, isObject } from '@domql/utils'
4
3
  import { getSpacingByKey, getMediaTheme, getColor, getMediaColor } from '@symbo.ls/scratch'
5
4
 
6
5
  import { depth } from './Shape/style'
@@ -8,15 +7,14 @@ import { depth } from './Shape/style'
8
7
  const isBorderStyle = str =>
9
8
  ['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'initial'].some(v => str.includes(v))
10
9
 
11
- const transformBorder = (border, key = 'border') => {
12
- const obj = {}
13
- const arr = isObject(border) ? Object.values(border) : isArray(border) ? border : border.split(', ')
14
- arr.map(v => {
15
- if (v.slice(-2) === 'px' || v.slice(-2) === 'em') obj[`${key}Width`] = v // TODO: add map spacing
16
- else if (isBorderStyle(v)) obj[`${key}Style`] = v || 'solid'
17
- else if (getColor(v)) obj[`${key}Color`] = getColor(v)
18
- })
19
- return obj
10
+ const transformBorder = border => {
11
+ const arr = border.split(', ')
12
+ return arr.map(v => {
13
+ if (isBorderStyle(v)) return v || 'solid'
14
+ else if (v.slice(-2) === 'px' || v.slice(-2) === 'em') return v // TODO: add map spacing
15
+ else if (getColor(v).length > 2) return getColor(v)
16
+ return getSpacingByKey(v, 'border').border
17
+ }).join(' ')
20
18
  }
21
19
 
22
20
  const transformTextStroke = stroke => ({
@@ -65,14 +63,28 @@ export const Theme = {
65
63
 
66
64
  textStroke: ({ props }) => props.textStroke ? transformTextStroke(props.textStroke) : null,
67
65
 
68
- border: ({ props }) => props.border ? transformBorder(props.border) : null,
66
+ outline: ({ props }) => props.outline && ({
67
+ outline: transformBorder(props.outline)
68
+ }),
69
+
70
+ border: ({ props }) => props.border && ({
71
+ border: transformBorder(props.border)
72
+ }),
69
73
  borderColor: ({ props }) => (props.borderColor) && getMediaColor(props.borderColor, 'borderColor'),
70
74
  borderStyle: ({ props }) => props.borderStyle && ({ borderStyle: props.borderStyle }),
71
75
 
72
- borderLeft: ({ props }) => props.borderLeft ? transformBorder(props.borderLeft, 'borderLeft') : null,
73
- borderTop: ({ props }) => props.borderTop ? transformBorder(props.borderTop, 'borderTop') : null,
74
- borderRight: ({ props }) => props.borderRight ? transformBorder(props.borderRight, 'borderRight') : null,
75
- borderBottom: ({ props }) => props.borderBottom ? transformBorder(props.borderBottom, 'borderBottom') : null,
76
+ borderLeft: ({ props }) => props.borderLeft && ({
77
+ borderLeft: transformBorder(props.borderLeft)
78
+ }),
79
+ borderTop: ({ props }) => props.borderTop && ({
80
+ borderTop: transformBorder(props.borderTop)
81
+ }),
82
+ borderRight: ({ props }) => props.borderRight && ({
83
+ borderRight: transformBorder(props.borderRight)
84
+ }),
85
+ borderBottom: ({ props }) => props.borderBottom && ({
86
+ borderBottom: transformBorder(props.borderBottom)
87
+ }),
76
88
 
77
89
  boxShadow: ({ props }) => props.boxShadow ? transformShadow(props.boxShadow) : null,
78
90
 
package/src/index.js CHANGED
@@ -18,6 +18,7 @@ export * from './Position'
18
18
  export * from './Overflow'
19
19
  export * from './Transform'
20
20
  export * from './Timing'
21
+
21
22
  export * from './Media'
22
23
  export * from './Interaction'
23
24
  export * from './XYZ'