Skip to content

Commit 6ab4e87

Browse files
committed
Prettier + Refactoring
1 parent 2153be7 commit 6ab4e87

32 files changed

+1518
-1356
lines changed

.babelrc.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module.exports = {
2-
presets: [['next/babel', { 'preset-react': { runtime: 'automatic' } }]],
3-
plugins: [
4-
'babel-plugin-macros',
5-
['babel-plugin-styled-components', { ssr: true }],
6-
],
7-
}
2+
presets: [["next/babel", { "preset-react": { runtime: "automatic" } }]],
3+
plugins: [
4+
"babel-plugin-macros",
5+
["babel-plugin-styled-components", { ssr: true }],
6+
],
7+
};

.prettierignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.next
2+
node_modules
3+
.idea
4+
.git

README.md

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,43 @@
11
# HelpChat ToolBox
22

33
## What is it?
4+
45
HelpChat ToolBox is a toolbox of useful tools for HelpChat's Minecraft plugins, configs, and more!
56

67
It currently includes the following features:
7-
- [DeluxeChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/deluxechat)
8-
- [EssentialsChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/essentialschat)
9-
- [VentureChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/venturechat)
10-
- [Yaml Config Validator](https://toolbox.helpch.at/validators/yaml)
11-
- [Properties Config Validator](https://toolbox.helpch.at/validators/properties)
12-
- [Toml Config Validator](https://toolbox.helpch.at/validators/toml)
8+
9+
- [DeluxeChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/deluxechat)
10+
- [EssentialsChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/essentialschat)
11+
- [VentureChat to ChatChat Config Converter](https://toolbox.helpch.at/converters/chatchat/venturechat)
12+
- [Yaml Config Validator](https://toolbox.helpch.at/validators/yaml)
13+
- [Properties Config Validator](https://toolbox.helpch.at/validators/properties)
14+
- [Toml Config Validator](https://toolbox.helpch.at/validators/toml)
15+
1316
### Usage
14-
HelpChat's ToolBox is hosted at [toolbox.helpch.at](https://toolbox.helpch.at/).
1517

18+
HelpChat's ToolBox is hosted at [toolbox.helpch.at](https://toolbox.helpch.at/).
1619

1720
## Development
21+
1822
### Starting Guide
19-
1) Clone the repository
20-
2) Install NPM, and NodeJS for your respective platform
21-
3) Install yarn globally (`npm i -g yarn`)
22-
4) Install the dependencies of this project (`yarn install`)
23-
5) Run the dev server (`yarn dev`)
24-
6) Start making changes! They'll be automatically reloaded @ http://localhost:3000/
23+
24+
1. Clone the repository
25+
2. Install NPM, and NodeJS for your respective platform
26+
3. Install yarn globally (`npm i -g yarn`)
27+
4. Install the dependencies of this project (`yarn install`)
28+
5. Run the dev server (`yarn dev`)
29+
6. Start making changes! They'll be automatically reloaded @ http://localhost:3000/
2530

2631
### Generating JSON Schemas for Converter Types
32+
2733
Run the command `yarn generateschema`, and pass it to the Converter. It will validate types for you at runtime.
2834

2935
### UI Development & Design
36+
3037
Run `yarn dev`, and it will automatically reload the UI at http://localhost:3000/ as you make changes.
3138
Pages are generated from the `pages/` directory, so to add a new page simply just create that file in the directory.
3239

3340
### Feature Development
34-
Converters are currently written in their own folder (`converters/`), directory.
41+
42+
Converters are currently written in their own folder (`converters/`), directory.
3543
To test a newly created one you'll need to create a new page for it to see live updates in your browser, refer to the UI Development & Design section above for more information on developing with live-updates

cli/generateschema.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
export {}
1+
export {};
22

3-
const tsj = require('ts-json-schema-generator');
4-
const fs = require('fs');
3+
const tsj = require("ts-json-schema-generator");
4+
const fs = require("fs");
55

6-
const directory = fs.readdirSync('./converters/types/').filter((f: string) => f.endsWith('.ts'));
6+
const directory = fs
7+
.readdirSync("./converters/types/")
8+
.filter((f: string) => f.endsWith(".ts"));
79

810
directory.forEach((f: string) => {
9-
const file = fs.readFileSync(`./converters/types/${f}`, 'utf8');
11+
const file = fs.readFileSync(`./converters/types/${f}`, "utf8");
1012

11-
const regex = /\/\/ @ToolBox - ([a-zA-Z]{1,30})/;
12-
const match = file.match(regex);
13+
const regex = /\/\/ @ToolBox - ([a-zA-Z]{1,30})/;
14+
const match = file.match(regex);
1315

14-
if (!match || match.length < 2) return;
16+
if (!match || match.length < 2) return;
1517

16-
const schema = tsj.createGenerator({
17-
path: `./converters/types/${f}`,
18-
tsconfig: './tsconfig.json',
19-
type: match[1],
20-
additionalProperties: true,
21-
}).createSchema(match[1])
18+
const schema = tsj
19+
.createGenerator({
20+
path: `./converters/types/${f}`,
21+
tsconfig: "./tsconfig.json",
22+
type: match[1],
23+
additionalProperties: true,
24+
})
25+
.createSchema(match[1]);
2226

23-
const schemaString = JSON.stringify(schema, null, 2);
24-
fs.writeFileSync(`./converters/types/${f.replace('.ts', '.json')}`, schemaString);
25-
})
27+
const schemaString = JSON.stringify(schema, null, 2);
28+
fs.writeFileSync(
29+
`./converters/types/${f.replace(".ts", ".json")}`,
30+
schemaString
31+
);
32+
});

