@symbo.ls/uikit 1.2.2 → 1.2.6
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/README.md +1 -1
- package/{packages/uikit/index.js → index.js} +0 -0
- package/package.json +32 -35
- package/.babelrc.json +0 -3
- package/.eslintrc.js +0 -16
- package/components/Atoms/Animation.js +0 -53
- package/components/Atoms/Block.js +0 -151
- package/components/Atoms/Collection.js +0 -82
- package/components/Atoms/Direction.js +0 -10
- package/components/Atoms/Flex.js +0 -17
- package/components/Atoms/Form.js +0 -11
- package/components/Atoms/Grid.js +0 -30
- package/components/Atoms/Iframe.js +0 -16
- package/components/Atoms/Img.js +0 -17
- package/components/Atoms/Interaction.js +0 -9
- package/components/Atoms/InteractiveComponent.js +0 -78
- package/components/Atoms/Media.js +0 -164
- package/components/Atoms/Overflow.js +0 -7
- package/components/Atoms/Picture.js +0 -31
- package/components/Atoms/Position.js +0 -21
- package/components/Atoms/Pseudo.js +0 -7
- package/components/Atoms/SVG.js +0 -16
- package/components/Atoms/Shape/index.js +0 -42
- package/components/Atoms/Shape/style.js +0 -204
- package/components/Atoms/Text.js +0 -40
- package/components/Atoms/Theme.js +0 -136
- package/components/Atoms/Timing.js +0 -55
- package/components/Atoms/Transform.js +0 -8
- package/components/Atoms/XYZ.js +0 -7
- package/components/Atoms/index.js +0 -25
- package/components/Atoms/package.json +0 -13
- package/components/Avatar/index.js +0 -32
- package/components/Avatar/package.json +0 -12
- package/components/Avatar/style.js +0 -19
- package/components/Banner/index.js +0 -22
- package/components/Banner/package.json +0 -12
- package/components/Banner/style.js +0 -27
- package/components/Box/index.js +0 -44
- package/components/Box/package.json +0 -10
- package/components/Button/README.md +0 -11
- package/components/Button/index.js +0 -48
- package/components/Button/package.json +0 -12
- package/components/ButtonSet/index.js +0 -10
- package/components/ButtonSet/package.json +0 -12
- package/components/Datepicker/index.js +0 -156
- package/components/Datepicker/package.json +0 -13
- package/components/Datepicker/style.js +0 -18
- package/components/Dropdown/index.js +0 -52
- package/components/Dropdown/package.json +0 -12
- package/components/Field/index.js +0 -43
- package/components/Field/package.json +0 -13
- package/components/Field/style.js +0 -30
- package/components/Icon/index.js +0 -50
- package/components/Icon/package.json +0 -11
- package/components/Icon/style.js +0 -8
- package/components/IconText/index.js +0 -16
- package/components/IconText/package.json +0 -14
- package/components/Input/index.js +0 -32
- package/components/Input/package.json +0 -11
- package/components/Label/index.js +0 -25
- package/components/Label/package.json +0 -13
- package/components/Link/index.js +0 -38
- package/components/Link/package.json +0 -12
- package/components/Notification/index.js +0 -47
- package/components/Notification/package.json +0 -16
- package/components/Pills/index.js +0 -25
- package/components/Pills/package.json +0 -11
- package/components/Range/index.js +0 -131
- package/components/Range/package.json +0 -13
- package/components/Select/index.js +0 -36
- package/components/Select/package.json +0 -11
- package/components/Sidebar/index.js +0 -24
- package/components/Sidebar/package.json +0 -12
- package/components/Slider/index.js +0 -105
- package/components/Slider/package.json +0 -13
- package/components/Slider/style.js +0 -19
- package/components/TextArea/index.js +0 -15
- package/components/TextArea/package.json +0 -11
- package/components/Tooltip/index.js +0 -37
- package/components/Tooltip/package.json +0 -11
- package/components/Tooltip/style.js +0 -12
- package/lerna.json +0 -9
- package/packages/react/index.js +0 -5
- package/packages/react/package.json +0 -16
- package/packages/uikit/README.md +0 -38
- package/packages/uikit/package.json +0 -40
- package/react/box/README.md +0 -114
- package/react/box/index.d.ts +0 -3
- package/react/box/index.js +0 -63
- package/react/box/package.json +0 -33
- package/svgSprite.config.js +0 -7
- package/watch.js +0 -12
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { merge, isArray } from '@domql/utils'
|
|
4
|
-
import { getSystemTheme } from './Theme'
|
|
5
|
-
|
|
6
|
-
const keySetters = {
|
|
7
|
-
'@': (key, props, result, element, isSubtree) => applyMediaProps(key, props, isSubtree ? result : result.media, element),
|
|
8
|
-
':': (key, props, result, element, isSubtree) => applySelectorProps(key, props, isSubtree ? result : result.selector, element),
|
|
9
|
-
'[': (key, props, result, element, isSubtree) => applySelectorProps(key, props, isSubtree ? result : result.selector, element),
|
|
10
|
-
'&': (key, props, result, element, isSubtree) => applySelectorProps(key, props, isSubtree ? result : result.selector, element),
|
|
11
|
-
$: (key, props, result, element, isSubtree) => applyCaseProps(key, props, isSubtree ? result : result.case, element),
|
|
12
|
-
'.': (key, props, result, element, isSubtree) => applyConditionalCaseProps(key, props, isSubtree ? result : result.case, element),
|
|
13
|
-
'!': (key, props, result, element, isSubtree) => applyConditionalFalsyProps(key, props, isSubtree ? result : result.case, element)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const execClass = (key, props, result, element) => {
|
|
17
|
-
const { class: className } = element
|
|
18
|
-
const classnameExec = className[key]
|
|
19
|
-
|
|
20
|
-
if (typeof classnameExec !== 'function') return
|
|
21
|
-
|
|
22
|
-
let classExec = classnameExec({
|
|
23
|
-
props,
|
|
24
|
-
context: element.context,
|
|
25
|
-
state: element.state
|
|
26
|
-
})
|
|
27
|
-
if (isArray(classExec)) {
|
|
28
|
-
classExec = classExec.reduce((a, c) => merge(a, c), {})
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
for (const finalProp in classExec) {
|
|
32
|
-
result[finalProp] = classExec[finalProp]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return classExec
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const convertPropsToClass = (props, result, element) => {
|
|
39
|
-
const propsClassObj = {}
|
|
40
|
-
|
|
41
|
-
for (const key in props) {
|
|
42
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
43
|
-
if (setter) {
|
|
44
|
-
setter(key, props[key], propsClassObj, element, true)
|
|
45
|
-
continue
|
|
46
|
-
} else {
|
|
47
|
-
execClass(key, props, propsClassObj, element)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return propsClassObj
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const applyMediaProps = (key, props, result, element) => {
|
|
55
|
-
const { context } = element
|
|
56
|
-
if (!context.system || !context.system.MEDIA) return
|
|
57
|
-
const globalTheme = getSystemTheme(element)
|
|
58
|
-
const { MEDIA } = context.system
|
|
59
|
-
const mediaName = MEDIA[key.slice(1)]
|
|
60
|
-
const generatedClass = convertPropsToClass(props, result, element)
|
|
61
|
-
|
|
62
|
-
const name = key.slice(1)
|
|
63
|
-
const isTheme = ['dark', 'light'].includes(name)
|
|
64
|
-
const matchesGlobal = name === globalTheme
|
|
65
|
-
|
|
66
|
-
if (globalTheme && isTheme) {
|
|
67
|
-
if (matchesGlobal) return merge(result, generatedClass)
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const mediaKey = `@media screen and ${mediaName}`
|
|
72
|
-
result[mediaKey] = generatedClass
|
|
73
|
-
return result[mediaKey]
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const applySelectorProps = (key, props, result, element) => {
|
|
77
|
-
const selectorKey = `&${key}`
|
|
78
|
-
result[selectorKey] = convertPropsToClass(props, result, element)
|
|
79
|
-
return result[selectorKey]
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const applyCaseProps = (key, props, result, element) => {
|
|
83
|
-
const { CASES } = element.context && element.context.system
|
|
84
|
-
const caseKey = key.slice(1)
|
|
85
|
-
const isPropTrue = element.props[caseKey]
|
|
86
|
-
if (!CASES[caseKey] && !isPropTrue) return
|
|
87
|
-
return merge(result, convertPropsToClass(props, result, element))
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const applyConditionalCaseProps = (key, props, result, element) => {
|
|
91
|
-
const caseKey = key.slice(1)
|
|
92
|
-
const isPropTrue = element.props[caseKey] || element.state[caseKey] === true
|
|
93
|
-
if (!isPropTrue) return // remove classname if not here
|
|
94
|
-
return merge(result, convertPropsToClass(props, result, element))
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const applyConditionalFalsyProps = (key, props, result, element) => {
|
|
98
|
-
const caseKey = key.slice(1)
|
|
99
|
-
const isPropTrue = element.props[caseKey] || element.state[caseKey] === true
|
|
100
|
-
if (!isPropTrue) return merge(result, convertPropsToClass(props, result, element))
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
const applyTrueProps = (props, result, element) => merge(result, convertPropsToClass(props, result, element))
|
|
104
|
-
|
|
105
|
-
const beforeClassAssign = (element, s) => {
|
|
106
|
-
const { props, class: className } = element
|
|
107
|
-
|
|
108
|
-
const CLASS_NAMES = {
|
|
109
|
-
media: {},
|
|
110
|
-
selector: {},
|
|
111
|
-
case: {}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
for (const key in props) {
|
|
115
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
116
|
-
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
merge(className, CLASS_NAMES)
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export const initUpdate = element => {
|
|
123
|
-
const { props, class: className } = element
|
|
124
|
-
const globalTheme = getSystemTheme(element)
|
|
125
|
-
|
|
126
|
-
const parentProps = element.parent.props
|
|
127
|
-
if (parentProps && parentProps.spacingRatio && parentProps.inheritSpacingRatio) {
|
|
128
|
-
element.setProps({
|
|
129
|
-
spacingRatio: parentProps.spacingRatio,
|
|
130
|
-
inheritSpacingRatio: true
|
|
131
|
-
}, {
|
|
132
|
-
preventRecursive: true,
|
|
133
|
-
ignoreInitUpdate: true
|
|
134
|
-
})
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (globalTheme) {
|
|
138
|
-
const CLASS_NAMES = {
|
|
139
|
-
media: {},
|
|
140
|
-
selector: {},
|
|
141
|
-
case: {}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
for (const key in props) {
|
|
145
|
-
const setter = keySetters[key.slice(0, 1)]
|
|
146
|
-
if (key === 'theme') {
|
|
147
|
-
props.update({
|
|
148
|
-
themeModifier: globalTheme
|
|
149
|
-
}, { preventRecursive: true, ignoreInitUpdate: true, preventDefineUpdate: '$setStateCollection' })
|
|
150
|
-
} else if (key === 'true') applyTrueProps(props[key], CLASS_NAMES, element)
|
|
151
|
-
if (setter) setter(key, props[key], CLASS_NAMES, element)
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
if (Object.keys(CLASS_NAMES.media).length) {
|
|
155
|
-
className.media = CLASS_NAMES.media
|
|
156
|
-
}
|
|
157
|
-
className.selector = CLASS_NAMES.selector
|
|
158
|
-
className.case = CLASS_NAMES.case
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export const Media = {
|
|
163
|
-
on: { beforeClassAssign, initUpdate }
|
|
164
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getSystemTheme } from './Theme'
|
|
4
|
-
|
|
5
|
-
export const Picture = {
|
|
6
|
-
tag: 'picture',
|
|
7
|
-
|
|
8
|
-
childExtend: {
|
|
9
|
-
tag: 'source',
|
|
10
|
-
attr: {
|
|
11
|
-
media: element => {
|
|
12
|
-
const { props, key, context } = element
|
|
13
|
-
const { MEDIA } = context.system
|
|
14
|
-
const globalTheme = getSystemTheme(element)
|
|
15
|
-
const mediaName = (props.media || key).slice(1)
|
|
16
|
-
|
|
17
|
-
if (mediaName === globalTheme) return '(min-width: 0px)'
|
|
18
|
-
else if (mediaName === 'dark' || mediaName === 'light') return '(max-width: 0px)'
|
|
19
|
-
|
|
20
|
-
return MEDIA[mediaName]
|
|
21
|
-
},
|
|
22
|
-
srcset: ({ props }) => props.srcset
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
// Img: ({ props }) => ({
|
|
27
|
-
// width: 'inherit',
|
|
28
|
-
// height: 'inherit',
|
|
29
|
-
// src: props.src
|
|
30
|
-
// })
|
|
31
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getSpacingByKey } from '@symbo.ls/scratch'
|
|
4
|
-
|
|
5
|
-
export const Position = {
|
|
6
|
-
props: {},
|
|
7
|
-
|
|
8
|
-
class: {
|
|
9
|
-
position: ({ props }) => props.position && ({ position: props.position }),
|
|
10
|
-
inset: ({ props }) => {
|
|
11
|
-
const { inset } = props
|
|
12
|
-
if (typeof inset !== 'string') return
|
|
13
|
-
return { inset: inset.split(' ').map(v => getSpacingByKey(v, 'k').k).join(' ') }
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
left: ({ props }) => getSpacingByKey(props.left, 'left'),
|
|
17
|
-
top: ({ props }) => getSpacingByKey(props.top, 'top'),
|
|
18
|
-
right: ({ props }) => getSpacingByKey(props.right, 'right'),
|
|
19
|
-
bottom: ({ props }) => getSpacingByKey(props.bottom, 'bottom')
|
|
20
|
-
}
|
|
21
|
-
}
|
package/components/Atoms/SVG.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
const useSVGSymbol = file => `<use xlink:href="${file}" />`
|
|
4
|
-
|
|
5
|
-
// create SVG symbol
|
|
6
|
-
export const SVG = {
|
|
7
|
-
tag: 'svg',
|
|
8
|
-
props: {
|
|
9
|
-
style: { '*': { fill: 'currentColor' } }
|
|
10
|
-
},
|
|
11
|
-
attr: {
|
|
12
|
-
xmlns: 'http://www.w3.org/2000/svg',
|
|
13
|
-
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
|
|
14
|
-
},
|
|
15
|
-
html: ({ key, props }) => useSVGSymbol(props.src)
|
|
16
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { exec, isString } from '@domql/utils'
|
|
4
|
-
import { SHAPES } from './style'
|
|
5
|
-
import { getSpacingBasedOnRatio, getMediaColor } from '@symbo.ls/scratch'
|
|
6
|
-
import { Pseudo } from '../Pseudo'
|
|
7
|
-
|
|
8
|
-
const transformBorderRadius = (radius, props, propertyName) => {
|
|
9
|
-
if (!isString(radius)) return
|
|
10
|
-
return {
|
|
11
|
-
borderRadius: radius.split(' ').map((v, k) => getSpacingBasedOnRatio(props, propertyName, v)[propertyName]).join(' ')
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const Shape = {
|
|
16
|
-
extend: Pseudo,
|
|
17
|
-
|
|
18
|
-
class: {
|
|
19
|
-
shape: (element) => {
|
|
20
|
-
const { props } = element
|
|
21
|
-
const { shape } = props
|
|
22
|
-
return shape ? exec(SHAPES[shape], element) : null
|
|
23
|
-
},
|
|
24
|
-
shapeDirection: ({ props }) => {
|
|
25
|
-
const { shape, shapeDirection } = props
|
|
26
|
-
if (!shape || !shapeDirection) return
|
|
27
|
-
const shapeDir = SHAPES[shape + 'Direction']
|
|
28
|
-
return shape && shapeDir ? shapeDir[shapeDirection || 'left'] : null
|
|
29
|
-
},
|
|
30
|
-
shapeDirectionColor: el => {
|
|
31
|
-
const { props } = el
|
|
32
|
-
const { background, backgroundColor } = props
|
|
33
|
-
const borderColor = getMediaColor(background || backgroundColor, 'borderColor')
|
|
34
|
-
return props.shapeDirection ? borderColor : null
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
round: ({ props, key, ...el }) => transformBorderRadius(props.round || props.borderRadius, props, 'round'),
|
|
38
|
-
borderRadius: ({ props, key, ...el }) => transformBorderRadius(props.borderRadius || props.round, props, 'borderRadius')
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export default Shape
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { UNIT, getColor, getTheme } from '@symbo.ls/scratch' // eslint-disable-line no-unused-vars
|
|
4
|
-
import { Timing } from '../Timing'
|
|
5
|
-
|
|
6
|
-
export const depth = {
|
|
7
|
-
4: { boxShadow: `rgba(0,0,0,.10) 0 2${UNIT.default} 4${UNIT.default}` },
|
|
8
|
-
6: { boxShadow: `rgba(0,0,0,.10) 0 3${UNIT.default} 6${UNIT.default}` },
|
|
9
|
-
10: { boxShadow: `rgba(0,0,0,.10) 0 4${UNIT.default} 10${UNIT.default}` },
|
|
10
|
-
16: { boxShadow: `rgba(0,0,0,.10) 0 8${UNIT.default} 16${UNIT.default}` },
|
|
11
|
-
26: { boxShadow: `rgba(0,0,0,.10) 0 14${UNIT.default} 26${UNIT.default}` },
|
|
12
|
-
42: { boxShadow: `rgba(0,0,0,.10) 0 20${UNIT.default} 42${UNIT.default}` }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const getComputedBackgroundColor = ({ props }) => {
|
|
16
|
-
return getColor(props.borderColor) || getColor(props.backgroundColor) || getColor(props.background)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const inheritTransition = (el) => {
|
|
20
|
-
const exec = Timing.class.transition(el)
|
|
21
|
-
return exec && exec['transition']
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const SHAPES = {
|
|
25
|
-
rectangle: {},
|
|
26
|
-
circle: { borderRadius: '100%' },
|
|
27
|
-
bubble: {},
|
|
28
|
-
tv: {
|
|
29
|
-
borderRadius: '1.15em/2.5em'
|
|
30
|
-
},
|
|
31
|
-
|
|
32
|
-
tooltip: el => ({
|
|
33
|
-
position: el.props.position || 'relative',
|
|
34
|
-
'&:before': {
|
|
35
|
-
content: '""',
|
|
36
|
-
display: 'block',
|
|
37
|
-
width: '0px',
|
|
38
|
-
height: '0px',
|
|
39
|
-
border: `.35em solid`,
|
|
40
|
-
borderColor: getComputedBackgroundColor(el),
|
|
41
|
-
transition: inheritTransition(el),
|
|
42
|
-
transitionProperty: 'border-color',
|
|
43
|
-
position: 'absolute',
|
|
44
|
-
borderRadius: '.15em'
|
|
45
|
-
}
|
|
46
|
-
}),
|
|
47
|
-
|
|
48
|
-
tooltipDirection: {
|
|
49
|
-
top: {
|
|
50
|
-
'&:before': {
|
|
51
|
-
top: '0',
|
|
52
|
-
left: '50%',
|
|
53
|
-
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
right: {
|
|
57
|
-
'&:before': {
|
|
58
|
-
top: '50%',
|
|
59
|
-
right: '0',
|
|
60
|
-
transform: 'translate(50%, -50%) rotate(45deg)'
|
|
61
|
-
}
|
|
62
|
-
},
|
|
63
|
-
bottom: {
|
|
64
|
-
'&:before': {
|
|
65
|
-
bottom: '0',
|
|
66
|
-
left: '50%',
|
|
67
|
-
transform: 'translate(-50%, 50%) rotate(45deg)'
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
left: {
|
|
71
|
-
'&:before': {
|
|
72
|
-
top: '50%',
|
|
73
|
-
left: '0',
|
|
74
|
-
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
tag: el => ({
|
|
80
|
-
position: 'relative',
|
|
81
|
-
'&:before': {
|
|
82
|
-
content: '""',
|
|
83
|
-
display: 'block',
|
|
84
|
-
background: getComputedBackgroundColor(el),
|
|
85
|
-
transition: inheritTransition(el),
|
|
86
|
-
transitionProperty: 'background',
|
|
87
|
-
borderRadius: '.25em',
|
|
88
|
-
position: 'absolute',
|
|
89
|
-
zIndex: '-1',
|
|
90
|
-
aspectRatio: '1/1',
|
|
91
|
-
top: '50%',
|
|
92
|
-
transformOrigin: '50% 50%',
|
|
93
|
-
height: '73%'
|
|
94
|
-
}
|
|
95
|
-
}),
|
|
96
|
-
|
|
97
|
-
tagDirection: {
|
|
98
|
-
top: {
|
|
99
|
-
'&:before': {
|
|
100
|
-
bottom: '100%',
|
|
101
|
-
left: '50%',
|
|
102
|
-
transform: 'translate(-50%, 50%) rotate(45deg)'
|
|
103
|
-
}
|
|
104
|
-
},
|
|
105
|
-
right: {
|
|
106
|
-
'&:before': {
|
|
107
|
-
top: '50%',
|
|
108
|
-
left: '100%',
|
|
109
|
-
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
bottom: {
|
|
113
|
-
'&:before': {
|
|
114
|
-
top: '100%',
|
|
115
|
-
left: '50%',
|
|
116
|
-
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
left: {
|
|
120
|
-
'&:before': {
|
|
121
|
-
top: '50%',
|
|
122
|
-
right: '100%',
|
|
123
|
-
transform: 'translate(50%, -50%) rotate(45deg)'
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
},
|
|
127
|
-
|
|
128
|
-
hexagon: el => ({
|
|
129
|
-
position: 'relative',
|
|
130
|
-
'&:before, &:after': {
|
|
131
|
-
content: '""',
|
|
132
|
-
display: 'block',
|
|
133
|
-
position: 'absolute',
|
|
134
|
-
zIndex: '-1',
|
|
135
|
-
borderRadius: '.25em',
|
|
136
|
-
aspectRatio: '1/1',
|
|
137
|
-
top: '50%',
|
|
138
|
-
transformOrigin: '50% 50%',
|
|
139
|
-
height: '73%',
|
|
140
|
-
background: getComputedBackgroundColor(el),
|
|
141
|
-
transition: inheritTransition(el),
|
|
142
|
-
transitionProperty: 'background'
|
|
143
|
-
},
|
|
144
|
-
'&:before': {
|
|
145
|
-
left: '0',
|
|
146
|
-
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
147
|
-
},
|
|
148
|
-
'&:after': {
|
|
149
|
-
left: '100%',
|
|
150
|
-
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
151
|
-
}
|
|
152
|
-
}),
|
|
153
|
-
|
|
154
|
-
chevron: el => ({
|
|
155
|
-
position: 'relative',
|
|
156
|
-
// overflow: 'hidden',
|
|
157
|
-
'&:before, &:after': {
|
|
158
|
-
content: '""',
|
|
159
|
-
display: 'block',
|
|
160
|
-
position: 'absolute',
|
|
161
|
-
zIndex: '-1',
|
|
162
|
-
aspectRatio: '1/1',
|
|
163
|
-
top: '50%',
|
|
164
|
-
transformOrigin: '50% 50%',
|
|
165
|
-
transition: inheritTransition(el),
|
|
166
|
-
transitionProperty: 'background'
|
|
167
|
-
|
|
168
|
-
},
|
|
169
|
-
'&:before': {
|
|
170
|
-
background: `linear-gradient(225deg, ${getComputedBackgroundColor(el)} 25%, transparent 25%), linear-gradient(315deg, ${getComputedBackgroundColor(el)} 25%, transparent 25%)`
|
|
171
|
-
},
|
|
172
|
-
'&:after': {
|
|
173
|
-
background: getComputedBackgroundColor(el),
|
|
174
|
-
borderRadius: '.25em'
|
|
175
|
-
}
|
|
176
|
-
}),
|
|
177
|
-
|
|
178
|
-
chevronDirection: {
|
|
179
|
-
left: {
|
|
180
|
-
'&:before': {
|
|
181
|
-
height: '100%',
|
|
182
|
-
left: '100%',
|
|
183
|
-
transform: 'translate3d(-1%, -50%, 1px) scale(-1, 1)'
|
|
184
|
-
},
|
|
185
|
-
'&:after': {
|
|
186
|
-
height: '73%',
|
|
187
|
-
left: '0',
|
|
188
|
-
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
189
|
-
}
|
|
190
|
-
},
|
|
191
|
-
right: {
|
|
192
|
-
'&:before': {
|
|
193
|
-
height: '100%',
|
|
194
|
-
left: '0',
|
|
195
|
-
transform: 'translate3d(-99%, -50%, 1px)'
|
|
196
|
-
},
|
|
197
|
-
'&:after': {
|
|
198
|
-
height: '73%',
|
|
199
|
-
left: '100%',
|
|
200
|
-
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
}
|
package/components/Atoms/Text.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getFontSizeByKey, getFontFamily } from '@symbo.ls/scratch'
|
|
4
|
-
|
|
5
|
-
export const Text = {
|
|
6
|
-
text: ({ key, props, state }) => {
|
|
7
|
-
if (props.text === true) return (state && state[key]) || (props && props[key])
|
|
8
|
-
return props.text
|
|
9
|
-
},
|
|
10
|
-
class: {
|
|
11
|
-
fontSize: ({ props }) => props.fontSize ? getFontSizeByKey(props.fontSize) : null,
|
|
12
|
-
fontFamily: ({ props }) => props.fontFamily && ({ fontFamily: getFontFamily(props.fontFamily) || props.fontFamily }),
|
|
13
|
-
lineHeight: ({ props }) => props.lineHeight && ({ lineHeight: props.lineHeight }),
|
|
14
|
-
// lineHeight: ({ props }) => props.lineHeight && getSpacingBasedOnRatio(props, 'lineHeight', null, ''),
|
|
15
|
-
textDecoration: ({ props }) => props.textDecoration && ({ textDecoration: props.textDecoration }),
|
|
16
|
-
textTransform: ({ props }) => props.textTransform && ({ textTransform: props.textTransform }),
|
|
17
|
-
whiteSpace: ({ props }) => props.whiteSpace && ({ whiteSpace: props.whiteSpace }),
|
|
18
|
-
letterSpacing: ({ props }) => props.letterSpacing && ({ letterSpacing: props.letterSpacing }),
|
|
19
|
-
textAlign: ({ props }) => props.textAlign && ({ textAlign: props.textAlign }),
|
|
20
|
-
fontWeight: ({ props }) => props.fontWeight && ({
|
|
21
|
-
fontWeight: props.fontWeight,
|
|
22
|
-
fontVariationSettings: '"wght" ' + props.fontWeight
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const H1 = { tag: 'h1' }
|
|
28
|
-
export const H2 = { tag: 'h2' }
|
|
29
|
-
export const H3 = { tag: 'h3' }
|
|
30
|
-
export const H4 = { tag: 'h4' }
|
|
31
|
-
export const H5 = { tag: 'h5' }
|
|
32
|
-
export const H6 = { tag: 'h6' }
|
|
33
|
-
export const P = { tag: 'p' }
|
|
34
|
-
export const Caption = { tag: 'caption' }
|
|
35
|
-
export const Strong = {
|
|
36
|
-
tag: 'strong',
|
|
37
|
-
props: { fontWeight: '700' }
|
|
38
|
-
}
|
|
39
|
-
export const Underline = { tag: 'u' }
|
|
40
|
-
export const Italic = { tag: 'i' }
|
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
|
-
import { getSpacingByKey, getMediaTheme, getColor, getMediaColor } from '@symbo.ls/scratch'
|
|
4
|
-
|
|
5
|
-
import { depth } from './Shape/style'
|
|
6
|
-
|
|
7
|
-
const isBorderStyle = str =>
|
|
8
|
-
['none', 'hidden', 'dotted', 'dashed', 'solid', 'double', 'groove', 'ridge', 'inset', 'outset', 'initial'].some(v => str.includes(v))
|
|
9
|
-
|
|
10
|
-
const transformBorder = border => {
|
|
11
|
-
const arr = border.split(', ')
|
|
12
|
-
return arr.map(v => {
|
|
13
|
-
v = v.trim()
|
|
14
|
-
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
15
|
-
else if (isBorderStyle(v)) return v || 'solid'
|
|
16
|
-
else if (v.slice(-2) === 'px' || v.slice(-2) === 'em') return v // TODO: add map spacing
|
|
17
|
-
else if (getColor(v).length > 2) return getColor(v)
|
|
18
|
-
return getSpacingByKey(v, 'border').border
|
|
19
|
-
}).join(' ')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const transformTextStroke = stroke => ({
|
|
23
|
-
WebkitTextStroke: stroke.split(', ').map(v => {
|
|
24
|
-
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
25
|
-
if (v.includes('px')) return v
|
|
26
|
-
else if (getColor(v)) return getColor(v)
|
|
27
|
-
}).join(' ')
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
export const transformShadow = shadows => shadows.split('|').map(shadow => {
|
|
31
|
-
return shadow.split(', ').map(v => {
|
|
32
|
-
v = v.trim()
|
|
33
|
-
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
34
|
-
if (getColor(v).length > 2) return getColor(v)
|
|
35
|
-
if (v.includes('px') || v.slice(-2) === 'em') return v
|
|
36
|
-
const arr = v.split(' ')
|
|
37
|
-
if (!arr.length) return v
|
|
38
|
-
return arr.map(v => getSpacingByKey(v, 'shadow').shadow).join(' ')
|
|
39
|
-
}).join(' ')
|
|
40
|
-
}).join(',')
|
|
41
|
-
|
|
42
|
-
const transformBackgroundImage = (backgroundImage, ctx, globalTheme) => ({
|
|
43
|
-
backgroundImage: backgroundImage.split(', ').map(v => {
|
|
44
|
-
if (v.slice(0, 2) === '--') return `var(${v})`
|
|
45
|
-
if (v.includes('url') || v.includes('gradient')) return v
|
|
46
|
-
else if (ctx.system.GRADIENT[backgroundImage]) {
|
|
47
|
-
return getMediaColor(backgroundImage, 'backgroundImage', globalTheme)
|
|
48
|
-
}
|
|
49
|
-
return `url(${v})`
|
|
50
|
-
}).join(' ')
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
export const getSystemTheme = (element, state) => {
|
|
54
|
-
const { context } = element
|
|
55
|
-
const rootState = element.__root ? element.__root.state : element.state
|
|
56
|
-
return rootState.globalTheme || context.system.globalTheme
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export const Theme = {
|
|
60
|
-
class: {
|
|
61
|
-
depth: ({ props }) => depth[props.depth],
|
|
62
|
-
|
|
63
|
-
theme: (element) => {
|
|
64
|
-
const { props } = element
|
|
65
|
-
const globalTheme = getSystemTheme(element)
|
|
66
|
-
if (!props.theme) return
|
|
67
|
-
return getMediaTheme(props.theme, `@${props.themeModifier || globalTheme}`)
|
|
68
|
-
},
|
|
69
|
-
|
|
70
|
-
color: (element) => {
|
|
71
|
-
const { props } = element
|
|
72
|
-
const globalTheme = getSystemTheme(element)
|
|
73
|
-
if (!props.color) return
|
|
74
|
-
return getMediaColor(props.color, 'color', globalTheme)
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
background: (element) => {
|
|
78
|
-
const { props } = element
|
|
79
|
-
const globalTheme = getSystemTheme(element)
|
|
80
|
-
if (!props.background) return
|
|
81
|
-
return getMediaColor(props.background, 'background', globalTheme)
|
|
82
|
-
},
|
|
83
|
-
|
|
84
|
-
backgroundColor: (element) => {
|
|
85
|
-
const { props } = element
|
|
86
|
-
const globalTheme = getSystemTheme(element)
|
|
87
|
-
if (!props.backgroundColor) return
|
|
88
|
-
return getMediaColor(props.backgroundColor, 'backgroundColor', globalTheme)
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
backgroundImage: (element) => {
|
|
92
|
-
const { props, context } = element
|
|
93
|
-
const globalTheme = getSystemTheme(element)
|
|
94
|
-
if (!props.backgroundImage) return
|
|
95
|
-
return transformBackgroundImage(props.backgroundImage, context, globalTheme)
|
|
96
|
-
},
|
|
97
|
-
backgroundSize: ({ props }) => props.backgroundSize ? ({ backgroundSize: props.backgroundSize }) : null,
|
|
98
|
-
backgroundPosition: ({ props }) => props.backgroundPosition ? ({ backgroundPosition: props.backgroundPosition }) : null,
|
|
99
|
-
|
|
100
|
-
textStroke: ({ props }) => props.textStroke ? transformTextStroke(props.textStroke) : null,
|
|
101
|
-
|
|
102
|
-
outline: ({ props }) => props.outline && ({
|
|
103
|
-
outline: transformBorder(props.outline)
|
|
104
|
-
}),
|
|
105
|
-
|
|
106
|
-
border: ({ props }) => props.border && ({
|
|
107
|
-
border: transformBorder(props.border)
|
|
108
|
-
}),
|
|
109
|
-
borderColor: ({ props }) => (props.borderColor) && getMediaColor(props.borderColor, 'borderColor'),
|
|
110
|
-
borderStyle: ({ props }) => props.borderStyle && ({ borderStyle: props.borderStyle }),
|
|
111
|
-
|
|
112
|
-
borderLeft: ({ props }) => props.borderLeft && ({
|
|
113
|
-
borderLeft: transformBorder(props.borderLeft)
|
|
114
|
-
}),
|
|
115
|
-
borderTop: ({ props }) => props.borderTop && ({
|
|
116
|
-
borderTop: transformBorder(props.borderTop)
|
|
117
|
-
}),
|
|
118
|
-
borderRight: ({ props }) => props.borderRight && ({
|
|
119
|
-
borderRight: transformBorder(props.borderRight)
|
|
120
|
-
}),
|
|
121
|
-
borderBottom: ({ props }) => props.borderBottom && ({
|
|
122
|
-
borderBottom: transformBorder(props.borderBottom)
|
|
123
|
-
}),
|
|
124
|
-
|
|
125
|
-
boxShadow: ({ props }) => props.boxShadow && ({
|
|
126
|
-
boxShadow: transformShadow(props.boxShadow)
|
|
127
|
-
}),
|
|
128
|
-
|
|
129
|
-
textShadow: ({ props }) => props.textShadow && ({
|
|
130
|
-
textShadow: transformShadow(props.textShadow)
|
|
131
|
-
}),
|
|
132
|
-
|
|
133
|
-
opacity: ({ props }) => props.opacity && ({ opacity: props.opacity }),
|
|
134
|
-
visibility: ({ props }) => props.visibility && ({ visibility: props.visibility })
|
|
135
|
-
}
|
|
136
|
-
}
|