-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsvelte-inspect.js
More file actions
62 lines (54 loc) · 1.36 KB
/
svelte-inspect.js
File metadata and controls
62 lines (54 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import SvelteInspect from './inspect/Inspect.svelte';
function configure(configuration) {
if (SvelteInspect.render) {
// It's an SSR'd component. We need to wrap .render
return {
...SvelteInspect,
render(props) {
return SvelteInspect.render({
...props,
[Symbol.for('configuration')]: configuration
})
}
};
} else {
// It's a client side component. We need to extend the class.
return class ConfiguredInspect extends SvelteInspect {
constructor(options) {
const props = options.props || {};
super({
...options,
props: {
...props,
[Symbol.for('configuration')]: configuration
}
});
}
};
}
};
const invertedPalette = {
red: 'red',
blue: 'dodgerblue',
green: 'yellowgreen',
purple: 'violet',
gray: '#808080',
black: '#d0d0d0',
white: '#202020',
selection: 'darkblue'
};
const Inverted = configure({
palette: invertedPalette
});
const Value = configure({
valueOnly: true
});
SvelteInspect.configure = configure;
SvelteInspect.Inverted = Inverted;
SvelteInspect.Value = Value;
for (let i = 0; i <= 10; i++) {
SvelteInspect[i] = configure({depth: i});
SvelteInspect.Inverted[i] = configure({depth: i, palette: invertedPalette});
}
export default SvelteInspect;
export {configure, Inverted, Value};