components/GlobalStyles.tsx

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
1-
import {createGlobalStyle} from 'styled-components'
2-
import tw, {theme, GlobalStyles as BaseStyles} from 'twin.macro'
1+
import { createGlobalStyle } from "styled-components";
2+
import tw, { theme, GlobalStyles as BaseStyles } from "twin.macro";
33

44
const CustomStyles = createGlobalStyle({
5-
body: {
6-
WebkitTapHighlightColor: theme`colors.purple.500`,
7-
...tw`antialiased`,
8-
},
9-
})
5+
body: {
6+
WebkitTapHighlightColor: theme`colors.purple.500`,
7+
...tw`antialiased`,
8+
},
9+
});
1010

1111
const GlobalStyles = () => (
12-
<>
13-
<BaseStyles/>
14-
<CustomStyles/>
15-
</>
16-
)
12+
<>
13+
<BaseStyles />
14+
<CustomStyles />
15+
</>
16+
);
1717

18-
export default GlobalStyles
18+
export default GlobalStyles;

components/TextBox.tsx

Lines changed: 103 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,101 +1,114 @@
1-
import tw, {css} from "twin.macro";
2-
import Highlight, {defaultProps} from "prism-react-renderer";
3-
import Prism from 'prismjs';
4-
import {Dispatch, SetStateAction} from "react";
5-
import Editor from 'react-simple-code-editor'
6-
import {faCopy} from '@fortawesome/free-solid-svg-icons'
7-
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
8-
import "prismjs/components/prism-yaml"
9-
import "prismjs/components/prism-properties"
1+
import tw, { css } from "twin.macro";
2+
import Highlight, { defaultProps, Language } from "prism-react-renderer";
3+
import Prism from "prismjs";
4+
import { Dispatch, SetStateAction } from "react";
5+
import Editor from "react-simple-code-editor";
6+
import { faCopy } from "@fortawesome/free-solid-svg-icons";
7+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
8+
import "prismjs/components/prism-yaml";
9+
import "prismjs/components/prism-toml";
10+
import "prismjs/components/prism-properties";
1011

1112
const textBoxStyle = tw`flex-grow flex-shrink border-none outline-none focus:outline-none max-h-full`;
1213

