@symbo.ls/preview 0.0.40 → 0.0.42

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.40",
5
+ "version": "0.0.42",
6
6
  "repository": "https://github.com/rackai/editor",
7
7
  "main": "src/index.js",
8
8
  "scripts": {
@@ -1,7 +1,7 @@
1
1
  'use strict'
2
2
 
3
3
  import { router } from '@domql/router'
4
- import { ClickableItem, Flex, Link, ResponsivePreview, SquareButton } from '@symbo.ls/components'
4
+ import { ClickableItem, Flex, Link, ResponsivePreview, SquareButton, TooltipParent } from '@symbo.ls/components'
5
5
  import { PageExtend,
6
6
  Color,
7
7
  Theme,
@@ -14,55 +14,74 @@ import { PageExtend,
14
14
  } from '..'
15
15
 
16
16
  const NAV = [{
17
+ state: {
18
+ href: '/colors',
19
+ tooltip: 'Colors'
20
+ },
17
21
  props: {
18
- icon: 'color outline colored',
19
- href: '/colors'
22
+ icon: { name: 'color outline colored' }
20
23
  }
21
24
  }, {
22
- props: {
23
- icon: 'typography outline',
25
+ state: {
24
26
  href: '/typography',
27
+ tooltip: 'Typography'
28
+ },
29
+ props: {
30
+ icon: { name: 'typography outline' },
25
31
  opacity: '.7'
26
32
  }
27
33
  }, {
28
- props: {
29
- icon: 'space outline',
34
+ state: {
30
35
  href: '/space',
36
+ tooltip: 'Spacing'
37
+ },
38
+ props: {
39
+ icon: { name: 'space outline' },
31
40
  opacity: '.7'
32
41
  }
33
42
  }, {
43
+ state: {
44
+ href: '/shape',
45
+ tooltip: 'Shapes'
46
+ },
34
47
  props: {
35
- icon: 'shape outline colored',
36
- href: '/shape'
48
+ icon: { name: 'shape outline colored' }
37
49
  }
38
50
  }, {
39
- props: {
40
- icon: 'icons outline colored',
51
+ state: {
41
52
  href: '/icons',
42
- $active: {
43
- icon: 'icons colored'
44
- }
45
- }
46
- }, {
53
+ tooltip: 'Icons'
54
+ },
47
55
  props: {
48
- icon: 'fontFace colored',
49
- href: '/fonts'
56
+ icon: { name: 'icons outline colored' },
57
+ '.active': {
58
+ icon: { name: 'icons colored' }
59
+ }
50
60
  }
51
61
  }, {
52
- props: {
53
- icon: 'device mobile half fill',
62
+ state: {
54
63
  href: '/media-query',
64
+ tooltip: 'Responsive'
65
+ },
66
+ props: {
67
+ icon: { name: 'device mobile half fill' },
55
68
  opacity: '.7'
56
69
  }
57
70
  }, {
71
+ state: {
72
+ href: '/timing',
73
+ tooltip: 'Timing'
74
+ },
58
75
  props: {
59
- icon: 'clock colored',
60
- href: '/timing'
76
+ icon: { name: 'clock colored' }
61
77
  }
62
78
  }, {
79
+ state: {
80
+ href: '/sequence',
81
+ tooltip: 'Sequence'
82
+ },
63
83
  props: {
64
- icon: 'sequence colored',
65
- href: '/sequence'
84
+ icon: { name: 'sequence colored' }
66
85
  }
67
86
  }]
68
87
 
@@ -81,7 +100,6 @@ export const DesignSystem = {
81
100
  '/colors': Color,
82
101
  '/theme': Theme,
83
102
  '/typography': Typography,
84
- '/fonts': Fonts,
85
103
  '/space': Spaces,
86
104
  '/shape': Shapes,
87
105
  '/icons': Icons,
@@ -105,13 +123,6 @@ export const DesignSystem = {
105
123
  sidebar: {
106
124
  tag: 'nav',
107
125
  extend: Flex,
108
- childExtend: {
109
- extend: [ClickableItem, Link, SquareButton],
110
- props: ({ props }) => ({
111
- active: props.href === window.location.pathname,
112
- theme: null
113
- })
114
- },
115
126
 
116
127
  props: {
117
128
  gap: 'B1',
@@ -123,6 +134,45 @@ export const DesignSystem = {
123
134
  top: 'E'
124
135
  },
125
136
 
137
+ childExtend: {
138
+ extend: [ClickableItem, Link, SquareButton, TooltipParent],
139
+ props: ({ state }) => ({
140
+ href: state.href,
141
+ active: window.location.pathname.includes(state.href),
142
+ theme: null,
143
+ position: 'relative',
144
+ style: {
145
+ '&:hover, &:focus-visible': {
146
+ '& [tooltip]': {
147
+ transform: 'translate3d(0%,-50%,0)'
148
+ }
149
+ }
150
+ }
151
+ }),
152
+ Tooltip: ({ state }) => ({
153
+ background: 'black .95',
154
+ position: 'absolute',
155
+ pointerEvents: 'none',
156
+ top: '50%',
157
+ left: '90%',
158
+ shape: 'rectangle',
159
+ shapeDirection: null,
160
+ padding: 'X2 Z1',
161
+ transform: 'translate3d(10%, -50%, 0)',
162
+ opacity: '0',
163
+ visibility: 'hidden',
164
+ transition: 'B default-bezier',
165
+ transitionProperty: 'opacity, transform',
166
+ zIndex: 1000,
167
+ lineHeight: 1,
168
+ title: {
169
+ fontSize: 'Z',
170
+ text: state.tooltip
171
+ },
172
+ p: { text: null }
173
+ })
174
+ },
175
+
126
176
  ...NAV
127
177
  },
128
178
 
@@ -9,7 +9,6 @@ import {
9
9
  SequenceSliders,
10
10
  DeviceButtonSet
11
11
  } from '@symbo.ls/components'
12
- import stylesHelpers from './stylesHelpers'
13
12
 
14
13
  import { HTML_TAGS } from '@domql/tags' // eslint-disable-line no-unused-vars
15
14
 
@@ -224,10 +223,6 @@ export default {
224
223
  }
225
224
  },
226
225
 
227
- Line: {},
228
-
229
- stylesHelpers,
230
-
231
226
  on: {
232
227
  init: (el, s) => {
233
228
  if (!el.context.SYSTEM) return
@@ -0,0 +1,50 @@
1
+ 'use strict'
2
+
3
+ import { Grid, Hoverable, FontObject } from '@symbo.ls/components'
4
+ import { TypeSection } from './shared'
5
+
6
+ const mapFonts = (el, s) => {
7
+ if (!el.context.SYSTEM) return
8
+ const { FONT } = el.context.SYSTEM
9
+ const fontKeys = Object.keys(FONT)
10
+
11
+ return fontKeys.map(v => {
12
+ const font = FONT[v]
13
+ const weights = Object.keys(font)
14
+ const weightsLength = weights.length
15
+ const fontWeightCaption = weights[0] === 'variable' ? 'variable' : `${weightsLength} style${weightsLength > 1 ? 's' : ''}`
16
+
17
+ return {
18
+ title: v,
19
+ href: `/fonts/font-settings/${v}`,
20
+ labels: [
21
+ { icon: 'fontVariable', text: fontWeightCaption }
22
+ ]
23
+ }
24
+ })
25
+ }
26
+
27
+ export default {
28
+ extend: TypeSection,
29
+ header: {
30
+ state: {
31
+ title: 'Document Fonts',
32
+ p: 'Document @font-face, default and backup fonts',
33
+ nav: [{
34
+ icon: 'plus',
35
+ href: '/fonts/upload-font'
36
+ }]
37
+ }
38
+ },
39
+
40
+ content: {
41
+ extend: Grid,
42
+ props: {
43
+ columns: 'repeat(2, 1fr)',
44
+ gap: 'A',
45
+ margin: '0 -Z'
46
+ },
47
+ childExtend: [FontObject, Hoverable],
48
+ $setStateCollection: mapFonts
49
+ }
50
+ }
@@ -0,0 +1,45 @@
1
+ 'use strict'
2
+
3
+ import { Grid, Hoverable, FontFamilyObject } from '@symbo.ls/components'
4
+ import { TypeSection } from './shared'
5
+
6
+ const mapFontFamilies = (el, s) => {
7
+ if (!el.context.SYSTEM) return
8
+ const { FONT_FAMILY } = el.context.SYSTEM
9
+ const fontFamilyKeys = Object.keys(FONT_FAMILY)
10
+
11
+ return fontFamilyKeys.map(v => {
12
+ const val = FONT_FAMILY[v]
13
+ if (v === 'default') return
14
+ return {
15
+ title: v,
16
+ href: `/fonts/font-family/${v}`,
17
+ val
18
+ }
19
+ }).filter(v => v)
20
+ }
21
+
22
+ export default {
23
+ extend: TypeSection,
24
+ header: {
25
+ state: {
26
+ title: 'Font Families',
27
+ p: 'Setup a set and fallback fonts as font families',
28
+ nav: [{
29
+ icon: 'plus',
30
+ href: '/fonts/add-font-family'
31
+ }]
32
+ }
33
+ },
34
+ content: {
35
+ extend: Grid,
36
+ props: {
37
+ columns: 'repeat(4, 1fr)',
38
+ gap: 'A',
39
+ margin: '0 -Z'
40
+ },
41
+
42
+ childExtend: [FontFamilyObject, Hoverable],
43
+ $setStateCollection: mapFontFamilies
44
+ }
45
+ }
@@ -2,8 +2,12 @@
2
2
 
3
3
  import state from './state'
4
4
 
5
+ import fontFaces from './fontFaces'
5
6
  import typeScale from './typeScale'
7
+ import fontFamilies from './fontFamilies'
6
8
  import documentStyles from './documentStyles'
9
+ import stylesHelpers from './stylesHelpers'
10
+ import { mapSequence, sortSequence } from '@symbo.ls/components'
7
11
 
8
12
  export const Typography = {
9
13
  state,
@@ -13,7 +17,25 @@ export const Typography = {
13
17
  p: 'A general configuration of type properties on the document.'
14
18
  },
15
19
 
20
+ line: { extend: 'Line' },
21
+
22
+ documentStyles,
23
+ line1: { extend: 'Line' },
24
+
25
+ stylesHelpers,
26
+ line2: { extend: 'Line' },
27
+
28
+ fontFaces,
29
+ line3: { extend: 'Line' },
30
+
31
+ fontFamilies,
32
+ line4: { extend: 'Line' },
33
+
16
34
  typeScale,
17
- Line: {},
18
- documentStyles
35
+
36
+ on: {
37
+ init: (el, s) => {
38
+ mapSequence(s, sortSequence)
39
+ }
40
+ }
19
41
  }
@@ -5,6 +5,7 @@ import {
5
5
  SectionHeader,
6
6
  TypeHelperObject
7
7
  } from '@symbo.ls/components'
8
+ import { findHeadingLetter, getFontFamily } from '@symbo.ls/scratch'
8
9
 
9
10
  export default {
10
11
  header: {
@@ -23,32 +24,39 @@ export default {
23
24
  extend: Grid,
24
25
  props: { columns: 'repeat(3, 1fr)' },
25
26
 
26
- childProto: TypeHelperObject,
27
+ childExtend: TypeHelperObject,
27
28
 
28
- $setStateCollection: () => [{
29
- p: {
30
- text: 'Headline',
31
- style: { fontSize: `${48 / 16}em` }
32
- }
33
- }, {
34
- p: {
35
- text: 'Headline 2',
36
- style: { fontSize: `${40 / 16}em` }
29
+ $setStateCollection: (el) => {
30
+ const { state, context } = el // eslint-disable-line no-unused-vars
31
+ const { TYPOGRAPHY, FONT_FAMILY } = context.SYSTEM
32
+ const { styles } = TYPOGRAPHY
33
+ el.removeContent()
37
34
 
38
- }
39
- }, {
40
- p: '',
41
- span: {
42
- props: {
43
- fontSize: 'Y',
44
- padding: 'B 0 0 0'
35
+ const family = FONT_FAMILY[FONT_FAMILY.default]
36
+ const familyValue = getFontFamily()
37
+ const lineHeight = TYPOGRAPHY.lineHeight
38
+ const font = family.arr[0]
39
+
40
+ const HELPERS = Object.keys(styles).filter(v => v.slice(0, 1) === '.')
41
+ console.log(HELPERS)
42
+ return HELPERS.map((v, k) => ({
43
+ key: v,
44
+ value: {
45
+ font,
46
+ fontFamily: familyValue,
47
+ fontWeight: 900 - (k * 100),
48
+ lineHeight,
49
+ ...styles[v]
45
50
  },
46
- text: 'Fontnote'
47
- }
48
- // p: {
49
- // text: 'Footnote',
50
- // style: { fontSize: `${12 / 16}em` }
51
- // }
52
- }]
51
+ labels: [
52
+ { icon: 'fontFace', text: font },
53
+ { icon: 'fontVariable', text: 900 - (k * 100) },
54
+ { icon: 'textLineHeight', text: lineHeight }
55
+ ],
56
+ sequenceValue: state.sequence[
57
+ findHeadingLetter(state.h1Matches, k)
58
+ ]
59
+ }))
60
+ }
53
61
  }
54
62
  }
package/src/state.js CHANGED
@@ -1,5 +1,6 @@
1
1
  'use strict'
2
2
 
3
+ import SYMBOLS_CONF from '@symbo.ls/config'
3
4
  import SYSTEM from './config'
4
5
  import { LIBRARY, COMPONENTS } from '../.symbols'
5
6
 
@@ -8,6 +9,7 @@ export const state = {
8
9
  }
9
10
 
10
11
  export const context = {
12
+ CONFIG: SYMBOLS_CONF,
11
13
  LIBRARY,
12
14
  SYSTEM,
13
15
  COMPONENTS