@symbo.ls/preview 0.0.25 → 0.0.26

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/.symbols/index.js CHANGED
@@ -15,6 +15,8 @@ import field from './field'
15
15
  import tooltip from './tooltip'
16
16
  import pills from './pills'
17
17
 
18
+ import * as smbls from '@symbo.ls/components/src/Fields'
19
+
18
20
  export const LIBRARY = [
19
21
  circleButton,
20
22
  buttonDownload,
@@ -31,3 +33,15 @@ export const LIBRARY = [
31
33
  tooltip,
32
34
  pills
33
35
  ]
36
+
37
+ export const COMPONENTS = Object.keys(smbls).map(key => {
38
+ const component = smbls[key]
39
+ return {
40
+ key,
41
+ component: { extend: component },
42
+ code: JSON.stringify(component, null, 2),
43
+ settings: {
44
+ gridOptions: { colspan: 3, rowspan: 2 }
45
+ }
46
+ }
47
+ })
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@symbo.ls/preview",
3
3
  "description": "",
4
4
  "author": "",
5
- "version": "0.0.25",
5
+ "version": "0.0.26",
6
6
  "repository": "https://github.com/rackai/editor",
7
7
  "main": "src/index.js",
8
8
  "scripts": {
package/src/index.js CHANGED
@@ -19,7 +19,8 @@ smbls.init({ verbose: false, ...SYMBOLS_CONF })
19
19
 
20
20
  DOM.define({
21
21
  __filepath: param => param,
22
- $setCollection: smbls.Collection.define.$setCollection
22
+ $setCollection: smbls.Collection.define.$setCollection,
23
+ $setStateCollection: smbls.Collection.define.$setStateCollection
23
24
  })
24
25
 
25
26
  // export default DOM.create(App, DevFocus, 'app', { TODO: try this
@@ -17,7 +17,7 @@ export default {
17
17
 
18
18
  childExtend: [GlobalThemeTemplate, Link],
19
19
 
20
- $setCollection: () => [{
20
+ $setStateCollection: () => [{
21
21
  title: 'Light',
22
22
  key: 'light',
23
23
  icon: 'sun'
@@ -36,7 +36,7 @@ export default {
36
36
  },
37
37
 
38
38
  childExtend: ColorTemplate,
39
- $setCollection: mapColors
39
+ $setStateCollection: mapColors
40
40
  }
41
41
  }
42
42
  }
@@ -31,6 +31,6 @@ export default {
31
31
  },
32
32
 
33
33
  childExtend: ThemeTemplate,
34
- $setCollection: (el, s) => mapThemes(el, s)
34
+ $setStateCollection: (el, s) => mapThemes(el, s)
35
35
  }
36
36
  }
@@ -5,7 +5,7 @@ import {
5
5
  Grid,
6
6
  SectionHeader
7
7
  } from '@symbo.ls/components'
8
- import { LIBRARY } from '../../../.symbols'
8
+ import { COMPONENTS } from '../../../.symbols'
9
9
  import { gridStyle, rowStyle } from './style'
10
10
 
11
11
  export default {
@@ -86,7 +86,7 @@ export default {
86
86
  }),
87
87
 
88
88
  childExtend: ComponentTemplate,
89
- $setCollection: ({ state }) => LIBRARY.filter(v => {
89
+ $setStateCollection: ({ state }) => COMPONENTS.filter(v => {
90
90
  if (!state.category) return true
91
91
  return state.category === v.category.key
92
92
  })
@@ -1,10 +1,11 @@
1
1
  'use strict'
2
2
 
3
3
  import { SEQUENCE, TYPOGRAPHY } from '@symbo.ls/scratch'
4
- import { LIBRARY } from '../../../.symbols'
4
+ import { LIBRARY, COMPONENTS } from '../../../.symbols'
5
5
 
6
6
  const COMPONENT_ROUTES = {}
7
7
  LIBRARY.map(v => (COMPONENT_ROUTES[`/${v.key}`] = v))
8
+ COMPONENTS.map(v => (COMPONENT_ROUTES[`/${v.key}`] = v))
8
9
 
9
10
  // const SEQUENCE = [8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20, 22, 24, 26, 32, 36, 42, 48, 56, 62, 68, 76, 84, 92, 100, 110]
10
11
 
@@ -39,7 +39,7 @@ export default {
39
39
 
40
40
  title: {},
41
41
  list: {
42
- $setCollection: ({ state }) => state.props
42
+ $setStateCollection: ({ state }) => state.props
43
43
  }
44
44
  },
45
45
 
@@ -12,10 +12,13 @@ import description from './description'
12
12
 
13
13
  import { COMPONENT_ROUTES } from './const'
14
14
 
15
- const componentState = (context) => context.LIBRARY.filter(v => {
16
- const key = window.location.pathname.split('component/')[1]
17
- return v.key === key
18
- })
15
+ const componentState = (context) => {
16
+ const arr = [...context.LIBRARY, ...context.COMPONENTS]
17
+ return arr.filter(v => {
18
+ const key = window.location.pathname.split('component/')[1]
19
+ return v.key === key
20
+ })
21
+ }
19
22
 
20
23
  export const Export = {
21
24
  key: 'export',
@@ -47,7 +47,7 @@ const FontFaces = {
47
47
  margin: '0 -Z'
48
48
  },
49
49
  childExtend: [FontObject, Hoverable],
50
- $setCollection: mapFonts
50
+ $setStateCollection: mapFonts
51
51
  }
52
52
  }
53
53
 
@@ -89,7 +89,7 @@ const FontFamilies = {
89
89
  },
90
90
 
91
91
  childExtend: [FontFamilyObject, Hoverable],
92
- $setCollection: mapFontFamilies
92
+ $setStateCollection: mapFontFamilies
93
93
  }
94
94
  }
95
95
 
@@ -56,7 +56,7 @@ const IconsGroup = {
56
56
  }),
