smbls 0.6.22 → 0.8.3

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.
Files changed (54) hide show
  1. package/README.md +25 -0
  2. package/package.json +24 -36
  3. package/src/Banner/index.js +24 -0
  4. package/src/Banner/style.js +27 -0
  5. package/src/Block/index.js +95 -0
  6. package/src/Block/style.js +1 -0
  7. package/src/Box/index.js +10 -0
  8. package/src/Button/index.js +54 -0
  9. package/src/Button/style.js +13 -0
  10. package/src/ButtonSet/index.js +14 -0
  11. package/src/DatePicker/index.js +115 -0
  12. package/src/DatePicker/style.js +100 -0
  13. package/src/Direction/index.js +10 -0
  14. package/src/Dropdown/index.js +42 -0
  15. package/src/Dropdown/style.js +37 -0
  16. package/src/Field/index.js +21 -0
  17. package/src/Field/style.js +30 -0
  18. package/src/Flex/index.js +20 -0
  19. package/src/Flex/style.js +5 -0
  20. package/src/Grid/index.js +18 -0
  21. package/src/Grid/style.js +5 -0
  22. package/src/GridLayouts/index.js +20 -0
  23. package/src/GridLayouts/style.js +47 -0
  24. package/src/Icon/index.js +14 -0
  25. package/src/Icon/style.js +8 -0
  26. package/src/IconText/index.js +18 -0
  27. package/src/IconText/style.js +12 -0
  28. package/src/Img/index.js +17 -0
  29. package/src/Input/index.js +32 -0
  30. package/src/Label/index.js +20 -0
  31. package/src/Link/index.js +19 -0
  32. package/src/Notification/index.js +37 -0
  33. package/src/Overflow/index.js +7 -0
  34. package/src/Pills/index.js +30 -0
  35. package/src/Position/index.js +27 -0
  36. package/src/Responsive/index.js +48 -0
  37. package/src/SVG/index.js +14 -0
  38. package/src/Select/index.js +24 -0
  39. package/src/Select/style.js +8 -0
  40. package/src/Shape/index.js +66 -0
  41. package/src/Shape/style.js +102 -0
  42. package/src/SideBar/index.js +22 -0
  43. package/src/Slider/index.js +89 -0
  44. package/src/Slider/style.js +19 -0
  45. package/src/Text/index.js +18 -0
  46. package/src/Text/style.js +2 -0
  47. package/src/Tooltip/index.js +13 -0
  48. package/src/Tooltip/style.js +12 -0
  49. package/src/Transform/index.js +9 -0
  50. package/src/User/index.js +25 -0
  51. package/src/User/style.js +19 -0
  52. package/src/index.js +39 -0
  53. package/src/styles.js +7 -0
  54. package/index.js +0 -37
