@getcortexlabs/create-mavis 0.1.0-rc.12.2 → 0.1.0-rc.14
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 +30 -9
- package/package.json +4 -2
- package/src/adapters.mjs +83 -0
- package/src/add-macos.mjs +386 -0
- package/src/add-target.mjs +1 -1
- package/src/capabilities.mjs +647 -0
- package/src/cli.mjs +129 -16
- package/src/doctor.mjs +159 -36
- package/src/macos-capabilities.generated.mjs +4190 -0
- package/src/macos.mjs +343 -58
- package/src/migrate-directory.mjs +121 -0
- package/src/package-manager.mjs +12 -4
- package/src/portability.mjs +110 -6
- package/src/presets.mjs +15 -108
- package/src/scaffold.mjs +32 -5
- package/src/ui.mjs +124 -82
- package/templates/directory/host/directory-storage.ts +78 -0
- package/templates/directory/macos/DirectoryStorage.swift +68 -0
- package/templates/directory/mobile/src/app.ts +11 -8
- package/templates/directory/nuxt/app/plugins/mavis.ts +11 -8
- package/templates/directory/shared/Edit.vue +8 -5
- package/templates/directory/shared/directory-store.ts +42 -46
- package/templates/directory/vite/src/main.ts +11 -8
- package/templates/macos/examples/tasks/shared/TaskDetail.lite.tsx +57 -0
- package/templates/macos/examples/tasks/shared/TaskRow.lite.tsx +33 -0
- package/templates/macos/examples/tasks/shared/Tasks.lite.tsx +251 -0
- package/templates/macos/examples/tasks/shared/types.ts +10 -0
- package/templates/macos/mobile/src/App.vue +14 -0
- package/templates/macos/mobile/src/app.ts +7 -0
- package/templates/macos/native/Package.swift +11 -1
- package/templates/macos/native/Sources/MavisDesktop/App.swift +27 -12
- package/templates/macos/native/Sources/MavisDesktop/Fonts/LICENSE +45 -0
- package/templates/macos/native/Sources/MavisDesktop/Fonts/lucide.ttf +0 -0
- package/templates/macos/root/tsconfig.json +14 -0
- package/templates/macos/scripts/generate.mjs +12 -16
- package/templates/macos/scripts/macos-manifest.mjs +33 -0
- package/templates/macos/scripts/macos.mjs +26 -19
- package/templates/macos/shared/Welcome.lite.tsx +8 -6
- package/templates/macos/{index.html → web/index.html} +2 -2
- package/templates/macos/web/src/main.js +212 -0
- package/templates/macos/web/src/mavis.js +2 -0
- package/templates/macos/web/{style.css → src/style.css} +3 -2
- package/templates/macos/web/vite.config.mjs +14 -0
- package/templates/migrations/directory-rc13.json +36 -0
- package/templates/mobile/src/mavis.ts +2 -82
- package/templates/mobile/webpack.config.js +4 -0
- package/templates/nuxt/app/mavis.ts +2 -84
- package/templates/vite/src/mavis.ts +2 -84
- package/templates/macos/scripts/portable.mjs +0 -395
- package/templates/macos/vite.config.mjs +0 -3
- package/templates/macos/web/main.js +0 -15
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import {
|
|
2
|
+
directorySeed,
|
|
3
|
+
validDirectoryEntries,
|
|
4
|
+
type DirectoryEntry,
|
|
5
|
+
type DirectorySnapshot,
|
|
6
|
+
type DirectoryStorage,
|
|
7
|
+
} from '../shared/directory-store'
|
|
8
|
+
|
|
9
|
+
export interface DirectoryPersistence {
|
|
10
|
+
read(): Promise<string | null>
|
|
11
|
+
write(value: string): Promise<void>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Host boundary: JSON and the write queue stay out of the shared screen/store. */
|
|
15
|
+
export function createDirectoryStorage(persistence: DirectoryPersistence): DirectoryStorage {
|
|
16
|
+
let entries = directorySeed.map((entry) => ({ ...entry }))
|
|
17
|
+
let revision = 0
|
|
18
|
+
let loadError = false
|
|
19
|
+
let restoring: Promise<void> | undefined
|
|
20
|
+
let writing = Promise.resolve()
|
|
21
|
+
const snapshot = (): DirectorySnapshot => ({
|
|
22
|
+
entries: entries.map((entry) => ({ ...entry })),
|
|
23
|
+
revision,
|
|
24
|
+
loadError,
|
|
25
|
+
})
|
|
26
|
+
const restore = () =>
|
|
27
|
+
(restoring ??= (async () => {
|
|
28
|
+
try {
|
|
29
|
+
const value = await persistence.read()
|
|
30
|
+
if (value === null) return
|
|
31
|
+
const parsed: unknown = JSON.parse(value)
|
|
32
|
+
if (
|
|
33
|
+
!Array.isArray(parsed) ||
|
|
34
|
+
!parsed.every(
|
|
35
|
+
(entry) =>
|
|
36
|
+
entry !== null &&
|
|
37
|
+
typeof entry === 'object' &&
|
|
38
|
+
typeof entry.id === 'string' &&
|
|
39
|
+
typeof entry.name === 'string' &&
|
|
40
|
+
typeof entry.city === 'string',
|
|
41
|
+
) ||
|
|
42
|
+
!validDirectoryEntries(parsed)
|
|
43
|
+
)
|
|
44
|
+
throw new Error('Invalid saved directory')
|
|
45
|
+
entries = (parsed as DirectoryEntry[]).map(({ id, name, city }) => ({ id, name, city }))
|
|
46
|
+
} catch {
|
|
47
|
+
loadError = true
|
|
48
|
+
}
|
|
49
|
+
})())
|
|
50
|
+
return {
|
|
51
|
+
async load() {
|
|
52
|
+
await restore()
|
|
53
|
+
return snapshot()
|
|
54
|
+
},
|
|
55
|
+
rename(id, name) {
|
|
56
|
+
const operation = writing
|
|
57
|
+
.catch(() => {})
|
|
58
|
+
.then(async () => {
|
|
59
|
+
await restore()
|
|
60
|
+
if (!name.trim() || !entries.some((entry) => entry.id === id))
|
|
61
|
+
throw new Error('Invalid entry')
|
|
62
|
+
const next = entries.map((entry) =>
|
|
63
|
+
entry.id === id ? { ...entry, name: name.trim() } : { ...entry },
|
|
64
|
+
)
|
|
65
|
+
await persistence.write(JSON.stringify(next))
|
|
66
|
+
entries = next
|
|
67
|
+
revision += 1
|
|
68
|
+
return snapshot()
|
|
69
|
+
})
|
|
70
|
+
// A failed write does not poison the queue or change the committed state.
|
|
71
|
+
writing = operation.then(
|
|
72
|
+
() => {},
|
|
73
|
+
() => {},
|
|
74
|
+
)
|
|
75
|
+
return operation
|
|
76
|
+
},
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
/// One instance per app. Uses the same JSON array and key as the Web and NativeScript hosts.
|
|
4
|
+
@MainActor final class UserDefaultsDirectoryStorage: DirectoryStorage {
|
|
5
|
+
private let defaults: UserDefaults
|
|
6
|
+
private let key: String
|
|
7
|
+
private var entries = DirectoryStoreModule.directorySeed
|
|
8
|
+
private var loaded = false
|
|
9
|
+
private var revision: Double = 0
|
|
10
|
+
private var loadError = false
|
|
11
|
+
|
|
12
|
+
init(defaults: UserDefaults = .standard, key: String = "mavis:directory") {
|
|
13
|
+
self.defaults = defaults
|
|
14
|
+
self.key = key
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
private func snapshot() -> DirectorySnapshot {
|
|
18
|
+
DirectorySnapshot(entries: entries, revision: revision, loadError: loadError)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
private func restore() {
|
|
22
|
+
guard !loaded else { return }
|
|
23
|
+
loaded = true
|
|
24
|
+
guard let text = defaults.string(forKey: key) else { return }
|
|
25
|
+
do {
|
|
26
|
+
guard let data = text.data(using: .utf8),
|
|
27
|
+
let values = try JSONSerialization.jsonObject(with: data) as? [[String: Any]]
|
|
28
|
+
else { throw MavisFailure(message: "Invalid saved directory") }
|
|
29
|
+
let decoded = try values.map { value -> DirectoryEntry in
|
|
30
|
+
guard let id = value["id"] as? String,
|
|
31
|
+
let name = value["name"] as? String,
|
|
32
|
+
let city = value["city"] as? String
|
|
33
|
+
else { throw MavisFailure(message: "Invalid saved directory") }
|
|
34
|
+
return DirectoryEntry(id: id, name: name, city: city)
|
|
35
|
+
}
|
|
36
|
+
guard DirectoryStoreModule.validDirectoryEntries(decoded)
|
|
37
|
+
else { throw MavisFailure(message: "Invalid saved directory") }
|
|
38
|
+
entries = decoded
|
|
39
|
+
} catch {
|
|
40
|
+
loadError = true
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
func load() async throws -> DirectorySnapshot {
|
|
45
|
+
restore()
|
|
46
|
+
return snapshot()
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
func rename(_ id: String, _ name: String) async throws -> DirectorySnapshot {
|
|
50
|
+
// This operation has no suspension: MainActor serializes restore/edit/write/commit.
|
|
51
|
+
restore()
|
|
52
|
+
let trimmed = mavisTrim(name)
|
|
53
|
+
guard !trimmed.isEmpty, entries.contains(where: { $0.id == id })
|
|
54
|
+
else { throw MavisFailure(message: "Invalid entry") }
|
|
55
|
+
let next = entries.map { entry in
|
|
56
|
+
DirectoryEntry(id: entry.id, name: entry.id == id ? trimmed : entry.name, city: entry.city)
|
|
57
|
+
}
|
|
58
|
+
let data = try JSONSerialization.data(withJSONObject: next.map {
|
|
59
|
+
["id": $0.id, "name": $0.name, "city": $0.city]
|
|
60
|
+
})
|
|
61
|
+
guard let text = String(data: data, encoding: .utf8)
|
|
62
|
+
else { throw MavisFailure(message: "Could not encode directory") }
|
|
63
|
+
defaults.set(text, forKey: key)
|
|
64
|
+
entries = next
|
|
65
|
+
revision += 1
|
|
66
|
+
return snapshot()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -6,16 +6,19 @@ import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-co
|
|
|
6
6
|
import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
|
|
7
7
|
import { routes } from '__MAVIS_SHARED__/routes'
|
|
8
8
|
import App from './App.vue'
|
|
9
|
+
import { createDirectoryStorage } from './directory-storage'
|
|
9
10
|
|
|
10
11
|
const router = createRouter({ routes })
|
|
11
|
-
const directory = createDirectory(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
12
|
+
const directory = createDirectory(
|
|
13
|
+
createDirectoryStorage({
|
|
14
|
+
async read() {
|
|
15
|
+
return ApplicationSettings.getString('mavis:directory', '') || null
|
|
16
|
+
},
|
|
17
|
+
async write(value) {
|
|
18
|
+
ApplicationSettings.setString('mavis:directory', value)
|
|
19
|
+
},
|
|
20
|
+
}),
|
|
21
|
+
)
|
|
19
22
|
createApp(App)
|
|
20
23
|
.use(router)
|
|
21
24
|
.use(
|
|
@@ -2,6 +2,7 @@ import { createMavisServices } from '@getcortexlabs/mavis-web/services'
|
|
|
2
2
|
import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-core'
|
|
3
3
|
import { useMavisTheme } from '@getcortexlabs/mavis-core/vue'
|
|
4
4
|
import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
|
|
5
|
+
import { createDirectoryStorage } from '../utils/directory-storage'
|
|
5
6
|
|
|
6
7
|
export default defineNuxtPlugin(({ vueApp, $router }) => {
|
|
7
8
|
const saved = useCookie<string>('appearance')
|
|
@@ -18,14 +19,16 @@ export default defineNuxtPlugin(({ vueApp, $router }) => {
|
|
|
18
19
|
)
|
|
19
20
|
const theme = vueApp.runWithContext(useMavisTheme)
|
|
20
21
|
// Each server request has its own store. Storage is accessed only after hydration.
|
|
21
|
-
const directory = createDirectory(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
22
|
+
const directory = createDirectory(
|
|
23
|
+
createDirectoryStorage({
|
|
24
|
+
async read() {
|
|
25
|
+
return localStorage.getItem('mavis:directory')
|
|
26
|
+
},
|
|
27
|
+
async write(value) {
|
|
28
|
+
localStorage.setItem('mavis:directory', value)
|
|
29
|
+
},
|
|
30
|
+
}),
|
|
31
|
+
)
|
|
29
32
|
vueApp.provide(directoryKey, directory)
|
|
30
33
|
onNuxtReady(() => {
|
|
31
34
|
theme.setAppearance(saved.value === 'dark' || saved.value === 'light' ? saved.value : 'system')
|
|
@@ -20,9 +20,12 @@ const dirty = ref(false),
|
|
|
20
20
|
saving = ref(false),
|
|
21
21
|
saved = ref(false),
|
|
22
22
|
error = ref('')
|
|
23
|
-
watch(
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
watch(
|
|
24
|
+
() => entry.value?.name ?? '',
|
|
25
|
+
(value) => {
|
|
26
|
+
if (!dirty.value) name.value = value
|
|
27
|
+
},
|
|
28
|
+
)
|
|
26
29
|
watch(
|
|
27
30
|
() => props.id,
|
|
28
31
|
() => {
|
|
@@ -38,8 +41,8 @@ function edit() {
|
|
|
38
41
|
}
|
|
39
42
|
async function save() {
|
|
40
43
|
if (saving.value || !name.value.trim()) return
|
|
41
|
-
const id = props.id
|
|
42
|
-
|
|
44
|
+
const id = props.id
|
|
45
|
+
const draft = name.value
|
|
43
46
|
saving.value = true
|
|
44
47
|
saved.value = false
|
|
45
48
|
error.value = ''
|
|
@@ -6,49 +6,55 @@ export interface DirectoryEntry {
|
|
|
6
6
|
city: string
|
|
7
7
|
}
|
|
8
8
|
export interface DirectoryStorage {
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
load(): Promise<DirectorySnapshot>
|
|
10
|
+
rename(id: string, name: string): Promise<DirectorySnapshot>
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
export interface DirectorySnapshot {
|
|
13
|
+
entries: DirectoryEntry[]
|
|
14
|
+
revision: number
|
|
15
|
+
loadError: boolean
|
|
16
|
+
}
|
|
17
|
+
export const directorySeed: DirectoryEntry[] = [
|
|
13
18
|
{ id: 'garden', name: 'Community garden', city: 'Porto' },
|
|
14
19
|
{ id: 'library', name: 'Open library', city: 'Recife' },
|
|
15
20
|
{ id: 'studio', name: 'Neighbourhood studio', city: 'Porto' },
|
|
16
21
|
]
|
|
17
22
|
|
|
23
|
+
/** JSON decoding belongs to the host; the accepted directory records are the same everywhere. */
|
|
24
|
+
export function validDirectoryEntries(entries: DirectoryEntry[]): boolean {
|
|
25
|
+
return (
|
|
26
|
+
entries.length === directorySeed.length &&
|
|
27
|
+
entries.every((entry) => entry.name.trim() !== '') &&
|
|
28
|
+
directorySeed.every(
|
|
29
|
+
(original) => entries.filter((entry) => entry.id === original.id).length === 1,
|
|
30
|
+
)
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
18
34
|
/** Create once per app/request. Storage is a host service, never a module singleton. */
|
|
19
35
|
export function createDirectory(storage: DirectoryStorage) {
|
|
20
|
-
const entries = ref(
|
|
36
|
+
const entries = ref<DirectoryEntry[]>(directorySeed.map((entry) => ({ ...entry })))
|
|
21
37
|
const query = ref('')
|
|
22
38
|
const storageError = ref('')
|
|
23
|
-
let
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
).length === 1,
|
|
43
|
-
)
|
|
44
|
-
)
|
|
45
|
-
throw new Error('Invalid saved directory')
|
|
46
|
-
entries.value = parsed.map(({ id, name, city }) => ({ id, name, city }))
|
|
47
|
-
} catch {
|
|
48
|
-
storageError.value =
|
|
49
|
-
'Saved entries could not be loaded. The sample entries are still available.'
|
|
50
|
-
}
|
|
51
|
-
})())
|
|
39
|
+
let revision = -1
|
|
40
|
+
function accept(snapshot: DirectorySnapshot) {
|
|
41
|
+
// A delayed load or save must not undo a newer confirmed write.
|
|
42
|
+
if (snapshot.revision < revision) return
|
|
43
|
+
revision = snapshot.revision
|
|
44
|
+
entries.value = snapshot.entries.map((entry) => ({ ...entry }))
|
|
45
|
+
if (snapshot.loadError)
|
|
46
|
+
storageError.value =
|
|
47
|
+
'Saved entries could not be loaded. The sample entries are still available.'
|
|
48
|
+
}
|
|
49
|
+
async function restore() {
|
|
50
|
+
try {
|
|
51
|
+
const snapshot = await storage.load()
|
|
52
|
+
accept(snapshot)
|
|
53
|
+
} catch {
|
|
54
|
+
storageError.value =
|
|
55
|
+
'Saved entries could not be loaded. The sample entries are still available.'
|
|
56
|
+
}
|
|
57
|
+
}
|
|
52
58
|
return {
|
|
53
59
|
entries: readonly(entries),
|
|
54
60
|
query,
|
|
@@ -57,19 +63,9 @@ export function createDirectory(storage: DirectoryStorage) {
|
|
|
57
63
|
async save(id: string, name: string) {
|
|
58
64
|
if (!name.trim() || !entries.value.some((entry) => entry.id === id))
|
|
59
65
|
throw new Error('Invalid entry')
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
await restore()
|
|
64
|
-
const next = entries.value.map((entry) =>
|
|
65
|
-
entry.id === id ? { ...entry, name: name.trim() } : { ...entry },
|
|
66
|
-
)
|
|
67
|
-
// Commit state only after the host confirms persistence. A rejected write preserves the draft.
|
|
68
|
-
await storage.write(JSON.stringify(next))
|
|
69
|
-
entries.value = next
|
|
70
|
-
})
|
|
71
|
-
writing = pending
|
|
72
|
-
await pending
|
|
66
|
+
// The host performs an atomic edit against its latest persisted value, not a stale snapshot.
|
|
67
|
+
const snapshot = await storage.rename(id, name.trim())
|
|
68
|
+
accept(snapshot)
|
|
73
69
|
},
|
|
74
70
|
}
|
|
75
71
|
}
|
|
@@ -5,18 +5,21 @@ import { createRouterNavigation, mavis, midnight } from '@getcortexlabs/mavis-co
|
|
|
5
5
|
import { createDirectory, directoryKey } from '__MAVIS_SHARED__/directory-store'
|
|
6
6
|
import { routes } from '__MAVIS_SHARED__/routes'
|
|
7
7
|
import App from './App.vue'
|
|
8
|
+
import { createDirectoryStorage } from './directory-storage'
|
|
8
9
|
import '@getcortexlabs/mavis-web/style.css'
|
|
9
10
|
import './style.css'
|
|
10
11
|
|
|
11
12
|
const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes })
|
|
12
|
-
const directory = createDirectory(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
13
|
+
const directory = createDirectory(
|
|
14
|
+
createDirectoryStorage({
|
|
15
|
+
async read() {
|
|
16
|
+
return localStorage.getItem('mavis:directory')
|
|
17
|
+
},
|
|
18
|
+
async write(value) {
|
|
19
|
+
localStorage.setItem('mavis:directory', value)
|
|
20
|
+
},
|
|
21
|
+
}),
|
|
22
|
+
)
|
|
20
23
|
const app = createApp(App)
|
|
21
24
|
.use(router)
|
|
22
25
|
.use(
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { PriorityOption, Task } from './types'
|
|
2
|
+
|
|
3
|
+
// The selected task. Every edit goes straight to the list, so the row updates while you type.
|
|
4
|
+
export default function TaskDetail(props: {
|
|
5
|
+
task: Task
|
|
6
|
+
priorities: PriorityOption[]
|
|
7
|
+
canMoveUp: boolean
|
|
8
|
+
canMoveDown: boolean
|
|
9
|
+
onToggle: () => void
|
|
10
|
+
onRename: (title: string) => void
|
|
11
|
+
onNotes: (notes: string) => void
|
|
12
|
+
onPriority: (priority: string) => void
|
|
13
|
+
onMove: (by: number) => void
|
|
14
|
+
}) {
|
|
15
|
+
return (
|
|
16
|
+
<MCard gap="md">
|
|
17
|
+
<MText variant="overline" tone="muted">
|
|
18
|
+
SELECTED TASK
|
|
19
|
+
</MText>
|
|
20
|
+
<MCheckbox label="Done" checked={props.task.done} onChange={() => props.onToggle()} />
|
|
21
|
+
<MInput
|
|
22
|
+
label="Task title"
|
|
23
|
+
value={props.task.title}
|
|
24
|
+
onChange={(value) => props.onRename(value)}
|
|
25
|
+
maxLength={60}
|
|
26
|
+
/>
|
|
27
|
+
<MInput
|
|
28
|
+
label="Task notes"
|
|
29
|
+
multiline
|
|
30
|
+
rows={3}
|
|
31
|
+
value={props.task.notes}
|
|
32
|
+
onChange={(value) => props.onNotes(value)}
|
|
33
|
+
placeholder="Anything worth remembering"
|
|
34
|
+
/>
|
|
35
|
+
<MSelect
|
|
36
|
+
label="Task priority"
|
|
37
|
+
value={props.task.priority}
|
|
38
|
+
options={props.priorities}
|
|
39
|
+
onChange={(value) => props.onPriority(value)}
|
|
40
|
+
/>
|
|
41
|
+
<MRow gap="sm">
|
|
42
|
+
<MButton
|
|
43
|
+
text="Move up"
|
|
44
|
+
variant="secondary"
|
|
45
|
+
disabled={!props.canMoveUp}
|
|
46
|
+
onClick={() => props.onMove(-1)}
|
|
47
|
+
/>
|
|
48
|
+
<MButton
|
|
49
|
+
text="Move down"
|
|
50
|
+
variant="secondary"
|
|
51
|
+
disabled={!props.canMoveDown}
|
|
52
|
+
onClick={() => props.onMove(1)}
|
|
53
|
+
/>
|
|
54
|
+
</MRow>
|
|
55
|
+
</MCard>
|
|
56
|
+
)
|
|
57
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Show } from '@builder.io/mitosis'
|
|
2
|
+
import type { Task } from './types'
|
|
3
|
+
|
|
4
|
+
// One task in the list. The whole card is a button; its label is what assistive technology reads.
|
|
5
|
+
export default function TaskRow(props: {
|
|
6
|
+
task: Task
|
|
7
|
+
selected: boolean
|
|
8
|
+
onSelect: (id: string) => void
|
|
9
|
+
}) {
|
|
10
|
+
return (
|
|
11
|
+
<MCard
|
|
12
|
+
gap="xs"
|
|
13
|
+
padding="md"
|
|
14
|
+
tone={props.selected ? 'primarySoft' : 'surface'}
|
|
15
|
+
label={`${props.task.title}, ${props.task.done ? 'done' : 'open'}, ${props.task.priority} priority${props.selected ? ', selected' : ''}`}
|
|
16
|
+
onClick={() => props.onSelect(props.task.id)}
|
|
17
|
+
>
|
|
18
|
+
<MText tone={props.task.done ? 'muted' : 'text'}>{props.task.title}</MText>
|
|
19
|
+
<MText variant="caption" tone="muted">
|
|
20
|
+
{props.task.priority === 'high'
|
|
21
|
+
? 'High priority'
|
|
22
|
+
: props.task.priority === 'low'
|
|
23
|
+
? 'Low priority'
|
|
24
|
+
: 'Normal priority'}
|
|
25
|
+
</MText>
|
|
26
|
+
<Show when={props.task.done} animate>
|
|
27
|
+
<MText variant="caption" tone="success">
|
|
28
|
+
Done
|
|
29
|
+
</MText>
|
|
30
|
+
</Show>
|
|
31
|
+
</MCard>
|
|
32
|
+
)
|
|
33
|
+
}
|