Skip to content

Commit cb5f750

Browse files
Merge pull request #20 from tien/chore/update-template
chore: update React template
2 parents c69fc6f + dfdc72a commit cb5f750

File tree

18 files changed

+160
-161
lines changed

18 files changed

+160
-161
lines changed

.prettierrc.cjs

Lines changed: 0 additions & 1 deletion
This file was deleted.

.prettierrc.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import defaultConfiguration from "@eng-automation/js-style/src/prettier/configuration.js";
2+
3+
export default {
4+
...defaultConfiguration,
5+
plugins: ["prettier-plugin-tailwindcss"],
6+
};

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
"@eng-automation/js-style": "^3.1.0",
99
"chokidar": "^4.0.1",
1010
"commander": "^12.1.0",
11+
"prettier": "^3.5.3",
12+
"prettier-plugin-tailwindcss": "^0.6.11",
1113
"type-fest": "^4.27.0",
1214
"typescript": "^5.4.5"
1315
},
@@ -26,9 +28,7 @@
2628
"lint": "npx eslint ./src/ --ext .js,.jsx,.ts,.tsx",
2729
"lint:fix": "npx eslint ./src/ --ext .js,.jsx,.ts,.tsx --fix"
2830
},
29-
"bin": {
30-
"create-polkadot-dapp": "src/bin/main.js"
31-
},
31+
"bin": "src/bin/main.js",
3232
"imports": {
3333
"#src/*": "./src/*.js"
3434
}
Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# react-papi-tailwind template
22