@@ -0,0 +1,30 @@
1
+ 'use strict'
2
+
3
+ import { TYPOGRAPHY } from '@symbo.ls/scratch'
4
+
5
+ const primaryFont = Object.keys(TYPOGRAPHY)[0]
6
+ const defaultFont = primaryFont || '--system-default'
7
+
8
+ export default {
9
+ appearance: 'none',
10
+ outline: 0,
11
+ border: 'none',
12
+ cursor: 'pointer',
13
+ fontFamily: 'inherit',
14
+ boxSizing: 'border-box',
15
+ position: 'relative',
16
+ padding: 0,
17
+
18
+ width: '16em',
19
+
20
+ input: {
21
+ width: '100%',
22
+ height: '100%',
23
+ border: 'none'
24
+ },
25
+
26
+ svg: {
27
+ position: 'absolute',
28
+ right: '1em'
29
+ }
30
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+ import style from './style'
4
+ import { mapBasedOnRatio } from '../Block'
5
+
6
+ export const Flex = {
7
+ style,
8
+
9
+ props: {
10
+ flow: 'row'
11
+ },
12
+
13
+ class: {
14
+ flow: ({ props }) => ({ flexFlow: props.flow }),
15
+ flexDirection: ({ props }) => ({ flexDirection: props.flexDirection }),
16
+ alignItems: ({ props }) => ({ alignItems: props.alignItems }),
17
+ justifyContent: ({ props }) => ({ justifyContent: props.justifyContent }),
18
+ gap: ({ props }) => mapBasedOnRatio(props, 'gap')
19
+ }
20
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ display: 'flex'
5
+ }
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ import style from './style'
4
+ import { mapBasedOnRatio } from '../Block'
5
+
6
+ export const Grid = {
7
+ style,
8
+
9
+ props: {},
10
+
11
+ class: {
12
+ columns: ({ props }) => ({ gridTemplateColumns: props.columns }),
13
+ rows: ({ props }) => ({ gridTemplateRows: props.rows }),
14
+ gap: ({ props }) => mapBasedOnRatio(props, 'gap'),
15
+ columnGap: ({ props }) => mapBasedOnRatio(props, 'columnGap'),
16
+ rowGap: ({ props }) => mapBasedOnRatio(props, 'rowGap')
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ display: 'grid'
5
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+
3
+ import { Button, Link } from '..'
4
+
5
+ import { styleGrid, styleGrid2 } from './style'
6
+
7
+ const componentLink = {
8
+ proto: Link,
9
+ attr: {
10
+ href: '#'
11
+ }
12
+ }
13
+
14
+ export const grid = {
15
+ style: styleGrid
16
+ }
17
+
18
+ export const grid2 = {
19
+ style: styleGrid2
20
+ }
@@ -0,0 +1,47 @@
1
+ 'use strict'
2
+
3
+ export const styleGrid = {
4
+ display: 'grid',
5
+ gridTemplateColumns: 'repeat(15, 1fr)',
6
+ boxSizing: 'border-box',
7
+ padding: '0 8em',
8
+ marginBottom: '2em',
9
+ rowGap: '10px',
10
+ gridAutoColumns: 'auto',
11
+ gridAutoRows: 'auto',
12
+ gridAutoFlow: 'column',
13
+ '> a': {
14
+ padding: '70px 0',
15
+ display: 'flex',
16
+ justifyContent: 'center',
17
+ background: 'rgba(255, 255, 255, .05)',
18
+ borderRadius: '12px',
19
+ alignItems: 'center'
20
+ },
21
+ '> a:first-child': {
22
+ gridColumn: '1 / span 15'
23
+ },
24
+ '> a:nth-child(2)': {
25
+ gridRow: '2',
26
+ gridColumn: '1 / span 3',
27
+ marginRight: '10px'
28
+ },
29
+ '> a:nth-child(3)': {
30
+ gridRow: '2',
31
+ gridColumn: '4 / span 6',
32
+ marginRight: '10px'
33
+ },
34
+ '> a:nth-child(4)': {
35
+ gridRow: '2',
36
+ gridColumn: '10 / span 15'
37
+ },
38
+ '> a:nth-child(5)': {
39
+ gridRow: '3',
40
+ gridColumn: '1 / span 6',
41
+ marginRight: '10px'
42
+ },
43
+ '> a:nth-child(6)': {
44
+ gridRow: '3',
45
+ gridColumn: '7 / span 15'
46
+ }
47
+ }
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ import style from './style'
4
+
5
+ import { SVG } from '..'
6
+
7
+ export const Icon = {
8
+ proto: SVG,
9
+ style,
10
+ define: { name: param => param },
11
+ name: ({ props }) => props.icon,
12
+ attr: { viewBox: '0 0 24 24' },
13
+ src: ({ key, name }) => name || key || 'noIcon'
14
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ width: '1em',
5
+ height: '1em',
6
+ fill: 'currentColor',
7
+ display: 'inline-block'
8
+ }
@@ -0,0 +1,18 @@
1
+ 'use strict'
2
+
3
+ import style from './style'
4
+
5
+ import { Icon, Text, Direction, Block } from '../'
6
+ import { } from '../Flex'
7
+
8
+ export const IconText = {
9
+ style,
10
+
11
+ props: {
12
+ flexAlign: 'center flex-start'
13
+ },
14
+
15
+ icon: { proto: Icon, if: ({ parent }) => parent.props.icon, props: ({ parent }) => ({ icon: parent.props.icon }) },
16
+
17
+ text: ({ props }) => props.text
18
+ }
@@ -0,0 +1,12 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ display: 'flex',
5
+ alignItems: 'center',
6
+ alignContent: 'center',
7
+ lineHeight: 1,
8
+
9
+ '> svg': {
10
+ // marginInlineEnd: `${0.35}em`
11
+ }
12
+ }
@@ -0,0 +1,17 @@
1
+ 'use strict'
2
+
3
+ export const Img = {
4
+ tag: 'img',
5
+
6
+ props: {
7
+ src: '',
8
+ alt: '',
9
+ title: ''
10
+ },
11
+
12
+ attr: {
13
+ src: ({ props }) => props.src,
14
+ alt: ({ props }) => props.alt,
15
+ title: ({ props }) => props.title || props.alt
16
+ }
17
+ }
@@ -0,0 +1,32 @@
1
+ 'use strict'
2
+
3
+ import { Box } from '..'
4
+
5
+ export const Input = {
6
+ proto: Box,
7
+ tag: 'input',
8
+
9
+ props: {
10
+ type: 'input',
11
+ // value: s[el.key],
12
+ // placeholder: '',
13
+ round: 'C',
14
+ padding: 'A B',
15
+ theme: 'transparent'
16
+ },
17
+
18
+ attr: {
19
+ placeholder: ({ props }) => props.placeholder,
20
+ value: ({ props }) => props.value,
21
+ disabled: ({ props }) => props.disabled || null,
22
+ readonly: ({ props }) => props.readonly,
23
+ required: ({ props }) => props.required,
24
+ type: ({ props }) => props.type
25
+ },
26
+
27
+ on: {
28
+ input: ({ key, value, props }) => {
29
+
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ 'use strict'
2
+ import { Block } from '../Block'
3
+ import { Shape } from '../Shape'
4
+ import { Text } from '../Text'
5
+
6
+ export const Label = {
7
+ proto: [Shape, Block, Text],
8
+
9
+ style: { lineHeight: 1 },
10
+
11
+ props: {
12
+ emoji: '👍',
13
+ text: '3',
14
+ padding: 'X2 Z',
15
+ round: 'C',
16
+ depth: 16
17
+ },
18
+
19
+ emoji: ({ props }) => props.emoji
20
+ }
@@ -0,0 +1,19 @@
1
+ 'use strict'
2
+
3
+ import { Shape, Text } from '..'
4
+
5
+ export const Link = {
6
+ proto: [Shape, Text],
7
+ tag: 'a',
8
+ props: {
9
+ href: '',
10
+ target: '',
11
+ theme: 'link',
12
+ aria: {}
13
+ },
14
+ attr: {
15
+ href: ({ props }) => props.href,
16
+ target: ({ props }) => props.target,
17
+ 'aria-label': ({ props }) => props.aria.label || props.text
18
+ }
19
+ }
@@ -0,0 +1,37 @@
1
+ 'use strict'
2
+
3
+ import { Shape, Block, IconText, Direction, Flex, Text } from '../'
4
+
5
+ export const Notification = {
6
+ style: { cursor: 'pointer' },
7
+ proto: [Shape, Block, Direction, Flex],
8
+ icon: {
9
+ proto: [IconText],
10
+ props: {
11
+ icon: 'info'
12
+ },
13
+ style: {
14
+ width: 'fit-content',
15
+ height: 'fit-content'
16
+ }
17
+ },
18
+ article: {
19
+ proto: [Flex],
20
+ style: {
21
+ flexDirection: 'column',
22
+ alignItems: 'flex-start'
23
+ },
24
+ caption: {
25
+ proto: Text,
26
+ text: 'Notification'
27
+ },
28
+ p: {
29
+ proto: Text,
30
+ props: {
31
+ fontSize: 'Z',
32
+ text: 'is not always a distraction'
33
+ },
34
+ style: { margin: 0 }
35
+ }
36
+ }
37
+ }
@@ -0,0 +1,7 @@
1
+ 'use strict'
2
+
3
+ export const Overflow = {
4
+ class: {
5
+ overflow: ({ props }) => ({ overflow: props.overflow }),
6
+ }
7
+ }
@@ -0,0 +1,30 @@
1
+ 'use strict'
2
+ import Shape from '../Shape'
3
+
4
+ export const Pills = {
5
+ style: {
6
+ display: 'flex',
7
+ div: {
8
+ width: '6px',
9
+ height: '6px',
10
+ background: 'white'
11
+ },
12
+ 'div:not(:last-child)': {
13
+ marginRight: '10px'
14
+ },
15
+ 'div:first-child': { opacity: '.5' },
16
+ 'div:nth-child(2)': { opacity: '.3' },
17
+ 'div:nth-child(3)': { opacity: '.3' }
18
+ },
19
+ childProto: {
20
+ tag: 'div',
21
+ proto: Shape,
22
+ props: {
23
+ round: 42,
24
+ theme: 'White'
25
+ }
26
+ },
27
+ ...[
28
+ {}, {}, {}
29
+ ]
30
+ }
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ import { mapSpacing } from '@symbo.ls/scratch'
4
+
5
+ export const Position = {
6
+ props: {},
7
+
8
+ class: {
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
+ }
20
+ },
21
+
22
+ left: ({ props }) => mapSpacing(props.left, 'left'),
23
+ top: ({ props }) => mapSpacing(props.top, 'top'),
24
+ right: ({ props }) => mapSpacing(props.right, 'right'),
25
+ bottom: ({ props }) => mapSpacing(props.bottom, 'bottom')
26
+ }
27
+ }
@@ -0,0 +1,48 @@
1
+ 'use strict'
2
+
3
+ import { RESPONSIVE } from '@symbo.ls/scratch'
4
+
5
+ export const Responsive = {
6
+ on: {
7
+ init: (el, s) => {
8
+ const { props } = el
9
+
10
+ // Object.keys(props)
11
+ // .filter(v => v.slice(0, 1) === '@')
12
+ // .map()
13
+
14
+ for (const screen in props) {
15
+ if (screen.slice(0, 1) === '@') {
16
+ const screenName = screen.slice(1)
17
+ const responsiveKey = `@media screen and ${RESPONSIVE[screenName]}`
18
+ const screenProps = props[screen]
19
+ const calculatedScreenProps = {}
20
+
21
+ for (const prop in screenProps) {
22
+ // if (!el.class || !el.class[prop]) return
23
+ // const classProp = el.class[prop]
24
+ const classProp = el.class[prop]
25
+ if (typeof classProp !== 'function') continue
26
+ let calculatedProp = classProp({ props: screenProps })
27
+
28
+ if (Array.isArray(calculatedProp)) {
29
+ calculatedProp = Object.assign({}, ...calculatedProp)
30
+ }
31
+
32
+ for (const finalProp in calculatedProp) {
33
+ calculatedScreenProps[finalProp] = calculatedProp[finalProp]
34
+ }
35
+ }
36
+
37
+ const { responsive } = el.class
38
+ if (responsive) responsive[responsiveKey] = calculatedScreenProps
39
+ else {
40
+ el.class.responsive = {
41
+ [responsiveKey]: calculatedScreenProps
42
+ }
43
+ }
44
+ }
45
+ }
46
+ }
47
+ }
48
+ }
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+
3
+ var useSVGSymbol = file => `<use xlink:href="${file}" />`
4
+
5
+ // create icon
6
+ export const SVG = {
7
+ tag: 'svg',
8
+ attr: {
9
+ xmlns: 'http://www.w3.org/2000/svg',
10
+ 'xmlns:xlink': 'http://www.w3.org/1999/xlink'
11
+ },
12
+ define: { src: param => param },
13
+ html: ({ key, src, props }) => useSVGSymbol(props.src || src || key)
14
+ }
@@ -0,0 +1,24 @@
1
+ 'use strict'
2
+
3
+ import Shape from '../Shape'
4
+ import style from './style'
5
+
6
+ export const Select = {
7
+ proto: Shape,
8
+ tag: 'select',
9
+ style,
10
+
11
+ childProto: {
12
+ tag: 'option',
13
+ props: {
14
+ value: '',
15
+ selected: '',
16
+ disabled: ''
17
+ },
18
+ attr: {
19
+ value: ({ props }) => props.value,
20
+ selected: ({ props }) => props.selected,
21
+ disabled: ({ props }) => props.disabled
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ 'use strict'
2
+
3
+ export default {
4
+ border: 'none',
5
+ boxSizing: 'border-box',
6
+ cursor: 'pointer',
7
+ fontSize: '1em'
8
+ }
@@ -0,0 +1,66 @@
1
+ 'use strict'
2
+
3
+ import { mapSpacing, getTheme, getColor } from '@symbo.ls/scratch'
4
+
5
+ import style, { shape, depth } from './style'
6
+
7
+ const isBorderStyle = str =>
8
+ ['none','hidden','dotted','dashed','solid','double','groove','ridge','inset','outset','initial'].some(v => str.includes(v))
9
+
10
+ const diffBorder = (border, key = 'border') => {
11
+ const obj = {}
12
+ const arr = border.split(' ')
13
+ arr.map(v => {
14
+ if (v.includes('px')) obj[`${key}Width`] = v
15
+ else if (isBorderStyle(v)) obj[`${key}Style`] = v || 'solid'
16
+ else if (getColor(v)) obj[`${key}Color`] = getColor(v)
17
+ })
18
+ return obj
19
+ }
20
+
21
+ export const Shape = {
22
+ class: {
23
+ default: style,
24
+ shape: ({ props }) => props.shape ? shape[props.shape] : null,
25
+ shapeDirection: ({ props }) => props.shape ? shape[props.shape][props.shapeDirection || 'top'] : null,
26
+ shapeDirectionColor: ({ props, ...el }) => props.shapeDirection ? { '&:before': { borderColor: el.class.backgroundColor } } : null,
27
+ depth: ({ props }) => depth[props.depth],
28
+ round: ({ props, key, ...el }) => props.round ? (mapSpacing(props.round, 'borderRadius') || ({ borderRadius: props.round })) : null,
29
+ theme: ({ props }) => props.theme ? getTheme(props.theme) : null,
30
+ color: ({ props }) => props.color ? ({ color: getColor(props.color) }) : null,
31
+ background: ({ props }) => props.background ? ({ backgroundColor: getColor(props.background) }) : null,
32
+ // border: ({ props }) => props.border ? ({ borderColor: getColor(props.border) }) : null,
33
+
34
+ border: ({ props }) => props.border ? diffBorder(props.border) : null,
35
+ borderLeft: ({ props }) => props.borderLeft ? diffBorder(props.borderLeft, 'borderLeft') : null,
36
+ borderTop: ({ props }) => props.borderTop ? diffBorder(props.borderTop, 'borderTop') : null,
37
+ borderRight: ({ props }) => props.borderRight ? diffBorder(props.borderRight, 'borderRight') : null,
38
+ borderBottom: ({ props }) => props.borderBottom ? diffBorder(props.borderBottom, 'borderBottom') : null,
39
+
40
+ opacity: ({ props }) => props.opacity && ({ opacity: props.opacity }),
41
+ visibility: ({ props }) => props.visibility && ({ visibility: props.visibility })
42
+ }
43
+
44
+ // mode: {
45
+ // dark: {
46
+ // theme: 'white'
47
+ // }
48
+ // }
49
+
50
+ // theme: {
51
+ // default: 'primary',
52
+ // dark: 'whiteish'
53
+ // }
54
+
55
+ // size: {
56
+ // default: 'auto',
57
+ // mobile: 'fit'
58
+ // }
59
+
60
+ // padding: {
61
+ // default: ratio.phi,
62
+ // mobile: ratio.perfect
63
+ // }
64
+ }
65
+
66
+ export default Shape
@@ -0,0 +1,102 @@
1
+ 'use strict'
2
+
3
+ import { UNIT } from '@symbo.ls/scratch'
4
+
5
+ export default {
6
+ boxSizing: 'border-box'
7
+ }
8
+
9
+ export const depth = {
10
+ 4: { boxShadow: `rgba(0,0,0,.10) 0 2${UNIT.default} 4${UNIT.default}` },
11
+ 6: { boxShadow: `rgba(0,0,0,.10) 0 3${UNIT.default} 6${UNIT.default}` },
12
+ 10: { boxShadow: `rgba(0,0,0,.10) 0 4${UNIT.default} 10${UNIT.default}` },
13
+ 16: { boxShadow: `rgba(0,0,0,.10) 0 8${UNIT.default} 16${UNIT.default}` },
14
+ 26: { boxShadow: `rgba(0,0,0,.10) 0 14${UNIT.default} 26${UNIT.default}` },
15
+ 42: { boxShadow: `rgba(0,0,0,.10) 0 20${UNIT.default} 42${UNIT.default}` }
16
+ }
17
+
18
+ export const shape = {
19
+ rectangle: {},
20
+ circle: { borderRadius: '100%' },
21
+ bubble: {},
22
+ tooltip: {
23
+ position: 'relative',
24
+ '&:before': {
25
+ content: '""',
26
+ display: 'block',
27
+ width: '0px',
28
+ height: '0px',
29
+ border: '6px solid #343434',
30
+ position: 'absolute',
31
+ borderRadius: '2px'
32
+ },
33
+ top: {
34
+ '&:before': {
35
+ top: '2px',
36
+ left: '50%',
37
+ transform: 'translate(-50%, -50%) rotate(45deg)'
38
+ }
39
+ },
40
+ right: {
41
+ '&:before': {
42
+ top: '50%',
43
+ right: '-10px',
44
+ transform: 'translate(-50%, -50%) rotate(45deg)'
45
+ }
46
+ },
47
+ bottom: {
48
+ '&:before': {
49
+ bottom: '-10px',
50
+ left: '50%',
51
+ transform: 'translate(-50%, -50%) rotate(45deg)'
52
+ }
53
+ },
54
+ left: {
55
+ '&:before': {
56
+ top: '50%',
57
+ left: '2px',
58
+ transform: 'translate(-50%, -50%) rotate(45deg)'
59
+ }
60
+ }
61
+ },
62
+ tag: {
63
+ position: 'relative',
64
+ '&:before': {
65
+ content: '""',
66
+ display: 'block',
67
+ width: '0',
68
+ height: '0',
69
+ border: '16px solid #343434',
70
+ borderRadius: '6px',
71
+ position: 'absolute'
72
+ },
73
+ top: {
74
+ '&:before': {
75
+ bottom: '100%',
76
+ left: '50%',
77
+ transform: 'translate(-50%, 60%) rotate(45deg)'
78
+ }
79
+ },
80
+ right: {
81
+ '&:before': {
82
+ top: '50%',
83
+ left: '100%',
84
+ transform: 'translate(-60%, -50%) rotate(45deg)'
85
+ }
86
+ },
87
+ bottom: {
88
+ '&:before': {
89
+ top: '100%',
90
+ left: '50%',
91
+ transform: 'translate(-50%, -60%) rotate(45deg)'
92
+ }
93
+ },
94
+ left: {
95
+ '&:before': {
96
+ top: '50%',
97
+ right: '100%',
98
+ transform: 'translate(60%, -50%) rotate(45deg)'
99
+ }
100
+ }
101
+ }
102
+ }