@cmdoss/walrus-site-builder-react 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +256 -0
- package/dist/index.css +1442 -0
- package/dist/index.d.ts +484 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4908 -0
- package/dist/index.js.map +1 -0
- package/package.json +64 -0
package/README.md
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
# @cmdoss/walrus-site-builder-react
|
|
2
|
+
|
|
3
|
+
React components for building and publishing sites to Walrus network with SuiNS domain integration.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pnpm add @cmdoss/walrus-site-builder-react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
- 🎨 **Vanilla Extract Styling** - Type-safe, zero-runtime CSS with light/dark theme support
|
|
14
|
+
- 🔧 **Nanostores State Management** - Lightweight and performant state management
|
|
15
|
+
- � **TypeScript First** - Full type safety out of the box
|
|
16
|
+
- 🌐 **Walrus Sites** - Deploy to decentralized Walrus network
|
|
17
|
+
- 🔗 **SuiNS Integration** - Associate your sites with .sui domains
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
|
|
21
|
+
### Use PublishButton Component
|
|
22
|
+
|
|
23
|
+
The `PublishButton` component handles the entire publishing workflow including UI, state management, and wallet interactions:
|
|
24
|
+
|
|
25
|
+
```tsx
|
|
26
|
+
import { PublishButton } from '@cmdoss/walrus-site-builder-react'
|
|
27
|
+
import type { IAsset } from '@cmdoss/walrus-site-builder'
|
|
28
|
+
import { SuiClient } from '@mysten/sui/client'
|
|
29
|
+
import { QueryClient } from '@tanstack/react-query'
|
|
30
|
+
|
|
31
|
+
function MyApp() {
|
|
32
|
+
const suiClient = new SuiClient({ url: '...' })
|
|
33
|
+
const queryClient = new QueryClient()
|
|
34
|
+
const assets: IAsset[] = [] // Your assets here
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<PublishButton
|
|
38
|
+
siteId={existingSiteId} // Optional: pass existing site ID to update
|
|
39
|
+
clients={{ suiClient, queryClient }}
|
|
40
|
+
currentAccount={walletAccount}
|
|
41
|
+
signAndExecuteTransaction={signAndExecuteTransaction}
|
|
42
|
+
portalDomain="walrus.site"
|
|
43
|
+
portalHttps={true}
|
|
44
|
+
assets={assets}
|
|
45
|
+
onUpdateSiteMetadata={async (site) => {
|
|
46
|
+
// Optional: Save site metadata to your backend
|
|
47
|
+
}}
|
|
48
|
+
onAssociatedDomain={async (nftId, siteId) => {
|
|
49
|
+
// Optional: Handle domain association callback
|
|
50
|
+
}}
|
|
51
|
+
onError={(msg) => console.error(msg)}
|
|
52
|
+
/>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Components
|
|
58
|
+
|
|
59
|
+
### PublishButton
|
|
60
|
+
|
|
61
|
+
Main component that includes PublishMenu, PublishModal, and SuiNsModal. It wraps everything with a ThemeProvider automatically.
|
|
62
|
+
|
|
63
|
+
```tsx
|
|
64
|
+
import { PublishButton } from '@cmdoss/walrus-site-builder-react'
|
|
65
|
+
|
|
66
|
+
<PublishButton
|
|
67
|
+
siteId={siteId}
|
|
68
|
+
clients={{ suiClient, queryClient }}
|
|
69
|
+
currentAccount={currentAccount}
|
|
70
|
+
signAndExecuteTransaction={signAndExecuteTransaction}
|
|
71
|
+
portalDomain="walrus.site"
|
|
72
|
+
portalHttps={true}
|
|
73
|
+
assets={assets}
|
|
74
|
+
onUpdateSiteMetadata={handleUpdateMetadata}
|
|
75
|
+
onAssociatedDomain={handleAssociate}
|
|
76
|
+
onError={handleError}
|
|
77
|
+
>
|
|
78
|
+
{/* Optional: custom trigger button */}
|
|
79
|
+
<Button>My Custom Publish Button</Button>
|
|
80
|
+
</PublishButton>
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Individual Components
|
|
84
|
+
|
|
85
|
+
You can also use components separately:
|
|
86
|
+
|
|
87
|
+
```tsx
|
|
88
|
+
import { PublishMenu, PublishModal, SuiNsModal } from '@cmdoss/walrus-site-builder-react'
|
|
89
|
+
|
|
90
|
+
// Use individually
|
|
91
|
+
<PublishMenu
|
|
92
|
+
siteId={siteId}
|
|
93
|
+
network="mainnet"
|
|
94
|
+
portalDomain="walrus.site"
|
|
95
|
+
portalHttps={true}
|
|
96
|
+
onPublishClick={handlePublishClick}
|
|
97
|
+
onDomainClick={handleDomainClick}
|
|
98
|
+
>
|
|
99
|
+
<button>Publish</button>
|
|
100
|
+
</PublishMenu>
|
|
101
|
+
|
|
102
|
+
<PublishModal
|
|
103
|
+
siteId={siteId}
|
|
104
|
+
clients={{ suiClient, queryClient }}
|
|
105
|
+
onDeploy={handleDeploy}
|
|
106
|
+
onSaveMetadata={handleSave}
|
|
107
|
+
/>
|
|
108
|
+
|
|
109
|
+
<SuiNsModal
|
|
110
|
+
siteId={siteId}
|
|
111
|
+
currentAccount={currentAccount}
|
|
112
|
+
portalDomain="walrus.site"
|
|
113
|
+
portalHttps={true}
|
|
114
|
+
clients={{ suiClient, queryClient }}
|
|
115
|
+
onAssociateDomain={handleAssociate}
|
|
116
|
+
/>
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
## Hooks
|
|
120
|
+
|
|
121
|
+
### useSitePublishing
|
|
122
|
+
|
|
123
|
+
Main hook for site publishing logic:
|
|
124
|
+
|
|
125
|
+
```tsx
|
|
126
|
+
import { useSitePublishing } from '@cmdoss/walrus-site-builder-react'
|
|
127
|
+
|
|
128
|
+
const publishing = useSitePublishing({
|
|
129
|
+
siteId: string | undefined,
|
|
130
|
+
clients: { suiClient: SuiClient, queryClient: QueryClient },
|
|
131
|
+
currentAccount: WalletAccount | null,
|
|
132
|
+
signAndExecuteTransaction: ISignAndExecuteTransaction,
|
|
133
|
+
portalDomain?: string,
|
|
134
|
+
portalHttps?: boolean,
|
|
135
|
+
assets: IAsset[],
|
|
136
|
+
onUpdateSiteMetadata?: (site: SiteMetadataUpdate) => Promise<SiteMetadata | undefined>,
|
|
137
|
+
onAssociatedDomain?: (nftId: string, siteId: string) => Promise<void>,
|
|
138
|
+
onError?: (msg: string) => void
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
// Access state
|
|
142
|
+
publishing.state.isDeployed
|
|
143
|
+
publishing.state.walrusSiteUrl
|
|
144
|
+
publishing.state.isWorking
|
|
145
|
+
publishing.state.deployStatus
|
|
146
|
+
publishing.state.deployStatusText
|
|
147
|
+
publishing.state.deployStepIndex
|
|
148
|
+
publishing.state.nsDomains
|
|
149
|
+
publishing.state.isLoadingNsDomains
|
|
150
|
+
publishing.state.associatedDomains
|
|
151
|
+
publishing.state.isEditingSiteMetadata
|
|
152
|
+
publishing.state.isSavingSiteMetadata
|
|
153
|
+
// ... more state
|
|
154
|
+
|
|
155
|
+
// Access actions
|
|
156
|
+
publishing.actions.handleRunDeploymentStep()
|
|
157
|
+
publishing.actions.handleSaveSiteMetadata()
|
|
158
|
+
publishing.actions.handleAssociateDomain(nftId, siteId)
|
|
159
|
+
publishing.actions.handleOpenPublishingDialog()
|
|
160
|
+
publishing.actions.handleOpenDomainDialog()
|
|
161
|
+
publishing.actions.handleCancelEditingSiteMetadata()
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Stores
|
|
165
|
+
|
|
166
|
+
Direct access to nanostores:
|
|
167
|
+
|
|
168
|
+
```tsx
|
|
169
|
+
import {
|
|
170
|
+
sitePublishingStore,
|
|
171
|
+
siteMetadataStore,
|
|
172
|
+
isDomainDialogOpen,
|
|
173
|
+
isAssigningDomain
|
|
174
|
+
} from '@cmdoss/walrus-site-builder-react'
|
|
175
|
+
|
|
176
|
+
// Read state
|
|
177
|
+
const isOpen = sitePublishingStore.isPublishDialogOpen.get()
|
|
178
|
+
|
|
179
|
+
// Update state
|
|
180
|
+
sitePublishingStore.isPublishDialogOpen.set(true)
|
|
181
|
+
|
|
182
|
+
// Subscribe to changes (in React)
|
|
183
|
+
import { useStore } from '@nanostores/react'
|
|
184
|
+
const isOpen = useStore(sitePublishingStore.isPublishDialogOpen)
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## UI Components
|
|
188
|
+
|
|
189
|
+
Base UI components with vanilla-extract styling:
|
|
190
|
+
|
|
191
|
+
```tsx
|
|
192
|
+
import { Button, Input, Label, Textarea, Banner, Stepper } from '@cmdoss/walrus-site-builder-react'
|
|
193
|
+
|
|
194
|
+
<Button variant="default" size="lg">Click me</Button>
|
|
195
|
+
<Button variant="outline">Outline</Button>
|
|
196
|
+
<Button variant="gradient">Gradient</Button>
|
|
197
|
+
|
|
198
|
+
<Label htmlFor="name">Name</Label>
|
|
199
|
+
<Input id="name" placeholder="Enter name" />
|
|
200
|
+
|
|
201
|
+
<Textarea rows={4} placeholder="Description" />
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
### Button Variants
|
|
205
|
+
|
|
206
|
+
- `default` - Primary button style
|
|
207
|
+
- `outline` - Outlined button
|
|
208
|
+
- `ghost` - Transparent button
|
|
209
|
+
- `destructive` - Danger/delete button
|
|
210
|
+
- `gradient` - Gradient button (blue to cyan)
|
|
211
|
+
|
|
212
|
+
### Button Sizes
|
|
213
|
+
|
|
214
|
+
- `sm` - Small (2rem height)
|
|
215
|
+
- `default` - Default (2.5rem height)
|
|
216
|
+
- `lg` - Large (3rem height)
|
|
217
|
+
- `icon` - Square icon button (2.5rem)
|
|
218
|
+
|
|
219
|
+
## Theme Customization
|
|
220
|
+
|
|
221
|
+
The package uses vanilla-extract with a ThemeProvider. The `PublishButton` component automatically wraps children with the ThemeProvider. You can customize themes by overriding CSS variables:
|
|
222
|
+
|
|
223
|
+
```css
|
|
224
|
+
:root, .light {
|
|
225
|
+
--colors-background: #ffffff;
|
|
226
|
+
--colors-foreground: #09090b;
|
|
227
|
+
--colors-muted: #f4f4f5;
|
|
228
|
+
--colors-mutedForeground: #71717a;
|
|
229
|
+
--colors-border: #e4e4e7;
|
|
230
|
+
--colors-primary: #18181b;
|
|
231
|
+
--colors-primaryForeground: #fafafa;
|
|
232
|
+
/* ... other variables */
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
.dark {
|
|
236
|
+
--colors-background: #09090b;
|
|
237
|
+
--colors-foreground: #fafafa;
|
|
238
|
+
/* ... other variables */
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## TypeScript Types
|
|
243
|
+
|
|
244
|
+
All components and hooks are fully typed:
|
|
245
|
+
|
|
246
|
+
```tsx
|
|
247
|
+
import type {
|
|
248
|
+
UseSitePublishingParams,
|
|
249
|
+
SiteMetadata,
|
|
250
|
+
SiteMetadataUpdate
|
|
251
|
+
} from '@cmdoss/walrus-site-builder-react'
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
## License
|
|
255
|
+
|
|
256
|
+
MIT
|