33
This template describes a React front-end app with
4-
* [PAPI](papi.how) + [ReactiveDOT](https://reactivedot.dev) + [dotconnect](https://dotconnect.dev/) for chain and wallet interactions.<br/>
5-
* [Tailwind CSS](https://tailwindcss.com) + [Tailwind UI](https://tailwindui.com/). <br/>
6-
* [Vite](https://vite.dev/) for dev tooling.
74

5+
- [PAPI](papi.how) + [ReactiveDOT](https://reactivedot.dev) + [dotconnect](https://dotconnect.dev/) for chain and wallet interactions.<br/>
6+
- [Tailwind CSS](https://tailwindcss.com) + [Tailwind UI](https://tailwindui.com/). <br/>
7+
- [Vite](https://vite.dev/) for dev tooling.
88

99
### Note on wallet connection
10+
1011
This template has PJS Apps, Talisman, SubWallet and Ledger enabled by default.
1112
In order to enable WalletConnect, set up WalletConnect project ID / metadata in [reactive-dot.ts](./templates/react-tailwind/src/reactive-dot.ts)
Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1-
import js from '@eslint/js'
2-
import globals from 'globals'
3-
import reactHooks from 'eslint-plugin-react-hooks'
4-
import reactRefresh from 'eslint-plugin-react-refresh'
5-
import tseslint from 'typescript-eslint'
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import reactHooks from "eslint-plugin-react-hooks";
4+
import reactRefresh from "eslint-plugin-react-refresh";
5+
import tseslint from "typescript-eslint";
66

77
export default tseslint.config(
8-
{ ignores: ['dist'] },
8+
{ ignores: ["dist"] },
99
{
1010
extends: [js.configs.recommended, ...tseslint.configs.recommended],
11-
files: ['**/*.{ts,tsx}'],
11+
files: ["**/*.{ts,tsx}"],
1212
languageOptions: {
1313
ecmaVersion: 2020,
1414
globals: globals.browser,
1515
},
1616
plugins: {
17-
'react-hooks': reactHooks,
18-
'react-refresh': reactRefresh,
17+
"react-hooks": reactHooks,
18+
"react-refresh": reactRefresh,
1919
},
2020
rules: {
2121
...reactHooks.configs.recommended.rules,
22-
'react-refresh/only-export-components': [
23-
'warn',
24-
{ allowConstantExport: true },
25-
],
22+
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
2623
},
2724
},
28-
)
25+
);

templates/react-papi-tailwind/package.json

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,30 +11,29 @@
1111
},
1212
"dependencies": {
1313
"@headlessui/react": "^2.2.0",
14-
"@heroicons/react": "^2.1.5",
15-
"@reactive-dot/react": "^0.29.0",
16-
"@reactive-dot/core": "^0.29.0",
17-
"@reactive-dot/wallet-ledger": "^0.16.21",
18-
"@reactive-dot/wallet-walletconnect": "^0.17.1",
19-
"dot-connect": "^0.13.2",
20-
"polkadot-api": "^1.7.7",
21-
"react": "^18.3.1",
22-
"react-dom": "^18.3.1"
14+
"@heroicons/react": "^2.2.0",
15+
"@reactive-dot/core": "^0.36.0",
16+
"@reactive-dot/react": "^0.36.0",
17+
"@reactive-dot/wallet-ledger": "^0.16.27",
18+
"@reactive-dot/wallet-walletconnect": "^0.17.7",
19+
"dot-connect": "^0.15.0",
20+
"polkadot-api": "^1.9.4",
21+
"react": "^19.0.0",
22+
"react-dom": "^19.0.0"
2323
},
2424
"devDependencies": {
25-
"@eslint/js": "^9.14.0",
26-
"@types/react": "^18.3.12",
27-
"@types/react-dom": "^18.3.1",
28-
"@vitejs/plugin-react": "^4.3.3",
29-
"autoprefixer": "^10.4.20",
30-
"eslint": "^9.14.0",
31-
"eslint-plugin-react-hooks": "^5.0.0",
32-
"eslint-plugin-react-refresh": "^0.4.14",
33-
"globals": "^15.11.0",
34-
"postcss": "^8.4.47",
35-
"tailwindcss": "^3.4.14",
36-
"typescript": "~5.6.2",
37-
"typescript-eslint": "^8.12.2",
38-
"vite": "^5.4.10"
25+
"@eslint/js": "^9.21.0",
26+
"@tailwindcss/vite": "^4.0.9",
27+
"@types/react": "^19.0.10",
28+
"@types/react-dom": "^19.0.4",
29+
"@vitejs/plugin-react": "^4.3.4",
30+
"eslint": "^9.21.0",
31+
"eslint-plugin-react-hooks": "^5.2.0",
32+
"eslint-plugin-react-refresh": "^0.4.19",
33+
"globals": "^16.0.0",
34+
"tailwindcss": "^4.0.9",
35+
"typescript": "~5.8.2",
36+
"typescript-eslint": "^8.26.0",
37+
"vite": "^6.2.0"
3938
}
4039
}

templates/react-papi-tailwind/postcss.config.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

templates/react-papi-tailwind/src/App.tsx

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,19 @@ import polkadotLogo from "./assets/polkadot-logo.svg";
1010

1111
import { AccountList } from "./components/AccountList";
1212

13-
function App({ chainId, setChainId }: {
14-
chainId: ChainId;
15-
setChainId: React.Dispatch<React.SetStateAction<ChainId>>
16-
}) {
17-
13+
function App({ chainId, setChainId }: { chainId: ChainId; setChainId: React.Dispatch<React.SetStateAction<ChainId>> }) {
1814
return (
1915
<>
20-
<div className="fixed top-10 right-10">
21-
<div className="inline-block ml-5">
16+
<div className="fixed right-10 top-10">
17+
<div className="ml-5 inline-block">
2218
<ConnectionButton />
2319
</div>
24-
<div className="inline-block ml-5">
20+
<div className="ml-5 inline-block">
2521
<ChainSwitch chainId={chainId} setChainId={setChainId} />
2622
</div>
2723
</div>
2824

29-
<img src={polkadotLogo} className="mx-auto h-52 p-4 logo" alt="Polkadot logo" />
25+
<img src={polkadotLogo} className="logo mx-auto h-52 p-4" alt="Polkadot logo" />
3026
<div className="container mx-auto p-2 leading-6">
3127
<ChainPage />
3228
</div>
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import { useChainId, useLazyLoadQuery } from "@reactive-dot/react";
22

33
export function ChainPage() {
4-
54
const chainId = useChainId();
65

76
const [timestamp, blockNumber] = useLazyLoadQuery((builder) =>
8-
builder
9-
.readStorage("Timestamp", "Now", [])
10-
.readStorage("System", "Number", [])
7+
builder.readStorage("Timestamp", "Now", []).readStorage("System", "Number", []),
118
);
129

13-
return <>
10+
return (
11+
<>
1412
<h1>Your app is ready</h1>
1513
<p className="m-2">
1614
Connected to chain <strong>{chainId}</strong>
@@ -21,5 +19,6 @@ export function ChainPage() {
2119
<p className="m-2">
2220
Timestamp: <strong>{timestamp.toString()}</strong>
2321
</p>
24-
</>;
22+
</>
23+
);
2524
}

templates/react-papi-tailwind/src/components/AccountList.tsx

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,21 @@
11
import { useAccounts } from "@reactive-dot/react";
22
import { getWalletMetadata } from "dot-connect";
33

4-
function AccountInfo({ address, name, wallet }: { address: string; name?: string, wallet: string }) {
5-
return <div className="container md grid grid-cols-2 border rounded p-2 my-2">
6-
<div className="static text-left font-bold text-lg">{name}</div>
7-
<div className="static text-right font-light">{wallet}</div>
8-
<div className="static col-span-2 text-left">{address}</div>
9-
</div>;
4+
function AccountInfo({ address, name, wallet }: { address: string; name?: string; wallet: string }) {
5+
return (
6+
<div className="md container my-2 grid grid-cols-2 rounded-sm border p-2">
7+
<div className="static text-left text-lg font-bold">{name}</div>
8+
<div className="static text-right font-light">{wallet}</div>
9+
<div className="static col-span-2 text-left">{address}</div>
10+
</div>
11+
);
1012
}
1113

1214
export function AccountList() {
1315
const accounts = useAccounts();
1416

1517
if (accounts.length === 0) {
16-
return (<></>);
18+
return <></>;
1719
}
1820

1921
return (
@@ -33,5 +35,4 @@ export function AccountList() {
3335
</ul>
3436
</div>
3537
);
36-
3738
}

0 commit comments

Comments
 (0)