@symbo.ls/preview 2.6.17 → 2.6.22

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": "2.6.17",
5
+ "version": "2.6.22",
6
6
  "main": "src/app.js",
7
7
  "scripts": {
8
8
  "link:all": "yarn link smbls domql css-in-props @symbo.ls/icons @symbo.ls/config @symbo.ls/components @symbo.ls/scratch @symbo.ls/playground @symbo.ls/utils @symbo.ls/init @symbo.ls/config-default @domql/router @domql/utils @domql/router",
@@ -29,12 +29,13 @@
29
29
  "@symbo.ls/init": "latest",
30
30
  "@symbo.ls/scratch": "latest",
31
31
  "@symbo.ls/temp-db": "latest",
32
- "@symbo.ls/utils": "latest"
32
+ "@symbo.ls/utils": "latest",
33
+ "colorthief": "^2.3.2"
33
34
  },
34
35
  "devDependencies": {
35
- "domql": "^1.5.35",
36
36
  "@babel/core": "^7.11.5",
37
37
  "babel-eslint": "^10.0.3",
38
+ "domql": "^1.5.35",
38
39
  "eslint": "^6.1.0",
39
40
  "parcel-bundler": "^1.12.4",
40
41
  "parcel-plugin-svg-sprite": "^1.4.1",
package/src/app.js CHANGED
@@ -38,7 +38,6 @@ const App = {
38
38
  '/design-system': DesignSystem,
39
39
  '/components': Components,
40
40
  '/component': Export,
41
- // '/state': State,
42
41
  ...SUB_ROUTES
43
42
  },
44
43
 
@@ -25,7 +25,6 @@ export const ThemeButtons = {
25
25
  on: {
26
26
  stateUpdated: (el, s) => {
27
27
  s.parent.update({ [s.key]: s.value })
28
- return false
29
28
  }
30
29
  }
31
30
  },
@@ -0,0 +1,15 @@
1
+ 'use strict'
2
+
3
+ export const fieldsGridProps = {
4
+ width: 'fit-content',
5
+ columns: 'repeat(2, 1fr)',
6
+ columnGap: 'C',
7
+ rowGap: 'C2',
8
+ childProps: {
9
+ width: 'F3',
10
+ element: {
11
+ placeholder: null,
12
+ height: 'C'
13
+ }
14
+ }
15
+ }
@@ -1,111 +1,111 @@
1
1
  'use strict'
2
2
 
3
- import { Link, Img, SquareButton, ClickableItem } from '@symbo.ls/components'
3
+ import { Flex, IconButton, Link, SquareButton, User } from '@symbo.ls/components'
4
+ import { fetchProject } from '@symbo.ls/fetch'
5
+ import { setCookie } from 'domql/packages/cookie'
4
6
 
5
- const sideBar = {
6
- tag: 'aside',
7
- style: {
8
- },
9
- props: {
10
- flexFlow: 'column',
11
- flexAlign: 'flex-start space-between',
12
- padding: '0 C 0 0',
13
- height: '100%',
14
- style: { borderRight: '1px solid rgba(255, 255, 255, .06)' }
15
- },
16
- nav: {
17
- props: {
18
- flexFlow: 'column',
19
- gap: 'A1'
20
- },
21
- childExtend: {
22
- tag: 'a',
23
-
24
- extend: [SquareButton, Link, ClickableItem],
25
- props: {
26
- theme: 'quaternary',
27
- padding: 0,
28
- boxSize: 'B1 B1'
29
- }
30
- },
7
+ import { personalAccount } from './personalAccount'
8
+ import { projectAccount } from './projectAccount'
31
9
 
32
- personal: {
33
- props: { icon: 'githubOutline' },
34
- style: { svg: { color: 'white' } },
10
+ const ProjectButton = {
11
+ extend: [SquareButton],
12
+ props: { theme: 'transparent' },
13
+ User: {
14
+ props: ({ state }) => ({
15
+ round: '100%',
16
+ src: state.icon && state.icon.src,
17
+ title: state.projectName
18
+ })
19
+ },
20
+ on: {
21
+ click: (event, el, s) => {
22
+ setCookie('activeProject', el.key + '', 3)
23
+ const { projectId, username } = s.parse
24
+ fetchProject(el, s, {
25
+ username: s.name,
26
+ projectId: s.id
27
+ })
28
+ }
29
+ }
30
+ }
35
31
 
36
- on: {
37
- click: (ev, el, s) => {
38
- s.update({ activeTab: el.key })
39
- Link.on.click(ev, el, s)
40
- }
41
- }
42
- },
43
- project: {
44
- style: {
45
- borderRadius: '100%',
46
- display: 'block'
47
- },
48
- image: {
49
- extend: Img,
50
- props: {
51
- src: 'https://ui-avatars.com/api/?font-size=0.5&size=150&name=Rockstar',
52
- width: '100%',
53
- height: '100%',
54
- borderRadius: '100%'
55
- }
56
- },
32
+ const sidebar = {
33
+ extend: Flex,
57
34
 
58
- on: {
59
- click: (ev, el, s) => {
60
- s.update({ activeTab: el.key })
61
- Link.on.click(ev, el, s)
62
- }
63
- }
64
- },
35
+ props: {
36
+ flow: 'column',
37
+ boxSize: '100% fit-content',
38
+ justifyContent: 'space-between',
39
+ padding: '- C - -',
40
+ borderRight: 'gray2, solid',
41
+ borderWidth: '1px',
42
+ minWidth: 'D1',
43
+
44
+ childProps: {
45
+ flow: 'column',
46
+ gap: 'A2'
47
+ }
48
+ },
65
49
 
66
- add: {
67
- props: { icon: 'plus' },
68
- style: { svg: { color: 'rgba(255, 255, 255, .25)' } },
50
+ childExtend: {
51
+ tag: 'nav',
52
+ extend: Flex
53
+ },
69
54
 
55
+ Flex: {
56
+ extend: Flex,
57
+ profile: {
58
+ extend: [IconButton],
59
+ props: { icon: 'openSource' },
70
60
  on: {
71
- click: (ev, el, s) => {
72
- s.update({ activeTab: el.key })
73
- Link.on.click(ev, el, s)
61
+ click: (event, element, state) => {
62
+ state.update({ activePersonalAccount: true })
74
63
  }
75
64
  }
76
- }
77
- },
78
-
79
- nav2: {
80
- tag: 'nav',
81
- props: {
82
- flexFlow: 'column',
83
- gap: 'A1'
84
65
  },
85
66
 
86
- style: { svg: { color: 'rgba(255, 255, 255, .25)' } },
87
- childExtend: {
88
- extend: [SquareButton, Link],
67
+ projects: {
68
+ extend: Flex,
89
69
  props: {
90
- theme: 'quaternary',
91
- padding: 0,
92
- boxSize: 'B1 B1'
70
+ flow: 'column',
71
+ gap: 'A'
93
72
  },
94
- style: { padding: 0 }
73
+ childExtend: ProjectButton,
74
+ $setStateCollection: ({ state }) => state.projects
95
75
  },
96
76
 
97
- info: { props: { icon: 'info' } },
98
- logout: {
99
- props: { icon: 'logout', href: '/logout' }
77
+ add: {
78
+ extend: [IconButton, Link],
79
+ props: { icon: 'plus', href: '/init/create' }
100
80
  }
81
+ },
82
+
83
+ meta: {
84
+ extend: Flex,
85
+ props: { gap: 'A' },
86
+ info: { extend: IconButton, props: { icon: 'info' } },
87
+ logout: { extend: IconButton, props: { icon: 'logout' } }
88
+ }
89
+ }
90
+
91
+ const props = {
92
+ boxSize: '100% 100%',
93
+ padding: 'D - D D1',
94
+ gap: 'E',
95
+ overflow: 'hidden',
96
+
97
+ content: {
98
+ flex: '1'
101
99
  }
102
100
  }
103
101
 
104
102
  export const Account = {
105
- sideBar,
106
- on: {
107
- render: element => {
103
+ extend: Flex,
104
+ props,
108
105
 
109
- }
106
+ sidebar,
107
+ content: {
108
+ personalAccount,
109
+ projectAccount
110
110
  }
111
111
  }
@@ -0,0 +1,73 @@
1
+ 'use strict'
2
+
3
+ import { Flex, InputField, Grid, ContinueButton, PasswordField, SelectField2 } from '@symbo.ls/components'
4
+
5
+ import { fieldsGridProps } from './fieldsGridProps'
6
+
7
+ const fields = {
8
+ extend: Grid,
9
+ ...[
10
+ {
11
+ extend: InputField,
12
+ props: {
13
+ gridColumn: 'span 2',
14
+ title: { text: 'Your Email' }
15
+ }
16
+ },
17
+
18
+ {
19
+ extend: InputField,
20
+ props: { title: { text: 'Your Username' } }
21
+ },
22
+
23
+ {
24
+ extend: SelectField2,
25
+ props: { title: { text: 'Your role' } }
26
+ },
27
+
28
+ {
29
+ extend: PasswordField,
30
+ props: { title: { text: 'Change Password' } }
31
+ },
32
+
33
+ {
34
+ extend: PasswordField,
35
+ props: { title: { opacity: '0' } }
36
+ }
37
+ ]
38
+
39
+ }
40
+
41
+ const props = {
42
+ boxSize: '100% 100%',
43
+ flow: 'column',
44
+ title: {
45
+ text: 'Your personal account',
46
+ padding: '- - C2 -'
47
+ },
48
+ fields: {
49
+ ...fieldsGridProps
50
+ },
51
+ button: {
52
+ text: 'Update',
53
+ padding: 'Z1 C1',
54
+ fontSize: 'Z2',
55
+ margin: 'auto - - -',
56
+ width: 'fit-content'
57
+ }
58
+ }
59
+
60
+ export const personalAccount = {
61
+ props,
62
+ extend: Flex,
63
+
64
+ class: {
65
+ show: (element, state) => state.activePersonalAccount
66
+ ? { display: 'flex' }
67
+ : { display: 'none' }
68
+ },
69
+
70
+ title: {},
71
+ fields,
72
+ button: { extend: ContinueButton }
73
+ }
@@ -0,0 +1,153 @@
1
+ 'use strict'
2
+
3
+ import {
4
+ Flex,
5
+ CommonField,
6
+ Upload,
7
+ InputField,
8
+ Grid,
9
+ ContinueButton,
10
+ ColumnParagraphs,
11
+ PasswordField,
12
+ SelectField2,
13
+ DragNdropUser
14
+ } from '@symbo.ls/components'
15
+
16
+ import { fieldsGridProps } from './fieldsGridProps'
17
+
18
+ const fields = {
19
+ extend: Grid,
20
+ props: fieldsGridProps,
21
+ ...[
22
+ {
23
+ extend: InputField,
24
+ props: { title: { text: 'Name the project' } }
25
+ },
26
+
27
+ {
28
+ extend: InputField,
29
+ props: { title: { text: 'Key' } }
30
+ },
31
+
32
+ {
33
+ extend: SelectField2,
34
+ props: {
35
+ title: { text: 'URL Access' },
36
+ element: { title: { text: 'Password Protected' } }
37
+ }
38
+ },
39
+
40
+ {
41
+ extend: PasswordField,
42
+ props: {
43
+ opacity: '.3',
44
+ title: { text: 'Password' }
45
+ }
46
+ },
47
+ {
48
+ extend: SelectField2,
49
+ props: {
50
+ title: { text: 'Environment' },
51
+ element: { title: { text: 'JavaScript' } }
52
+ }
53
+ },
54
+
55
+ {
56
+ extend: SelectField2,
57
+ props: {
58
+ title: { text: 'Framework' },
59
+ element: { title: { text: 'DOMQL' } }
60
+ }
61
+ }
62
+ ]
63
+ }
64
+ const props = {
65
+ style: { overFlowY: 'auto' },
66
+ header: {
67
+ title: {
68
+ text: 'Settings for Rockstar',
69
+ padding: '- - A1 -'
70
+ },
71
+ paragraphs: { padding: '- - D2 -' }
72
+ },
73
+
74
+ content: {
75
+ sideUpload: {
76
+ title: {
77
+ text: 'Project icon',
78
+ fontSize: 'Z'
79
+ },
80
+ element: {
81
+ flow: 'column',
82
+ gap: 'Z1',
83
+ childProps: {
84
+ width: 'fit-content',
85
+ padding: '0',
86
+ boxSize: 'E E',
87
+ background: 'gray1',
88
+ border: 'none'
89
+ },
90
+
91
+ uploadIcon: {
92
+ icon: {
93
+ fontSize: 'E2'
94
+ },
95
+ p: {
96
+ text: 'Drag and drop or click',
97
+ fontSize: 'Z',
98
+ textAlign: 'center',
99
+ maxWidth: 'E'
100
+ }
101
+ }
102
+ }
103
+ }
104
+ },
105
+
106
+ button: {
107
+ text: 'Update',
108
+ padding: 'Z1 C1',
109
+ fontSize: 'Z2',
110
+ margin: 'F3 - - -',
111
+ width: 'fit-content'
112
+ }
113
+ }
114
+
115
+ export const projectAccount = {
116
+ props,
117
+ class: {
118
+ show: (element, state) => state.activePersonalAccount
119
+ ? { display: 'none' }
120
+ : { display: 'block' }
121
+ },
122
+
123
+ header: {
124
+ title: {},
125
+ paragraphs: {
126
+ extend: ColumnParagraphs,
127
+ ...[
128
+ { props: { text: `In this example we'll initialize a Symbols Design System for you.` } },
129
+ { props: { text: `But we already initialized your system, let's just make sure it's all good.` } }
130
+ ]
131
+ }
132
+ },
133
+
134
+ content: {
135
+ extend: Flex,
136
+ sideUpload: {
137
+ extend: CommonField,
138
+ title: {},
139
+ element: {
140
+ extend: Flex,
141
+ uploadIcon: {
142
+ extend: Upload,
143
+ icon: {},
144
+ p: { span: null }
145
+ },
146
+ projectImg: { extend: DragNdropUser }
147
+ }
148
+ },
149
+
150
+ fields
151
+ },
152
+ button: { extend: ContinueButton }
153
+ }
@@ -68,7 +68,7 @@ export default {
68
68
 
69
69
  title: {},
70
70
  list: {
71
- $setStateCollection: ({ state }) => state.props
71
+ // $setStateCollection: ({ state }) => state.props
72
72
  }
73
73
  },
74
74
 
@@ -52,6 +52,7 @@ export const Export = {
52
52
  ...content
53
53
  }, { preventUpdate: true })
54
54
  }
55
+
55
56
  if (componentKey.length === 32) { // this might be Gist
56
57
  fetchGist(componentKey, state)
57
58
  }
@@ -73,8 +74,8 @@ export const Export = {
73
74
  flex: '1'
74
75
  },
75
76
 
76
- tools
77
- // description
77
+ tools,
78
+ description
78
79
  }
79
80
 
80
81
  // footer: { extend: Footer }
@@ -1,17 +1,7 @@
1
1
  'use strict'
2
2
 
3
- import DOM from 'domql'
4
- import { transformEmotionClass, transformEmotionStyle } from 'domql/packages/emotion'
5
- import { createEmotion } from '@symbo.ls/create-emotion'
6
- import { updateReset } from '@symbo.ls/init'
7
- import { isString } from '@domql/utils'
8
-
9
- import { getActiveConfig, activateConfig } from '@symbo.ls/scratch'
10
- import { init, Box, Scene } from '@symbo.ls/components'
11
-
12
- import * as components from '../../components'
13
-
14
- const emCache = {}
3
+ import { getActiveConfig } from '@symbo.ls/scratch'
4
+ import { Scene } from '@symbo.ls/components'
15
5
 
16
6
  export default {
17
7
  extend: Scene,
@@ -31,6 +21,7 @@ export default {
31
21
  props: {
32
22
  padding: 'B 0',
33
23
  maxHeight: '40em',
24
+ position: 'relative',
34
25
  minHeight: '65vh'
35
26
  },
36
27
 
@@ -42,86 +33,26 @@ export default {
42
33
  })
43
34
  },
44
35
 
45
- content: {
46
- props: {
47
- transition: 'all, B, defaultBezier',
48
- style: {
49
- '*': { transition: 'all 255ms cubic-bezier(.29,.67,.51,.97)' }
50
- }
51
- },
52
-
53
- comp: (el, s) => {
54
- if (s.live) {
55
- const PROJECT_SYSTEM = s.__projectSystem
56
- const styleNode = document.createElement('head')
57
- const emotion = createEmotion('client', styleNode)
58
- emCache['client'] = emotion
59
-
60
- const emotionStyle = transformEmotionStyle(emotion, true)
61
- const emotionClass = transformEmotionClass(emotion, true)
62
-
63
- const newDom = DOM.create({
64
- tag: 'shadow',
65
- state: s.state
66
- }, el.parent.node, 'comp', {
67
- extend: [Box],
68
- define: { style: emotionStyle, class: emotionClass },
69
- components,
70
- context: { system: PROJECT_SYSTEM }
71
- })
72
-
73
- newDom.node.appendChild(styleNode)
74
-
75
- init(PROJECT_SYSTEM, null, { emotion, initDOMQLDefine: false, newConfig: 'client' })
76
- activateConfig('client')
77
-
78
- newDom.set({
79
- tag: 'fragment',
80
- [s.key]: {
81
- extend: isString(s.component) ? document.eval(s.component) : s.component,
82
- props: { inheritSpacingRatio: true }
83
- },
84
- on: {
85
- render: (el) => {
86
- // const appKey = el.__root.state.appKey && el.__root.state.appKey.split('.')[0]
87
- }
88
- }
89
- })
90
-
91
- activateConfig(0)
92
- return newDom
93
- }
94
-
95
- return {
96
- extend: {
97
- extend: isString(s.component) ? document.eval(s.component) : s.component
98
- },
99
- props: { inheritSpacingRatio: true }
100
- }
101
- },
102
-
36
+ Iframe: {
37
+ props: (el, s) => ({
38
+ id: 'component',
39
+ src: `/scene/${s.key}`,
40
+ border: '0',
41
+ background: 'transparent',
42
+ position: 'absolute',
43
+ boxSize: '100% 100%',
44
+ inset: '0 0 0 0'
45
+ }),
103
46
  on: {
104
47
  initUpdate: (el, s) => {
105
- if (s.live) {
106
- activateConfig('client')
107
- updateReset({ emotion: emCache['client'] })
108
- } else {
109
- el.comp.setProps({
110
- base: s.base,
111
- fontSize: s.base + 'px',
112
- spacingRatio: s.ratio,
113
- direction: s.direction
114
- }, { preventUpdate: true })
115
- updateReset()
116
- }
117
- activateConfig(0)
48
+ return false
118
49
  }
119
50
  }
120
51
  }
121
52
  },
122
53
 
123
54
  on: {
124
- update: (el, s) => {
55
+ stateUpdated: (el, s) => {
125
56
  el.__root.node.scrollTo({ top: 0, behavior: 'smooth' })
126
57
  }
127
58
  }
@@ -9,7 +9,9 @@ export default {
9
9
  theme: '',
10
10
  zoomLevel: 1,
11
11
  currentFontSizeIndex: 3,
12
+ }
12
13
 
14
+ export const toolsState = {
13
15
  base: TYPOGRAPHY.base,
14
16
  ratio: SPACING.ratio,
15
17
  range: [-1, +4],
@@ -5,8 +5,10 @@ import {
5
5
  SequenceSliders,
6
6
  ClickableItem,
7
7
  SquareButton,
8
- ThemeSwitcher
8
+ ThemeSwitcher // eslint-disable-line no-unused-vars
9
9
  } from '@symbo.ls/components'
10
+ import { Link } from '@symbo.ls/components/src/Link'
11
+ import { toolsState } from './state'
10
12
 
11
13
  export default {
12
14
  props: {
@@ -18,6 +20,54 @@ export default {
18
20
  extend: Flex,
19
21
  props: { gap: 'B1' },
20
22
  // theme: { extend: ThemeSwitcher },
23
+ state: toolsState,
24
+
25
+ on: {
26
+ stateUpdated: (el, s, changes) => {
27
+ // window.componentRoot.context.system = s.__projectSystem
28
+ window.componentState.update(changes)
29
+ }
30
+ },
31
+
32
+ editors: {
33
+ extend: Flex,
34
+ props: { gap: 'Z2' },
35
+
36
+ childExtend: {
37
+ extend: [ClickableItem, SquareButton],
38
+ props: {}
39
+ },
40
+
41
+ add: {
42
+ props: {
43
+ icon: 'plus'
44
+ }
45
+ },
46
+ remix: {
47
+ props: {
48
+ icon: 'magicstar outline'
49
+ },
50
+ on: {
51
+ click: (ev, el, s) => {
52
+ window.componentState.update({
53
+ system: s.__projectSystem
54
+ })
55
+ }
56
+ }
57
+ },
58
+ editor: {
59
+ extend: Link,
60
+ props: {
61
+ icon: 'edit',
62
+ href: '/editor/' + window.location.pathname.split('component/')[1]
63
+ }
64
+ }
65
+ },
66
+
67
+ VerticalLine: {
68
+ margin: 'auto 0',
69
+ height: 'A2'
70
+ },
21
71
 
22
72
  sliders: {
23
73
  extend: SequenceSliders,
@@ -31,13 +81,11 @@ export default {
31
81
 
32
82
  direction: {
33
83
  extend: [ClickableItem, SquareButton],
34
- props: {
35
- icon: 'languageDirection'
36
- },
84
+ props: { icon: 'languageDirection' },
37
85
  on: {
38
86
  click: (ev, el, s) => {
39
- s.update({
40
- direction: s.direction === 'rtl' ? 'ltr' : 'rtl'
87
+ window.componentState.update({
88
+ direction: window.componentState.direction === 'rtl' ? 'ltr' : 'rtl'
41
89
  })
42
90
  }
43
91
  }
@@ -8,7 +8,7 @@ import * as LOGOS from '@symbo.ls/icons/src/logos'
8
8
  import * as SIGNS from '@symbo.ls/icons/src/signs'
9
9
  import * as STYLE from '@symbo.ls/icons/src/style'
10
10
  import * as KEYBOARD from '@symbo.ls/icons/src/keyboard'
11
- import * as SVG from '@symbo.ls/icons/src/svg'
11
+ import * as SVG from '@symbo.ls/icons/src/miscellaneous'
12
12
  import * as TECH from '@symbo.ls/icons/src/tech'
13
13
  import * as TEXT from '@symbo.ls/icons/src/text'
14
14
 
@@ -0,0 +1,62 @@
1
+ 'use strict'
2
+
3
+ import { fetch } from '@symbo.ls/based'
4
+ import { Flex, CommonField, ProjectTab, ContinueButton } from '@symbo.ls/components'
5
+ import { Grid } from '@symbo.ls/components/src'
6
+ import { InitPage } from '../../components'
7
+
8
+ const props = {
9
+ align: 'flex-start flex-start',
10
+ width: '100%',
11
+
12
+ footer: {
13
+ p: {
14
+ color: 'gray6',
15
+ maxWidth: `${272 / 14}em`,
16
+ margin: '0'
17
+ }
18
+ }
19
+ }
20
+
21
+ export const ChooseProject = {
22
+ extend: InitPage,
23
+
24
+ props,
25
+
26
+ back: null,
27
+
28
+ HeaderHeading: {
29
+ margin: '- - D -',
30
+
31
+ Caption: { text: 'Sign in to one of your projects' },
32
+ H1: { text: null }
33
+ },
34
+
35
+ cnt: {
36
+ extend: Grid,
37
+ props: {
38
+ columns: 'repeat(6, 1fr)',
39
+ gap: 'D1',
40
+ margin: '10% -Z auto'
41
+ },
42
+
43
+ childExtend: ProjectTab,
44
+ $setStateCollection: ({ state }) => state.projects
45
+ },
46
+
47
+ footer: {
48
+ extend: Flex,
49
+ props: {
50
+ align: 'flex-start flex-start',
51
+ gap: 'C',
52
+ margin: 'auto - -',
53
+ },
54
+ ContinueButton: {
55
+ text: 'Create',
56
+ href: '/init/personalize'
57
+ },
58
+ p: {
59
+ text: `In this example we'll initialize a Symbols Design System for you.`
60
+ }
61
+ }
62
+ }
@@ -124,7 +124,7 @@ export const CreateDocumentTheme = {
124
124
  }
125
125
  },
126
126
 
127
- back: { props: { href: '/init/' } },
127
+ back: { props: { href: '/init/personalize' } },
128
128
 
129
129
  HeaderHeading: {},
130
130
  paragraphs,
@@ -1,8 +1,16 @@
1
1
  'use strict'
2
2
 
3
+ import ColorThief from 'colorthief'
4
+ import { observe, upload } from '@symbo.ls/based'
3
5
  import { Flex, ColorPickerWithTitle } from '@symbo.ls/components'
4
6
  import { InitPage } from '../../components'
5
7
 
8
+ window.colorThief = new ColorThief()
9
+ // colorThief.getPalette(img, 5)
10
+ // .then(palette => { console.log(palette) })
11
+ // .catch(err => { console.log(err) })
12
+ // s.update({ imageUrl: pic.src })
13
+
6
14
  const colors = {
7
15
  extend: Flex,
8
16
  props: {
@@ -44,7 +52,35 @@ const content = {
44
52
 
45
53
  colors,
46
54
 
47
- ImageColorPicker: {},
55
+ ImageColorPicker: {
56
+ props: {},
57
+ title: {},
58
+ element: {
59
+ upload: {
60
+ input: {
61
+ on: {
62
+ change: (ev, el, s) => {
63
+ upload(ev.target.files[0], d => {
64
+ observe({
65
+ $id: d.id,
66
+ $all: true
67
+ }, pic => {
68
+ console.log(pic)
69
+ if (pic.progress) {
70
+ console.log(pic.src)
71
+ // ColorThief.getPalette(pic.src, 5)
72
+ // .then(palette => { console.log(palette) })
73
+ // .catch(err => { console.log(err) })
74
+ s.update({ imageUrl: pic.src })
75
+ }
76
+ })
77
+ })
78
+ }
79
+ }
80
+ }
81
+ }
82
+ }
83
+ },
48
84
  ColorsPalette: {
49
85
  props: ({ state }) => ({
50
86
  hide: state.imageUrl,
@@ -32,28 +32,25 @@ export default {
32
32
  },
33
33
 
34
34
  projectName: {
35
- props: {
36
- title: { text: 'Name the project' },
37
- element: { placeholder: 'You name it' }
38
- },
39
-
40
- title: {},
35
+ title: { text: 'Name the project' },
41
36
  element: {
42
37
  extend: Input,
43
- props: ({ state }) => ({ value: state.projectName })
38
+ props: ({ state }) => ({
39
+ placeholder: 'You name it',
40
+ value: state.projectName,
41
+ required: true
42
+ })
44
43
  }
45
44
  },
46
45
 
47
46
  appKey: {
48
- props: {
49
- title: { text: 'Key' }
50
- },
51
- title: {},
47
+ title: { text: 'Key' },
52
48
  element: {
53
49
  extend: Input,
54
50
  props: ({ state }) => ({
55
51
  placeholder: 'a-zA-Z0-9',
56
- value: state.appKey && state.appKey.split('.')[0]
52
+ value: state.appKey && state.appKey.split('.')[0],
53
+ required: true
57
54
  }),
58
55
  on: {
59
56
  change: (ev, el, s) => {
@@ -72,7 +69,7 @@ export default {
72
69
  },
73
70
 
74
71
  urlVisibility: {
75
- props: { title: { text: 'URL Access' } },
72
+ title: { text: 'URL Access' },
76
73
  title: {},
77
74
  element: {
78
75
  extend: [SelectField],
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- import { set } from '@symbo.ls/based'
3
+ import { fetch, observe, set, upload } from '@symbo.ls/based'
4
4
  import { User } from '@symbo.ls/components'
5
5
  import { UploadImage } from '../../../components'
6
6
 
@@ -42,16 +42,24 @@ export default {
42
42
 
43
43
  input: {
44
44
  on: {
45
- change: async (ev, el, s) => {
45
+ change: (ev, el, s) => {
46
46
  s.update({ icon: { pending: true } })
47
47
 
48
48
  try {
49
- set({
50
- $id: s.projectId,
51
- icon: ev.target.files[0]
52
- }, d => {
53
- console.log('udpateIcon', d)
54
- s.update({ icon: { pending: false } })
49
+ upload(ev.target.files[0], d => {
50
+ observe({
51
+ $id: d.id,
52
+ $all: true
53
+ }, icon => {
54
+ if (icon.progress) {
55
+ set({
56
+ $id: s.projectId,
57
+ type: 'project',
58
+ icon
59
+ })
60
+ s.update({ icon })
61
+ }
62
+ })
55
63
  })
56
64
  } catch (e) {
57
65
  console.log(e)
@@ -14,7 +14,7 @@ export const Personalize = {
14
14
  height: '100%'
15
15
  },
16
16
 
17
- back: null,
17
+ back: { props: { href: '/init/' } },
18
18
 
19
19
  HeaderHeading: {
20
20
  props: { margin: '- - D1 -' },
@@ -39,15 +39,14 @@ export const Personalize = {
39
39
  },
40
40
 
41
41
  Flex: {
42
- props: ({ state }) => ({
43
- gap: 'D1'
44
- }),
42
+ props: { gap: 'D1' },
45
43
 
46
44
  icon,
47
45
  fields
48
46
  },
49
47
 
50
48
  ContinueButton: {
49
+ href: null,
51
50
  type: 'submit'
52
51
  },
53
52
 
@@ -60,3 +59,41 @@ export const Personalize = {
60
59
  }
61
60
  }
62
61
  }
62
+
63
+ export const CreateProject = {
64
+ extend: Personalize,
65
+
66
+ back: null,
67
+
68
+ HeaderHeading: {
69
+ props: { margin: '- - D1 -' },
70
+ Caption: { text: ({ state }) => `Hi ${state.userName}, let's start` },
71
+ H1: { text: `Creating a Project` }
72
+ },
73
+
74
+ ColumnParagraphs: {
75
+ extend: true,
76
+ ...[
77
+ { props: { text: `In this example we'll initialize a Symbols Design System for you.` } },
78
+ { props: { text: `You can connect Symbols to your app and style it online.` } }
79
+ ]
80
+ },
81
+
82
+ Form: {
83
+ state: {},
84
+ Flex: {},
85
+
86
+ ContinueButton: {
87
+ href: null,
88
+ type: 'submit'
89
+ },
90
+
91
+ on: {
92
+ submit: (ev, el, s) => {
93
+ ev.preventDefault()
94
+ console.log(s.parse())
95
+ // router(el.__root, '/init/theme', {})
96
+ }
97
+ }
98
+ }
99
+ }
@@ -1,7 +1,8 @@
1
1
  'use strict'
2
2
 
3
3
  import { Flex } from '@symbo.ls/components'
4
- import { Personalize } from './Personalize'
4
+ import { CreateProject, Personalize } from './Personalize'
5
+ import { ChooseProject } from './ChooseProject'
5
6
  import { CreateDocumentTheme } from './CreateDocumentTheme'
6
7
  import { CreatePallete } from './CreatePalette'
7
8
  import { FontText } from './FontText'
@@ -19,7 +20,9 @@ export const Init = {
19
20
 
20
21
  define: { routes: param => param },
21
22
  routes: {
22
- '/': Personalize,
23
+ '/': ChooseProject,
24
+ '/create': CreateProject,
25
+ '/personalize': Personalize,
23
26
  '/theme': CreateDocumentTheme,
24
27
  '/pallete': CreatePallete,
25
28
  '/font': FontText,
@@ -0,0 +1,111 @@
1
+ 'use strict'
2
+
3
+ import { Link, Img, SquareButton, ClickableItem } from '@symbo.ls/components'
4
+
5
+ const sideBar = {
6
+ tag: 'aside',
7
+ style: {
8
+ },
9
+ props: {
10
+ flexFlow: 'column',
11
+ flexAlign: 'flex-start space-between',
12
+ padding: '0 C 0 0',
13
+ height: '100%',
14
+ style: { borderRight: '1px solid rgba(255, 255, 255, .06)' }
15
+ },
16
+ nav: {
17
+ props: {
18
+ flexFlow: 'column',
19
+ gap: 'A1'
20
+ },
21
+ childExtend: {
22
+ tag: 'a',
23
+
24
+ extend: [SquareButton, Link, ClickableItem],
25
+ props: {
26
+ theme: 'quaternary',
27
+ padding: 0,
28
+ boxSize: 'B1 B1'
29
+ }
30
+ },
31
+
32
+ personal: {
33
+ props: { icon: 'githubOutline' },
34
+ style: { svg: { color: 'white' } },
35
+
36
+ on: {
37
+ click: (ev, el, s) => {
38
+ s.update({ activeTab: el.key })
39
+ Link.on.click(ev, el, s)
40
+ }
41
+ }
42
+ },
43
+ project: {
44
+ style: {
45
+ borderRadius: '100%',
46
+ display: 'block'
47
+ },
48
+ image: {
49
+ extend: Img,
50
+ props: {
51
+ src: 'https://ui-avatars.com/api/?font-size=0.5&size=150&name=Rockstar',
52
+ width: '100%',
53
+ height: '100%',
54
+ borderRadius: '100%'
55
+ }
56
+ },
57
+
58
+ on: {
59
+ click: (ev, el, s) => {
60
+ s.update({ activeTab: el.key })
61
+ Link.on.click(ev, el, s)
62
+ }
63
+ }
64
+ },
65
+
66
+ add: {
67
+ props: { icon: 'plus' },
68
+ style: { svg: { color: 'rgba(255, 255, 255, .25)' } },
69
+
70
+ on: {
71
+ click: (ev, el, s) => {
72
+ s.update({ activeTab: el.key })
73
+ Link.on.click(ev, el, s)
74
+ }
75
+ }
76
+ }
77
+ },
78
+
79
+ nav2: {
80
+ tag: 'nav',
81
+ props: {
82
+ flexFlow: 'column',
83
+ gap: 'A1'
84
+ },
85
+
86
+ style: { svg: { color: 'rgba(255, 255, 255, .25)' } },
87
+ childExtend: {
88
+ extend: [SquareButton, Link],
89
+ props: {
90
+ theme: 'quaternary',
91
+ padding: 0,
92
+ boxSize: 'B1 B1'
93
+ },
94
+ style: { padding: 0 }
95
+ },
96
+
97
+ info: { props: { icon: 'info' } },
98
+ logout: {
99
+ props: { icon: 'logout', href: '/logout' }
100
+ }
101
+ }
102
+ }
103
+
104
+ export const Account = {
105
+ sideBar,
106
+ on: {
107
+ render: element => {
108
+
109
+ }
110
+ }
111
+ }
File without changes