|
1 |
| -import React, { useState } from 'react'; |
2 |
| -import { Container, Paper, Box, Button, Typography, Link as MuiLink, Snackbar, IconButton, Grid, Accordion, AccordionSummary, AccordionDetails, Divider } from '@mui/material'; |
| 1 | +import React, { useState, useCallback } from 'react'; |
| 2 | +import { Container, Paper, Box, Typography, Link as MuiLink, Snackbar, IconButton, Accordion, AccordionSummary, AccordionDetails, Button } from '@mui/material'; |
3 | 3 | import { ThemeProvider } from '@mui/material/styles';
|
4 | 4 | import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
|
5 | 5 | import CloseIcon from '@mui/icons-material/Close';
|
6 | 6 | import GitHubIcon from '@mui/icons-material/GitHub';
|
7 |
| -import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; |
8 | 7 | import theme from './theme';
|
9 |
| -import ContextForm from './components/ContextForm'; |
10 |
| -import ContextDocsForm from './components/ContextDocsForm'; |
11 |
| -import ContextIgnoreForm from './components/ContextIgnoreForm'; |
12 | 8 | import PromptViewer from './components/PromptViewer';
|
13 |
| -import NavTabs from './components/NavTabs'; |
14 | 9 | import SpecificationModal from './components/SpecificationModal';
|
15 |
| -import ActionButtons from './components/ActionButtons'; |
16 |
| -import OptionsDescription from './components/OptionsDescription'; |
17 |
| -import { handleCopyToClipboard, handleDownload } from './utils/helpers'; |
| 10 | +import NavTabs from './components/NavTabs'; |
| 11 | +import ContextForm from './components/ContextForm'; |
| 12 | +import { handleCopyToClipboard } from './utils/helpers'; |
18 | 13 | import usePrompts from './hooks/usePrompts';
|
19 | 14 | import useSnackbar from './hooks/useSnackbar';
|
20 | 15 | import './App.css';
|
21 | 16 |
|
22 |
| -// Conditional base path for GitHub Pages |
23 |
| -const BASE_PATH = process.env.NODE_ENV === 'production' ? '/codebase-context-spec' : ''; |
24 |
| - |
25 | 17 | const App: React.FC = () => {
|
26 |
| - const [generatedContent, setGeneratedContent] = useState(''); |
27 | 18 | const [specModalOpen, setSpecModalOpen] = useState(false);
|
| 19 | + const [selectedTab, setSelectedTab] = useState(0); |
28 | 20 |
|
29 | 21 | const { snackbarOpen, snackbarMessage, showSnackbar, closeSnackbar } = useSnackbar();
|
30 |
| - const { codebaseContext, generateContextPrompt, codingAssistantPrompt } = usePrompts( |
| 22 | + const { codebaseContext, generateContextPrompt, codingAssistantPrompts } = usePrompts( |
31 | 23 | showSnackbar,
|
32 | 24 | (open: boolean) => open ? showSnackbar('') : closeSnackbar()
|
33 | 25 | );
|
34 | 26 |
|
35 |
| - const handleFormSubmit = (content: string) => { |
36 |
| - setGeneratedContent(content); |
| 27 | + const handleTabChange = (event: React.SyntheticEvent, newValue: number) => { |
| 28 | + setSelectedTab(newValue); |
37 | 29 | };
|
38 | 30 |
|
| 31 | + const handleContextFormSubmit = (content: string) => { |
| 32 | + console.log('Generated .context.md content:', content); |
| 33 | + showSnackbar('Context form submitted successfully'); |
| 34 | + // Here you can add logic to save or process the generated content |
| 35 | + }; |
| 36 | + |
| 37 | + const handleCopy = useCallback((content: string) => { |
| 38 | + handleCopyToClipboard( |
| 39 | + content, |
| 40 | + (message: string) => showSnackbar(message), |
| 41 | + (open: boolean) => open ? showSnackbar('') : closeSnackbar() |
| 42 | + ); |
| 43 | + }, [showSnackbar, closeSnackbar]); |
| 44 | + |
39 | 45 | return (
|
40 | 46 | <ThemeProvider theme={theme}>
|
41 |
| - <Router basename={BASE_PATH}> |
42 |
| - <Container className="container" maxWidth="lg"> |
43 |
| - <Paper className="paper" elevation={3}> |
44 |
| - <Box className="header" display="flex" justifyContent="space-between" alignItems="center"> |
45 |
| - <Typography className="title" variant="h4" component="h1"> |
46 |
| - Codebase Context Editor |
| 47 | + <Container className="container" maxWidth="lg"> |
| 48 | + <Paper className="paper" elevation={3}> |
| 49 | + <Box className="header" display="flex" justifyContent="space-between" alignItems="flex-start" mb={4}> |
| 50 | + <Box> |
| 51 | + <Typography className="title" variant="h4" component="h1" gutterBottom> |
| 52 | + Codebase Context Suite |
| 53 | + </Typography> |
| 54 | + <Typography variant="subtitle1"> |
| 55 | + A comprehensive tool for managing codebase context, generating prompts, and enhancing development workflows. |
47 | 56 | </Typography>
|
48 |
| - <Box display="flex" alignItems="center"> |
49 |
| - <Button |
50 |
| - className="viewLatestSpec" |
51 |
| - onClick={() => setSpecModalOpen(true)} |
52 |
| - sx={{ mr: 2 }} |
53 |
| - > |
54 |
| - View Latest Specification v1.0.0-RFC |
55 |
| - </Button> |
56 |
| - <MuiLink href="https://github.com/Agentic-Insights/codebase-context-spec" target="_blank" rel="noopener noreferrer"> |
57 |
| - <GitHubIcon fontSize="large" /> |
58 |
| - </MuiLink> |
59 |
| - </Box> |
60 | 57 | </Box>
|
61 |
| - <Typography variant="body1" paragraph sx={{ mb: 3 }}> |
62 |
| - This editor helps you create .context.md, .contextdocs.md, and .contextignore files for your project. |
63 |
| - </Typography> |
64 |
| - |
65 |
| - <OptionsDescription /> |
66 |
| - |
67 |
| - <Divider sx={{ my: 3 }} /> |
68 |
| - |
69 |
| - <Accordion sx={{ |
70 |
| - mb: 3, |
71 |
| - '&.MuiAccordion-root': { |
72 |
| - borderLeft: `6px solid ${theme.palette.secondary.main}`, |
73 |
| - } |
74 |
| - }}> |
75 |
| - <AccordionSummary |
76 |
| - expandIcon={<ExpandMoreIcon />} |
77 |
| - sx={{ |
78 |
| - backgroundColor: theme.palette.background.paper, |
79 |
| - '&.Mui-expanded': { |
80 |
| - minHeight: 48, |
81 |
| - }, |
82 |
| - }} |
| 58 | + <Box display="flex" alignItems="center"> |
| 59 | + <Button |
| 60 | + onClick={() => setSpecModalOpen(true)} |
| 61 | + variant="contained" |
| 62 | + color="primary" |
| 63 | + sx={{ mr: 2 }} |
83 | 64 | >
|
84 |
| - <Typography variant="h6" color="secondary">Prompts: Generate draft & Usage / custom instructions</Typography> |
85 |
| - </AccordionSummary> |
86 |
| - <AccordionDetails> |
87 |
| - <Grid container spacing={2}> |
88 |
| - <Grid item xs={12} md={6}> |
89 |
| - <PromptViewer |
90 |
| - title="Generate Context Prompt" |
91 |
| - subtitle="GENERATE-CONTEXT-PROMPT.md" |
92 |
| - explanation={generateContextPrompt.explanation} |
93 |
| - content={generateContextPrompt.content} |
94 |
| - onCopy={() => handleCopyToClipboard(generateContextPrompt.content, showSnackbar, () => showSnackbar(''))} |
95 |
| - /> |
96 |
| - </Grid> |
97 |
| - <Grid item xs={12} md={6}> |
| 65 | + View Specification |
| 66 | + </Button> |
| 67 | + <MuiLink href="https://github.com/Agentic-Insights/codebase-context-spec" target="_blank" rel="noopener noreferrer"> |
| 68 | + <GitHubIcon fontSize="large" /> |
| 69 | + </MuiLink> |
| 70 | + </Box> |
| 71 | + </Box> |
| 72 | + |
| 73 | + <NavTabs value={selectedTab} onChange={handleTabChange} /> |
| 74 | + |
| 75 | + <Box mt={2}> |
| 76 | + {selectedTab === 0 && ( |
| 77 | + <Box> |
| 78 | + <Typography variant="h5" sx={{ mb: 2 }}>Coding Assistant Prompts</Typography> |
| 79 | + <Accordion defaultExpanded> |
| 80 | + <AccordionSummary expandIcon={<ExpandMoreIcon />}> |
| 81 | + <Typography>Claude-dev Prompt</Typography> |
| 82 | + </AccordionSummary> |
| 83 | + <AccordionDetails> |
98 | 84 | <PromptViewer
|
99 |
| - title="Coding Assistant Prompt" |
100 |
| - subtitle="CODING-ASSISTANT-PROMPT.md" |
101 |
| - explanation={codingAssistantPrompt.explanation} |
102 |
| - content={codingAssistantPrompt.content} |
103 |
| - onCopy={() => handleCopyToClipboard(codingAssistantPrompt.content, showSnackbar, () => showSnackbar(''))} |
| 85 | + title="CLAUDE-DEV Prompt" |
| 86 | + subtitle="CLAUDE-DEV-PROMPT.md" |
| 87 | + explanation={codingAssistantPrompts['claude-dev']?.explanation || ''} |
| 88 | + content={codingAssistantPrompts['claude-dev']?.content || ''} |
| 89 | + onCopy={() => handleCopy(codingAssistantPrompts['claude-dev']?.content || '')} |
104 | 90 | />
|
105 |
| - </Grid> |
106 |
| - </Grid> |
107 |
| - </AccordionDetails> |
108 |
| - </Accordion> |
109 |
| - <NavTabs /> |
110 |
| - <Box className="form-section"> |
111 |
| - <Routes> |
112 |
| - <Route path="/" element={<ContextForm onSubmit={handleFormSubmit} />} /> |
113 |
| - <Route path="/contextdocs" element={<ContextDocsForm onSubmit={handleFormSubmit} />} /> |
114 |
| - <Route path="/contextignore" element={<ContextIgnoreForm onSubmit={handleFormSubmit} />} /> |
115 |
| - </Routes> |
116 |
| - </Box> |
117 |
| - <ActionButtons |
118 |
| - generatedContent={generatedContent} |
119 |
| - onCopy={() => handleCopyToClipboard(generatedContent, showSnackbar, () => showSnackbar(''))} |
120 |
| - onDownload={() => handleDownload(generatedContent, 'generated_context.md', showSnackbar, () => showSnackbar(''))} |
121 |
| - /> |
122 |
| - </Paper> |
| 91 | + </AccordionDetails> |
| 92 | + </Accordion> |
| 93 | + {/* Add other coding assistant prompts here if needed */} |
| 94 | + </Box> |
| 95 | + )} |
123 | 96 |
|
124 |
| - <SpecificationModal |
125 |
| - open={specModalOpen} |
126 |
| - onClose={() => setSpecModalOpen(false)} |
127 |
| - content={codebaseContext.content} |
128 |
| - onCopy={() => handleCopyToClipboard(codebaseContext.content, showSnackbar, () => showSnackbar(''))} |
129 |
| - /> |
| 97 | + {selectedTab === 1 && ( |
| 98 | + <Box> |
| 99 | + <Typography variant="h5" sx={{ mb: 2 }}>Generate Context Files</Typography> |
| 100 | + <PromptViewer |
| 101 | + title="Generate Context Prompt" |
| 102 | + subtitle="GENERATE-CONTEXT-PROMPT.md" |
| 103 | + explanation={generateContextPrompt.explanation} |
| 104 | + content={generateContextPrompt.content} |
| 105 | + onCopy={() => handleCopy(generateContextPrompt.content)} |
| 106 | + /> |
| 107 | + </Box> |
| 108 | + )} |
130 | 109 |
|
131 |
| - <Snackbar |
132 |
| - anchorOrigin={{ |
133 |
| - vertical: 'bottom', |
134 |
| - horizontal: 'center', |
135 |
| - }} |
136 |
| - open={snackbarOpen} |
137 |
| - autoHideDuration={2000} |
138 |
| - onClose={closeSnackbar} |
139 |
| - message={snackbarMessage} |
140 |
| - action={ |
141 |
| - <IconButton |
142 |
| - size="small" |
143 |
| - aria-label="close" |
144 |
| - color="inherit" |
145 |
| - onClick={closeSnackbar} |
146 |
| - > |
147 |
| - <CloseIcon fontSize="small" /> |
148 |
| - </IconButton> |
149 |
| - } |
150 |
| - /> |
151 |
| - </Container> |
152 |
| - </Router> |
| 110 | + {selectedTab === 2 && ( |
| 111 | + <Box> |
| 112 | + <Typography variant="h5" sx={{ mb: 2 }}>Manual Context Form</Typography> |
| 113 | + <ContextForm onSubmit={handleContextFormSubmit} /> |
| 114 | + </Box> |
| 115 | + )} |
| 116 | + </Box> |
| 117 | + </Paper> |
| 118 | + |
| 119 | + <SpecificationModal |
| 120 | + open={specModalOpen} |
| 121 | + onClose={() => setSpecModalOpen(false)} |
| 122 | + content={codebaseContext.content} |
| 123 | + onCopy={() => handleCopy(codebaseContext.content)} |
| 124 | + /> |
| 125 | + |
| 126 | + <Snackbar |
| 127 | + anchorOrigin={{ |
| 128 | + vertical: 'bottom', |
| 129 | + horizontal: 'center', |
| 130 | + }} |
| 131 | + open={snackbarOpen} |
| 132 | + autoHideDuration={2000} |
| 133 | + onClose={closeSnackbar} |
| 134 | + message={snackbarMessage} |
| 135 | + action={ |
| 136 | + <IconButton |
| 137 | + size="small" |
| 138 | + aria-label="close" |
| 139 | + color="inherit" |
| 140 | + onClick={closeSnackbar} |
| 141 | + > |
| 142 | + <CloseIcon fontSize="small" /> |
| 143 | + </IconButton> |
| 144 | + } |
| 145 | + /> |
| 146 | + </Container> |
153 | 147 | </ThemeProvider>
|
154 | 148 | );
|
155 | 149 | };
|
|
0 commit comments