Skip to content

Commit

Permalink
docs: use codebase convention for code snippets (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
tien authored Jul 23, 2024
1 parent dfa501f commit cff1c85
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 21 deletions.
12 changes: 5 additions & 7 deletions apps/docs/docs/getting-started/connect-wallets.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ import {
WalletConnect,
} from "@reactive-dot/core/wallets.js";

const config = {
export const config = {
// ...
wallets: [
new InjectedWalletAggregator(),
Expand All @@ -72,20 +72,18 @@ const config = {
}),
],
} as const satisfies Config;

export default config;
```

## Connect to wallets

```tsx title="Wallets.tsx"
```tsx title="wallets.tsx"
import {
useConnectedWallets,
useWallets,
useConnectWallet,
} from "@reactive-dot/react";

export default function Wallets() {
export function Wallets() {
const wallets = useWallets();
const connectedWallets = useConnectedWallets();

Expand Down Expand Up @@ -123,10 +121,10 @@ export default function Wallets() {

## Display available accounts

```tsx title="Accounts.tsx"
```tsx title="accounts.tsx"
import { useAccounts } from "@reactive-dot/react";

export default function Accounts() {
export function Accounts() {
const accounts = useAccounts();

return (
Expand Down
4 changes: 1 addition & 3 deletions apps/docs/docs/getting-started/multichain.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ declare module "@reactive-dot/core" {
import type { dot, ksm, wnd } from "@polkadot-api/descriptors";
import type { Config } from "@reactive-dot/core";

const config = {
export const config = {
chains: {
polkadot: {
descriptor: dot,
Expand All @@ -56,8 +56,6 @@ const config = {
},
//...
} as const satisfies Config;

export default config;
```

## Chain selection
Expand Down
18 changes: 7 additions & 11 deletions apps/docs/docs/getting-started/setup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ const smoldot = startFromWorker(
}),
);

const config = {
export const config = {
chains: {
// "polkadot" here can be any unique string value
polkadot: {
Expand All @@ -93,8 +93,6 @@ const config = {
},
wallets: [new InjectedWalletAggregator()],
} as const satisfies Config;

export default config;
```

{/* prettier-ignore-start */}
Expand All @@ -110,7 +108,7 @@ import { WebSocketProvider } from "@polkadot-api/ws-provider/web";
import type { Config } from "@reactive-dot/core";
import { InjectedWalletAggregator } from "@reactive-dot/core/wallets.js";

const config = {
export const config = {
chains: {
polkadot: {
descriptor: dot,
Expand All @@ -119,8 +117,6 @@ const config = {
},
wallets: [new InjectedWalletAggregator()],
} as const satisfies Config;

export default config;
```

{/* prettier-ignore-start */}
Expand All @@ -145,12 +141,12 @@ declare module "@reactive-dot/core" {

## Wrap app in context providers

```tsx title="App.tsx"
import config from "./config";
```tsx title="app.tsx"
import { config } from "./config";
import { ReDotChainProvider, ReDotProvider } from "@reactive-dot/react";
import { Suspense } from "react";

export default function App() {
export function App() {
return (
<ReDotProvider config={config}>
{/* `chainId` match the ID previously specified via `polkadot: typeof dot` */}
Expand All @@ -165,11 +161,11 @@ export default function App() {

## Use Reactive DOT

```tsx title="MyComponent.tsx"
```tsx title="my-component.tsx"
import { config } from "./config";
import { useAccounts, useLazyLoadQuery } from "@reactive-dot/react";

export default function MyComponent() {
export function MyComponent() {
const accounts = useAccounts();
const [timestamp, totalIssuance] = useLazyLoadQuery((builder) =>
builder
Expand Down

0 comments on commit cff1c85

Please sign in to comment.