57
57
 
58
58
  childExtend: IconItem,
59
- $setCollection: ({ state }) => state.list
59
+ $setStateCollection: ({ state }) => state.list
60
60
  }
61
61
  }
62
62
 
@@ -110,5 +110,5 @@ export const Icons = {
110
110
  },
111
111
 
112
112
  childExtend: IconsGroup,
113
- $setCollection: () => ICON_GROUPS
113
+ $setStateCollection: () => ICON_GROUPS
114
114
  }
@@ -27,6 +27,6 @@ export const Library = {
27
27
  },
28
28
 
29
29
  childExtend: ComponentTemplate,
30
- $setCollection: () => LIBRARY
30
+ $setStateCollection: () => LIBRARY
31
31
  }
32
32
  }
@@ -205,6 +205,6 @@ export const Table = {
205
205
 
206
206
  cnt: {
207
207
  childExtend: Row,
208
- $setCollection: (el) => mapSequence(el.state, sortSequence)
208
+ $setStateCollection: (el) => mapSequence(el.state, sortSequence)
209
209
  }
210
210
  }
@@ -1,14 +1,14 @@
1
1
  'use strict'
2
2
 
3
+ import { findHeadingLetter, getFontFamily } from '@symbo.ls/scratch'
3
4
  import {
4
5
  DocumentStylesSequence,
5
6
  Flex,
6
7
  SectionHeader,
7
8
  SelectField,
8
9
  SequenceSliders,
9
- TestText
10
+ DeviceButtonSet
10
11
  } from '@symbo.ls/components'
11
- // import { mapSequence, sortSequence } from '@symbo.ls/utils'
12
12
  import stylesHelpers from './stylesHelpers'
13
13
 
