Skip to content

Commit a0148ef

Browse files
committed
add and run prettier
1 parent 95534c2 commit a0148ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+4544
-3372
lines changed

package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@
4040
"start": "react-scripts start",
4141
"build": "react-scripts build",
4242
"test": "react-scripts test",
43-
"eject": "react-scripts eject"
43+
"eject": "react-scripts eject",
44+
"prettier": "prettier src/**/*.{ts,tsx} -w"
4445
},
4546
"eslintConfig": {
4647
"extends": "react-app"
@@ -59,6 +60,7 @@
5960
},
6061
"devDependencies": {
6162
"@types/lodash": "^4.14.158",
62-
"@types/redux-state-sync": "^3.1.1"
63+
"@types/redux-state-sync": "^3.1.1",
64+
"prettier": "^2.8.3"
6365
}
6466
}

src/App.tsx

Lines changed: 64 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,80 @@
1-
import React, {useEffect} from 'react';
2-
import {PromptEditor} from './components/PromptEditor';
3-
import {Box, Container, createMuiTheme, CssBaseline, ThemeProvider, Typography,} from "@material-ui/core";
4-
import {useHotkeys} from "react-hotkeys-hook";
5-
import {useDispatch} from "react-redux";
6-
import {fetchForCurrentTab, updateTabIndex, normalizeConversations} from "./slices/editorSlice";
1+
import React, { useEffect } from "react";
2+
import { PromptEditor } from "./components/PromptEditor";
3+
import {
4+
Box,
5+
Container,
6+
createMuiTheme,
7+
CssBaseline,
8+
ThemeProvider,
9+
Typography,
10+
} from "@material-ui/core";
11+
import { useHotkeys } from "react-hotkeys-hook";
12+
import { useDispatch } from "react-redux";
13+
import {
14+
fetchForCurrentTab,
15+
updateTabIndex,
16+
normalizeConversations,
17+
} from "./slices/editorSlice";
718
import Header from "./components/Header";
819
import TemplateDialog from "./components/dialogs/TemplateDialog";
920
import ApiKeyDialog from "./components/dialogs/ApiKeyDialog";
1021

1122
function App() {
12-
const dispatch = useDispatch();
13-
const theme = createMuiTheme({
14-
palette: {
15-
type: "dark"
16-
}
17-
});
23+
const dispatch = useDispatch();
24+
const theme = createMuiTheme({
25+
palette: {
26+
type: "dark",
27+
},
28+
});
1829

19-
useEffect(() => {
20-
dispatch(normalizeConversations());
21-
});
30+
useEffect(() => {
31+
dispatch(normalizeConversations());
32+
});
2233

23-
useHotkeys('ctrl+enter,cmd+enter', () => {
24-
dispatch(fetchForCurrentTab());
25-
}, {filter: () => true});
26-
useHotkeys('ctrl+1', () => {
27-
dispatch(updateTabIndex(0));
28-
});
29-
useHotkeys('ctrl+2', () => {
30-
dispatch(updateTabIndex(1));
31-
});
32-
useHotkeys('ctrl+3', () => {
33-
dispatch(updateTabIndex(2));
34-
});
35-
useHotkeys('ctrl+4', () => {
36-
dispatch(updateTabIndex(3));
37-
});
34+
useHotkeys(
35+
"ctrl+enter,cmd+enter",
36+
() => {
37+
dispatch(fetchForCurrentTab());
38+
},
39+
{ filter: () => true }
40+
);
41+
useHotkeys("ctrl+1", () => {
42+
dispatch(updateTabIndex(0));
43+
});
44+
useHotkeys("ctrl+2", () => {
45+
dispatch(updateTabIndex(1));
46+
});
47+
useHotkeys("ctrl+3", () => {
48+
dispatch(updateTabIndex(2));
49+
});
50+
useHotkeys("ctrl+4", () => {
51+
dispatch(updateTabIndex(3));
52+
});
3853

39-
return (
40-
<ThemeProvider theme={theme}>
41-
<CssBaseline/>
54+
return (
55+
<ThemeProvider theme={theme}>
56+
<CssBaseline />
4257

43-
<ApiKeyDialog/>
44-
<TemplateDialog/>
58+
<ApiKeyDialog />
59+
<TemplateDialog />
4560

46-
<Header/>
61+
<Header />
4762

48-
<Container maxWidth={"lg"}>
49-
<Box mt={2}>
50-
<PromptEditor/>
51-
</Box>
52-
{/*<Box mt={2}>
63+
<Container maxWidth={"lg"}>
64+
<Box mt={2}>
65+
<PromptEditor />
66+
</Box>
67+
{/*<Box mt={2}>
5368
<ModeTabs/>
5469
</Box>*/}
55-
<Box mt={2}>
56-
<Typography>
57-
Not affiliated with OpenAI. Feedback: seva@zhidkoff.com.</Typography>
58-
</Box>
59-
</Container>
60-
</ThemeProvider>
61-
);
70+
<Box mt={2}>
71+
<Typography>
72+
Not affiliated with OpenAI. Feedback: seva@zhidkoff.com.
73+
</Typography>
74+
</Box>
75+
</Container>
76+
</ThemeProvider>
77+
);
6278
}
6379

