@symbo.ls/preview 0.0.86 → 0.0.88

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
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/preview",
3
3
  "description": "",
4
4
  "author": "",
5
- "version": "0.0.86",
5
+ "version": "0.0.88",
6
6
  "repository": "https://github.com/rackai/editor",
7
7
  "main": "src/index.js",
8
8
  "scripts": {
@@ -3,6 +3,22 @@
3
3
  import { Link, ClickableItem, TooltipParent } from '@symbo.ls/components'
4
4
  import { Flex, SquareButton } from 'smbls'
5
5
 
6
+ const setTooltipPosition = (el, s, options = {}) => {
7
+ const key = parseInt(el.key)
8
+ const rowHeight = `(var(--spacing-C) + var(--spacing-B1) + ${key}%)`
9
+ const translateY = `calc(${rowHeight} * ${key} + var(--spacing-Y2))`
10
+ const transform = `translate3d(0%, ${translateY}, 1px)`
11
+ const Tooltip = el.lookup('Tooltip')
12
+ if (Tooltip.setProps) {
13
+ Tooltip.setProps({
14
+ opacity: options.visible && '1',
15
+ visibility: options.visible && 'visible',
16
+ text: s.title,
17
+ transform
18
+ })
19
+ }
20
+ }
21
+
6
22
  export const NavbarButton = {
7
23
  extend: [ClickableItem, Link, SquareButton, TooltipParent],
8
24
 
@@ -11,16 +27,30 @@ export const NavbarButton = {
11
27
  active: window.location.pathname.includes(state.href),
12
28
  isActive: window.location.pathname.includes(state.href),
13
29
  theme: null,
14
- position: 'relative',
15
- style: {
16
- '&:hover, &:focus-visible': {
17
- '& [tooltip]': {
18
- transform: 'translate3d(0%,-50%,0)'
19
- }
30
+ position: 'relative'
31
+ }),
32
+
33
+ on: {
34
+ update: (el, s) => {
35
+ const active = window.location.pathname.includes(s.href)
36
+ if (active) setTooltipPosition(el, s)
37
+ },
38
+ mouseover: (ev, el, s) => {
39
+ if (!s.hover) {
40
+ s.hover = true
41
+ setTooltipPosition(el, s, { visible: true })
42
+ }
43
+ },
44
+ mouseleave: (ev, el, s) => {
45
+ if (s.hover) {
46
+ s.hover = false
47
+ el.lookup('Tooltip').setProps({
48
+ opacity: '0',
49
+ visibility: 'hidden'
50
+ })
20
51
  }
21
52
  }
22
- })
23
-
53
+ }
24
54
  }
25
55
 
