Skip to content

Commit 5666cd4

Browse files
authored
feat: started simple Homepage to showcase SW (coinbase#483)
1 parent d442f74 commit 5666cd4

File tree

5 files changed

+85
-12
lines changed

5 files changed

+85
-12
lines changed

.changeset/little-spies-watch.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@coinbase/build-onchain-apps': patch
3+
---
4+
5+
- **feat**: started simple Homepage to showcase SW. By @zizzamia

src/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,9 @@ This folder contains cli code for `build-onchain-apps`
77
## How to modify blank app
88

99
We eject a blank page.tsx file to `template/web/app/pages`. `create/setupProject.ts``setupBlankApp` function contains the blank page file.
10+
11+
## To test from root
12+
13+
```
14+
ts-node src/index.ts create
15+
```

src/create/setupProject.ts

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,27 @@ import {
1313
import { experiences } from './experiences';
1414

1515
function generateNavbarExperiencesList(projectDir: string, experiences) {
16-
const filePath = path.join(projectDir, '/web/src/components/layout/header/Experiences.tsx');
16+
const filePath = path.join(
17+
projectDir,
18+
'/web/src/components/layout/header/Experiences.tsx'
19+
);
1720
const content = `
1821
import { ListItem } from './ListItem';
1922
2023
export function Experiences() {
2124
return (
2225
<>
23-
${experiences.map(({ value, label }) => (
24-
` <ListItem href="/${value}">${label}</ListItem>`
25-
)).join('\n')}
26+
${experiences
27+
.map(
28+
({ value, label }) => ` <ListItem href="/${value}">${label}</ListItem>`
29+
)
30+
.join('\n')}
2631
</>
2732
);
2833
}
29-
`
34+
`;
3035
fs.writeFileSync(filePath, content);
31-
};
36+
}
3237

3338
async function execAsync(command: string, options = {}) {
3439
return new Promise((resolve, reject) => {
@@ -122,10 +127,17 @@ export async function setupProject(projectDir: string, project) {
122127
process.exit(1);
123128
}
124129

130+
// Prepare simple homepage
131+
removeDownloadedApps(projectDir + '/web/app/home');
132+
renameDownloadedFile(
133+
projectDir + '/web/app/simple',
134+
projectDir + '/web/app/home'
135+
);
136+
125137
if (project.selectedModules.length === 0) {
126138
experiences.map(({ value }) => {
127139
removeDownloadedApps(projectDir + `/web/app/${value}`);
128-
})
140+
});
129141

130142
generateNavbarExperiencesList(projectDir, []);
131143
} else {
@@ -143,17 +155,25 @@ export async function setupProject(projectDir: string, project) {
143155
}
144156

145157
if (project.pickSmartWallet) {
146-
removeDownloadedApps(projectDir + '/web/src/store/createWagmiConfigWithRK.ts');
158+
removeDownloadedApps(
159+
projectDir + '/web/src/store/createWagmiConfigWithRK.ts'
160+
);
147161
removeDownloadedApps(projectDir + '/web/src/OnchainProvidersWithRK.tsx');
148162
} else {
149163
// Replace createWagmiConfig.ts with createWagmiConfigWithRK.ts content
150164
removeDownloadedApps(projectDir + '/web/src/store/createWagmiConfig.ts');
151165
const newFilename = projectDir + '/web/src/store/createWagmiConfig.ts';
152-
renameDownloadedFile(projectDir + '/web/src/store/createWagmiConfigWithRK.ts', newFilename);
166+
renameDownloadedFile(
167+
projectDir + '/web/src/store/createWagmiConfigWithRK.ts',
168+
newFilename
169+
);
153170
// Replace OnchainProviders.ts with OnchainProvidersWithRK.ts content
154171
removeDownloadedApps(projectDir + '/web/src/OnchainProviders.tsx');
155172
const newProviderFilename = projectDir + '/web/src/OnchainProviders.tsx';
156-
renameDownloadedFile(projectDir + '/web/src/OnchainProvidersWithRK.tsx', newProviderFilename);
173+
renameDownloadedFile(
174+
projectDir + '/web/src/OnchainProvidersWithRK.tsx',
175+
newProviderFilename
176+
);
157177
}
158178

159179
await execAsync('git add .', { cwd: projectDir, stdio: 'ignore' });

template/web/app/simple/HomePage.tsx

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use client';
2+
import { useAccount } from 'wagmi';
3+
import Footer from '@/components/layout/footer/Footer';
4+
import Header from '@/components/layout/header/Header';
5+
6+
/**
7+
* Use the page component to wrap the components
8+
* that you want to render on the page.
9+
*/
10+
export default function HomePage() {
11+
const account = useAccount();
12+
13+
return (
14+
<>
15+
<Header />
16+
<main className="container mx-auto flex flex-col px-8 py-16">
17+
<div>
18+
<h2 className="text-xl">Developer information</h2>
19+
<br />
20+
<h3 className="text-lg">Account</h3>
21+
<ul>
22+
<li>
23+
<b>status</b>: {account.status}
24+
</li>
25+
<li>
26+
<b>addresses</b>: {JSON.stringify(account.addresses)}
27+
</li>
28+
<li>
29+
<b>chainId</b>: {account.chainId}
30+
</li>
31+
</ul>
32+
</div>
33+
</main>
34+
<Footer />
35+
</>
36+
);
37+
}

tsconfig.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,17 @@
1010
"importHelpers": true,
1111
"target": "es2015",
1212
"module": "commonjs",
13-
"lib": ["es2020", "dom"],
13+
"lib": [
14+
"es2020",
15+
"dom"
16+
],
1417
"skipLibCheck": true,
1518
"skipDefaultLibCheck": true,
1619
"baseUrl": ".",
1720
"paths": {
18-
"@coinbase/build-onchain-apps": ["src/index.ts"]
21+
"@coinbase/build-onchain-apps": [
22+
"src/index.ts"
23+
]
1924
}
2025
},
2126
"files": [],

0 commit comments

Comments
 (0)