6480
export default App;

src/components/Header.tsx

Lines changed: 70 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,83 @@
1-
import {AppBar, Container, IconButton, Theme, Toolbar, Typography} from "@material-ui/core";
1+
import {
2+
AppBar,
3+
Container,
4+
IconButton,
5+
Theme,
6+
Toolbar,
7+
Typography,
8+
} from "@material-ui/core";
29
import VpnKeyIcon from "@material-ui/icons/VpnKey";
310
import UndoIcon from "@material-ui/icons/Undo";
411
import RedoIcon from "@material-ui/icons/Redo";
512
import GitHubIcon from "@material-ui/icons/GitHub";
613
import React from "react";
7-
import {makeStyles} from "@material-ui/core/styles";
8-
import {useDispatch, useSelector} from "react-redux";
9-
import {
10-
selectApiKey,
11-
toggleApiKeyDialog,
12-
} from "../slices/editorSlice";
13-
import {ActionCreators} from "redux-undo";
14+
import { makeStyles } from "@material-ui/core/styles";
15+
import { useDispatch, useSelector } from "react-redux";
16+
import { selectApiKey, toggleApiKeyDialog } from "../slices/editorSlice";
17+
import { ActionCreators } from "redux-undo";
1418

1519
const useStyles = makeStyles((theme: Theme) => ({
16-
buttonGroup: {
17-
marginRight: theme.spacing(2),
18-
},
19-
apiKeyInput: {
20-
minWidth: '400px',
21-
},
20+
buttonGroup: {
21+
marginRight: theme.spacing(2),
22+
},
23+
apiKeyInput: {
24+
minWidth: "400px",
25+
},
2226
}));
2327

2428
export default function Header() {
25-
const dispatch = useDispatch();
26-
const classes = useStyles();
29+
const dispatch = useDispatch();
30+
const classes = useStyles();
2731

28-
const apiKey = useSelector(selectApiKey);
29-
const apiKeyPresent = !!apiKey;
30-
const handleApiKeyDialogOpen = () => {
31-
dispatch(toggleApiKeyDialog(true));
32-
};
33-
const handleUndoClick = () => {
34-
dispatch(ActionCreators.undo());
35-
};
36-
const handleRedoClick = () => {
37-
dispatch(ActionCreators.redo());
38-
};
32+
const apiKey = useSelector(selectApiKey);
33+
const apiKeyPresent = !!apiKey;
34+
const handleApiKeyDialogOpen = () => {
35+
dispatch(toggleApiKeyDialog(true));
36+
};
37+
const handleUndoClick = () => {
38+
dispatch(ActionCreators.undo());
39+
};
40+
const handleRedoClick = () => {
41+
dispatch(ActionCreators.redo());
42+
};
3943

40-
return <AppBar position="static">
41-
<Container maxWidth={"lg"}>
42-
<Toolbar variant="regular" disableGutters={true}>
43-
<div className={classes.buttonGroup}>
44-
<Typography variant="h6" color="inherit">
45-
Prompts.ai
46-
</Typography>
47-
</div>
48-
<div className={classes.buttonGroup}>
49-
<IconButton onClick={handleApiKeyDialogOpen}><VpnKeyIcon color={apiKeyPresent ? "action" : "error"}/></IconButton>
50-
</div>
51-
<div className={classes.buttonGroup}>
52-
<IconButton onClick={handleUndoClick}><UndoIcon/></IconButton>
53-
<IconButton onClick={handleRedoClick}><RedoIcon/></IconButton>
54-
</div>
55-
<div className={classes.buttonGroup}>
56-
<IconButton aria-label="GitHib" onClick={() => window.open('https://github.com/sevazhidkov/prompts-ai', '_blank')}>
57-
<GitHubIcon fontSize={'small'}/>
58-
</IconButton>
59-
</div>
60-
</Toolbar>
61-
</Container>
44+
return (
45+
<AppBar position="static">
46+
<Container maxWidth={"lg"}>
47+
<Toolbar variant="regular" disableGutters={true}>
48+
<div className={classes.buttonGroup}>
49+
<Typography variant="h6" color="inherit">
50+
Prompts.ai
51+
</Typography>
52+
</div>
53+
<div className={classes.buttonGroup}>
54+
<IconButton onClick={handleApiKeyDialogOpen}>
55+
<VpnKeyIcon color={apiKeyPresent ? "action" : "error"} />
56+
</IconButton>
57+
</div>
58+
<div className={classes.buttonGroup}>
59+
<IconButton onClick={handleUndoClick}>
60+
<UndoIcon />
61+
</IconButton>
62+
<IconButton onClick={handleRedoClick}>
63+
<RedoIcon />
64+
</IconButton>
65+
</div>
66+
<div className={classes.buttonGroup}>
67+
<IconButton
68+
aria-label="GitHib"
69+
onClick={() =>
70+
window.open(
71+
"https://github.com/sevazhidkov/prompts-ai",
72+
"_blank"
73+
)
74+
}
75+
>
76+
<GitHubIcon fontSize={"small"} />
77+
</IconButton>
78+
</div>
79+
</Toolbar>
80+
</Container>
6281
</AppBar>
63-
}
82+
);
83+
}

0 commit comments

Comments
 (0)