Skip to content

Commit 3f30b40

Browse files
added indent setting
1 parent c60130b commit 3f30b40

File tree

4 files changed

+13
-10
lines changed

4 files changed

+13
-10
lines changed

src/config.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import { ConfigType, TypeofTypes } from 'src/config.types';
22

33
const config: ConfigType = {
4+
indent: 4, // Number of spaces
45
colors: {
5-
main_text: '#ffffff',
6-
background: '#1e1e1e',
7-
header: '#252526',
8-
icon_color: '#ffd700',
9-
indent_lines: '#404040',
10-
line_index: '#6e7681',
11-
keys: '#9cdcfe'
6+
main_text: '#ffffff', // Comma, colon color
7+
background: '#1e1e1e', // Main background color
8+
header: '#252526', // Color of header
9+
icon_color: '#ffd700', // Color of `{}` icon in filename
10+
indent_lines: '#404040', // Color of indent lines
11+
line_index: '#6e7681', // Color of indexes of lines
12+
keys: '#9cdcfe' // Color of JSON keys
1213
},
1314
/**
1415
* Get the color associated with a JavaScript data type.

src/config.types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type TypeofTypes = 'string' | 'boolean' | 'function' | 'number' | 'object' | 'symbol' | 'undefined' | 'bigint';
22

33
export type ConfigType = {
4+
indent: number,
45
colors: {
56
main_text: string,
67
background: string,

src/widget/views/index.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{{{json}}}
3232
</text>
3333

34-
<g style="transform: translate(70px, 45px);">
34+
<g style="transform: translate({{indent_x}}px, 45px);">
3535
{{{indents}}}
3636
</g>
3737
</svg>

src/widget/widget.controller.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export class WidgetController {
1919
@Res({ passthrough: true }) res: Response
2020
) {
2121
const json = await this.widgetService.generate();
22-
const content = this.parserService.parse(json, 30);
22+
const content = this.parserService.parse(json, config.indent * 7.5);
2323

2424
const indents = this.parserService.parseObjectStructure(json);
2525

@@ -30,10 +30,11 @@ export class WidgetController {
3030
return {
3131
json: content,
3232
indexes: indexes,
33-
indents: this.widgetService.generateIndentLines(indents, 30),
33+
indents: this.widgetService.generateIndentLines(indents, config.indent * 7.5),
3434
height: 52 + (lines_count * 19),
3535
height_: 60 + (lines_count * 19),
3636
height_main_line: (lines_count - 2) * 19,
37+
indent_x: 40 + config.indent * 7.5,
3738

3839
background_color: config.colors.background,
3940
header_color: config.colors.header,

0 commit comments

Comments
 (0)