@monimesl/dot-cli 0.1.0-alpha.4 → 0.1.0-alpha.40
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 +84 -29
- package/dist/cli.js +686 -319
- package/dist/cli.js.map +1 -1
- package/dist/{server-DFOUQnLA.js → server-DMnWDdJ6.js} +582 -537
- package/dist/server-DMnWDdJ6.js.map +1 -0
- package/dist/templates/showcase/.env +1 -1
- package/dist/templates/showcase/dot.ts +53 -14
- package/dist/templates/showcase/pages/basics/bars/controller.ts +47 -0
- package/dist/templates/showcase/pages/basics/bars/state.ts +7 -0
- package/dist/templates/showcase/pages/basics/bars/view.dml +36 -0
- package/dist/templates/showcase/pages/basics/bindings/controller.ts +15 -0
- package/dist/templates/showcase/pages/basics/bindings/state.ts +14 -0
- package/dist/templates/showcase/pages/basics/bindings/view.dml +41 -0
- package/dist/templates/showcase/pages/basics/colors/controller.ts +112 -0
- package/dist/templates/showcase/pages/basics/colors/palette.ts +52 -0
- package/dist/templates/showcase/pages/basics/colors/state.ts +17 -0
- package/dist/templates/showcase/pages/basics/colors/view.dml +142 -0
- package/dist/templates/showcase/pages/basics/concert/controller.ts +16 -0
- package/dist/templates/showcase/pages/basics/concert/state.ts +7 -0
- package/dist/templates/showcase/pages/basics/concert/view.dml +20 -0
- package/dist/templates/showcase/pages/basics/control-flow/controller.ts +18 -0
- package/dist/templates/showcase/pages/basics/control-flow/state.ts +16 -0
- package/dist/templates/showcase/pages/basics/control-flow/view.dml +55 -0
- package/dist/templates/showcase/pages/basics/events/controller.ts +43 -0
- package/dist/templates/showcase/pages/basics/events/state.ts +11 -0
- package/dist/templates/showcase/pages/basics/events/view.dml +51 -0
- package/dist/templates/showcase/pages/basics/hooks/controller.ts +43 -0
- package/dist/templates/showcase/pages/basics/hooks/state.ts +10 -0
- package/dist/templates/showcase/pages/basics/hooks/view.dml +37 -0
- package/dist/templates/showcase/pages/basics/navigation/controller.ts +41 -0
- package/dist/templates/showcase/pages/basics/navigation/state.ts +11 -0
- package/dist/templates/showcase/pages/basics/navigation/view.dml +48 -0
- package/dist/templates/showcase/pages/basics/pick-genre/controller.ts +18 -0
- package/dist/templates/showcase/pages/basics/pick-genre/state.ts +3 -0
- package/dist/templates/showcase/pages/basics/pick-genre/view.dml +10 -0
- package/dist/templates/showcase/pages/basics/share/concerts.ts +31 -0
- package/dist/templates/showcase/pages/basics/share/controller.ts +12 -0
- package/dist/templates/showcase/pages/basics/share/state.ts +5 -0
- package/dist/templates/showcase/pages/basics/share/view.dml +21 -0
- package/dist/templates/showcase/pages/{state → basics/state}/controller.ts +1 -0
- package/dist/templates/showcase/pages/{state → basics/state}/state.ts +1 -1
- package/dist/templates/showcase/pages/basics/state/view.dml +46 -0
- package/dist/templates/showcase/pages/components/carousel/controller.ts +41 -0
- package/dist/templates/showcase/pages/components/carousel/state.ts +77 -0
- package/dist/templates/showcase/pages/components/carousel/view.dml +42 -0
- package/dist/templates/showcase/pages/components/feedback/controller.ts +32 -0
- package/dist/templates/showcase/pages/components/feedback/state.ts +41 -0
- package/dist/templates/showcase/pages/components/feedback/view.dml +116 -0
- package/dist/templates/showcase/pages/components/forms/controller.ts +72 -0
- package/dist/templates/showcase/pages/components/forms/state.ts +37 -0
- package/dist/templates/showcase/pages/components/forms/view.dml +97 -0
- package/dist/templates/showcase/pages/components/icons/controller.ts +15 -0
- package/dist/templates/showcase/pages/components/icons/state.ts +75 -0
- package/dist/templates/showcase/pages/components/icons/view.dml +36 -0
- package/dist/templates/showcase/pages/components/images/controller.ts +44 -0
- package/dist/templates/showcase/pages/{images → components/images}/state.ts +3 -0
- package/dist/templates/showcase/pages/components/images/view.dml +83 -0
- package/dist/templates/showcase/pages/components/layout/controller.ts +61 -0
- package/dist/templates/showcase/pages/components/layout/state.ts +34 -0
- package/dist/templates/showcase/pages/components/layout/view.dml +143 -0
- package/dist/templates/showcase/pages/components/lists/controller.ts +18 -0
- package/dist/templates/showcase/pages/components/lists/state.ts +130 -0
- package/dist/templates/showcase/pages/components/lists/view.dml +88 -0
- package/dist/templates/showcase/pages/components/money/controller.ts +45 -0
- package/dist/templates/showcase/pages/{payments → components/money}/state.ts +3 -0
- package/dist/templates/showcase/pages/components/money/view.dml +54 -0
- package/dist/templates/showcase/pages/components/reading/controller.ts +6 -0
- package/dist/templates/showcase/pages/components/reading/state.ts +23 -0
- package/dist/templates/showcase/pages/components/reading/view.dml +42 -0
- package/dist/templates/showcase/pages/components/sheets/controller.ts +36 -0
- package/dist/templates/showcase/pages/components/sheets/state.ts +26 -0
- package/dist/templates/showcase/pages/components/sheets/view.dml +38 -0
- package/dist/templates/showcase/pages/components/styles/controller.ts +6 -0
- package/dist/templates/showcase/pages/components/styles/state.ts +3 -0
- package/dist/templates/showcase/pages/components/styles/view.dml +101 -0
- package/dist/templates/showcase/pages/components/tabs/controller.ts +41 -0
- package/dist/templates/showcase/pages/components/tabs/state.ts +127 -0
- package/dist/templates/showcase/pages/components/tabs/view.dml +57 -0
- package/dist/templates/showcase/pages/components/text/controller.ts +10 -0
- package/dist/templates/showcase/pages/components/text/state.ts +3 -0
- package/dist/templates/showcase/pages/components/text/view.dml +95 -0
- package/dist/templates/showcase/pages/dash/account/controller.ts +32 -0
- package/dist/templates/showcase/pages/dash/account/state.ts +9 -0
- package/dist/templates/showcase/pages/dash/account/view.dml +33 -0
- package/dist/templates/showcase/pages/dash/cache/controller.ts +50 -0
- package/dist/templates/showcase/pages/dash/cache/state.ts +17 -0
- package/dist/templates/showcase/pages/dash/cache/view.dml +48 -0
- package/dist/templates/showcase/pages/dash/calls/controller.ts +67 -0
- package/dist/templates/showcase/pages/dash/calls/state.ts +9 -0
- package/dist/templates/showcase/pages/dash/calls/view.dml +69 -0
- package/dist/templates/showcase/pages/dash/contacts/controller.ts +30 -0
- package/dist/templates/showcase/pages/dash/contacts/state.ts +6 -0
- package/dist/templates/showcase/pages/dash/contacts/view.dml +33 -0
- package/dist/templates/showcase/pages/dash/crypto/controller.ts +38 -0
- package/dist/templates/showcase/pages/dash/crypto/state.ts +10 -0
- package/dist/templates/showcase/pages/dash/crypto/view.dml +48 -0
- package/dist/templates/showcase/pages/dash/files/controller.ts +71 -0
- package/dist/templates/showcase/pages/dash/files/state.ts +23 -0
- package/dist/templates/showcase/pages/dash/files/view.dml +78 -0
- package/dist/templates/showcase/pages/dash/media/controller.ts +65 -0
- package/dist/templates/showcase/pages/dash/media/state.ts +12 -0
- package/dist/templates/showcase/pages/dash/media/view.dml +53 -0
- package/dist/templates/showcase/pages/dash/network/controller.ts +215 -0
- package/dist/templates/showcase/pages/dash/network/state.ts +35 -0
- package/dist/templates/showcase/pages/dash/network/view.dml +108 -0
- package/dist/templates/showcase/pages/dash/payments/controller.ts +83 -0
- package/dist/templates/showcase/pages/dash/payments/state.ts +10 -0
- package/dist/templates/showcase/pages/dash/payments/view.dml +38 -0
- package/dist/templates/showcase/pages/dash/secrets/controller.ts +44 -0
- package/dist/templates/showcase/pages/dash/secrets/state.ts +5 -0
- package/dist/templates/showcase/pages/dash/secrets/view.dml +26 -0
- package/dist/templates/showcase/pages/dash/system/controller.ts +89 -0
- package/dist/templates/showcase/pages/dash/system/state.ts +13 -0
- package/dist/templates/showcase/pages/dash/system/view.dml +96 -0
- package/dist/templates/showcase/pages/dash/ui/controller.ts +70 -0
- package/dist/templates/showcase/pages/dash/ui/state.ts +8 -0
- package/dist/templates/showcase/pages/dash/ui/view.dml +31 -0
- package/dist/templates/showcase/pages/index/controller.ts +1 -1
- package/dist/templates/showcase/pages/index/state.ts +181 -54
- package/dist/templates/showcase/pages/index/view.dml +8 -5
- package/dist/templates/showcase/statics/logo.png +0 -0
- package/package.json +6 -6
- package/dist/server-DFOUQnLA.js.map +0 -1
- package/dist/templates/showcase/pages/carousel/controller.ts +0 -10
- package/dist/templates/showcase/pages/carousel/state.ts +0 -40
- package/dist/templates/showcase/pages/carousel/view.dml +0 -37
- package/dist/templates/showcase/pages/device/controller.ts +0 -70
- package/dist/templates/showcase/pages/device/state.ts +0 -7
- package/dist/templates/showcase/pages/device/view.dml +0 -44
- package/dist/templates/showcase/pages/feedback/controller.ts +0 -16
- package/dist/templates/showcase/pages/feedback/state.ts +0 -7
- package/dist/templates/showcase/pages/feedback/view.dml +0 -87
- package/dist/templates/showcase/pages/files/controller.ts +0 -47
- package/dist/templates/showcase/pages/files/state.ts +0 -11
- package/dist/templates/showcase/pages/files/view.dml +0 -35
- package/dist/templates/showcase/pages/filters/controller.ts +0 -28
- package/dist/templates/showcase/pages/filters/state.ts +0 -72
- package/dist/templates/showcase/pages/filters/view.dml +0 -43
- package/dist/templates/showcase/pages/forms/controller.ts +0 -44
- package/dist/templates/showcase/pages/forms/state.ts +0 -15
- package/dist/templates/showcase/pages/forms/view.dml +0 -39
- package/dist/templates/showcase/pages/images/controller.ts +0 -15
- package/dist/templates/showcase/pages/images/view.dml +0 -38
- package/dist/templates/showcase/pages/layout/controller.ts +0 -26
- package/dist/templates/showcase/pages/layout/state.ts +0 -14
- package/dist/templates/showcase/pages/layout/view.dml +0 -80
- package/dist/templates/showcase/pages/lists/controller.ts +0 -36
- package/dist/templates/showcase/pages/lists/state.ts +0 -96
- package/dist/templates/showcase/pages/lists/view.dml +0 -59
- package/dist/templates/showcase/pages/navigation/controller.ts +0 -64
- package/dist/templates/showcase/pages/navigation/state.ts +0 -17
- package/dist/templates/showcase/pages/navigation/view.dml +0 -34
- package/dist/templates/showcase/pages/network/controller.ts +0 -107
- package/dist/templates/showcase/pages/network/state.ts +0 -15
- package/dist/templates/showcase/pages/network/view.dml +0 -56
- package/dist/templates/showcase/pages/payments/controller.ts +0 -42
- package/dist/templates/showcase/pages/payments/view.dml +0 -35
- package/dist/templates/showcase/pages/state/view.dml +0 -33
- package/dist/templates/showcase/pages/text/controller.ts +0 -10
- package/dist/templates/showcase/pages/text/state.ts +0 -7
- package/dist/templates/showcase/pages/text/view.dml +0 -49
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<View>
|
|
2
|
-
<Text variant="title">Forms</Text>
|
|
3
|
-
<Text>Each change reaches the controller, which keeps the value in state and checks it when the form is sent.</Text>
|
|
4
|
-
|
|
5
|
-
<View variant="card">
|
|
6
|
-
<Select label="Pay from" placeholder="Choose an account" value="{{ account }}" onChange="setAccount">
|
|
7
|
-
<Option value="savings" label="Savings · Le 1,250,000" />
|
|
8
|
-
<Option value="wallet" label="Mobile wallet · Le 84,500" />
|
|
9
|
-
<Option value="card" label="Debit card · Le 310,000" />
|
|
10
|
-
</Select>
|
|
11
|
-
<Input label="Name" placeholder="Ada Lovelace" value="{{ name }}" maxLength="40" onChange="setName" />
|
|
12
|
-
<Input label="Email" type="email" placeholder="ada@example.com" hint="For the receipt" value="{{ email }}" onChange="setEmail" />
|
|
13
|
-
<Input label="Phone" type="phone" placeholder="076 123456" value="{{ phone }}" error="{{ errors.phone }}" onChange="setPhone" />
|
|
14
|
-
<Input label="Amount" type="number" prefix="Le" placeholder="0" value="{{ amount }}" error="{{ errors.amount }}" onChange="setAmount" />
|
|
15
|
-
<TextArea label="Note" placeholder="What it's for" rows="3" maxLength="140" hint="{{ note.length }} of 140" value="{{ note }}" onChange="setNote" />
|
|
16
|
-
</View>
|
|
17
|
-
|
|
18
|
-
<View variant="card">
|
|
19
|
-
<RadioGroup label="How often" value="{{ plan }}" onChange="setPlan">
|
|
20
|
-
<Radio value="once" label="Just once" />
|
|
21
|
-
<Radio value="monthly" label="Every month" />
|
|
22
|
-
<Radio value="yearly" label="Every year" />
|
|
23
|
-
</RadioGroup>
|
|
24
|
-
<Divider />
|
|
25
|
-
<Switch label="Send me receipts" checked="{{ receipts }}" onChange="setReceipts" />
|
|
26
|
-
<Checkbox label="I agree to the terms" checked="{{ agreed }}" onChange="setAgreed" />
|
|
27
|
-
</View>
|
|
28
|
-
|
|
29
|
-
<If condition="{{ sent }}">
|
|
30
|
-
<Notice tone="success" title="Sent">{{ sent }}</Notice>
|
|
31
|
-
</If>
|
|
32
|
-
<If condition="{{ failure }}">
|
|
33
|
-
<Notice tone="danger" title="Not sent">{{ failure }}</Notice>
|
|
34
|
-
</If>
|
|
35
|
-
|
|
36
|
-
<Footer>
|
|
37
|
-
<Button onClick="send" loading="{{ sending }}" disabled="{{ !agreed }}">Send</Button>
|
|
38
|
-
</Footer>
|
|
39
|
-
</View>
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import state from './state';
|
|
2
|
-
|
|
3
|
-
export default definePage({
|
|
4
|
-
initialState: state,
|
|
5
|
-
mutations: {
|
|
6
|
-
grow: (state) => ({ size: Math.min(state.size + 16, 128) }),
|
|
7
|
-
shrink: (state) => ({ size: Math.max(state.size - 16, 16) }),
|
|
8
|
-
logoLoaded: (_state, event: DotEvent<{ width: number; height: number }>) => ({
|
|
9
|
-
loaded: `${event.detail.width} × ${event.detail.height}`,
|
|
10
|
-
}),
|
|
11
|
-
missingFailed: (_state, event: DotEvent<{ message: string }>) => ({
|
|
12
|
-
failure: event.detail.message,
|
|
13
|
-
}),
|
|
14
|
-
},
|
|
15
|
-
});
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
<View>
|
|
2
|
-
<Text variant="title">Images</Text>
|
|
3
|
-
<Text>Pictures in the dot's statics/ folder ship with it. The build checks each one.</Text>
|
|
4
|
-
|
|
5
|
-
<View variant="card" direction="row" align="end" gap="large">
|
|
6
|
-
<Image src="statics/logo.png" alt="Small logo" width="24" height="24" />
|
|
7
|
-
<Image src="statics/logo.png" alt="Medium logo" width="48" height="48" />
|
|
8
|
-
<Image src="statics/logo.png" alt="Large logo" width="96" height="96" />
|
|
9
|
-
</View>
|
|
10
|
-
|
|
11
|
-
<Text variant="caption" tone="muted">Shapes, and how a picture fills its box</Text>
|
|
12
|
-
<View variant="card" direction="row" align="center" gap="large">
|
|
13
|
-
<Image src="statics/logo.png" alt="Rounded" width="56" height="56" />
|
|
14
|
-
<Image src="statics/logo.png" alt="Square" width="56" height="56" shape="square" />
|
|
15
|
-
<Image src="statics/logo.png" alt="Circle" width="56" height="56" shape="circle" />
|
|
16
|
-
<Image src="statics/logo.png" alt="Contained" width="96" height="56" fit="contain" />
|
|
17
|
-
</View>
|
|
18
|
-
|
|
19
|
-
<Text variant="caption" tone="muted">Sizes can come from state</Text>
|
|
20
|
-
<View variant="card" gap="small">
|
|
21
|
-
<Image src="statics/logo.png" alt="Logo" width="{{ size }}" height="{{ size }}" onLoad="logoLoaded" />
|
|
22
|
-
<Text>{{ size }} × {{ size }} on screen, {{ loaded }} in the file</Text>
|
|
23
|
-
<View direction="row" gap="small">
|
|
24
|
-
<Button variant="secondary" onClick="shrink" disabled="{{ size <= 16 }}">Smaller</Button>
|
|
25
|
-
<Button variant="secondary" onClick="grow" disabled="{{ size >= 128 }}">Bigger</Button>
|
|
26
|
-
</View>
|
|
27
|
-
</View>
|
|
28
|
-
|
|
29
|
-
<Text variant="caption" tone="muted">An image that fails says why</Text>
|
|
30
|
-
<View variant="card">
|
|
31
|
-
<If condition="{{ failure }}">
|
|
32
|
-
<Text>{{ failure }}</Text>
|
|
33
|
-
</If>
|
|
34
|
-
<Else>
|
|
35
|
-
<Image src="{{ missing }}" alt="" width="48" height="48" onError="missingFailed" />
|
|
36
|
-
</Else>
|
|
37
|
-
</View>
|
|
38
|
-
</View>
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Align, Direction, Justify, Space } from './state';
|
|
2
|
-
import state from './state';
|
|
3
|
-
|
|
4
|
-
const DIRECTIONS: Direction[] = ['row', 'column'];
|
|
5
|
-
const JUSTIFIES: Justify[] = ['start', 'center', 'end', 'between'];
|
|
6
|
-
const ALIGNS: Align[] = ['stretch', 'start', 'center', 'end'];
|
|
7
|
-
const SPACES: Space[] = ['none', 'small', 'medium', 'large'];
|
|
8
|
-
|
|
9
|
-
export default definePage({
|
|
10
|
-
initialState: state,
|
|
11
|
-
mutations: {
|
|
12
|
-
nextDirection: (state) => ({ direction: after(DIRECTIONS, state.direction) }),
|
|
13
|
-
nextJustify: (state) => ({ justify: after(JUSTIFIES, state.justify) }),
|
|
14
|
-
nextAlign: (state) => ({ align: after(ALIGNS, state.align) }),
|
|
15
|
-
nextGap: (state) => ({ gap: after(SPACES, state.gap) }),
|
|
16
|
-
toggleWrap: (state) => ({ wrap: !state.wrap }),
|
|
17
|
-
openService: (_state, event: DotEvent<unknown, { name: string }>) => ({
|
|
18
|
-
service: event.data.name,
|
|
19
|
-
}),
|
|
20
|
-
},
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
function after<Value>(values: Value[], current: Value): Value {
|
|
24
|
-
const next = (values.indexOf(current) + 1) % values.length;
|
|
25
|
-
return values[next]!;
|
|
26
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export type Direction = 'row' | 'column';
|
|
2
|
-
export type Justify = 'start' | 'center' | 'end' | 'between';
|
|
3
|
-
export type Align = 'stretch' | 'start' | 'center' | 'end';
|
|
4
|
-
export type Space = 'none' | 'small' | 'medium' | 'large';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
direction: 'row' as Direction,
|
|
8
|
-
justify: 'start' as Justify,
|
|
9
|
-
align: 'center' as Align,
|
|
10
|
-
gap: 'small' as Space,
|
|
11
|
-
wrap: true,
|
|
12
|
-
// The service tapped in the grid.
|
|
13
|
-
service: '',
|
|
14
|
-
};
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
<View>
|
|
2
|
-
<Text variant="title">Layout</Text>
|
|
3
|
-
<Text>A View lays out what it holds in a column, or in a row. Change the one below.</Text>
|
|
4
|
-
|
|
5
|
-
<View variant="card" direction="{{ direction }}" justify="{{ justify }}" align="{{ align }}" gap="{{ gap }}" wrap="{{ wrap }}">
|
|
6
|
-
<Button variant="secondary">One</Button>
|
|
7
|
-
<Button variant="secondary">Two</Button>
|
|
8
|
-
<Text variant="title">Three</Text>
|
|
9
|
-
<Button variant="secondary">Four</Button>
|
|
10
|
-
<Text variant="caption" tone="muted">Five</Text>
|
|
11
|
-
</View>
|
|
12
|
-
|
|
13
|
-
<View gap="small">
|
|
14
|
-
<View direction="row" align="center">
|
|
15
|
-
<Text>direction="{{ direction }}"</Text>
|
|
16
|
-
<View grow />
|
|
17
|
-
<Button variant="secondary" onClick="nextDirection">Change</Button>
|
|
18
|
-
</View>
|
|
19
|
-
<View direction="row" align="center">
|
|
20
|
-
<Text>justify="{{ justify }}"</Text>
|
|
21
|
-
<View grow />
|
|
22
|
-
<Button variant="secondary" onClick="nextJustify">Change</Button>
|
|
23
|
-
</View>
|
|
24
|
-
<View direction="row" align="center">
|
|
25
|
-
<Text>align="{{ align }}"</Text>
|
|
26
|
-
<View grow />
|
|
27
|
-
<Button variant="secondary" onClick="nextAlign">Change</Button>
|
|
28
|
-
</View>
|
|
29
|
-
<View direction="row" align="center">
|
|
30
|
-
<Text>gap="{{ gap }}"</Text>
|
|
31
|
-
<View grow />
|
|
32
|
-
<Button variant="secondary" onClick="nextGap">Change</Button>
|
|
33
|
-
</View>
|
|
34
|
-
<View direction="row" align="center">
|
|
35
|
-
<Text>wrap="{{ wrap }}"</Text>
|
|
36
|
-
<View grow />
|
|
37
|
-
<Button variant="secondary" onClick="toggleWrap">Change</Button>
|
|
38
|
-
</View>
|
|
39
|
-
</View>
|
|
40
|
-
|
|
41
|
-
<Text variant="caption" tone="muted">grow takes the space that's left</Text>
|
|
42
|
-
<View direction="row" gap="small">
|
|
43
|
-
<View variant="card" grow>
|
|
44
|
-
<Text>grow</Text>
|
|
45
|
-
</View>
|
|
46
|
-
<View variant="card">
|
|
47
|
-
<Text>fixed</Text>
|
|
48
|
-
</View>
|
|
49
|
-
</View>
|
|
50
|
-
|
|
51
|
-
<Text variant="caption" tone="muted">padding, on every side or just one</Text>
|
|
52
|
-
<View direction="row" gap="small">
|
|
53
|
-
<View variant="card" padding="small">
|
|
54
|
-
<Text>small</Text>
|
|
55
|
-
</View>
|
|
56
|
-
<View variant="card" padding="large">
|
|
57
|
-
<Text>large</Text>
|
|
58
|
-
</View>
|
|
59
|
-
<View variant="card" padding="small" paddingStart="large">
|
|
60
|
-
<Text>start</Text>
|
|
61
|
-
</View>
|
|
62
|
-
</View>
|
|
63
|
-
|
|
64
|
-
<Text variant="caption" tone="muted">A Grid keeps equal columns, here of services to tap</Text>
|
|
65
|
-
<View variant="card" gap="medium">
|
|
66
|
-
<Grid columns="4">
|
|
67
|
-
<GridItem icon="send" label="Send" data-name="Send" onTap="openService" />
|
|
68
|
-
<GridItem icon="phone" label="Airtime" data-name="Airtime" onTap="openService" />
|
|
69
|
-
<GridItem icon="bolt" label="Electricity" badge="New" data-name="Electricity" onTap="openService" />
|
|
70
|
-
<GridItem icon="water" label="Water" data-name="Water" onTap="openService" />
|
|
71
|
-
<GridItem icon="qr-code" label="Scan to pay" data-name="Scan to pay" onTap="openService" />
|
|
72
|
-
<GridItem icon="wallet" label="Save" data-name="Save" onTap="openService" />
|
|
73
|
-
<GridItem icon="receipt" label="Receipts" data-name="Receipts" onTap="openService" />
|
|
74
|
-
<GridItem icon="more" label="More" data-name="More" onTap="openService" />
|
|
75
|
-
</Grid>
|
|
76
|
-
<If condition="{{ service }}">
|
|
77
|
-
<Text tone="muted">You tapped {{ service }}</Text>
|
|
78
|
-
</If>
|
|
79
|
-
</View>
|
|
80
|
-
</View>
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import state from './state';
|
|
2
|
-
|
|
3
|
-
export default definePage({
|
|
4
|
-
initialState: state,
|
|
5
|
-
mutations: {
|
|
6
|
-
choose: (state, event: DotEvent<unknown, { id: string }>) => {
|
|
7
|
-
const account = state.accounts.find((candidate) => candidate.id === event.data.id);
|
|
8
|
-
return { chosen: account?.name ?? '' };
|
|
9
|
-
},
|
|
10
|
-
openPayment: (state, event: DotEvent<unknown, { id: string }>) => ({
|
|
11
|
-
selected: state.payments.find((payment) => payment.id === event.data.id) ?? null,
|
|
12
|
-
}),
|
|
13
|
-
closeSheet: () => ({ selected: null }),
|
|
14
|
-
clearToast: () => ({ toast: '' }),
|
|
15
|
-
},
|
|
16
|
-
actions: {
|
|
17
|
-
async copyReference(state) {
|
|
18
|
-
if (!state.selected) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
await this.dash.system.copyText(state.selected.reference);
|
|
22
|
-
this.setState({ selected: null, toast: 'Reference copied' });
|
|
23
|
-
},
|
|
24
|
-
async shareReceipt(state) {
|
|
25
|
-
if (!state.selected) {
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
const { title, amount, status, reference } = state.selected;
|
|
29
|
-
this.setState({ selected: null });
|
|
30
|
-
await this.dash.system.share({
|
|
31
|
-
title: `${title} receipt`,
|
|
32
|
-
text: `${title}: ${amount}, ${status}. Reference ${reference}.`,
|
|
33
|
-
});
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
});
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
export interface Account {
|
|
2
|
-
id: string;
|
|
3
|
-
name: string;
|
|
4
|
-
number: string;
|
|
5
|
-
balance: string;
|
|
6
|
-
icon: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export interface Payment {
|
|
10
|
-
id: string;
|
|
11
|
-
title: string;
|
|
12
|
-
date: string;
|
|
13
|
-
amount: string;
|
|
14
|
-
status: string;
|
|
15
|
-
tone: string;
|
|
16
|
-
reference: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export default {
|
|
20
|
-
accounts: [
|
|
21
|
-
{
|
|
22
|
-
id: 'savings',
|
|
23
|
-
name: 'Savings',
|
|
24
|
-
number: '•••• 2041',
|
|
25
|
-
balance: 'Le 1,250,000',
|
|
26
|
-
icon: 'bank',
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: 'wallet',
|
|
30
|
-
name: 'Mobile wallet',
|
|
31
|
-
number: '076 •••• 21',
|
|
32
|
-
balance: 'Le 84,500',
|
|
33
|
-
icon: 'mobile',
|
|
34
|
-
},
|
|
35
|
-
{ id: 'card', name: 'Debit card', number: '•••• 7730', balance: 'Le 310,000', icon: 'card' },
|
|
36
|
-
] as Account[],
|
|
37
|
-
payments: [
|
|
38
|
-
{
|
|
39
|
-
id: 'p1',
|
|
40
|
-
title: 'Electricity',
|
|
41
|
-
date: 'Today',
|
|
42
|
-
amount: 'Le 50,000',
|
|
43
|
-
status: 'Paid',
|
|
44
|
-
tone: 'success',
|
|
45
|
-
reference: 'EDSA-58213',
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
id: 'p2',
|
|
49
|
-
title: 'Airtime',
|
|
50
|
-
date: 'Yesterday',
|
|
51
|
-
amount: 'Le 10,000',
|
|
52
|
-
status: 'Pending',
|
|
53
|
-
tone: 'warning',
|
|
54
|
-
reference: 'AIR-11907',
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
id: 'p3',
|
|
58
|
-
title: 'Water',
|
|
59
|
-
date: '12 September',
|
|
60
|
-
amount: 'Le 35,000',
|
|
61
|
-
status: 'Failed',
|
|
62
|
-
tone: 'danger',
|
|
63
|
-
reference: 'GVWC-40022',
|
|
64
|
-
},
|
|
65
|
-
] as Payment[],
|
|
66
|
-
chosen: '',
|
|
67
|
-
// The payment whose actions the sheet shows.
|
|
68
|
-
selected: null as Payment | null,
|
|
69
|
-
toast: '',
|
|
70
|
-
icons: [
|
|
71
|
-
'home',
|
|
72
|
-
'search',
|
|
73
|
-
'bell',
|
|
74
|
-
'user',
|
|
75
|
-
'settings',
|
|
76
|
-
'wallet',
|
|
77
|
-
'bank',
|
|
78
|
-
'card',
|
|
79
|
-
'cash',
|
|
80
|
-
'send',
|
|
81
|
-
'receipt',
|
|
82
|
-
'qr-code',
|
|
83
|
-
'bolt',
|
|
84
|
-
'water',
|
|
85
|
-
'phone',
|
|
86
|
-
'mail',
|
|
87
|
-
'calendar',
|
|
88
|
-
'clock',
|
|
89
|
-
'location',
|
|
90
|
-
'lock',
|
|
91
|
-
'share',
|
|
92
|
-
'copy',
|
|
93
|
-
'download',
|
|
94
|
-
'star',
|
|
95
|
-
],
|
|
96
|
-
};
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
<View>
|
|
2
|
-
<Text variant="title">Lists and icons</Text>
|
|
3
|
-
<Text>A List draws rows in a card. A row shows an icon or a picture, a value or anything at its end, and a chevron when it can be tapped.</Text>
|
|
4
|
-
|
|
5
|
-
<View gap="small">
|
|
6
|
-
<Text variant="caption" tone="muted">Rows know which one was tapped from their data- attributes</Text>
|
|
7
|
-
<List>
|
|
8
|
-
<For each="{{ accounts }}" item="account" key="id">
|
|
9
|
-
<ListItem icon="{{ account.icon }}" title="{{ account.name }}" subtitle="{{ account.number }}" value="{{ account.balance }}" data-id="{{ account.id }}" onTap="choose" />
|
|
10
|
-
</For>
|
|
11
|
-
</List>
|
|
12
|
-
<If condition="{{ chosen }}">
|
|
13
|
-
<Text>You chose {{ chosen }}</Text>
|
|
14
|
-
</If>
|
|
15
|
-
</View>
|
|
16
|
-
|
|
17
|
-
<View gap="small">
|
|
18
|
-
<Text variant="caption" tone="muted">A badge at the end of each row; tap one for its actions</Text>
|
|
19
|
-
<List>
|
|
20
|
-
<For each="{{ payments }}" item="payment" key="id">
|
|
21
|
-
<ListItem title="{{ payment.title }}" subtitle="{{ payment.date }} · {{ payment.amount }}" data-id="{{ payment.id }}" onTap="openPayment">
|
|
22
|
-
<Badge tone="{{ payment.tone }}">{{ payment.status }}</Badge>
|
|
23
|
-
</ListItem>
|
|
24
|
-
</For>
|
|
25
|
-
</List>
|
|
26
|
-
</View>
|
|
27
|
-
|
|
28
|
-
<View gap="small">
|
|
29
|
-
<Text variant="caption" tone="muted">Icons, by name, in any tone</Text>
|
|
30
|
-
<View variant="card" direction="row" wrap gap="large">
|
|
31
|
-
<For each="{{ icons }}" item="icon" key="*this">
|
|
32
|
-
<Icon name="{{ icon }}" />
|
|
33
|
-
</For>
|
|
34
|
-
</View>
|
|
35
|
-
<View variant="card" direction="row" wrap gap="large" align="center">
|
|
36
|
-
<Icon name="info" tone="info" size="small" />
|
|
37
|
-
<Icon name="success" tone="success" />
|
|
38
|
-
<Icon name="warning" tone="warning" size="large" />
|
|
39
|
-
<Icon name="error" tone="danger" size="large" />
|
|
40
|
-
<Icon name="star" tone="muted" />
|
|
41
|
-
</View>
|
|
42
|
-
</View>
|
|
43
|
-
|
|
44
|
-
<View gap="small">
|
|
45
|
-
<Text variant="caption" tone="muted">A divider between things</Text>
|
|
46
|
-
<View variant="card">
|
|
47
|
-
<Text>Above the line</Text>
|
|
48
|
-
<Divider />
|
|
49
|
-
<Text>Below the line</Text>
|
|
50
|
-
</View>
|
|
51
|
-
</View>
|
|
52
|
-
|
|
53
|
-
<Sheet open="{{ selected !== null }}" title="{{ selected.title }} · {{ selected.amount }}" onClose="closeSheet">
|
|
54
|
-
<Button variant="secondary" onClick="copyReference">Copy reference {{ selected.reference }}</Button>
|
|
55
|
-
<Button variant="secondary" onClick="shareReceipt">Share receipt</Button>
|
|
56
|
-
<Button onClick="closeSheet">Cancel</Button>
|
|
57
|
-
</Sheet>
|
|
58
|
-
<Toast message="{{ toast }}" tone="success" onHide="clearToast" />
|
|
59
|
-
</View>
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { HookRun } from './state';
|
|
2
|
-
import state from './state';
|
|
3
|
-
|
|
4
|
-
export default definePage({
|
|
5
|
-
initialState: state,
|
|
6
|
-
// What Dash's navigation bar shows until the page changes it.
|
|
7
|
-
configs: { navigationBar: { title: 'Navigation' } },
|
|
8
|
-
hooks: {
|
|
9
|
-
// Options come from the page that opened this one, as strings.
|
|
10
|
-
onLoad(options) {
|
|
11
|
-
const depth = Number(options.depth ?? '1') + 1;
|
|
12
|
-
const from = options.trail ?? 'Home';
|
|
13
|
-
this.setState({ depth, from, trail: `${from} › ${depth}` });
|
|
14
|
-
this.setNavigationBar({ title: `Page ${depth}` });
|
|
15
|
-
this.setState((current) => ({ hooks: ran(current.hooks, 'onLoad') }));
|
|
16
|
-
},
|
|
17
|
-
onShow() {
|
|
18
|
-
this.setState((current) => ({ hooks: ran(current.hooks, 'onShow') }));
|
|
19
|
-
},
|
|
20
|
-
onHide() {
|
|
21
|
-
this.setState((current) => ({ hooks: ran(current.hooks, 'onHide') }));
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
actions: {
|
|
25
|
-
openAnother(state) {
|
|
26
|
-
this.navigation.push('navigation', { depth: String(state.depth), trail: state.trail });
|
|
27
|
-
},
|
|
28
|
-
replaceThis(state) {
|
|
29
|
-
this.navigation.replace('navigation', { depth: String(state.depth - 1), trail: state.from });
|
|
30
|
-
},
|
|
31
|
-
back() {
|
|
32
|
-
this.navigation.back();
|
|
33
|
-
},
|
|
34
|
-
backTwo() {
|
|
35
|
-
this.navigation.back(2);
|
|
36
|
-
},
|
|
37
|
-
home() {
|
|
38
|
-
this.navigation.reset('index');
|
|
39
|
-
},
|
|
40
|
-
toggleColors(state) {
|
|
41
|
-
const colored = !state.colored;
|
|
42
|
-
// Undefined puts Dash's own colors back.
|
|
43
|
-
this.setNavigationBar({
|
|
44
|
-
backgroundColor: colored ? '#1A73E8' : undefined,
|
|
45
|
-
textColor: colored ? '#FFFFFF' : undefined,
|
|
46
|
-
});
|
|
47
|
-
this.setState({ colored });
|
|
48
|
-
},
|
|
49
|
-
toggleNavigationBar(state) {
|
|
50
|
-
const navigationBarHidden = !state.navigationBarHidden;
|
|
51
|
-
this.setNavigationBar({ hidden: navigationBarHidden });
|
|
52
|
-
this.setState({ navigationBarHidden });
|
|
53
|
-
},
|
|
54
|
-
toggleTabBar(state) {
|
|
55
|
-
const tabBarHidden = !state.tabBarHidden;
|
|
56
|
-
this.setTabBar({ hidden: tabBarHidden });
|
|
57
|
-
this.setState({ tabBarHidden });
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
function ran(hooks: readonly HookRun[], hook: string): HookRun[] {
|
|
63
|
-
return [...hooks, { id: hooks.length + 1, hook }];
|
|
64
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export interface HookRun {
|
|
2
|
-
id: number;
|
|
3
|
-
hook: string;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
depth: 1,
|
|
8
|
-
maxDepth: 8,
|
|
9
|
-
// The trail of the page that opened this one.
|
|
10
|
-
from: '',
|
|
11
|
-
trail: '',
|
|
12
|
-
hooks: [] as HookRun[],
|
|
13
|
-
// What this page set in Dash's bars.
|
|
14
|
-
colored: false,
|
|
15
|
-
navigationBarHidden: false,
|
|
16
|
-
tabBarHidden: false,
|
|
17
|
-
};
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<View>
|
|
2
|
-
<Text variant="caption" tone="muted">{{ trail }}</Text>
|
|
3
|
-
<Text variant="title">Navigation and hooks</Text>
|
|
4
|
-
<Text>Each page opens on top of the one before it; back returns to the one below. A dot has room for {{ maxDepth }} pages at once.</Text>
|
|
5
|
-
|
|
6
|
-
<View variant="card" gap="small">
|
|
7
|
-
<Text>This is page {{ depth }} of {{ maxDepth }}</Text>
|
|
8
|
-
<View direction="row" wrap gap="small">
|
|
9
|
-
<Button onClick="openAnother" disabled="{{ depth >= maxDepth }}">Open another</Button>
|
|
10
|
-
<Button variant="secondary" onClick="replaceThis">Replace this one</Button>
|
|
11
|
-
<Button variant="secondary" onClick="back">Back</Button>
|
|
12
|
-
<Button variant="secondary" onClick="backTwo" disabled="{{ depth < 3 }}">Back two</Button>
|
|
13
|
-
<Button variant="secondary" onClick="home">Start over</Button>
|
|
14
|
-
</View>
|
|
15
|
-
</View>
|
|
16
|
-
|
|
17
|
-
<Text variant="caption" tone="muted">Dash's bars, which each page sets: this one's title is its number</Text>
|
|
18
|
-
<View variant="card" gap="small">
|
|
19
|
-
<View direction="row" wrap gap="small">
|
|
20
|
-
<Button variant="secondary" onClick="toggleColors">{{ colored ? 'Plain bar' : 'Blue bar' }}</Button>
|
|
21
|
-
<Button variant="secondary" onClick="toggleNavigationBar">{{ navigationBarHidden ? 'Show the navigation bar' : 'Hide the navigation bar' }}</Button>
|
|
22
|
-
<Button variant="secondary" onClick="toggleTabBar">{{ tabBarHidden ? 'Show the tab bar' : 'Hide the tab bar' }}</Button>
|
|
23
|
-
</View>
|
|
24
|
-
<Text variant="caption" tone="muted">Going back to a page shows its bars again, and leaving the dot puts Dash's own back.</Text>
|
|
25
|
-
</View>
|
|
26
|
-
|
|
27
|
-
<Text variant="caption" tone="muted">The hooks this page ran, in order</Text>
|
|
28
|
-
<View variant="card" gap="small">
|
|
29
|
-
<For each="{{ hooks }}" item="run" key="id">
|
|
30
|
-
<Text>{{ run.id }}. {{ run.hook }}</Text>
|
|
31
|
-
</For>
|
|
32
|
-
<Text variant="caption" tone="muted">Open another page and come back: this one runs onHide, then onShow.</Text>
|
|
33
|
-
</View>
|
|
34
|
-
</View>
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import state from './state';
|
|
2
|
-
|
|
3
|
-
const PICTURE = 'pictures/octocat.png';
|
|
4
|
-
|
|
5
|
-
interface GitHubUser {
|
|
6
|
-
login: string;
|
|
7
|
-
name: string | null;
|
|
8
|
-
followers: number;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
interface Echo {
|
|
12
|
-
json: unknown;
|
|
13
|
-
files: Record<string, string>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default definePage({
|
|
17
|
-
initialState: state,
|
|
18
|
-
actions: {
|
|
19
|
-
async fetchZen() {
|
|
20
|
-
try {
|
|
21
|
-
const response = await this.dash.network.http.request({
|
|
22
|
-
url: 'https://api.github.com/zen',
|
|
23
|
-
});
|
|
24
|
-
this.setState({ zen: response.ok ? response.body : `GitHub answered ${response.status}` });
|
|
25
|
-
} catch (error) {
|
|
26
|
-
this.setState({ note: (error as Error).message });
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
async fetchProfile() {
|
|
30
|
-
try {
|
|
31
|
-
const { body } = await this.dash.network.http.request<GitHubUser>(
|
|
32
|
-
{ url: 'https://api.github.com/users/octocat', as: 'json' },
|
|
33
|
-
{ timeout: 10_000 },
|
|
34
|
-
);
|
|
35
|
-
this.setState({
|
|
36
|
-
profile: { login: body.login, name: body.name ?? body.login, followers: body.followers },
|
|
37
|
-
});
|
|
38
|
-
} catch (error) {
|
|
39
|
-
this.setState({ note: (error as Error).message });
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
async sendJson() {
|
|
43
|
-
try {
|
|
44
|
-
const { body } = await this.dash.network.http.request<Echo>({
|
|
45
|
-
url: 'https://httpbin.org/post',
|
|
46
|
-
method: 'POST',
|
|
47
|
-
body: { item: 'rice', count: 2 },
|
|
48
|
-
as: 'json',
|
|
49
|
-
});
|
|
50
|
-
this.setState({ echo: JSON.stringify(body.json) });
|
|
51
|
-
} catch (error) {
|
|
52
|
-
this.setState({ note: (error as Error).message });
|
|
53
|
-
}
|
|
54
|
-
},
|
|
55
|
-
async download() {
|
|
56
|
-
try {
|
|
57
|
-
const response = await this.dash.network.http.download({
|
|
58
|
-
url: 'https://avatars.githubusercontent.com/u/583231?s=128',
|
|
59
|
-
name: 'octocat.png',
|
|
60
|
-
});
|
|
61
|
-
if (response.ok) {
|
|
62
|
-
const { id, url, size } = response.file;
|
|
63
|
-
this.setState({ picture: { id, url, size }, kept: false });
|
|
64
|
-
} else {
|
|
65
|
-
this.setState({ note: `GitHub answered ${response.status}` });
|
|
66
|
-
}
|
|
67
|
-
} catch (error) {
|
|
68
|
-
this.setState({ note: (error as Error).message });
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
async upload(state) {
|
|
72
|
-
try {
|
|
73
|
-
const { body } = await this.dash.network.http.upload<Echo>({
|
|
74
|
-
url: 'https://httpbin.org/post',
|
|
75
|
-
fields: { title: 'Octocat' },
|
|
76
|
-
files: [{ field: 'picture', file: state.picture.id }],
|
|
77
|
-
as: 'json',
|
|
78
|
-
});
|
|
79
|
-
this.setState({ uploaded: Object.keys(body.files).join(', ') });
|
|
80
|
-
} catch (error) {
|
|
81
|
-
this.setState({ note: (error as Error).message });
|
|
82
|
-
}
|
|
83
|
-
},
|
|
84
|
-
async sharePicture(state) {
|
|
85
|
-
try {
|
|
86
|
-
await this.dash.system.share({ file: state.picture.id });
|
|
87
|
-
} catch (error) {
|
|
88
|
-
this.setState({ note: (error as Error).message });
|
|
89
|
-
}
|
|
90
|
-
},
|
|
91
|
-
async keep(state) {
|
|
92
|
-
try {
|
|
93
|
-
await this.dash.file.save(state.picture.id, PICTURE, { overwrite: true });
|
|
94
|
-
this.setState({ kept: true });
|
|
95
|
-
} catch (error) {
|
|
96
|
-
this.setState({ note: (error as Error).message });
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
async tryUnlistedHost() {
|
|
100
|
-
try {
|
|
101
|
-
await this.dash.network.http.request({ url: 'https://example.com' });
|
|
102
|
-
} catch (error) {
|
|
103
|
-
this.setState({ note: (error as Error).message });
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
});
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export interface Profile {
|
|
2
|
-
login: string;
|
|
3
|
-
name: string;
|
|
4
|
-
followers: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default {
|
|
8
|
-
zen: '',
|
|
9
|
-
profile: null as Profile | null,
|
|
10
|
-
echo: '',
|
|
11
|
-
picture: { id: '', url: '', size: 0 },
|
|
12
|
-
uploaded: '',
|
|
13
|
-
kept: false,
|
|
14
|
-
note: '',
|
|
15
|
-
};
|