@symbo.ls/default-config 3.8.9 → 3.14.1
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 +4 -1
- package/__tests__/assetMedia.test.js +242 -0
- package/__tests__/componentsManifest.test.js +41 -0
- package/blank/font.js +1 -1
- package/blank/index.js +8 -8
- package/components/Atoms/AssetPicture.js +34 -0
- package/components/Atoms/Audio.js +38 -0
- package/components/Atoms/Block.js +29 -0
- package/components/Atoms/Box.js +37 -0
- package/components/Atoms/Form.js +5 -0
- package/components/Atoms/Grid.js +37 -0
- package/components/Atoms/Hgroup.js +75 -0
- package/components/Atoms/Iframe.js +8 -0
- package/components/Atoms/Img.js +33 -0
- package/components/Atoms/InteractiveComponent.js +65 -0
- package/components/Atoms/Picture.js +34 -0
- package/components/Atoms/Shape/index.js +3 -0
- package/components/Atoms/Shape.js +249 -0
- package/components/Atoms/Svg.js +78 -0
- package/components/Atoms/Text.js +45 -0
- package/components/Atoms/Theme.js +20 -0
- package/components/Atoms/Video.js +45 -0
- package/components/Avatar.js +10 -0
- package/components/Button.js +72 -0
- package/components/Dialog.js +69 -0
- package/components/Dropdown.js +153 -0
- package/components/Icon/index.js +236 -0
- package/components/Icon/style.js +8 -0
- package/components/Input/Checkbox.js +54 -0
- package/components/Input/Input.js +37 -0
- package/components/Input/NumberInput.js +25 -0
- package/components/Input/Radio.js +31 -0
- package/components/Input/Textarea.js +47 -0
- package/components/Input/Toggle.js +36 -0
- package/components/Link.js +166 -0
- package/components/Notification.js +43 -0
- package/components/Range.js +106 -0
- package/components/Select.js +33 -0
- package/components/Tooltip/index.js +133 -0
- package/components/Tooltip/style.js +12 -0
- package/components/index.js +91 -0
- package/default/font.js +1 -1
- package/default/index.js +2 -2
- package/designSystem/color.js +70 -0
- package/designSystem/font.js +21 -0
- package/designSystem/icons.js +69 -0
- package/designSystem/index.js +45 -0
- package/designSystem/media.js +31 -0
- package/designSystem/spacing.js +6 -0
- package/designSystem/theme.js +247 -0
- package/designSystem/timing.js +8 -0
- package/designSystem/typography.js +9 -0
- package/index.js +15 -0
- package/package.json +4 -1
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const style = {
|
|
4
|
+
appearance: 'none',
|
|
5
|
+
cursor: 'pointer',
|
|
6
|
+
fontFamily: 'inherit'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export const Hoverable = {
|
|
10
|
+
transition: 'C defaultBezier',
|
|
11
|
+
transitionProperty: 'opacity, transform',
|
|
12
|
+
opacity: 0.85,
|
|
13
|
+
|
|
14
|
+
':hover': {
|
|
15
|
+
opacity: 0.9,
|
|
16
|
+
transform: 'scale(1.015)'
|
|
17
|
+
},
|
|
18
|
+
':active': {
|
|
19
|
+
opacity: 1,
|
|
20
|
+
transform: 'scale(1.015)'
|
|
21
|
+
},
|
|
22
|
+
'.active': {
|
|
23
|
+
opacity: 1,
|
|
24
|
+
transform: 'scale(1.015)',
|
|
25
|
+
|
|
26
|
+
':hover': { opacity: 1 }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const Clickable = {
|
|
31
|
+
extends: 'Hoverable',
|
|
32
|
+
':active': {
|
|
33
|
+
opacity: 1,
|
|
34
|
+
transform: 'scale(1.015)'
|
|
35
|
+
},
|
|
36
|
+
'.active': {
|
|
37
|
+
opacity: 1
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const Focusable = {
|
|
42
|
+
border: 'none',
|
|
43
|
+
outline: 'solid 0 blue.3',
|
|
44
|
+
':focus-visible': {
|
|
45
|
+
opacity: 1,
|
|
46
|
+
outline: 'solid X blue.3'
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
attr: {
|
|
50
|
+
tabIndex: (el) => el.tabIndex
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const FocusableComponent = {
|
|
55
|
+
extends: 'Focusable',
|
|
56
|
+
tag: 'button',
|
|
57
|
+
fontSize: 'A',
|
|
58
|
+
type: 'button',
|
|
59
|
+
border: 'none',
|
|
60
|
+
textDecoration: 'none',
|
|
61
|
+
lineHeight: '1',
|
|
62
|
+
whiteSpace: 'nowrap',
|
|
63
|
+
fontFamily: 'inherit',
|
|
64
|
+
style
|
|
65
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { getSystemGlobalTheme } from './Theme.js'
|
|
4
|
+
|
|
5
|
+
export const Picture = {
|
|
6
|
+
deps: { getSystemGlobalTheme },
|
|
7
|
+
tag: 'picture',
|
|
8
|
+
|
|
9
|
+
childExtends: {
|
|
10
|
+
deps: { getSystemGlobalTheme },
|
|
11
|
+
tag: 'source',
|
|
12
|
+
attr: {
|
|
13
|
+
media: (element) => {
|
|
14
|
+
const { key, context, deps } = element
|
|
15
|
+
const { media } = context.designSystem
|
|
16
|
+
const globalTheme = deps.getSystemGlobalTheme(element)
|
|
17
|
+
const mediaName = (element.media || key).slice(1)
|
|
18
|
+
|
|
19
|
+
if (mediaName === globalTheme) return '(min-width: 0px)'
|
|
20
|
+
else if (mediaName === 'dark' || mediaName === 'light')
|
|
21
|
+
return '(max-width: 0px)'
|
|
22
|
+
|
|
23
|
+
return media[mediaName]
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
Img: {
|
|
29
|
+
width: 'inherit',
|
|
30
|
+
ignoreChildExtends: true,
|
|
31
|
+
height: 'inherit',
|
|
32
|
+
src: (element, state) => element.parent?.src || state.src
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { exec } from '@symbo.ls/utils'
|
|
4
|
+
import { getActiveConfig, getColor, getSpacingBasedOnRatio, getMediaColor } from '@symbo.ls/scratch' // eslint-disable-line no-unused-vars
|
|
5
|
+
import { TIMING_PROPS } from 'css-in-props/src/props'
|
|
6
|
+
|
|
7
|
+
const CONFIG = getActiveConfig()
|
|
8
|
+
|
|
9
|
+
export const depth = {
|
|
10
|
+
4: {
|
|
11
|
+
boxShadow: `rgba(0,0,0,.10) 0 2${CONFIG.unit.default} 4${CONFIG.unit.default}`
|
|
12
|
+
},
|
|
13
|
+
6: {
|
|
14
|
+
boxShadow: `rgba(0,0,0,.10) 0 3${CONFIG.unit.default} 6${CONFIG.unit.default}`
|
|
15
|
+
},
|
|
16
|
+
10: {
|
|
17
|
+
boxShadow: `rgba(0,0,0,.10) 0 4${CONFIG.unit.default} 10${CONFIG.unit.default}`
|
|
18
|
+
},
|
|
19
|
+
16: {
|
|
20
|
+
boxShadow: `rgba(0,0,0,.10) 0 8${CONFIG.unit.default} 16${CONFIG.unit.default}`
|
|
21
|
+
},
|
|
22
|
+
26: {
|
|
23
|
+
boxShadow: `rgba(0,0,0,.10) 0 14${CONFIG.unit.default} 26${CONFIG.unit.default}`
|
|
24
|
+
},
|
|
25
|
+
42: {
|
|
26
|
+
boxShadow: `rgba(0,0,0,.10) 0 20${CONFIG.unit.default} 42${CONFIG.unit.default}`
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const getComputedBackgroundColor = (el) => {
|
|
31
|
+
return (
|
|
32
|
+
getColor(el.shapeDirectionColor) ||
|
|
33
|
+
getColor(el.borderColor) ||
|
|
34
|
+
getColor(el.backgroundColor) ||
|
|
35
|
+
getColor(el.background)
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const inheritTransition = (el) => {
|
|
40
|
+
const result = TIMING_PROPS.transition(el.transition, el)
|
|
41
|
+
return result && result.transition
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export const SHAPES = {
|
|
45
|
+
rectangle: {},
|
|
46
|
+
circle: { borderRadius: '100%' },
|
|
47
|
+
bubble: {},
|
|
48
|
+
tv: {
|
|
49
|
+
borderRadius: '1.15em/2.5em'
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
tooltip: (el) => ({
|
|
53
|
+
position: el.position || 'relative',
|
|
54
|
+
'&:before': {
|
|
55
|
+
content: '""',
|
|
56
|
+
display: 'block',
|
|
57
|
+
width: '0px',
|
|
58
|
+
height: '0px',
|
|
59
|
+
border: '.35em solid',
|
|
60
|
+
borderColor: getComputedBackgroundColor(el),
|
|
61
|
+
transition: inheritTransition(el),
|
|
62
|
+
transitionProperty: 'border-color',
|
|
63
|
+
position: 'absolute',
|
|
64
|
+
borderRadius: '.15em'
|
|
65
|
+
}
|
|
66
|
+
}),
|
|
67
|
+
|
|
68
|
+
tooltipDirection: {
|
|
69
|
+
top: {
|
|
70
|
+
'&:before': {
|
|
71
|
+
top: '0',
|
|
72
|
+
left: '50%',
|
|
73
|
+
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
right: {
|
|
77
|
+
'&:before': {
|
|
78
|
+
top: '50%',
|
|
79
|
+
right: '0',
|
|
80
|
+
transform: 'translate(50%, -50%) rotate(45deg)'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
bottom: {
|
|
84
|
+
'&:before': {
|
|
85
|
+
bottom: '0',
|
|
86
|
+
left: '50%',
|
|
87
|
+
transform: 'translate(-50%, 50%) rotate(45deg)'
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
left: {
|
|
91
|
+
'&:before': {
|
|
92
|
+
top: '50%',
|
|
93
|
+
left: '0',
|
|
94
|
+
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
|
|
99
|
+
tag: (el) => ({
|
|
100
|
+
position: 'relative',
|
|
101
|
+
'&:before': {
|
|
102
|
+
content: '""',
|
|
103
|
+
display: 'block',
|
|
104
|
+
background: getComputedBackgroundColor(el),
|
|
105
|
+
transition: inheritTransition(el),
|
|
106
|
+
transitionProperty: 'background',
|
|
107
|
+
borderRadius: '.25em',
|
|
108
|
+
position: 'absolute',
|
|
109
|
+
zIndex: '-1',
|
|
110
|
+
aspectRatio: '1/1',
|
|
111
|
+
top: '50%',
|
|
112
|
+
transformOrigin: '50% 50%',
|
|
113
|
+
height: '73%'
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
|
|
117
|
+
tagDirection: {
|
|
118
|
+
top: {
|
|
119
|
+
'&:before': {
|
|
120
|
+
bottom: '100%',
|
|
121
|
+
left: '50%',
|
|
122
|
+
transform: 'translate(-50%, 50%) rotate(45deg)'
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
right: {
|
|
126
|
+
'&:before': {
|
|
127
|
+
top: '50%',
|
|
128
|
+
left: '100%',
|
|
129
|
+
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
bottom: {
|
|
133
|
+
'&:before': {
|
|
134
|
+
top: '100%',
|
|
135
|
+
left: '50%',
|
|
136
|
+
transform: 'translate(-50%, -50%) rotate(45deg)'
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
left: {
|
|
140
|
+
'&:before': {
|
|
141
|
+
top: '50%',
|
|
142
|
+
right: '100%',
|
|
143
|
+
transform: 'translate(50%, -50%) rotate(45deg)'
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
hexagon: (el) => ({
|
|
149
|
+
position: 'relative',
|
|
150
|
+
'&:before, &:after': {
|
|
151
|
+
content: '""',
|
|
152
|
+
display: 'block',
|
|
153
|
+
position: 'absolute',
|
|
154
|
+
zIndex: '-1',
|
|
155
|
+
borderRadius: '.25em',
|
|
156
|
+
aspectRatio: '1/1',
|
|
157
|
+
top: '50%',
|
|
158
|
+
transformOrigin: '50% 50%',
|
|
159
|
+
height: '73%',
|
|
160
|
+
background: getComputedBackgroundColor(el),
|
|
161
|
+
transition: inheritTransition(el),
|
|
162
|
+
transitionProperty: 'background'
|
|
163
|
+
},
|
|
164
|
+
'&:before': {
|
|
165
|
+
left: '0',
|
|
166
|
+
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
167
|
+
},
|
|
168
|
+
'&:after': {
|
|
169
|
+
left: '100%',
|
|
170
|
+
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
171
|
+
}
|
|
172
|
+
}),
|
|
173
|
+
|
|
174
|
+
chevron: (el) => ({
|
|
175
|
+
position: 'relative',
|
|
176
|
+
'&:before, &:after': {
|
|
177
|
+
content: '""',
|
|
178
|
+
display: 'block',
|
|
179
|
+
position: 'absolute',
|
|
180
|
+
zIndex: '-1',
|
|
181
|
+
aspectRatio: '1/1',
|
|
182
|
+
top: '50%',
|
|
183
|
+
transformOrigin: '50% 50%',
|
|
184
|
+
transition: inheritTransition(el),
|
|
185
|
+
transitionProperty: 'background'
|
|
186
|
+
},
|
|
187
|
+
'&:before': {
|
|
188
|
+
background: `linear-gradient(225deg, ${getComputedBackgroundColor(el)} 25%, transparent 25%), linear-gradient(315deg, ${getComputedBackgroundColor(el)} 25%, transparent 25%)`
|
|
189
|
+
},
|
|
190
|
+
'&:after': {
|
|
191
|
+
background: getComputedBackgroundColor(el),
|
|
192
|
+
borderRadius: '.25em'
|
|
193
|
+
}
|
|
194
|
+
}),
|
|
195
|
+
|
|
196
|
+
chevronDirection: {
|
|
197
|
+
left: {
|
|
198
|
+
'&:before': {
|
|
199
|
+
height: '100%',
|
|
200
|
+
left: '100%',
|
|
201
|
+
transform: 'translate3d(-1%, -50%, 1px) scale(-1, 1)'
|
|
202
|
+
},
|
|
203
|
+
'&:after': {
|
|
204
|
+
height: '73%',
|
|
205
|
+
left: '0',
|
|
206
|
+
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
right: {
|
|
210
|
+
'&:before': {
|
|
211
|
+
height: '100%',
|
|
212
|
+
left: '0',
|
|
213
|
+
transform: 'translate3d(-99%, -50%, 1px)'
|
|
214
|
+
},
|
|
215
|
+
'&:after': {
|
|
216
|
+
height: '73%',
|
|
217
|
+
left: '100%',
|
|
218
|
+
transform: 'translate3d(-50%, -50%, 1px) rotate(45deg)'
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
export const Shape = {
|
|
225
|
+
deps: { exec, getSpacingBasedOnRatio, getMediaColor },
|
|
226
|
+
|
|
227
|
+
classlist: {
|
|
228
|
+
shape: (el) => {
|
|
229
|
+
return el.deps.exec(SHAPES[el.shape], el)
|
|
230
|
+
},
|
|
231
|
+
shapeDirection: (el) => {
|
|
232
|
+
if (!el.shape || !el.shapeDirection) return
|
|
233
|
+
const shapeDir = SHAPES[el.shape + 'Direction']
|
|
234
|
+
return el.shape && shapeDir ? shapeDir[el.shapeDirection || 'left'] : null
|
|
235
|
+
},
|
|
236
|
+
shapeDirectionColor: (el) => {
|
|
237
|
+
const borderColor = {
|
|
238
|
+
borderColor: el.deps.getMediaColor(el.background || el.backgroundColor)
|
|
239
|
+
}
|
|
240
|
+
return el.shapeDirection ? borderColor : null
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export const Circle = {
|
|
246
|
+
round: '100%'
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export default Shape
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
// create SVG symbol
|
|
4
|
+
export const Svg = {
|
|
5
|
+
tag: 'svg',
|
|
6
|
+
attr: {
|
|
7
|
+
xmlns: 'http://www.w3.org/2000/svg',
|
|
8
|
+
'xmlns:xlink': 'http://www.w3.org/1999/xlink'
|
|
9
|
+
},
|
|
10
|
+
html: (el) => {
|
|
11
|
+
const { context } = el
|
|
12
|
+
if (el.semanticIcons) return
|
|
13
|
+
if (el.html && typeof el.html !== 'function') return el.call('exec', el.html, el)
|
|
14
|
+
|
|
15
|
+
const { designSystem, utils } = context
|
|
16
|
+
const SVG = designSystem && designSystem.svg
|
|
17
|
+
const useSvgSprite = el.spriteId || (designSystem && designSystem.useSvgSprite)
|
|
18
|
+
|
|
19
|
+
const src = el.call('exec', el.src, el)
|
|
20
|
+
if (!useSvgSprite && src) return src
|
|
21
|
+
|
|
22
|
+
const useSVGSymbol = icon => `<use xlink:href="#${icon}" />`
|
|
23
|
+
|
|
24
|
+
const spriteId = el.spriteId
|
|
25
|
+
if (spriteId) return useSVGSymbol(spriteId)
|
|
26
|
+
|
|
27
|
+
if (SVG && SVG[src]) return useSVGSymbol(src)
|
|
28
|
+
|
|
29
|
+
const symbolId = Symbol.for(src)
|
|
30
|
+
let SVGKey = SVG[symbolId]
|
|
31
|
+
if (SVGKey && SVG[SVGKey]) return useSVGSymbol(SVGKey)
|
|
32
|
+
|
|
33
|
+
// FA-L3: when `el.src` is a sprite symbol NAME (string) but the symbol
|
|
34
|
+
// isn't registered in the merged sprite, the previous code allocated
|
|
35
|
+
// `Math.random()` as the href, producing `<use href="#0.7878391…">`
|
|
36
|
+
// which never resolves and silently renders nothing. That made every
|
|
37
|
+
// missing icon a needle-in-haystack visual bug.
|
|
38
|
+
//
|
|
39
|
+
// New behavior:
|
|
40
|
+
// - If `src` is missing entirely: emit an empty `<use>` (no href).
|
|
41
|
+
// - If `src` is a string (sprite-symbol lookup) but unknown: warn
|
|
42
|
+
// in dev and render no `<use>`. The console-warn surfaces the
|
|
43
|
+
// bad icon name to the consumer.
|
|
44
|
+
// - If `src` is an actual SVG body string (registered raw via
|
|
45
|
+
// `utils.init({svg:{…}})` — the original Math.random path): keep
|
|
46
|
+
// a stable hash-derived key instead of Math.random so the same
|
|
47
|
+
// SVG body always resolves to the same symbol id (and so SSR /
|
|
48
|
+
// hydration produce identical output).
|
|
49
|
+
if (!src) return useSVGSymbol('')
|
|
50
|
+
|
|
51
|
+
if (typeof src === 'string' && !src.includes('<')) {
|
|
52
|
+
// Bare symbol name — not in sprite. Warn loudly in dev so the
|
|
53
|
+
// consumer fixes the icon name; render nothing rather than a
|
|
54
|
+
// broken random href.
|
|
55
|
+
if (typeof console !== 'undefined' && console.warn) {
|
|
56
|
+
console.warn(`[Svg] Unknown sprite symbol "${src}" — not registered in design-system sprite. Set the icon name to one that exists in designSystem.icons / context.svg, or register the SVG body via utils.init({ svg: { '${src}': '<svg>...</svg>' } }).`)
|
|
57
|
+
}
|
|
58
|
+
return useSVGSymbol('')
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Inline SVG body — derive a stable sha-like key from the content so
|
|
62
|
+
// identical bodies share a sprite symbol across renders. Avoids
|
|
63
|
+
// Math.random churn in SSR diffs.
|
|
64
|
+
let hash = 0
|
|
65
|
+
for (let i = 0; i < src.length; i++) {
|
|
66
|
+
hash = ((hash << 5) - hash + src.charCodeAt(i)) | 0
|
|
67
|
+
}
|
|
68
|
+
SVGKey = SVG[symbolId] = `svg-${(hash >>> 0).toString(36)}`
|
|
69
|
+
utils.init({
|
|
70
|
+
svg: { [SVGKey]: src }
|
|
71
|
+
}, {
|
|
72
|
+
document: context.document,
|
|
73
|
+
emotion: context.emotion
|
|
74
|
+
})
|
|
75
|
+
|
|
76
|
+
return useSVGSymbol(SVGKey)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const Text = {}
|
|
4
|
+
|
|
5
|
+
export const Span = { tag: 'span' }
|
|
6
|
+
|
|
7
|
+
export const H1 = { tag: 'h1' }
|
|
8
|
+
export const H2 = { tag: 'h2' }
|
|
9
|
+
export const H3 = { tag: 'h3' }
|
|
10
|
+
export const H4 = { tag: 'h4' }
|
|
11
|
+
export const H5 = { tag: 'h5' }
|
|
12
|
+
export const H6 = { tag: 'h6' }
|
|
13
|
+
export const P = { tag: 'p' }
|
|
14
|
+
export const Caption = { tag: 'caption' }
|
|
15
|
+
export const Strong = {
|
|
16
|
+
tag: 'strong',
|
|
17
|
+
fontWeight: '700'
|
|
18
|
+
}
|
|
19
|
+
export const U = { tag: 'u' }
|
|
20
|
+
export const Underline = { tag: 'u' }
|
|
21
|
+
export const Italic = { tag: 'i' }
|
|
22
|
+
|
|
23
|
+
export const Title = {}
|
|
24
|
+
|
|
25
|
+
export const Headline = {
|
|
26
|
+
tag: 'h6',
|
|
27
|
+
fontSize: 'B',
|
|
28
|
+
fontWeight: 500
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export const Subhead = {
|
|
32
|
+
tag: 'span',
|
|
33
|
+
fontSize: 'Z1'
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const Footnote = {
|
|
37
|
+
tag: 'span',
|
|
38
|
+
fontSize: 'Z'
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const B = { tag: 'b' }
|
|
42
|
+
|
|
43
|
+
export const I = { tag: 'i' }
|
|
44
|
+
|
|
45
|
+
export const Data = { tag: 'data' }
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { depth } from './Shape.js'
|
|
4
|
+
import { isUndefined } from '@symbo.ls/utils'
|
|
5
|
+
|
|
6
|
+
export const getSystemGlobalTheme = ({ context, state }) => {
|
|
7
|
+
const rootState = state && state.root
|
|
8
|
+
const theme = (rootState && rootState.globalTheme) || (context.designSystem && context.designSystem.globalTheme)
|
|
9
|
+
return theme === 'auto' ? null : theme
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Theme = {
|
|
13
|
+
deps: {
|
|
14
|
+
depth
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
classlist: {
|
|
18
|
+
depth: (el) => !isUndefined(el.depth) && el.deps.depth[el.depth]
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
import { resolveAsset } from '@symbo.ls/utils'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* `<video>` with smart asset resolution. Set `src` to either a manifest
|
|
7
|
+
* key (local-discovered or cloud-uploaded) or a literal URL — the
|
|
8
|
+
* component figures out which one and emits `<source>` children only
|
|
9
|
+
* when the manifest carries multiple variants.
|
|
10
|
+
*
|
|
11
|
+
* Same `src`-prop convention as `<img>` and `<audio>`. See
|
|
12
|
+
* `resolveAsset` in `@symbo.ls/utils` for the normalization rules.
|
|
13
|
+
*/
|
|
14
|
+
export const Video = {
|
|
15
|
+
tag: 'video',
|
|
16
|
+
|
|
17
|
+
controls: true,
|
|
18
|
+
|
|
19
|
+
attr: {
|
|
20
|
+
src: (el) => {
|
|
21
|
+
const asset = resolveAsset(el)
|
|
22
|
+
return (asset && asset.src) || el.src
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
// Auto-populate <source> children only when the resolved asset carries
|
|
27
|
+
// a variants array. Returns undefined otherwise so DOMQL's extends
|
|
28
|
+
// chain falls through to user-provided `children: [...]` when present
|
|
29
|
+
// (override semantics) or to the empty list. Reading `el.children`
|
|
30
|
+
// inside this function would recursively re-enter it — never do that.
|
|
31
|
+
children: (el) => {
|
|
32
|
+
const asset = resolveAsset(el)
|
|
33
|
+
if (!asset || !Array.isArray(asset.variants) || !asset.variants.length) {
|
|
34
|
+
return undefined
|
|
35
|
+
}
|
|
36
|
+
return asset.variants.map((v) => ({
|
|
37
|
+
tag: 'source',
|
|
38
|
+
attr: { src: v.src, type: v.format }
|
|
39
|
+
}))
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
childExtends: {
|
|
43
|
+
tag: 'source'
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const Avatar = {
|
|
4
|
+
extends: 'Img',
|
|
5
|
+
display: 'block',
|
|
6
|
+
avatarType: 'adventurer-neutral',
|
|
7
|
+
borderRadius: '100%',
|
|
8
|
+
boxSize: 'C+X C+X',
|
|
9
|
+
src: el => `https://api.dicebear.com/7.x/${el.avatarType || 'initials'}/svg?seed=${el.key || 'no-avatar'}`
|
|
10
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A Button component
|
|
5
|
+
* The `Button` component represents a clickable button element with customizable styles and properties.
|
|
6
|
+
*
|
|
7
|
+
* @description
|
|
8
|
+
* @extends {FocusableComponent, IconText}
|
|
9
|
+
* @typedef {Object} Button
|
|
10
|
+
* @property {string} tag - The HTML tag used to render the button (e.g., 'button').
|
|
11
|
+
* @property {string} props.type - The type attribute of the button ('button' by default).
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* // Example usage of the Button component:
|
|
15
|
+
* const myButton = {
|
|
16
|
+
* extends: Button
|
|
17
|
+
* }
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
export const Button = {
|
|
21
|
+
extends: ['IconText', 'FocusableComponent'],
|
|
22
|
+
tag: 'button',
|
|
23
|
+
|
|
24
|
+
fontSize: 'A',
|
|
25
|
+
type: 'button',
|
|
26
|
+
borderStyle: 'none',
|
|
27
|
+
display: 'inline-flex',
|
|
28
|
+
align: 'center center',
|
|
29
|
+
textDecoration: 'none',
|
|
30
|
+
lineHeight: '1',
|
|
31
|
+
whiteSpace: 'nowrap',
|
|
32
|
+
padding: 'Z B2',
|
|
33
|
+
fontWeight: '500',
|
|
34
|
+
fontFamily: 'inherit',
|
|
35
|
+
round: 'C2',
|
|
36
|
+
|
|
37
|
+
disabled: (el) => el.call('exec', el.disabled)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export const SquareButton = {
|
|
41
|
+
extends: 'Button',
|
|
42
|
+
fontSize: 'A',
|
|
43
|
+
width: 'A',
|
|
44
|
+
padding: 'Z',
|
|
45
|
+
aspectRatio: '1 / 1',
|
|
46
|
+
icon: 'smile',
|
|
47
|
+
boxSize: 'fit-content fit-content',
|
|
48
|
+
justifyContent: 'center',
|
|
49
|
+
round: 'Z2',
|
|
50
|
+
boxSizing: 'content-box'
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export const CircleButton = {
|
|
54
|
+
extends: 'SquareButton',
|
|
55
|
+
round: 'C'
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export const KangorooButton = {
|
|
59
|
+
extends: 'Button',
|
|
60
|
+
childExtends: 'IconText'
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export const ButtonSet = {
|
|
64
|
+
tag: 'nav',
|
|
65
|
+
display: 'flex',
|
|
66
|
+
childExtends: 'SquareButton'
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export const IconButton = {
|
|
70
|
+
extends: ['SquareButton', 'ClickableItem'],
|
|
71
|
+
round: 'Z'
|
|
72
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
export const Dialog = {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
tag: 'dialog',
|
|
6
|
+
flow: 'column',
|
|
7
|
+
border: '0',
|
|
8
|
+
theme: 'dialog',
|
|
9
|
+
round: 'Z2'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const DialogHeader = {
|
|
13
|
+
extends: 'Hgroup',
|
|
14
|
+
|
|
15
|
+
minWidth: '100%',
|
|
16
|
+
gap: 'A',
|
|
17
|
+
|
|
18
|
+
Title: {
|
|
19
|
+
align: 'center space-between',
|
|
20
|
+
|
|
21
|
+
Text: { text: 'Title' },
|
|
22
|
+
|
|
23
|
+
SquareButton: {
|
|
24
|
+
icon: 'x',
|
|
25
|
+
theme: 'transparent'
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
Paragraph: {
|
|
30
|
+
color: 'caption'
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const DialogFooter = {
|
|
35
|
+
display: 'flex',
|
|
36
|
+
|
|
37
|
+
align: 'center flex-end',
|
|
38
|
+
gap: 'X2',
|
|
39
|
+
margin: 'auto - -',
|
|
40
|
+
padding: 'Y2 X2',
|
|
41
|
+
|
|
42
|
+
childExtends: {
|
|
43
|
+
extends: 'Button',
|
|
44
|
+
textTransform: 'uppercase',
|
|
45
|
+
background: 'transparent',
|
|
46
|
+
'@dark': {
|
|
47
|
+
theme: 'primary @dark .color-only'
|
|
48
|
+
},
|
|
49
|
+
'@light': {
|
|
50
|
+
theme: 'primary @light .color-only'
|
|
51
|
+
},
|
|
52
|
+
'&': {
|
|
53
|
+
padding: 'Z A'
|
|
54
|
+
},
|
|
55
|
+
':hover': {
|
|
56
|
+
theme: 'tertiary'
|
|
57
|
+
},
|
|
58
|
+
':active': {
|
|
59
|
+
background: 'white.1'
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
Cancel: {
|
|
64
|
+
text: 'cancel'
|
|
65
|
+
},
|
|
66
|
+
Ok: {
|
|
67
|
+
text: 'ok'
|
|
68
|
+
}
|
|
69
|
+
}
|