Skip to content

Commit a13f51a

Browse files
committed
Small add-to-app fixes
1 parent 896581d commit a13f51a

File tree

9 files changed

+69
-33
lines changed

9 files changed

+69
-33
lines changed

packages/cta-engine/src/add-to-app.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,7 @@ export async function writeFiles(
138138
)
139139
} else if (fName !== CONFIG_FILE) {
140140
if (isBase64(contents)) {
141-
await environment.writeFile(
142-
resolve(cwd, file),
143-
getBinaryFile(contents)!,
144-
)
141+
await environment.writeFileBase64(resolve(cwd, file), contents)
145142
} else {
146143
await environment.writeFile(resolve(cwd, file), contents)
147144
}

packages/cta-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"@tanstack/react-store": "^0.7.0",
4040
"@tanstack/router-plugin": "^1.114.3",
4141
"@tanstack/store": "^0.7.0",
42-
"@uiw/codemirror-theme-okaidia": "^4.23.10",
42+
"@uiw/codemirror-theme-github": "^4.23.10",
4343
"@uiw/react-codemirror": "^4.23.10",
4444
"class-variance-authority": "^0.7.1",
4545
"clsx": "^2.1.1",

packages/cta-ui/src/components/cta-sidebar.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export function AppSidebar() {
4747
</>
4848
)}
4949
</SidebarContent>
50-
<SidebarFooter>
50+
<SidebarFooter className="mb-5">
5151
<RunAddOns />
5252
<RunCreateApp />
5353
</SidebarFooter>

packages/cta-ui/src/components/file-navigator.tsx

+9-6
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ import type { FileTreeItem } from '@/types'
1010
import { Label } from '@/components/ui/label'
1111
import { Checkbox } from '@/components/ui/checkbox'
1212
import { Separator } from '@/components/ui/separator'
13+
import { useSidebar } from '@/components/ui/sidebar'
14+
1315
import {
1416
applicationMode,
1517
includeFiles,
18+
isInitialized,
1619
projectFiles,
1720
projectLocalFiles,
18-
isInitialized,
1921
} from '@/store/project'
2022

2123
import { getFileClass, twClasses } from '@/file-classes'
@@ -35,8 +37,8 @@ export function Filters() {
3537
}
3638

3739
return (
38-
<>
39-
<div className="text-center text-sm border-b-1 mb-4">File Filters</div>
40+
<div className="p-2 rounded-md bg-gray-900 file-filters">
41+
<div className="text-center text-sm mb-2">File Filters</div>
4042
<div className="flex flex-row flex-wrap gap-y-2">
4143
<div className="flex flex-row items-center gap-2 w-1/3">
4244
<Checkbox
@@ -94,8 +96,7 @@ export function Filters() {
9496
</Label>
9597
</div>
9698
</div>
97-
<Separator className="my-4" />
98-
</>
99+
</div>
99100
)
100101
}
101102

@@ -192,7 +193,9 @@ export default function FileNavigator() {
192193
}
193194