26
56
  export const DesignSystemNavbar = {
@@ -29,6 +59,7 @@ export const DesignSystemNavbar = {
29
59
  props: {
30
60
  position: 'sticky',
31
61
  top: 'E',
62
+ zIndex: 1001,
32
63
 
33
64
  nav: {
34
65
  gap: 'B1',
@@ -44,27 +75,27 @@ export const DesignSystemNavbar = {
44
75
  childExtend: NavbarButton
45
76
  },
46
77
 
47
- Tooltip: ({ state }) => ({
48
- background: 'gray0 .95',
49
- position: 'absolute',
50
- pointerEvents: 'none',
51
- top: '50%',
52
- left: '100%',
53
- shape: 'rectangle',
54
- shapeDirection: null,
55
- padding: 'X2 Z1',
56
- transform: 'translate3d(5%, -50%, 0)',
57
- opacity: '0',
58
- visibility: 'hidden',
59
- transition: 'B defaultBezier',
60
- transitionProperty: 'opacity, transform',
61
- textAlign: 'start',
62
- zIndex: 9999,
63
- lineHeight: 1,
64
- title: {
65
- fontSize: 'Z',
66
- text: state.tooltip
78
+ Tooltip: {
79
+ props: {
80
+ background: 'gray0 .95',
81
+ position: 'absolute',
82
+ pointerEvents: 'none',
83
+ top: '0',
84
+ left: '100%',
85
+ shape: 'rectangle',
86
+ shapeDirection: null,
87
+ padding: 'X2 Z1',
88
+ transform: 'translate3d(5%, -50%, 0)',
89
+ opacity: '0',
90
+ visibility: 'hidden',
91
+ transition: 'C defaultBezier, C defaultBezier, B defaultBezier',
92
+ transitionProperty: 'opacity, visibility, transform',
93
+ textAlign: 'start',
94
+ zIndex: 99999,
95
+ lineHeight: 1,
96
+ title: { fontSize: 'Z' }
67
97
  },
68
- p: { text: null }
69
- })
98
+ title: null,
99
+ p: null
100
+ }
70
101
  }
@@ -73,7 +73,7 @@ export const ChoosableButton = {
73
73
  })
74
74
  }
75
75
 
76
- const DotForPropButton = {
76
+ export const DotForPropButton = {
77
77
  props: (el) => {
78
78
  const { table, row, property: direction } = getStateTree(el)
79
79
  const property = direction.parent
@@ -94,10 +94,10 @@ const DotForPropButton = {
94
94
  isRadius,
95
95
 
96
96
  '!isRadius': {
97
- ':nth-child(1)': { left: '50%', top: 'W' },
98
- ':nth-child(2)': { right: 'W', top: '50%' },
99
- ':nth-child(3)': { left: '50%', bottom: 'W' },
100
- ':nth-child(4)': { left: 'W', top: '50%' }
97
+ ':nth-child(1)': { left: '45%', top: 'W' },
98
+ ':nth-child(2)': { right: 'W', top: '45%' },
99
+ ':nth-child(3)': { left: '45%', bottom: 'W' },
100
+ ':nth-child(4)': { left: 'W', top: '45%' }
101
101
  },
102
102
 
103
103
  '.isRadius': {
@@ -110,6 +110,24 @@ const DotForPropButton = {
110
110
  }
111
111
  }
112
112
 
113
+ export const DotForRowButton = {
114
+ extend: DotForPropButton,
115
+ props: ({ state }) => {
116
+ const direction = state
117
+ const property = direction.parent
118
+ const row = property.parent
119
+ const table = row.parent
120
+
121
+ const propKey = diffPropValue(property.value, direction.value)
122
+ const active = table.props[propKey] === row.key
123
+
124
+ return {
125
+ hide: !active,
126
+ background: 'blue .65'
127
+ }
128
+ }
129
+ }
130
+
113
131
  export const SpacingPropButton = {
114
132
  extend: [ChoosableButton, DropdownParent, WiderButton],
115
133
 
@@ -119,7 +137,6 @@ export const SpacingPropButton = {
119
137
  const active = table.props[propValue] === (row && row.key)
120
138
  return {
121
139
  active,
122
- lazyLoad: true,
123
140
  icon: { name: property.value },
124
141
 
125
142
  '.active': {
@@ -1,13 +1,17 @@
1
1
  'use strict'
2
2
 
3
3
  import {
4
+ Icon,
4
5
  Grid,
5
6
  Pseudo,
6
7
  mapSequence,
7
8
  sortSequence
8
9
  } from '@symbo.ls/components'
9
10
 
10
- import buttons from '../pages/Spaces/buttons'
11
+ import buttons, { setRowButtons } from '../pages/Spaces/buttons'
12
+ import { DotForRowButton, SpacingPropButton } from './SpacingPropButton'
13
+
14
+ const DotsInButton = SpacingPropButton.dots
11
15
 
12
16
  const Cell = {
13
17
  tag: 'div',
@@ -85,10 +89,13 @@ const Row = {
85
89
  }
86
90
  },
87
91
  buttons: {
88
- display: 'flex',
92
+ columns: 'repeat(7, var(--spacing-B2))',
93
+ rows: 'var(--spacing-B2)',
94
+ position: 'relative',
89
95
  gap: '.2em',
90
96
  opacity: '1',
91
- boxSizing: 'content-box'
97
+ boxSizing: 'content-box',
98
+ margin: '0 0 0 -1.9em'
92
99
  }
93
100
  }),
94
101
 
@@ -98,7 +105,75 @@ const Row = {
98
105
  em: {},
99
106
  decimal: {},
100
107
  px: {},
101
- buttons: {},
108
+ buttons: {
109
+ extend: Grid,
110
+
111
+ childExtend: {
112
+ props: ({ state }) => {
113
+ const property = state
114
+ const row = property.parent
115
+ const table = row.parent
116
+
117
+ const propKey = property.value
118
+
119
+ const active = Object.keys(table.props).filter(prop => {
120
+ const hasProp = prop.toLowerCase().includes(propKey.toLowerCase())
121
+ const keyMathes = table.props[prop] === row.key
122
+ return hasProp && keyMathes
123
+ }).length
124
+
125
+ return {
126
+ active: !!active,
127
+ position: 'relative',
128
+ round: 'Z',
129
+ display: 'flex',
130
+
131
+ icon: {
132
+ name: propKey,
133
+ opacity: '0',
134
+ color: 'gray5',
135
+ margin: 'auto'
136
+ },
137
+
138
+ '.active': {
139
+ boxShadow: '0, 0, 0, 3px, gray1, inset'
140
+ }
141
+ }
142
+ },
143
+
144
+ icon: {
145
+ extend: Icon,
146
+ props: ({ state }) => {
147
+ const property = state
148
+ const row = property.parent
149
+ const table = row.parent
150
+
151
+ const propKey = property.value
152
+ const middleActive = table.props[propKey] === row.key
153
+
154
+ const active = Object.keys(table.props).filter(prop => {
155
+ const hasProp = prop.toLowerCase().includes(propKey.toLowerCase())
156
+ const keyMathes = table.props[prop] === row.key
157
+ return hasProp && keyMathes
158
+ }).length
159
+
160
+ return {
161
+ active,
162
+ middleActive,
163
+ '.active': { opacity: '1' },
164
+ '.middleActive': { color: 'blue' }
165
+ }
166
+ }
167
+ },
168
+
169
+ dots: {
170
+ childExtend: DotForRowButton,
171
+ $setStateCollection: DotsInButton.$setStateCollection
172
+ }
173
+ },
174
+
175
+ $setStateCollection: setRowButtons
176
+ },
102
177
  graph: { line: {} },
103
178
 
104
179
  overlay: {
@@ -25,16 +25,16 @@ import {
25
25
 
26
26
  const NAV = [{
27
27
  state: {
28
- href: '/colors',
29
- tooltip: 'Colors'
28
+ title: 'Colors',
29
+ href: '/colors'
30
30
  },
31
31
  props: {
32
32
  icon: { name: 'color outline colored' }
33
33
  }
34
34
  }, {
35
35
  state: {
36
- href: '/typography',
37
- tooltip: 'Typography'
36
+ title: 'Typography',
37
+ href: '/typography'
38
38
  },
39
39
  props: {
40
40
  icon: { name: 'typography outline' },
@@ -42,8 +42,8 @@ const NAV = [{
42
42
  }
43
43
  }, {
44
44
  state: {
45
- href: '/space',
46
- tooltip: 'Spacing'
45
+ title: 'Spacing',
46
+ href: '/space'
47
47
  },
48
48
  props: {
49
49
  icon: { name: 'space outline' },
@@ -51,16 +51,16 @@ const NAV = [{
51
51
  }
52
52
  }, {
53
53
  state: {
54
- href: '/shape',
55
- tooltip: 'Shapes'
54
+ title: 'Shapes',
55
+ href: '/shape'
56
56
  },
57
57
  props: {
58
58
  icon: { name: 'shape outline colored' }
59
59
  }
60
60
  }, {
61
61
  state: {
62
- href: '/icons',
63
- tooltip: 'Icons'
62
+ title: 'Icons',
63
+ href: '/icons'
64
64
  },
65
65
  props: {
66
66
  icon: { name: 'icons outline colored' },
@@ -70,8 +70,8 @@ const NAV = [{
70
70
  }
71
71
  }, {
72
72
  state: {
73
- href: '/media-query',
74
- tooltip: 'Responsive'
73
+ title: 'Responsive',
74
+ href: '/media-query'
75
75
  },
76
76
  props: {
77
77
  icon: { name: 'device mobile half fill' },
@@ -79,8 +79,8 @@ const NAV = [{
79
79
  }
80
80
  }, {
81
81
  state: {
82
- href: '/fonts',
83
- tooltip: 'Fonts'
82
+ title: 'Fonts',
83
+ href: '/fonts'
84
84
  },
85
85
  props: {
86
86
  icon: { name: 'fontFace colored' },
@@ -88,16 +88,16 @@ const NAV = [{
88
88
  }
89
89
  }, {
90
90
  state: {
91
- href: '/timing',
92
- tooltip: 'Timing'
91
+ title: 'Timing',
92
+ href: '/timing'
93
93
  },
94
94
  props: {
95
95
  icon: { name: 'clock colored' }
96
96
  }
97
97
  }, {
98
98
  state: {
99
- href: '/sequence',
100
- tooltip: 'Sequence'
99
+ title: 'Sequence',
100
+ href: '/sequence'
101
101
  },
102
102
  props: {
103
103
  icon: { name: 'sequence colored' }
@@ -3,6 +3,19 @@
3
3
  import { Flex } from '@symbo.ls/components'
4
4
  import { SpacingPropButton, SPACING_BUTTONS } from '../../components'
5
5
 
6
+ export const setTableButtons = ({ state }) =>
7
+ Object.keys(SPACING_BUTTONS).filter(v => {
8
+ const rowState = state.sequence[state.selectedKey]
9
+ const { maxValue } = SPACING_BUTTONS[v]
10
+ return maxValue ? maxValue > (rowState && rowState.val) : true
11
+ })
12
+
13
+ export const setRowButtons = ({ state }) =>
14
+ Object.keys(SPACING_BUTTONS).filter(v => {
15
+ const { maxValue } = SPACING_BUTTONS[v]
16
+ return maxValue ? maxValue > state.val : true
17
+ })
18
+
6
19
  export default {
7
20
  extend: Flex,
8
21
 
@@ -11,11 +24,10 @@ export default {
11
24
  left: 'G3',
12
25
  gap: 'X',
13
26
  top: 'Y',
14
- lazyLoad: true,
15
27
  height: 'B2',
16
28
  zIndex: 99,
17
29
  boxSizing: 'content-box',
18
- padding: '- - C2',
30
+ padding: '- - E',
19
31
  transition: 'C ease-out',
20
32
  transitionProperty: 'transform, opacity',
21
33
  opacity: '0',
@@ -25,11 +37,5 @@ export default {
25
37
 
26
38
  childExtend: SpacingPropButton,
27
39
 
28
- $setStateCollection: ({ props, state }) =>
29
- Object.keys(SPACING_BUTTONS).filter(v => {
30
- const rowState = state.sequence[state.selectedKey]
31
- const { maxValue } = SPACING_BUTTONS[v]
32
- return maxValue ? maxValue > rowState && rowState.val : true
33
- }
34
- )
40
+ $setStateCollection: setTableButtons
35
41
  }