14
14
  export default {
@@ -36,28 +36,116 @@ export default {
36
36
  header: {
37
37
  extend: Flex,
38
38
  SequenceSliders,
39
- TestText
39
+ DeviceButtonSet
40
40
  },
41
41
 
42
- sequence: {
42
+ headings: {
43
43
  extend: DocumentStylesSequence,
44
- $setCollection: (el) => {
44
+ $setStateCollection: (el) => {
45
45
  const { state, context } = el // eslint-disable-line no-unused-vars
46
- const { TYPOGRAPHY } = context.SYSTEM
46
+ const { TYPOGRAPHY, FONT_FAMILY } = context.SYSTEM
47
47
  const { styles } = TYPOGRAPHY
48
- console.log(styles)
49
- // state.sequence = {}
50
- return styles
48
+ el.removeContent()
49
+
50
+ const family = FONT_FAMILY[FONT_FAMILY.default]
51
+ const familyValue = getFontFamily()
52
+ const lineHeight = TYPOGRAPHY.lineHeight
53
+ const font = family.arr[0]
54
+
55
+ const HEADINGS = new Array(6).fill(null).map((_, i) => 'h' + (i + 1))
56
+
57
+ return HEADINGS.map((v, k) => ({
58
+ key: v,
59
+ value: {
60
+ font,
61
+ fontFamily: familyValue,
62
+ fontWeight: 900 - (k * 100),
63
+ lineHeight,
64
+ ...styles[v]
65
+ },
66
+ labels: [
67
+ { icon: 'fontFace', text: font },
68
+ { icon: 'fontVariable', text: 900 - (k * 100) },
69
+ { icon: 'textLineHeight', text: lineHeight }
70
+ ],
71
+ sequenceValue: state.sequence[
72
+ findHeadingLetter(state.h1Matches, k)
73
+ ]
74
+ }))
51
75
  }
52
76
  },
53
77
 
54
- footer: { }
78
+ doc: {
79
+ extend: DocumentStylesSequence,
80
+ $setStateCollection: (el) => {
81
+ const { state, context } = el // eslint-disable-line no-unused-vars
82
+ const { DOCUMENT, FONT_FAMILY } = context.SYSTEM
83
+ el.removeContent()
84
+
85
+ const family = FONT_FAMILY[FONT_FAMILY.default]
86
+ const familyValue = getFontFamily()
87
+ const font = family.arr[0]
88
+ const { fontWeight, lineHeight } = DOCUMENT
89
+
90
+ return [{
91
+ key: 'body',
92
+ value: {
93
+ font,
94
+ fontFamily: familyValue,
95
+ fontWeight: fontWeight || 400,
96
+ lineHeight
97
+ },
98
+ labels: [
99
+ { icon: 'fontFace', text: font },
100
+ { icon: 'fontVariable', text: fontWeight || 400 },
101
+ { icon: 'textLineHeight', text: lineHeight }
102
+ ],
103
+ sequenceValue: state.sequence['A']
104
+ }]
105
+ }
106
+ },
107
+
108
+ helpers: {
109
+ $setStateCollection: (el) => {
110
+ const { state, context } = el // eslint-disable-line no-unused-vars
111
+ const { TYPOGRAPHY, FONT_FAMILY } = context.SYSTEM
112
+ const { styles } = TYPOGRAPHY
113
+ el.removeContent()
114
+
115
+ const family = FONT_FAMILY[FONT_FAMILY.default]
116
+ const familyValue = getFontFamily()
117
+ const lineHeight = TYPOGRAPHY.lineHeight
118
+ const font = family.arr[0]
119
+
120
+ return Object.keys(styles).filter(v => v.slice(0, 1) === '.').map((v, k) => ({
121
+ key: v,
122
+ value: {
123
+ font,
124
+ fontFamily: familyValue,
125
+ fontWeight: 900 - (k * 100),
126
+ lineHeight,
127
+ ...styles[v]
128
+ },
129
+ labels: [
130
+ { icon: 'fontFace', text: font },
131
+ { icon: 'fontVariable', text: 900 - (k * 100) },
132
+ { icon: 'textLineHeight', text: lineHeight }
133
+ ],
134
+ sequenceValue: state.sequence[
135
+ findHeadingLetter(state.h1Matches, k)
136
+ ]
137
+ }))
138
+ }
139
+ },
140
+
141
+ footer: {}
55
142
  },
56
143
 
57
144
  fields: {
58
145
  extend: Flex,
59
146
  props: {
60
147
  gap: 'A',
148
+ margin: '0 0 0 E2+B',
61
149
  align: 'center flex-start'
62
150
  },
63
151
 
@@ -129,5 +217,19 @@ export default {
129
217
 
130
218
  Line: {},
131
219
 
132
- stylesHelpers
220
+ stylesHelpers,
221
+
222
+ on: {
223
+ init: (el, s) => {
224
+ if (!el.context.SYSTEM) return
225
+ const { context } = el // eslint-disable-line no-unused-vars
226
+ const { TYPOGRAPHY } = context.SYSTEM
227
+ const { styles } = TYPOGRAPHY
228
+ if (styles) {
229
+ s.update({
230
+ styles
231
+ }, { preventUpdate: true })
232
+ }
233
+ }
234
+ }
133
235
  }
@@ -2,8 +2,8 @@
2
2
 
3
3
  import state from './state'
4
4
 
5
+ import typeScale from './typeScale' // eslint-disable-line no-unused-vars
5
6
  import documentStyles from './documentStyles'
6
- import typeScale from './typeScale'
7
7
 
8
8
  export const Typography = {
9
9
  state,
@@ -13,7 +13,7 @@ export const Typography = {
13
13
  p: 'A general configuration of type properties on the document.'
14
14
  },
15
15
 
16
- // typeScale,
16
+ typeScale,
17
17
  Line: {},
18
18
  documentStyles
19
19
  }
@@ -25,7 +25,7 @@ export default {
25
25
 
26
26
  childProto: TypeHelperObject,
27
27
 
28
- $setCollection: () => [{
28
+ $setStateCollection: () => [{
29
29
  p: {
30
30
  text: 'Headline',
31
31
  style: { fontSize: `${48 / 16}em` }
@@ -70,9 +70,10 @@ export default {
70
70
 
71
71
  sequence: {
72
72
  extend: TypeScaleSequence,
73
- $setCollection: (el) => {
73
+ $setStateCollection: (el) => {
74
74
  const { state } = el
75
75
  state.sequence = {}
76
+ el.removeContent()
76
77
  return mapSequence(state, sortSequence)
77
78
  }
78
79
  },
package/src/state.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import SYSTEM from './config'
4
- import { LIBRARY } from '../.symbols'
4
+ import { LIBRARY, COMPONENTS } from '../.symbols'
5
5
 
6
6
  export const state = {
7
7
  globalTheme: 'dark'
@@ -9,5 +9,6 @@ export const state = {
9
9
 
10
10
  export const context = {
11
11
  LIBRARY,
12
- SYSTEM
12
+ SYSTEM,
13
+ COMPONENTS
13
14
  }