@symbo.ls/preview 0.0.81 → 0.0.83

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.81",
5
+ "version": "0.0.83",
6
6
  "repository": "https://github.com/rackai/editor",
7
7
  "main": "src/index.js",
8
8
  "scripts": {
@@ -35,7 +35,7 @@
35
35
  "@symbo.ls/scratch": "latest",
36
36
  "@symbo.ls/temp-db": "^0.0.2",
37
37
  "@symbo.ls/utils": "latest",
38
- "domql": "^1.5.7",
38
+ "domql": "^1.5.35",
39
39
  "showdown": "^2.1.0"
40
40
  },
41
41
  "devDependencies": {
package/src/app.js CHANGED
@@ -12,6 +12,7 @@ import {
12
12
  DesignSystem,
13
13
  Export,
14
14
  Library,
15
+ State,
15
16
  Account
16
17
  } from './pages'
17
18
 
@@ -45,6 +46,7 @@ const App = {
45
46
  '/design-system': DesignSystem,
46
47
  '/components': Components,
47
48
  '/component': Export,
49
+ '/state': State,
48
50
  ...SUB_ROUTES
49
51
  },
50
52
 
@@ -0,0 +1,23 @@
1
+ 'use strict'
2
+
3
+ import { Flex } from '@symbo.ls/components'
4
+
5
+ const props = {
6
+ gap: 'E',
7
+ margin: '- - D1 -',
8
+ childProps: {
9
+ fontSize: 'Z1',
10
+ color: 'gray6',
11
+ maxWidth: `${272 / 14}em`
12
+ }
13
+ }
14
+
15
+ export const ColumnParagraphs = {
16
+ props,
17
+ extend: Flex,
18
+
19
+ childExtend: { tag: 'p' },
20
+ ...[{ props: { text: 'To personalize your Symbols experience, we need to get started with themes' } },
21
+ { props: { text: 'Please fill in the document dark and light themes' } }]
22
+
23
+ }
@@ -0,0 +1,14 @@
1
+ 'use strict'
2
+ import { Button } from '@symbo.ls/components'
3
+
4
+ export const ContinueButton = {
5
+ extend: Button,
6
+ props: {
7
+ text: 'Continue',
8
+ fontSize: 'Z2',
9
+ padding: 'Z1 C',
10
+ background: 'linear-gradient(to top, rgba(50, 114, 184, .2), rgba(0, 121, 253, .27), rgba(0, 121, 253, .27))',
11
+ color: 'white',
12
+ fontWeight: '500'
13
+ }
14
+ }
@@ -35,7 +35,7 @@ export const InitPage = {
35
35
  position: 'absolute',
36
36
  fontSize: 'A1',
37
37
  top: '0',
38
- right: '102%',
38
+ right: '102.5%',
39
39
  icon: 'arrow angle left'
40
40
  }
41
41
  }
