@enbox/create-dapp 0.0.1 → 0.0.3
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 +8 -3
- package/bin/create-dapp.mjs +10 -7
- package/package.json +1 -2
- package/template/README.md +75 -25
- package/template/package.json +3 -3
- package/template/src/{App.tsx → app/App.tsx} +4 -4
- package/template/src/app/application.ts +7 -0
- package/template/src/app/runtime.ts +17 -0
- package/template/src/features/tasks/components/TaskBoard.tsx +163 -0
- package/template/src/features/tasks/components/tasks.css +15 -0
- package/template/src/features/tasks/protocol.ts +26 -0
- package/template/src/features/tasks/store.ts +31 -0
- package/template/src/main.tsx +7 -41
- package/template/package-lock.json +0 -3211
- package/template/src/application.ts +0 -10
- package/template/src/demo/Demo.tsx +0 -48
- package/template/src/demo/demo.css +0 -17
- package/template/src/demo/protocol.ts +0 -28
- /package/template/src/{ProfileCard.tsx → shared/components/ProfileCard.tsx} +0 -0
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { defineApplicationManifest } from '@enbox/react/config';
|
|
2
|
-
import type { CreateEnboxClientOptions } from '@enbox/react/config';
|
|
3
|
-
|
|
4
|
-
import app from './app.json' with { type: 'json' };
|
|
5
|
-
import { DemoProtocol } from './demo/protocol.js';
|
|
6
|
-
|
|
7
|
-
export const config = {
|
|
8
|
-
application: defineApplicationManifest({ protocols: [DemoProtocol] }),
|
|
9
|
-
wallet: { appName: app.name, applicationId: app.id },
|
|
10
|
-
} satisfies CreateEnboxClientOptions;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { useEnboxMutation, useRecords } from '@enbox/react';
|
|
2
|
-
|
|
3
|
-
import { CHOICES, DemoProtocol } from './protocol.js';
|
|
4
|
-
import type { ChoiceEmoji } from './protocol.js';
|
|
5
|
-
import './demo.css';
|
|
6
|
-
|
|
7
|
-
export function Demo({ disabled = false }: { disabled?: boolean }) {
|
|
8
|
-
const choices = useRecords(DemoProtocol, 'choice', { materialize: true, pagination: { limit: 1 } });
|
|
9
|
-
const save = useEnboxMutation((enbox, emoji: ChoiceEmoji) =>
|
|
10
|
-
enbox.using(DemoProtocol).records.set('choice', { data: { emoji } }));
|
|
11
|
-
const observed = CHOICES.find(({ emoji }) => emoji === choices.records[0]?.value.emoji);
|
|
12
|
-
|
|
13
|
-
return (
|
|
14
|
-
<section className="panel demo" aria-labelledby="demo-title">
|
|
15
|
-
<h2 id="demo-title">Your first record</h2>
|
|
16
|
-
<p>Choose a little hello. It’s encrypted for this app, separate from your public profile.</p>
|
|
17
|
-
<fieldset className="choice-options" disabled={disabled || save.isPending || choices.status !== 'ready'}>
|
|
18
|
-
<legend className="sr-only">Choose your hello</legend>
|
|
19
|
-
{CHOICES.map(({ emoji, label }) => (
|
|
20
|
-
<button type="button" className="choice-option" key={emoji}
|
|
21
|
-
aria-label={`Choose ${label.toLowerCase()}`}
|
|
22
|
-
aria-pressed={observed?.emoji === emoji}
|
|
23
|
-
onClick={() => { void save.run(emoji).catch(() => {}); }}>
|
|
24
|
-
<span className="choice-emoji" aria-hidden="true">{emoji}</span>
|
|
25
|
-
<span>{label}</span>
|
|
26
|
-
</button>
|
|
27
|
-
))}
|
|
28
|
-
</fieldset>
|
|
29
|
-
<p className="demo-status" role="status">
|
|
30
|
-
{save.isPending ? 'Saving your choice…'
|
|
31
|
-
: choices.status === 'loading' ? 'Reading your saved choice…'
|
|
32
|
-
: observed ? `Saved: ${observed.emoji} ${observed.label}` : 'Choose an emoji to get started.'}
|
|
33
|
-
</p>
|
|
34
|
-
{choices.status === 'error' && (
|
|
35
|
-
<div className="notice notice-error" role="alert">
|
|
36
|
-
<p>Couldn’t read your choice: {choices.error.message}</p>
|
|
37
|
-
<button type="button" className="button button-secondary" disabled={disabled || save.isPending}
|
|
38
|
-
onClick={() => { void choices.retry().catch(() => {}); }}>
|
|
39
|
-
Try again
|
|
40
|
-
</button>
|
|
41
|
-
</div>
|
|
42
|
-
)}
|
|
43
|
-
{save.error && (
|
|
44
|
-
<p className="error-detail" role="alert">Couldn’t save: {save.error.message} Choose an emoji again to retry.</p>
|
|
45
|
-
)}
|
|
46
|
-
</section>
|
|
47
|
-
);
|
|
48
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
.demo { padding: 30px; }
|
|
2
|
-
.demo > p { margin-top: 12px; color: var(--muted); font-size: .85rem; }
|
|
3
|
-
.choice-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 11px; padding: 0; margin: 24px 0 0; border: 0; min-width: 0; }
|
|
4
|
-
.choice-option { display: grid; place-items: center; gap: 10px; padding: 20px 8px 17px; border: 1px solid var(--border); border-radius: 13px; background: #fff; color: #59645a; font-size: .75rem; transition: background .15s, border-color .15s; }
|
|
5
|
-
.choice-option:hover:not(:disabled) { background: #f8faf5; border-color: #a6bea0; }
|
|
6
|
-
.choice-option[aria-pressed="true"] { background: #edf3e7; border-color: #709865; color: #315b46; }
|
|
7
|
-
.choice-emoji { font-size: 1.9rem; line-height: 1.3; }
|
|
8
|
-
.demo .demo-status { min-height: 20px; margin-top: 18px; font-size: .74rem; text-align: center; }
|
|
9
|
-
.demo > p[role="alert"] { color: #7d4533; }
|
|
10
|
-
.demo .notice { margin: 16px 0 0; }
|
|
11
|
-
@media (max-width: 600px) {
|
|
12
|
-
.demo { padding: 26px 20px; }
|
|
13
|
-
.choice-options { gap: 8px; }
|
|
14
|
-
}
|
|
15
|
-
@media (prefers-reduced-motion: reduce) {
|
|
16
|
-
.choice-option { transition: none; }
|
|
17
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { defineProtocol, recordCodecs } from '@enbox/react/config';
|
|
2
|
-
import type { RecordValidator } from '@enbox/react/config';
|
|
3
|
-
|
|
4
|
-
import app from '../app.json' with { type: 'json' };
|
|
5
|
-
|
|
6
|
-
export const CHOICES = [
|
|
7
|
-
{ emoji: '🌱', label: 'Grow' },
|
|
8
|
-
{ emoji: '✨', label: 'Spark' },
|
|
9
|
-
{ emoji: '🚀', label: 'Explore' },
|
|
10
|
-
] as const;
|
|
11
|
-
|
|
12
|
-
export type ChoiceEmoji = typeof CHOICES[number]['emoji'];
|
|
13
|
-
export type Choice = { emoji: ChoiceEmoji };
|
|
14
|
-
|
|
15
|
-
const validateChoice: RecordValidator = (value: unknown): boolean =>
|
|
16
|
-
value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
17
|
-
&& 'emoji' in value && CHOICES.some(({ emoji }) => emoji === value.emoji);
|
|
18
|
-
|
|
19
|
-
// Replace this example URI with one you own before publishing your app.
|
|
20
|
-
// Keep it stable after launch: it identifies the app's saved data and grants.
|
|
21
|
-
export const DemoProtocol = defineProtocol({
|
|
22
|
-
protocol: `https://example.com/${encodeURIComponent(app.id)}/demo/v1`,
|
|
23
|
-
published: false,
|
|
24
|
-
types: {
|
|
25
|
-
choice: { dataFormats: ['application/json'], encryptionRequired: true },
|
|
26
|
-
},
|
|
27
|
-
structure: { choice: { $recordLimit: { max: 1 } } },
|
|
28
|
-
} as const, { choice: recordCodecs.json<Choice>({ validator: validateChoice }) });
|
|
File without changes
|