@symbo.ls/preview 0.0.69 → 0.0.70

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.69",
5
+ "version": "0.0.70",
6
6
  "repository": "https://github.com/rackai/editor",
7
7
  "main": "src/index.js",
8
8
  "scripts": {
@@ -26,6 +26,7 @@ export const Spaces = {
26
26
  }
27
27
  },
28
28
  stateUpdated: (el, s, changes) => {
29
- s.systemUpdate({ SPACING: changes }, { preventUpdate: true })
29
+ console.log(s)
30
+ s.systemUpdate({ SPACING: { base: s.base, ratio: s.ratio } }, { preventUpdate: true })
30
31
  }
31
32
  }
@@ -37,35 +37,39 @@ export default {
37
37
  headings: {
38
38
  extend: DocumentStylesSequence,
39
39
 
40
- $setStateCollection: (el) => {
41
- const { state, context } = el // eslint-disable-line no-unused-vars
42
- const { TYPOGRAPHY, FONT_FAMILY } = context.SYSTEM
43
- const { styles } = TYPOGRAPHY
44
- el.removeContent()
45
-
46
- const family = FONT_FAMILY[FONT_FAMILY.default]
47
- const familyValue = getFontFamily()
48
- const lineHeight = TYPOGRAPHY.lineHeight
49
- const font = family.arr[0]
50
-
40
+ $setStateCollection: (el, s) => {
41
+ const { __system } = s
42
+ const { TYPOGRAPHY, FONT_FAMILY } = __system
43
+ let { styles } = TYPOGRAPHY
44
+ if (!styles) styles = TYPOGRAPHY.styles = {}
45
+
46
+ const familyValue = getFontFamily('def', FONT_FAMILY)
47
+ const { lineHeight, fontWeight } = TYPOGRAPHY
48
+ const font = familyValue[0]
51
49
  const HEADINGS = new Array(6).fill(null).map((_, i) => 'h' + (i + 1))
52
50
 
51
+ el.removeContent()
52
+ const calcProp = (key, prop, defaultValue) => {
53
+ if (!styles[key]) styles[key] = {}
54
+ return styles[key][prop] || styles[prop] || defaultValue
55
+ }
56
+
53
57
  return HEADINGS.map((v, k) => ({
54
58
  key: v,
55
59
  value: {
56
60
  font,
57
- fontFamily: familyValue,
58
- fontWeight: 900 - (k * 100),
59
- lineHeight,
60
- ...styles[v]
61
+ fontFamily: calcProp(v, 'fontFamily', familyValue),
62
+ fontWeight: calcProp(v, 'fontWeight', fontWeight),
63
+ lineHeight: calcProp(v, 'lineHeight', lineHeight),
64
+ ...(styles ? styles[v] : {})
61
65
  },
62
66
  labels: [
63
67
  { icon: 'fontFace', text: font },
64
68
  { icon: 'fontVariable', text: 900 - (k * 100) },
65
69
  { icon: 'textLineHeight', text: lineHeight }
66
70
  ],
67
- sequenceValue: state.sequence[
68
- findHeadingLetter(state.h1Matches, k)
71
+ sequenceValue: s.sequence[
72
+ findHeadingLetter(s.h1Matches, k)
69
73
  ]
70
74
  }))
71
75
  }
@@ -73,52 +77,52 @@ export default {
73
77
 
74
78
  doc: {
75
79
  extend: DocumentStylesSequence,
76
- $setStateCollection: (el) => {
77
- const { state, context } = el // eslint-disable-line no-unused-vars
78
- const { DOCUMENT, FONT_FAMILY } = context.SYSTEM
79
- el.removeContent()
80
+ $setStateCollection: (el, s) => {
81
+ const { __system } = s
82
+ const { FONT_FAMILY, TYPOGRAPHY } = __system
83
+ const { styles, lineHeight, fontWeight } = TYPOGRAPHY
84
+ if (!styles.body) styles.body = {}
80
85
 
81
- const family = FONT_FAMILY[FONT_FAMILY.default]
82
- const familyValue = getFontFamily()
83
- const font = family.arr[0]
84
- const { fontWeight, lineHeight } = DOCUMENT
86
+ const familyValue = getFontFamily('def', FONT_FAMILY)
87
+ const font = familyValue[0]
85
88
 
89
+ el.removeContent()
86
90
  return [{
87
91
  key: 'body',
88
92
  value: {
89
- font,
90
- fontFamily: familyValue,
91
- fontWeight: fontWeight || 400,
92
- lineHeight
93
+ fontFamily: styles ? styles['body'].fontFamily || styles.fontFamily : familyValue,
94
+ fontWeight: styles ? styles['body'].fontWeight || styles.fontWeight : fontWeight,
95
+ lineHeight: styles ? styles['body'].lineHeight || styles.lineHeight : lineHeight,
96
+ ...(styles ? styles['body'] : {})
93
97
  },
94
98
  labels: [
95
99
  { icon: 'fontFace', text: font },
96
100
  { icon: 'fontVariable', text: fontWeight || 400 },
97
101
  { icon: 'textLineHeight', text: lineHeight }
98
102
  ],
99
- sequenceValue: state.sequence['A']
103
+ sequenceValue: s.sequence['A']
100
104
  }]
101
105
  }
102
106
  },
103
107
 
104
108
  helpers: {
105
- $setStateCollection: (el) => {
109
+ $setStateCollection: (el, s) => {
106
110
  const { state, context } = el // eslint-disable-line no-unused-vars
107
- const { TYPOGRAPHY, FONT_FAMILY } = context.SYSTEM
108
- const { styles } = TYPOGRAPHY
109
- el.removeContent()
111
+ const { __system } = s
112
+ const { TYPOGRAPHY, FONT_FAMILY } = __system
113
+ const { styles, lineHeight, fontWeight } = TYPOGRAPHY
110
114
 
111
- const family = FONT_FAMILY[FONT_FAMILY.default]
112
- const familyValue = getFontFamily()
113
- const lineHeight = TYPOGRAPHY.lineHeight
114
- const font = family.arr[0]
115
+ const familyValue = getFontFamily('def', FONT_FAMILY)
116
+ const font = familyValue[0]
115
117
 
118
+ el.removeContent()
119
+ if (!styles) return
116
120
  return Object.keys(styles).filter(v => v.slice(0, 1) === '.').map((v, k) => ({
117
121
  key: v,
118
122
  value: {
119
123
  font,
120
124
  fontFamily: familyValue,
121
- fontWeight: 900 - (k * 100),
125
+ fontWeight: styles[v].fontWeight || fontWeight,
122
126
  lineHeight,
123
127
  ...styles[v]
124
128
  },
@@ -214,14 +218,12 @@ export default {
214
218
  on: {
215
219
  init: (el, s) => {
216
220
  if (!s.__system) return
217
- const { context } = el // eslint-disable-line no-unused-vars
218
- const { TYPOGRAPHY } = context.SYSTEM
221
+ const { __system } = s
222
+ const { TYPOGRAPHY } = __system
219
223
  const { styles } = TYPOGRAPHY
220
224
  if (styles) {
221
- s.update({
222
- styles
223
- }, { preventUpdate: true })
224
- }
225
+ s.update({ styles }, { preventUpdate: true })
226
+ } else TYPOGRAPHY.styles = {}
225
227
  }
226
228
  }
227
229
  }
package/src/sync.js CHANGED
@@ -17,6 +17,7 @@ export const Sync = {
17
17
  stateUpdated: (el, s, changes) => {
18
18
  if (changes.SYSTEM) {
19
19
  // init(changes.SYSTEM)
20
+ console.log(changes)
20
21
  send(changes.SYSTEM, s.SYSTEM)
21
22
  }
22
23
  }
package/user_data/4it.js CHANGED
@@ -118,13 +118,17 @@ export const FONT = {
118
118
  }, {
119
119
  url: S3_BUCKET + AvenirHeavy,
120
120
  fontWeight: 900
121
- }]
121
+ }],
122
+ AvenirVariable: {
123
+ url: 'https://s3-us-west-2.amazonaws.com/s.cdpn.io/2729/AvenirNext_Variable.ttf',
124
+ isVariable: true
125
+ }
122
126
  }
123
127
 
124
128
  export const FONT_FAMILY = {
125
129
  Default: {
126
130
  isDefault: true,
127
- value: ['"Avenir"'],
131
+ value: ['"AvenirVariable"', '"Avenir"'],
128
132
  type: 'serif'
129
133
  }
130
134
  }