194195
return (
195-
<div className="flex flex-row w-[calc(100vw-450px)]">
196+
<div
197+
className={`flex flex-row border-1 rounded-md mr-10 p-2 inset-shadow-gray-600 inset-shadow-sm`}
198+
>
196199
<div className="w-1/4 max-w-1/4 pr-2">
197200
{mode === 'add' && <Filters />}
198201
<FileTree selectedFile={selectedFile} tree={fileTree} />

packages/cta-ui/src/components/file-viewer.tsx

+11-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,15 @@ import { json } from '@codemirror/lang-json'
66
import { css } from '@codemirror/lang-css'
77
import { html } from '@codemirror/lang-html'
88

9-
import { okaidia } from '@uiw/codemirror-theme-okaidia'
9+
import { githubDarkInit } from '@uiw/codemirror-theme-github'
10+
11+
const theme = githubDarkInit({
12+
settings: {
13+
background: 'oklch(0.07 0.005 285.823)',
14+
foreground: '#c9d1d9',
15+
gutterBackground: 'oklch(0.22 0.005 285.823)',
16+
},
17+
})
1018

1119
export default function FileViewer({
1220
originalFile,
@@ -41,7 +49,7 @@ export default function FileViewer({
4149
return (
4250
<CodeMirror
4351
value={modifiedFile}
44-
theme={okaidia}
52+
theme={theme}
4553
height="100vh"
4654
width="100%"
4755
readOnly
@@ -51,7 +59,7 @@ export default function FileViewer({
5159
)
5260
}
5361
return (
54-
<CodeMirrorMerge orientation="a-b" theme={okaidia} className="text-lg">
62+
<CodeMirrorMerge orientation="a-b" theme={theme} className="text-lg">
5563
<CodeMirrorMerge.Original value={originalFile} extensions={[language]} />
5664
<CodeMirrorMerge.Modified value={modifiedFile} extensions={[language]} />
5765
</CodeMirrorMerge>

packages/cta-ui/src/routes/__root.tsx

+29-12
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ import appCss from '../styles.css?url'
99

1010
import type { QueryClient } from '@tanstack/react-query'
1111

12-
import { SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar'
12+
import {
13+
SidebarProvider,
14+
SidebarTrigger,
15+
useSidebar,
16+
} from '@/components/ui/sidebar'
1317
import { Toaster } from '@/components/toaster'
1418

1519
import { AppSidebar } from '@/components/cta-sidebar'
@@ -18,6 +22,20 @@ interface MyRouterContext {
1822
queryClient: QueryClient
1923
}
2024

25+
function Content() {
26+
const { open } = useSidebar()
27+
28+
return (
29+
<main
30+
className={
31+
open ? 'w-full max-w-[calc(100%-370px)]' : 'w-full max-w-[100%]'
32+
}
33+
>
34+
<SidebarTrigger className="m-2" />
35+
<Outlet />
36+
</main>
37+
)
38+
}
2139
export const Route = createRootRouteWithContext<MyRouterContext>()({
2240
head: () => ({
2341
meta: [
@@ -40,18 +58,17 @@ export const Route = createRootRouteWithContext<MyRouterContext>()({
4058
],
4159
}),
4260

43-
component: () => (
44-
<RootDocument>
45-
<SidebarProvider>
46-
<AppSidebar />
47-
<main className="w-[calc(100vw-200px)]">
48-
<SidebarTrigger />
49-
<Outlet />
61+
component: () => {
62+
return (
63+
<RootDocument>
64+
<SidebarProvider>
65+
<AppSidebar />
66+
<Content />
5067
<Toaster />
51-
</main>
52-
</SidebarProvider>
53-
</RootDocument>
54-
),
68+
</SidebarProvider>
69+
</RootDocument>
70+
)
71+
},
5572
})
5673

5774
function RootDocument({ children }: { children: React.ReactNode }) {

packages/cta-ui/src/routes/api/dry-run-add-to-app.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,15 @@ import { createAPIFileRoute } from '@tanstack/react-start/api'
55

66
import {
77
addToApp,
8-
cleanUpFiles,
98
createMemoryEnvironment,
109
recursivelyGatherFiles,
1110
} from '@tanstack/cta-engine'
1211

1312
import { register as registerReactCra } from '@tanstack/cta-framework-react-cra'
1413
import { register as registerSolid } from '@tanstack/cta-framework-solid'
1514

15+
import { cleanUpFileArray, cleanUpFiles } from '@/lib/file-helpers'
16+
1617
registerReactCra()
1718
registerSolid()
1819

@@ -37,7 +38,6 @@ export const APIRoute = createAPIFileRoute('/api/dry-run-add-to-app')({
3738
await recursivelyGatherFiles(projectPath, false),
3839
)
3940
for (const file of Object.keys(localFiles)) {
40-
console.log('writing local file', file)
4141
environment.writeFile(resolve(projectPath, file), localFiles[file])
4242
}
4343

@@ -57,6 +57,9 @@ export const APIRoute = createAPIFileRoute('/api/dry-run-add-to-app')({
5757

5858
environment.finishRun()
5959

60+
output.files = cleanUpFiles(output.files, projectPath)
61+
output.deletedFiles = cleanUpFileArray(output.deletedFiles, projectPath)
62+
6063
return json(output)
6164
},
6265
})

packages/cta-ui/src/styles.css

+8
Original file line numberDiff line numberDiff line change
@@ -175,3 +175,11 @@ code {
175175
[data-sidebar='header'] {
176176
@apply shadow-gray-700 shadow-md z-50;
177177
}
178+
179+
.cm-changedLine {
180+
background-color: oklch(0.27 0.005 285.823) !important;
181+
}
182+
183+
.file-filters {
184+
background-color: oklch(0.2 0.005 285.823);
185+
}

pnpm-lock.yaml

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)