13-
export const TextBox = (
14-
{
15-
title,
16-
code,
17-
editor,
18-
language
19-
}:
20-
{
21-
title: string,
22-
code: string,
23-
editor?: Dispatch<SetStateAction<string>>,
24-
language: string
25-
}
26-
) => {
27-
28-
if (!editor) {
29-
return (
30-
<div css={tw`flex flex-col h-full w-full pt-1`}>
31-
<div css={tw`flex flex-row pl-2`}>
32-
<p css={tw`text-xl font-semibold mx-auto mb-2`}>{title}</p>
33-
<div css={tw`flex flex-row h-8`}>
34-
<div css={tw`py-1 px-2 bg-green-400 rounded-md hover:cursor-pointer`} onClick={() => {
35-
navigator.clipboard.writeText(code);
36-
}}>
37-
<FontAwesomeIcon icon={faCopy} size="1x"/>
38-
</div>
39-
</div>
40-
</div>
41-
<div css={css`${tw`rounded-md overflow-auto h-full`} background-color: #2a2734`}>
42-
<div css={tw` py-2 px-4`}>
43-
{highlight(code, language)}
44-
</div>
45-
</div>
14+
export const TextBox = ({
15+
title,
16+
code,
17+
editor,
18+
language,
19+
}: {
20+
title: string;
21+
code: string;
22+
editor?: Dispatch<SetStateAction<string>>;
23+
language: string;
24+
}) => {
25+
if (!editor) {
26+
return (
27+
<div css={tw`flex flex-col h-full w-full pt-1`}>
28+
<div css={tw`flex flex-row pl-2`}>
29+
<p css={tw`text-xl font-semibold mx-auto mb-2`}>{title}</p>
30+
<div css={tw`flex flex-row h-8`}>
31+
<div
32+
css={tw`py-1 px-2 bg-green-400 rounded-md hover:cursor-pointer`}
33+
onClick={() => {
34+
navigator.clipboard.writeText(code);
35+
}}
36+
>
37+
<FontAwesomeIcon icon={faCopy} size="1x" />
4638
</div>
47-
);
48-
} else {
49-
return (
50-
<div css={tw`flex flex-col h-full w-full pt-1`}>
51-
<p css={tw`text-xl font-semibold mx-auto mb-2`}>{title}</p>
52-
<div css={css`${tw`rounded-md overflow-auto h-full flex flex-col`} background-color: #2a2734`}>
53-
<div css={tw`py-2 px-4 flex-grow flex-shrink`}>
54-
<Editor
55-
value={code}
56-
onValueChange={editor}
57-
highlight={(v) => highlight(v, language)}
58-
css={css`
59-
${textBoxStyle}
60-
${tw`h-full`}
39+
</div>
40+
</div>
41+
<div
42+
css={css`
43+
${tw`rounded-md overflow-auto h-full`} background-color: #2a2734
44+
`}
45+
>
46+
<div css={tw` py-2 px-4`}>{highlight(code, language)}</div>
47+
</div>
48+
</div>
49+
);
50+
} else {
51+
return (
52+
<div css={tw`flex flex-col h-full w-full pt-1`}>
53+
<p css={tw`text-xl font-semibold mx-auto mb-2`}>{title}</p>
54+
<div
55+
css={css`
56+
${tw`rounded-md overflow-auto h-full flex flex-col`} background-color: #2a2734
57+
`}
58+
>
59+
<div css={tw`py-2 px-4 flex-grow flex-shrink`}>
60+
<Editor
61+
value={code}
62+
onValueChange={editor}
63+
highlight={(v) => highlight(v, language)}
64+
css={css`
65+
${textBoxStyle}
66+
${tw`h-full`}
6167
min-width: fit-content;
62-
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
68+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco,
69+
Consolas, "Liberation Mono", "Courier New", monospace;
6370
64-
> pre {
65-
${tw`h-full w-full`}
66-
}
71+
> pre {
72+
${tw`h-full w-full`}
73+
}
6774
68-
> pre > pre {
69-
${tw`h-full w-full`}
70-
}
75+
> pre > pre {
76+
${tw`h-full w-full`}
77+
}
7178
72-
> textarea {
73-
z-index: 1;
74-
caret-color: whitesmoke;
75-
${tw`hover:outline-none focus:outline-none h-full`}
76-
}
77-
`}
78-
/>
79-
</div>
80-
</div>
81-
</div>
82-
);
83-
}
84-
}
79+
> textarea {
80+
z-index: 1;
81+
caret-color: whitesmoke;
82+
${tw`hover:outline-none focus:outline-none h-full`}
83+
}
84+
`}
85+
/>
86+
</div>
87+
</div>
88+
</div>
89+
);
90+
}
91+
};
8592

8693
function highlight(code: string, language: string) {
87-
// @ts-ignore (Prism is odd)
88-
return (<Highlight {...defaultProps} Prism={Prism} code={code} language={language}>
89-
{({className, style, tokens, getLineProps, getTokenProps}) => (
90-
<pre className={className} style={style} css={textBoxStyle}>
91-
{tokens.map((line, i) => (
92-
<div key={i} {...getLineProps({line, key: i})}>
93-
{line.map((token, key) => (
94-
<span key={key} {...getTokenProps({token, key})} />
95-
))}
96-
</div>
97-
))}
98-
</pre>
99-
)}
100-
</Highlight>)
94+
return (
95+
<Highlight
96+
{...defaultProps}
97+
Prism={Prism as any}
98+
code={code}
99+
language={language as Language}
100+
>
101+
{({ className, style, tokens, getLineProps, getTokenProps }) => (
102+
<pre className={className} style={style} css={textBoxStyle}>
103+
{tokens.map((line, i) => (
104+
<div key={i} {...getLineProps({ line, key: i })}>
105+
{line.map((token, key) => (
106+
<span key={key} {...getTokenProps({ token, key })} />
107+
))}
108+
</div>
109+
))}
110+
</pre>
111+
)}
112+
</Highlight>
113+
);
101114
}

0 commit comments

Comments
 (0)