smbls 0.14.4 → 0.14.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.14.4",
6
+ "version": "0.14.6",
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,11 +13,12 @@ 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',
21
20
  type: 'button',
21
+ border: 'none',
22
22
  display: 'inline-flex',
23
23
  alignItems: 'center',
24
24
  justifyContent: 'center',
@@ -55,38 +55,7 @@ export const CircleButton = {
55
55
 
56
56
  export const KangorooButton = {
57
57
  extend: Button,
58
+ childExtend: IconText,
58
59
 
59
- props: {
60
- theme: 'quinary',
61
- round: 'Z2',
62
- padding: 'X1 X1 X1 A2',
63
- size: 'A',
64
- gap: 'A',
65
- transition: 'A defaultBezier',
66
- transitionProperty: 'background, color, opacity',
67
-
68
- label: {
69
- gap: 'X1',
70
- text: 'Become PRO',
71
- alignItems: 'center',
72
- fontWeight: 'bold',
73
- icon: {
74
- name: 'star',
75
- color: 'yellow'
76
- }
77
- },
78
- child: {
79
- theme: 'tertiary',
80
- round: 'Z',
81
- size: 'Z',
82
- padding: 'Z A2',
83
- text: '1 month free',
84
- opacity: '.85'
85
- },
86
-
87
- style
88
- },
89
-
90
- label: { extend: IconText },
91
- child: { extend: IconText }
60
+ props: { style }
92
61
  }
package/src/Field.js CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict'
2
2
 
3
- import { IconText, Input } from '.'
3
+ import { IconText, Input, Focusable } from '.'
4
4
 
5
5
  export const Field = {
6
- extend: IconText,
6
+ extend: [IconText],
7
+
7
8
  props: (el, s) => ({
8
9
  value: s[el.key],
9
10
 
@@ -36,5 +37,5 @@ export const Field = {
36
37
  }
37
38
  }),
38
39
 
39
- input: { extend: Input }
40
+ input: { extend: [Focusable, Input] }
40
41
  }
package/src/Input.js CHANGED
@@ -1,10 +1,15 @@
1
1
  'use strict'
2
2
 
3
+ import { Focusable } from './'
4
+
3
5
  export const Input = {
6
+ extend: [Focusable],
4
7
  tag: 'input',
5
8
 
6
9
  props: {
10
+ border: 'none',
7
11
  type: 'input',
12
+ theme: 'quaternary',
8
13
  fontSize: 'A',
9
14
  round: 'C',
10
15
  lineHeight: 1,
@@ -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: 'Z2',
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: {},
@@ -11,6 +11,12 @@ export const Notification = {
11
11
  gap: 'X2',
12
12
  style: { cursor: 'pointer' },
13
13
 
14
+ icon: {
15
+ icon: {
16
+ name: 'info outline'
17
+ }
18
+ },
19
+
14
20
  article: {
15
21
  flow: 'column',
16
22
  align: 'flex-start',
@@ -29,13 +35,12 @@ export const Notification = {
29
35
  },
30
36
 
31
37
  icon: {
32
- extend: [IconText],
33
- props: {
34
- icon: {
35
- name: 'info outline'
36
- }
37
- }
38
+ extend: [IconText]
38
39
  },
39
40
 
40
- article: { extend: Flex }
41
+ article: {
42
+ extend: Flex,
43
+ title: {},
44
+ p: {}
45
+ }
41
46
  }
@@ -18,21 +18,22 @@ 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`,
26
+ border: `.35em solid`,
27
+ borderColor: getColor(props.background) || getColor(props.backgroundColor),
27
28
  position: 'absolute',
28
- borderRadius: 'X2'
29
+ borderRadius: '.15em'
29
30
  }
30
31
  }),
31
32
 
32
33
  tooltipDirection: {
33
34
  top: {
34
35
  '&:before': {
35
- top: '2px',
36
+ top: '-.1em',
36
37
  left: '50%',
37
38
  transform: 'translate(-50%, -50%) rotate(45deg)'
38
39
  }
@@ -40,13 +41,13 @@ export const SHAPES = {
40
41
  right: {
41
42
  '&:before': {
42
43
  top: '50%',
43
- right: '-10px',
44
+ right: '-.1em',
44
45
  transform: 'translate(-50%, -50%) rotate(45deg)'
45
46
  }
46
47
  },
47
48
  bottom: {
48
49
  '&:before': {
49
- bottom: '-10px',
50
+ bottom: '-.1em',
50
51
  left: '50%',
51
52
  transform: 'translate(-50%, -50%) rotate(45deg)'
52
53
  }
@@ -54,7 +55,7 @@ export const SHAPES = {
54
55
  left: {
55
56
  '&:before': {
56
57
  top: '50%',
57
- left: '2px',
58
+ left: '-.1em',
58
59
  transform: 'translate(-50%, -50%) rotate(45deg)'
59
60
  }
60
61
  }
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/Tooltip.js ADDED
@@ -0,0 +1,33 @@
1
+ 'use strict'
2
+
3
+ import { Button, Flex } from './'
4
+
5
+ export const Tooltip = {
6
+ extend: [Button, Flex],
7
+ props: {
8
+ background: 'black',
9
+ color: 'white',
10
+ flow: 'column',
11
+ shape: 'tooltip',
12
+ shapeDirection: 'top',
13
+ padding: 'Z2',
14
+ round: 'X2',
15
+ minWidth: 'D2',
16
+ gap: 'X1',
17
+
18
+ title: {
19
+ color: 'gray12',
20
+ text: 'And tooltip is coming'
21
+ },
22
+ p: {
23
+ fontSize: 'Z2',
24
+ margin: '0',
25
+ color: 'gray6',
26
+ text: 'and winter too',
27
+ fontWeight: '400'
28
+ }
29
+ },
30
+
31
+ title: {},
32
+ p: {}
33
+ }
package/src/index.js CHANGED
@@ -6,6 +6,7 @@ export * from '@symbo.ls/init'
6
6
 
7
7
  export * from './styles'
8
8
 
9
+ // atoms
9
10
  export * from './Text'
10
11
  export * from './Block'
11
12
  export * from './Shape'
@@ -18,12 +19,14 @@ export * from './Position'
18
19
  export * from './Overflow'
19
20
  export * from './Transform'
20
21
  export * from './Timing'
22
+
21
23
  export * from './Media'
22
24
  export * from './Interaction'
23
25
  export * from './XYZ'
24
26
 
25
27
  export * from './Box'
26
28
 
29
+ // atoms
27
30
  export * from './SVG'
28
31
  export * from './Icon'
29
32
  export * from './Img'
@@ -33,6 +36,7 @@ export * from './Input'
33
36
  export * from './Field'
34
37
  export * from './Button'
35
38
 
39
+ // components
36
40
  export * from './ButtonSet'
37
41
  export * from './User'
38
42
  export * from './Banner'
@@ -1,13 +0,0 @@
1
- 'use strict'
2
-
3
- import Shape from '../Shape'
4
-
5
- import style from './style'
6
-
7
- export const Tooltip = {
8
- style,
9
- extend: Shape,
10
- props: { theme: 'purple2' },
11
- caption: 'And tooltip is coming',
12
- span: 'and winter too'
13
- }
@@ -1,12 +0,0 @@
1
- 'use strict'
2
-
3
- export default {
4
- textAlign: 'center',
5
- padding: '1.2em',
6
- caption: {
7
- whiteSpace: 'nowrap'
8
- },
9
- span: {
10
- opacity: '.5'
11
- }
12
- }