@@ -0,0 +1,114 @@
1
+ 'use strict'
2
+
3
+ import {
4
+ Dropdown,
5
+ GridInDropdown
6
+ } from '@symbo.ls/components'
7
+
8
+ import {
9
+ ChoosableButton,
10
+ diffIconTypes,
11
+ diffPropPosition,
12
+ diffPropValue,
13
+ getStateTree,
14
+ keysOf,
15
+ SPACING_BUTTONS
16
+ } from '.'
17
+
18
+ const ButtonInDropdown = {
19
+ extend: [ChoosableButton],
20
+ props: (element) => {
21
+ const { table, row, property: direction } = getStateTree(element)
22
+ const property = direction.parent
23
+
24
+ const propValue = property.value
25
+ const directionValue = direction.value
26
+
27
+ const activeProperty = SPACING_BUTTONS[property.value]
28
+ const keyLength = Object.keys(activeProperty).length
29
+ const iconKey = diffIconTypes(propValue, directionValue)
30
+
31
+ const active = table.props[propValue] === row?.key
32
+
33
+ const gridArea = keyLength > 3 && diffPropPosition(propValue, directionValue)
34
+
35
+ return {
36
+ active,
37
+ gridArea,
38
+ lazyLoad: true,
39
+ icon: { name: iconKey },
40
+ theme: null,
41
+ '@dark': {
42
+ background: 'transparent 0',
43
+ color: 'gray7',
44
+ ':hover': {
45
+ theme: 'quinary',
46
+ color: 'gray8'
47
+ }
48
+ },
49
+ ':hover': null,
50
+ '.active': {
51
+ theme: null,
52
+ color: 'blue'
53
+ }
54
+ }
55
+ },
56
+ attr: { title: ({ state }) => state.value },
57
+ on: {
58
+ click: (ev, element) => {
59
+ const { table, row, property: direction } = getStateTree(element)
60
+ const property = direction.parent
61
+
62
+ const propKey = diffPropValue(property.value, direction.value)
63
+ const active = table.props[propKey] === row.key
64
+
65
+ if (active) {
66
+ delete table.props[propKey] && table.update()
67
+ } else {
68
+ table.update({ props: { [propKey]: row.key } })
69
+ }
70
+ }
71
+ }
72
+ }
73
+
74
+ export default {
75
+ extend: Dropdown,
76
+
77
+ props: {
78
+ lazyLoad: true,
79
+ minWidth: 'none',
80
+ left: 'auto',
81
+ grid: { gap: '0' }
82
+ },
83
+
84
+ header: { text: ({ state }) => state.value },
85
+
86
+ grid: {
87
+ extend: GridInDropdown,
88
+
89
+ props: ({ state }) => {
90
+ const keys = keysOf(state)
91
+ if (keys.length < 4) {
92
+ return {
93
+ lazyLoad: true,
94
+ columns: 'repeat(4, 1fr)'
95
+ }
96
+ }
97
+ return {
98
+ lazyLoad: true,
99
+ columns: 'auto 32px auto',
100
+ rows: 'auto 32px auto',
101
+ templateAreas: `"endStart blockStart startEnd"
102
+ "inlineStart content inlineEnd"
103
+ "startStart blockEnd endEnd"`
104
+ }
105
+ },
106
+
107
+ childExtend: ButtonInDropdown,
108
+
109
+ $setStateCollection: (element) => {
110
+ const { property } = getStateTree(element)
111
+ return keysOf(property)
112
+ }
113
+ }
114
+ }
@@ -0,0 +1,208 @@
1
+ 'use strict'
2
+
3
+ import { WiderButton, DropdownParent } from '@symbo.ls/components'
4
+
5
+ import dropdown from './dropdown'
6
+
7
+ export const SPACING_BUTTONS = {
8
+ margin: {
9
+ maxValue: 3000,
10
+ blockStart: {},
11
+ inlineEnd: {},
12
+ blockEnd: {},
13
+ inlineStart: {}
14
+ },
15
+ height: {
16
+ minWidth: {},
17
+ maxWidth: {}
18
+ },
19
+ width: {
20
+ minWidth: {},
21
+ maxWidth: {}
22
+ },
23
+ borderWidth: {
24
+ maxValue: 1280,
25
+ blockStartWidth: {},
26
+ inlineEndWidth: {},
27
+ blockEndWidth: {},
28
+ inlineStartWidth: {}
29
+ },
30
+ padding: {
31
+ maxValue: 3000,
32
+ blockStart: {},
33
+ inlineEnd: {},
34
+ blockEnd: {},
35
+ inlineStart: {}
36
+ },
37
+ gap: {
38
+ maxValue: 3000,
39
+ Horizontal: {},
40
+ Vertical: {}
41
+ },
42
+ borderRadius: {
43
+ maxValue: 1280,
44
+ endStart: {},
45
+ startEnd: {},
46
+ endEnd: {},
47
+ startStart: {}
48
+ }
49
+ }
50
+
51
+ export const ChoosableButton = {
52
+ props: ({ key }) => ({
53
+ padding: 'Z',
54
+ icon: key,
55
+ theme: null,
56
+ transition: 'B defaultBezier',
57
+ transitionProperty: 'opacity, background, color',
58
+ '@dark': {
59
+ background: 'gray1',
60
+ color: 'gray5'
61
+ },
62
+ '@light': {
63
+ background: 'white .5',
64
+ color: 'gray7'
65
+ },
66
+ ':hover': {
67
+ theme: 'quaternary',
68
+ '.active': { color: 'blue' }
69
+ },
70
+ '.active': {
71
+ theme: null
72
+ }
73
+ })
74
+ }
75
+
76
+ const DotForPropButton = {
77
+ props: (el) => {
78
+ const { table, row, property: direction } = getStateTree(el)
79
+ const property = direction.parent
80
+
81
+ const propKey = diffPropValue(property.value, direction.value)
82
+ const active = table.props[propKey] === row?.key
83
+
84
+ const isRadius = property.value === 'borderRadius'
85
+
86
+ return {
87
+ position: 'absolute',
88
+ round: '100%',
89
+ background: 'blue',
90
+ boxSize: 'W2',
91
+ lazyLoad: true,
92
+
93
+ hide: !active,
94
+ isRadius,
95
+
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%' }
101
+ },
102
+
103
+ '.isRadius': {
104
+ ':nth-child(1)': { left: 'X2', top: 'X2' },
105
+ ':nth-child(2)': { right: 'X2', top: 'X2' },
106
+ ':nth-child(3)': { right: 'X2', bottom: 'X2' },
107
+ ':nth-child(4)': { left: 'X2', bottom: 'X2' }
108
+ }
109
+ }
110
+ }
111
+ }
112
+
113
+ export const SpacingPropButton = {
114
+ extend: [ChoosableButton, DropdownParent, WiderButton],
115
+
116
+ props: (element) => {
117
+ const { table, row, property } = getStateTree(element)
118
+ const propValue = property.value
119
+ const active = table.props[propValue] === row?.key
120
+ return {
121
+ active,
122
+ lazyLoad: true,
123
+ icon: { name: property.value },
124
+
125
+ '.active': {
126
+ color: 'blue',
127
+ ':hover': { color: 'blue' }
128
+ },
129
+
130
+ style: {
131
+ '&:hover, &:focus-visible': {
132
+ '& [tooltip]': {
133
+ transform: 'translate3d(-50%,0,0)'
134
+ }
135
+ }
136
+ }
137
+ }
138
+ },
139
+
140
+ dots: {
141
+ props: {
142
+ lazyLoad: true,
143
+ position: 'absolute',
144
+ inset: '0 0 0 0'
145
+ },
146
+
147
+ on: {
148
+ click: (ev, el) => {
149
+ const { table, row, property } = getStateTree(el)
150
+ const active = table.props[property.value] === row.key
151
+ if (active) {
152
+ delete table.props[property.value] && table.update()
153
+ } else {
154
+ const allKeys = Object.keys(table.props)
155
+ allKeys.filter(v => {
156
+ const splitInWords = property.value.split(/(?=[A-Z])/)
157
+ return v.includes(splitInWords[0]) && v.includes(splitInWords[1])
158
+ })
159
+ .forEach(v => delete table.props[v])
160
+ table.update({ props: { [property.value]: row.key } })
161
+ }
162
+ }
163
+ },
164
+
165
+ attr: { title: ({ state }) => state.value },
166
+
167
+ childExtend: DotForPropButton,
168
+
169
+ $setStateCollection: ({ state }) => {
170
+ const buttonsByProperty = keysOf(state)
171
+ return buttonsByProperty
172
+ }
173
+ },
174
+
175
+ dropdown
176
+ }
177
+
178
+ export const getStateTree = element => {
179
+ const table = element.lookup('Page').state
180
+ const row = table.sequence[table.selectedKey]
181
+ const property = element.state
182
+
183
+ return { table, row, property }
184
+ }
185
+
186
+ export const jointPropDirection = (parentKey, key) => {
187
+ return parentKey + key.slice(0, 1).toUpperCase() + key.slice(1)
188
+ }
189
+
190
+ export const diffPropValue = (parentKey, key) => {
191
+ if (parentKey.includes('borderWidth')) parentKey = 'border'
192
+ return jointPropDirection(parentKey, key)
193
+ }
194
+
195
+ export const diffPropPosition = (parentKey, key) => {
196
+ if (parentKey.includes('borderWidth')) return key.split('Width')[0]
197
+ return key
198
+ }
199
+
200
+ export const diffIconTypes = (parentKey, key) => {
201
+ if (parentKey.includes('borderWidth')) key = key.split('Width')[0]
202
+ if (parentKey.includes('margin') || parentKey === 'borderWidth') parentKey = 'padding'
203
+ return jointPropDirection(parentKey, key)
204
+ }
205
+
206
+ export const keysOf = state => {
207
+ return Object.keys(SPACING_BUTTONS[state.value]).filter(v => v !== 'maxValue')
208
+ }
@@ -0,0 +1,27 @@
1
+ 'use strict'
2
+
3
+ import { Flex, CommonField, Upload, ClickableItem } from '@symbo.ls/components'
4
+
5
+ export const UploadImage = {
6
+ extend: [CommonField],
7
+ props: {
8
+ title: { text: 'Pick from the picture' },
9
+ element: {
10
+ border: 'none',
11
+ background: 'gray1',
12
+ padding: 'Z A Z Z',
13
+ gap: 'Z',
14
+ flow: 'row',
15
+ icon: { style: { fontSize: '52px' } },
16
+ p: {
17
+ text: 'Upload or drop the image'
18
+ }
19
+ }
20
+ },
21
+ title: {},
22
+ element: {
23
+ extend: [Upload, Flex, ClickableItem],
24
+ icon: { style: { fontSize: '52px' } },
25
+ p: { span: null }
26
+ }
27
+ }
@@ -19,3 +19,6 @@ export * from './ResponsivePreview'
19
19
  export * from './IconsGroup'
20
20
  export * from './FontText'
21
21
  export * from './DesignComponent'
22
+ export * from './ColumnParagrphs'
23
+ export * from './SpacingPropButton'
24
+ export * from './UploadImage'
package/src/index.js CHANGED
@@ -36,7 +36,6 @@ const app = DOM.create({
36
36
  },
37
37
 
38
38
  update: (el, s, changes) => {
39
- console.log(changes)
40
39
  smbls.openModal(el.parent, s)
41
40
  }
42
41
  }
@@ -7,10 +7,7 @@ import themes from './themes'
7
7
  export const Color = {
8
8
  key: 'colors',
9
9
 
10
- props: {
11
- gap: 'A'
12
- // style: { border: '4px solid red' }
13
- },
10
+ props: { gap: 'A' },
14
11
 
15
12
  globalThemes,
16
13
  Line: {},
@@ -1,8 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  import banners from './banners'
4
- import quickstart from './quickstart'
5
4
  import summary from './summary'
5
+ import quickstart from './quickstart'
6
6
 
7
7
  export const DesignSystemDashboard = {
8
8
  ArticleBig: {
@@ -11,6 +11,6 @@ export const DesignSystemDashboard = {
11
11
  },
12
12
 
13
13
  banners,
14
- quickstart,
15
- summary
14
+ summary,
15
+ quickstart
16
16
  }
@@ -24,7 +24,7 @@ export default {
24
24
 
25
25
  SectionHeader: {
26
26
  margin: '- - B2',
27
- title: 'Setting up',
27
+ title: 'Setting up locally',
28
28
  p: 'This is how you initialize Symbols Design System to your local app.'
29
29
  },
30
30
 
@@ -82,7 +82,7 @@ export default {
82
82
  Terminal: {
83
83
  note: { text: 'Sync live changes' },
84
84
  props: {
85
- command: { text: 'smbls sync' }
85
+ command: { text: 'smbls sync --live' }
86
86
  }
87
87
  }
88
88
  }
@@ -124,7 +124,7 @@ export const CreateDocumentTheme = {
124
124
  }
125
125
  },
126
126
 
127
- back: { props: { href: '/init/font' } },
127
+ back: { props: { href: '/init/' } },
128
128
 
129
129
  HeaderHeading: {},
130
130
  paragraphs,
@@ -0,0 +1,145 @@
1
+ 'use strict'
2
+
3
+ import { CommonField, Input, Grid, Flex, ClickableItem } from '@symbo.ls/components'
4
+
5
+ import { InitPage, UploadImage } from '../../components'
6
+
7
+ const fields = {
8
+ extend: Grid,
9
+ props: {
10
+ columns: 'repeat(2, 270px)',
11
+ columnGap: 'C',
12
+ rowGap: 'C2',
13
+ childProps: {
14
+ element: {
15
+ round: 'Y2'
16
+ // padding: '- A'
17
+ // height: 'C',
18
+
19
+ // style: { background: 'rgba(255, 255, 255, .1) !important' },
20
+ // align: 'center space-between',
21
+ }
22
+ }
23
+ },
24
+
25
+ childExtend: {
26
+ extend: CommonField,
27
+ title: {},
28
+ element: { extend: Flex }
29
+ },
30
+
31
+ ...[{
32
+ props: {
33
+ title: { text: 'Name the project' },
34
+ element: { placeholder: 'You name it' }
35
+ },
36
+
37
+ title: {},
38
+ element: { extend: Input, props: { } }
39
+ }, {
40
+ props: {
41
+ title: { text: 'Key' },
42
+ element: {
43
+ extend: Input,
44
+ props: {
45
+ placeholder: 'a-zA-Z0-9'
46
+ },
47
+ Span: {
48
+ position: 'absolute',
49
+ text: '.symbo.ls',
50
+ right: 'A',
51
+ pointerEvents: 'none'
52
+ }
53
+ }
54
+ },
55
+ title: {},
56
+ element: {
57
+ input: { extend: Input },
58
+ span: {}
59
+ }
60
+ }, {
61
+ props: { title: { text: 'URL Access' } },
62
+ title: {},
63
+ element: {
64
+ extend: [ClickableItem],
65
+ Select: {
66
+ props: {
67
+ outline: 'none',
68
+ pointerEvents: 'all',
69
+ appearance: 'none',
70
+ border: 'none',
71
+ width: '100%',
72
+ height: '100%',
73
+ background: 'none',
74
+ color: 'currentColor',
75
+ fontSize: 'A',
76
+ lineHeight: 1,
77
+ padding: 'Z A',
78
+
79
+ name: 'user',
80
+ id: 'user'
81
+ },
82
+ childExtend: { tag: 'option', text: ({ state }) => state.text },
83
+ $setCollection: () => [
84
+ { text: 'Private' },
85
+ { text: 'Public' }
86
+ ],
87
+ on: {
88
+ change: (ev, { parent }) => {
89
+ parent.user.update({ key: ev.target.value })
90
+ }
91
+ }
92
+ }
93
+ }
94
+ }]
95
+ }
96
+
97
+ const uploadImage = {
98
+ extend: UploadImage,
99
+ props: {
100
+ title: { text: 'Project icon' },
101
+ element: {
102
+ flow: 'column',
103
+ width: 'fit-content',
104
+ padding: 'A',
105
+ gap: '0',
106
+ p: {
107
+ text: 'Drag and drop or click',
108
+ maxWidth: 'E',
109
+ textAlign: 'center'
110
+ }
111
+ }
112
+ }
113
+
114
+ }
115
+
116
+ export const Personalize = {
117
+ extend: InitPage,
118
+
119
+ back: null,
120
+
121
+ HeaderHeading: {
122
+ props: { margin: '- - D2 -' },
123
+ Caption: { text: `Let's personalize your Symbols` },
124
+ H1: { text: 'Hi George' }
125
+ },
126
+
127
+ ColumnParagraphs: {
128
+ extend: true,
129
+ ...[
130
+ { props: { text: `In this example we'll initialize a Symbols Design System for you.` } },
131
+ { props: { text: `You can connect Symbols to your app and style it online.` } }
132
+ ]
133
+ },
134
+
135
+ content: {
136
+ extend: Flex,
137
+ props: { gap: 'D1' },
138
+ uploadImage,
139
+ fields
140
+ },
141
+
142
+ ContinueButton: {
143
+ href: '/init/theme'
144
+ }
145
+ }
@@ -1,6 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { Flex } from '@symbo.ls/components'
4
+ import { Personalize } from './Personalize'
4
5
  import { CreateDocumentTheme } from './CreateDocumentTheme'
5
6
  import { CreatePallete } from './CreatePalette'
6
7
  import { FontText } from './FontText'
@@ -18,7 +19,7 @@ export const Init = {
18
19
 
19
20
  define: { routes: param => param },
20
21
  routes: {
21
- '/': CreateDocumentTheme,
22
+ '/': Personalize,
22
23
  '/theme': CreateDocumentTheme,
23
24
  '/pallete': CreatePallete,
24
25
  '/font': FontText,
@@ -21,7 +21,7 @@ const Row = {
21
21
  key: state => state.key,
22
22
 
23
23
  props: ({ state }) => ({
24
- columns: '7ch 20em 14ch 12ch 12ch 1fr',
24
+ columns: '7ch 14ch 12ch 12ch 20em 1fr',
25
25
  alignItems: 'center',
26
26
  isBase: state.index === 0,
27
27
  active: (state.key && state.key.length) === 1,
@@ -29,6 +29,8 @@ const Row = {
29
29
  margin: '0 -A',
30
30
  padding: '0 B',
31
31
  position: 'relative',
32
+ height: 'C+Z',
33
+ transition: 'A defaultBezier background',
32
34
 
33
35
  '.isBase': {
34
36
  opacity: 1,
@@ -68,12 +70,6 @@ const Row = {
68
70
  color: 'gray6',
69
71
  text: state.scaling + 'em'
70
72
  },
71
- buttons: {
72
- display: 'flex',
73
- gap: '.2em',
74
- opacity: '1',
75
- boxSizing: 'content-box'
76
- },
77
73
  graph: {
78
74
  margin: '0 0 0 -B2',
79
75
  line: {
@@ -86,18 +82,55 @@ const Row = {
86
82
  height: '5px'
87
83
  }
88
84
  }
85
+ },
86
+ buttons: {
87
+ display: 'flex',
88
+ gap: '.2em',
89
+ opacity: '1',
90
+ boxSizing: 'content-box'
89
91
  }
90
92
  }),
91
93
 
92
94
  childExtend: Cell,
93
95
 
94
96
  i: {},
95
- buttons,
96
97
  em: {},
97
98
  decimal: {},
98
99
  px: {},
100
+ buttons: {},
101
+ graph: { line: {} },
99
102
 
100
- graph: { line: {} }
103
+ overlay: {
104
+ props: {
105
+ position: 'absolute',
106
+ right: '0',
107
+ top: '0',
108
+ bottom: '0',
109
+ width: 'calc(100% - var(--spacing-G3))',
110
+ height: '100%'
111
+ },
112
+
113
+ on: {
114
+ mouseover: (ev, el, s) => {
115
+ if (!s.parent.hovered !== s.key) {
116
+ const key = parseInt(el.parent.key)
117
+ const rowHeight = '(var(--spacing-C) + var(--spacing-Z))'
118
+ const translateY = `calc(${rowHeight} * ${key + 1})`
119
+ const transform = `translate3d(0px, ${translateY}, 1px)`
120
+ s.parent.hovered = s.key
121
+ s.parent.selectedKey = s.key
122
+ el.lookup('actionButtons').setProps({ opacity: '1', transform })
123
+ }
124
+ },
125
+
126
+ mouseleave: (ev, el, s) => {
127
+ if (s.parent.hovered && s.parent.hovered === s.key) {
128
+ s.parent.hovered = false
129
+ el.lookup('actionButtons').setProps({ opacity: '0' })
130
+ }
131
+ }
132
+ }
133
+ }
101
134
  }
102
135
 
103
136
  const HeaderRow = {
@@ -111,11 +144,12 @@ const HeaderRow = {
111
144
  },
112
145
 
113
146
  i: '#',
114
- buttons: ' ',
115
147
  em: 'em',
116
148
  decimal: 'decimal',
117
149
  px: 'px',
118
- graph: null
150
+ buttons: '',
151
+ graph: null,
152
+ overlay: null
119
153
  }
120
154
 
121
155
  export const Table = {
@@ -160,6 +194,8 @@ export const Table = {
160
194
  cnt: {
161
195
  childExtend: Row,
162
196
  props: { lazyLoad: true },
163
- $setStateCollection: (el) => mapSequence(el.state, sortSequence)
164
- }
197
+ $setStateCollection: ({ state }) => mapSequence(state, sortSequence)
198
+ },
199
+
200
+ actionButtons: buttons
165
201
  }
@@ -1,287 +1,35 @@
1
1
  'use strict'
2
2
 
3
- import {
4
- ClickableItem,
5
- WiderButton,
6
- DropdownParent,
7
- Dropdown,
8
- GridInDropdown
9
- } from '@symbo.ls/components'
10
-
11
- const ChoosableButton = {
12
- extend: [ClickableItem],
13
-
14
- props: ({ key, state, parent }) => ({
15
- padding: 'Z',
16
- icon: key,
17
- theme: null,
18
- '@dark': {
19
- background: 'gray1',
20
- color: 'gray5'
21
- },
22
- '@light': {
23
- background: 'white .5',
24
- color: 'gray7'
25
- },
26
- ':hover': {
27
- theme: 'quaternary',
28
- '.active': { color: 'blue' }
29
- },
30
- '.active': {
31
- theme: null
32
- }
33
- })
34
-
35
- }
36
-
37
- const jointPropDirection = (parentKey, key) => {
38
- return parentKey + key.slice(0, 1).toUpperCase() + key.slice(1)
39
- }
40
-
41
- const diffPropPosition = (parentKey, key) => {
42
- if (parentKey.includes('borderWidth')) return key.split('Width')[0]
43
- return key
44
- }
45
-
46
- const diffPropValue = (parentKey, key) => {
47
- if (parentKey.includes('borderWidth')) parentKey = 'border'
48
- return jointPropDirection(parentKey, key)
49
- }
50
-
51
- const diffIconTypes = (parentKey, key) => {
52
- if (parentKey.includes('borderWidth')) key = key.split('Width')[0]
53
- if (parentKey.includes('margin') || parentKey === 'borderWidth') parentKey = 'padding'
54
- return jointPropDirection(parentKey, key)
55
- }
56
-
57
- const BUTTONS = {
58
- margin: {
59
- maxValue: 3000,
60
- blockStart: {},
61
- inlineEnd: {},
62
- blockEnd: {},
63
- inlineStart: {}
64
- },
65
- height: {
66
- minWidth: {},
67
- maxWidth: {}
68
- },
69
- width: {
70
- minWidth: {},
71
- maxWidth: {}
72
- },
73
- borderWidth: {
74
- maxValue: 1280,
75
- blockStartWidth: {},
76
- inlineEndWidth: {},
77
- blockEndWidth: {},
78
- inlineStartWidth: {}
79
- },
80
- padding: {
81
- maxValue: 3000,
82
- blockStart: {},
83
- inlineEnd: {},
84
- blockEnd: {},
85
- inlineStart: {}
86
- },
87
- gap: {
88
- maxValue: 3000,
89
- Horizontal: {},
90
- Vertical: {}
91
- },
92
- borderRadius: {
93
- maxValue: 1280,
94
- endStart: {},
95
- startEnd: {},
96
- endEnd: {},
97
- startStart: {}
98
- }
99
- }
100
-
101
- const cachedKeys = state => {
102
- return Object.keys(BUTTONS[state.value]).filter(v => v !== 'maxValue')
103
- }
3
+ import { Flex } from '@symbo.ls/components'
4
+ import { SpacingPropButton, SPACING_BUTTONS } from '../../components'
104
5
 
105
6
  export default {
7
+ extend: Flex,
8
+
106
9
  props: {
10
+ position: 'absolute',
11
+ left: 'G3',
12
+ gap: 'X',
13
+ top: 'Y',
107
14
  lazyLoad: true,
108
15
  height: 'B2',
109
- boxSizing: 'content-box'
110
- },
111
-
112
- childExtend: {
113
- extend: [ChoosableButton, DropdownParent, WiderButton],
114
-
115
- props: ({ key, state, parent }) => ({
116
- lazyLoad: true,
117
- active: state.parent.parent.props[state.value] === state.parent.key,
118
- icon: { name: state.value },
119
-
120
- '.active': {
121
- color: 'blue',
122
- ':hover': {
123
- color: 'blue'
124
- }
125
- }
126
- }),
127
-
128
- dropdown: {
129
- extend: Dropdown,
130
-
131
- props: {
132
- lazyLoad: true,
133
- minWidth: 'none',
134
- grid: { gap: '0' }
135
- },
136
-
137
- header: { text: ({ state }) => state.value },
138
-
139
- grid: {
140
- extend: GridInDropdown,
141
- props: ({ state }) => {
142
- const keys = cachedKeys(state)
143
- if (keys.length < 4) {
144
- return {
145
- lazyLoad: true,
146
- columns: 'repeat(4, 1fr)'
147
- }
148
- }
149
- return {
150
- lazyLoad: true,
151
- columns: 'auto 32px auto',
152
- rows: 'auto 32px auto',
153
- templateAreas: `"endStart blockStart startEnd"
154
- "inlineStart content inlineEnd"
155
- "startStart blockEnd endEnd"`
156
- }
157
- },
158
- childExtend: {
159
- extend: [ChoosableButton],
160
- props: ({ key, parent, state }) => {
161
- const propState = state.parent
162
- const rowState = propState.parent
163
- const keys = Object.keys(BUTTONS[propState.value])
164
- const tableState = rowState.parent
165
- const propKey = diffPropValue(propState.value, state.value)
166
- const iconKey = diffIconTypes(propState.value, state.value)
167
- const active = tableState.props[propKey] === rowState.key
168
- return {
169
- lazyLoad: true,
170
- active,
171
- icon: { name: iconKey },
172
- gridArea: keys.length > 3 && diffPropPosition(propState.value, state.value),
173
- theme: null,
174
- '@dark': {
175
- background: 'transparent 0',
176
- color: 'gray7',
177
- ':hover': {
178
- theme: 'quinary',
179
- color: 'gray8'
180
- }
181
- },
182
- ':hover': null,
183
- '.active': {
184
- theme: null,
185
- color: 'blue'
186
- }
187
- }
188
- },
189
- attr: { title: ({ state }) => state.value },
190
- on: {
191
- click: (ev, { key, state, parent }) => {
192
- const propState = state.parent
193
- const rowState = propState.parent
194
- const tableState = rowState.parent
195
- const propKey = diffPropValue(propState.value, state.value)
196
- const active = tableState.props[propKey] === rowState.key
197
- if (active) {
198
- delete tableState.props[propKey] && tableState.update()
199
- } else {
200
- tableState.update({ props: { [propKey]: rowState.key } })
201
- }
202
- }
203
- }
204
- },
205
-
206
- $setStateCollection: ({ state, props }) => cachedKeys(state)
207
- }
208
- },
16
+ zIndex: 99,
17
+ boxSizing: 'content-box',
18
+ padding: '- - C2',
19
+ transition: 'C ease-out',
20
+ transitionProperty: 'transform, opacity',
21
+ opacity: '0',
209
22
 
210
- click: {
211
- props: {
212
- lazyLoad: true,
213
- position: 'absolute',
214
- inset: '0 0 0 0'
215
- },
216
-
217
- on: {
218
- click: (ev, { state, parent }) => {
219
- const rowState = state.parent
220
- const tableState = rowState.parent
221
- const propKey = state.value
222
- const active = tableState.props[propKey] === rowState.key
223
- if (active) {
224
- delete tableState.props[propKey] && tableState.update()
225
- } else {
226
- const allKeys = Object.keys(tableState.props)
227
- allKeys.filter(v => {
228
- const splitInWords = propKey.split(/(?=[A-Z])/)
229
- return v.includes(splitInWords[0]) && v.includes(splitInWords[1])
230
- })
231
- .forEach(v => delete tableState.props[v])
232
- tableState.update({ props: { [propKey]: rowState.key } })
233
- }
234
- }
235
- },
236
-
237
- attr: { title: ({ state }) => state.value },
238
-
239
- childExtend: {
240
- props: ({ key, parent, state }) => {
241
- const propState = state.parent
242
- const rowState = propState.parent
243
- const tableState = rowState.parent
244
- const propKey = diffPropValue(propState.value, state.value)
245
- const active = tableState.props[propKey] === rowState.key
246
-
247
- const isRadius = propState.value === 'borderRadius'
248
-
249
- return {
250
- position: 'absolute',
251
- round: '100%',
252
- background: 'blue',
253
- boxSize: 'W2',
254
- lazyLoad: true,
255
-
256
- hide: !active,
257
- isRadius,
258
-
259
- '!isRadius': {
260
- ':nth-child(1)': { left: '50%', top: 'W' },
261
- ':nth-child(2)': { right: 'W', top: '50%' },
262
- ':nth-child(3)': { left: '50%', bottom: 'W' },
263
- ':nth-child(4)': { left: 'W', top: '50%' }
264
- },
23
+ ':hover': { opacity: '1' }
24
+ },
265
25
 
266
- '.isRadius': {
267
- ':nth-child(1)': { left: 'X2', top: 'X2' },
268
- ':nth-child(2)': { right: 'X2', top: 'X2' },
269
- ':nth-child(3)': { right: 'X2', bottom: 'X2' },
270
- ':nth-child(4)': { left: 'X2', bottom: 'X2' }
271
- }
272
- }
273
- }
274
- },
26
+ childExtend: SpacingPropButton,
275
27
 
276
- $setStateCollection: ({ state }) => {
277
- const buttonsByProperty = cachedKeys(state)
278
- return buttonsByProperty
279
- }
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?.val : true
280
33
  }
281
- },
282
-
283
- $setStateCollection: ({ state }) => Object.keys(BUTTONS).filter(v => {
284
- const { maxValue } = BUTTONS[v]
285
- return maxValue ? maxValue > state.val : true
286
- })
34
+ )
287
35
  }
@@ -18,14 +18,21 @@ export const Spaces = {
18
18
 
19
19
  sequence,
20
20
 
21
- init: (el, s) => {
22
- if (!s.__system.SPACING) {
23
- s.systemUpdate({
24
- SPACING: { base: s.base, ratio: s.ratio }
25
- }, { preventUpdate: true })
21
+ on: {
22
+ init: (el, s) => {
23
+ if (!s.__system.SPACING) {
24
+ s.systemUpdate({
25
+ SPACING: { base: s.base, ratio: s.ratio }
26
+ }, { preventUpdate: true })
27
+ }
28
+ },
29
+ stateUpdated: (el, s, changes) => {
30
+ s.systemUpdate({
31
+ SPACING: { base: s.base, ratio: s.ratio }
32
+ }, {
33
+ preventUpdate: true
34
+ })
26
35
  }
27
- },
28
- stateUpdated: (el, s, changes) => {
29
- s.systemUpdate({ SPACING: { base: s.base, ratio: s.ratio } }, { preventUpdate: true })
30
36
  }
31
37
  }
38
+
@@ -0,0 +1,86 @@
1
+ 'use strict'
2
+
3
+ import { Input, Img, Flex, ClickableItem, CommonField } from '@symbo.ls/components'
4
+
5
+ const sideBar = {
6
+ tag: 'aside',
7
+ }
8
+
9
+ export const State = {
10
+ sideBar,
11
+
12
+ form: {
13
+ extend: Flex,
14
+
15
+ props: {
16
+ flow: 'column',
17
+ gap: 'A2',
18
+ margin: 'C1 - -',
19
+ width: 'G2'
20
+ },
21
+
22
+ childExtend: {
23
+ extend: CommonField,
24
+
25
+ element: {
26
+ on: {
27
+ input: (ev, el, s) => {
28
+ const rootState = el.__root.state
29
+ const obj = {
30
+ STATE: { [el.parent.key]: el.node.value }
31
+ }
32
+ rootState.update({ SYSTEM: obj })
33
+ }
34
+ }
35
+ }
36
+ },
37
+
38
+ websiteTitle: {
39
+ title: 'Title',
40
+ element: {
41
+ extend: Input
42
+ }
43
+ },
44
+
45
+ websiteDesc: {
46
+ title: 'Description',
47
+ element: {
48
+ extend: Input
49
+ }
50
+ },
51
+
52
+ websiteTags: {
53
+ title: 'Tags',
54
+ element: {
55
+ extend: Input
56
+ }
57
+ },
58
+
59
+ headline: {
60
+ title: 'Headline',
61
+ element: {
62
+ extend: Input
63
+ }
64
+ },
65
+
66
+ paragraph: {
67
+ title: 'Paragraph',
68
+ element: {
69
+ extend: Input
70
+ }
71
+ },
72
+
73
+ bookNowUrl: {
74
+ title: 'Book now URL:',
75
+ element: {
76
+ extend: Input
77
+ }
78
+ },
79
+ },
80
+
81
+ on: {
82
+ stateUpdated: (el, s) => {
83
+ s.systemUpdate({ STATE: s.parse })
84
+ }
85
+ }
86
+ }
@@ -11,6 +11,7 @@ export * from './Theme'
11
11
  export * from './Shapes'
12
12
  export * from './Spaces'
13
13
  export * from './Typography'
14
+ export * from './State'
14
15
  export * from './MediaQuery'
15
16
  export * from './DesignSystem'
16
17
  export * from './Account'
package/src/sync.js CHANGED
@@ -5,18 +5,11 @@ import { router } from '@domql/router'
5
5
 
6
6
  const onChange = (element, state) => {
7
7
  return (event, data) => {
8
- // if (event === 'change') {
9
- // const obj = JSON.parse(data)
10
- // state.update({ SYSTEM: obj })
11
- // }
12
8
  if (event === 'change') {
13
- console.log(data)
14
9
  // const obj = JSON.parse(data)
15
10
  state.update({ SYSTEM: data })
16
11
  }
17
12
  if (event === 'route') {
18
- console.log(data)
19
- // const obj = JSON.parse(data)
20
13
  router(element, data, {})
21
14
  }
22
15
  }
@@ -28,6 +21,8 @@ export const Sync = {
28
21
  if (s.appKey) {
29
22
  connect(s.appKey, {
30
23
  source: 'symbols',
24
+ // socketUrl: 'ws://socket.symbols.app',
25
+ location: window.location.host,
31
26
  onChange: onChange(el, s)
32
27
  })
33
28
  }
@@ -36,13 +31,6 @@ export const Sync = {
36
31
  if (s.appKey && changes.SYSTEM) {
37
32
  const { SYSTEM } = changes
38
33
  send('change', SYSTEM)
39
-
40
- // if (SYSTEM.COLOR && SYSTEM.THEME) {
41
- // init({
42
- // color: SYSTEM.COLOR,
43
- // theme: SYSTEM.THEME
44
- // })
45
- // }
46
34
  }
47
35
  }
48
36
  }