Skip to content
This repository has been archived by the owner on Dec 12, 2024. It is now read-only.

Feat/todo #199

Merged
merged 78 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
5dcc4c8
feat:dwa-starter-vue-app-hello-word
Johnnyevans32 Oct 1, 2024
1a60fdb
feat:dwa-starter-vue-app-hello-word
Johnnyevans32 Oct 2, 2024
722e6ba
feat:dwa-starter-vue-app-hello-word
Johnnyevans32 Oct 2, 2024
eb70ad6
added tailwind css
Johnnyevans32 Oct 2, 2024
5db4bad
added tailwind css
Johnnyevans32 Oct 2, 2024
6b58d57
added tbd example json for ci integration
Johnnyevans32 Oct 2, 2024
53399f8
added tbd example json for ci integration
Johnnyevans32 Oct 2, 2024
8dc06e1
replaced npm with pnpm in ci/cd file
Johnnyevans32 Oct 2, 2024
bf9ade2
fix:pnpm build error in ci/cd
Johnnyevans32 Oct 2, 2024
323a6f8
fix:pnpm build error in ci/cd
Johnnyevans32 Oct 2, 2024
c855e5f
fix:pnpm build error in ci/cd
Johnnyevans32 Oct 2, 2024
61e7bf9
break the commands into seperate items
Johnnyevans32 Oct 2, 2024
71f033f
break the commands into seperate items
Johnnyevans32 Oct 2, 2024
d1c191b
Setup routes for Home, About, Settings and 404 handling
Johnnyevans32 Oct 3, 2024
0cbffbd
Setup routes for Home, About, Settings and 404 handling
Johnnyevans32 Oct 3, 2024
bf4b6bd
conflict fix
Johnnyevans32 Oct 3, 2024
817dd9d
remove vite config timestamp file
Johnnyevans32 Oct 3, 2024
45863c1
remove vite config timestamp file
Johnnyevans32 Oct 3, 2024
299701c
initial commit
Johnnyevans32 Oct 3, 2024
2d4bc05
initial commit
Johnnyevans32 Oct 3, 2024
8f52853
fix:layout
Johnnyevans32 Oct 3, 2024
f5acb27
fix:layout
Johnnyevans32 Oct 3, 2024
0e5cdd8
fix:layout
Johnnyevans32 Oct 4, 2024
840901f
fix:layout
Johnnyevans32 Oct 4, 2024
ca39e83
responsive nav menu
Johnnyevans32 Oct 4, 2024
4d506f6
responsive nav menu
Johnnyevans32 Oct 4, 2024
d7f09f3
responsive nav menu
Johnnyevans32 Oct 4, 2024
af78a4d
backdrop blur
Johnnyevans32 Oct 4, 2024
fd9e803
updated dark mode specs
Johnnyevans32 Oct 4, 2024
927738f
vite plugin pwa
Johnnyevans32 Oct 4, 2024
ec39945
conflict fix
Johnnyevans32 Oct 4, 2024
9e83878
remove unused navigation menu component
Johnnyevans32 Oct 4, 2024
a728cd6
conflict fix
Johnnyevans32 Oct 4, 2024
3ad3b3a
pwa assets generation and settings page form
Johnnyevans32 Oct 5, 2024
968615c
pwa assets generation and settings page form
Johnnyevans32 Oct 5, 2024
74cd639
web5 connection setup
Johnnyevans32 Oct 5, 2024
7cce532
web5 connection setup
Johnnyevans32 Oct 5, 2024
405d8ae
test case fix
Johnnyevans32 Oct 5, 2024
c60f4fd
test unit specs update
Johnnyevans32 Oct 6, 2024
c504971
Merge branch 'feat/pwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 6, 2024
456bbda
test unit specs update
Johnnyevans32 Oct 6, 2024
212a907
feat:todo list
Johnnyevans32 Oct 6, 2024
fee7ea8
ci fix
Johnnyevans32 Oct 6, 2024
0ef7b9f
ci fix
Johnnyevans32 Oct 6, 2024
f390c32
ci fix
Johnnyevans32 Oct 6, 2024
bbe2eb4
Merge branch 'feat/dwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 6, 2024
55675c9
Merge branch 'TBD54566975:main' into feat/pwa
Johnnyevans32 Oct 6, 2024
63d7e4d
fix
Johnnyevans32 Oct 7, 2024
de6bbff
conflict fix
Johnnyevans32 Oct 7, 2024
d2b8924
Merge branch 'feat/pwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 7, 2024
e30be51
Merge branch 'feat/pwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 7, 2024
ebd2103
fix todo list functions
Johnnyevans32 Oct 7, 2024
e35b107
conflict fix
Johnnyevans32 Oct 7, 2024
d53936f
delete todo unused store
Johnnyevans32 Oct 7, 2024
83225c8
Merge branch 'feat/dwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 7, 2024
78ac362
conflict fix
Johnnyevans32 Oct 7, 2024
d87bfeb
conflict fix
Johnnyevans32 Oct 7, 2024
3c3bf8f
conflict fix
Johnnyevans32 Oct 7, 2024
ab05d43
conflict fix
Johnnyevans32 Oct 7, 2024
0c8ce1f
seperate web5 connect options button loading state
Johnnyevans32 Oct 7, 2024
174d9fc
seperate web5 connect options button loading state
Johnnyevans32 Oct 7, 2024
6ec1100
Merge branch 'feat/dwa' of https://github.com/Johnnyevans32/tbd-examp…
Johnnyevans32 Oct 7, 2024
98530bf
revert web5 composable to resemble that of the react vite version
Johnnyevans32 Oct 7, 2024
155c104
Merge branch 'main' of https://github.com/TBD54566975/tbd-examples in…
Johnnyevans32 Oct 7, 2024
fc569ee
revert to importing react linb utilties
Johnnyevans32 Oct 7, 2024
c3ead1c
revert to importing react linb utilties
Johnnyevans32 Oct 7, 2024
7b776d7
update
Johnnyevans32 Oct 7, 2024
5331f5a
update
Johnnyevans32 Oct 7, 2024
d189d2a
update
Johnnyevans32 Oct 7, 2024
695280a
update
Johnnyevans32 Oct 8, 2024
aa18bb3
connect task to web5
Johnnyevans32 Oct 8, 2024
3962494
connect task to web5
Johnnyevans32 Oct 8, 2024
3bfdd7b
connect task to web5
Johnnyevans32 Oct 9, 2024
f61f2f5
conflict fix
Johnnyevans32 Oct 9, 2024
6e6cd6c
conflict fix
Johnnyevans32 Oct 9, 2024
8289222
conflict fix
Johnnyevans32 Oct 9, 2024
eb9823c
edit button on todo item
Johnnyevans32 Oct 10, 2024
818780f
Merge branch 'main' of https://github.com/TBD54566975/tbd-examples in…
Johnnyevans32 Oct 10, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
181 changes: 178 additions & 3 deletions javascript/dwa-starter-vue/src/components/TodoList.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,181 @@
<script setup lang="ts"></script>
<script setup lang="ts">
import { useWeb5, type Task } from '@/composables/web5'
import { onBeforeMount, ref } from 'vue'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/ui/button'
import { TrashIcon, Pencil2Icon } from '@radix-icons/vue'
import {
Table,
TableBody,
TableCaption,
TableCell,
TableHead,
TableHeader,
TableRow
} from '@/components/ui/table'
import { Checkbox } from '@/components/ui/checkbox'
import { toast } from '@/components/ui/toast/use-toast'

const task = ref('')
const tasks = ref<Task[]>([])

const { listTasks, createTask, updateTask, deleteTask } = useWeb5()

onBeforeMount(() => {
findTasks()
})

const findTasks = async () => {
tasks.value = await listTasks()
}

async function addTodo() {
try {
if (!task.value) {
toast({
title: 'Error',
description: 'task cant be null'
})
return
}
const data = {
completed: false,
title: task.value
}

await createTask(data)
await findTasks()
task.value = ''
toast({
description: 'Todo added successfully'
})
} catch (err: any) {
toast({
description: `Failed to add todo: ${err.message || 'Unknown error'}`,
title: 'Error'
})
}
}

async function deleteTodo(id: string) {
try {
await deleteTask(id)
await findTasks()
toast({
description: 'Todo deleted successfully'
})
} catch (err: any) {
toast({
description: `Failed to delete todo: ${err.message || 'Unknown error'}`,
title: 'Error'
})
}
}

async function toggleTodoStatus(task: Task) {
try {
await updateTask(task)
await findTasks()
toast({
description: `Todo status updated to ${task.completed ? 'completed' : 'incomplete'}`
})
} catch (err: any) {
toast({
description: `Failed to update todo: ${err.message || 'Unknown error'}`,
title: 'Error'
})
}
}

function startEditing(id?: string) {
const task = tasks.value.find((i) => i.id === id)
if (task) task.isEditing = true
}

function stopEditing(id?: string) {
const task = tasks.value.find((i) => i.id === id)
if (task) task.isEditing = false
}

async function updateTodoTitle(task: Task) {
try {
await updateTask(task)
await findTasks()
toast({
description: 'Todo title updated successfully'
})
} catch (err: any) {
toast({
description: `Failed to update todo title: ${err.message || 'Unknown error'}`,
title: 'Error'
})
} finally {
stopEditing(task.id)
}
}
</script>

<template>
<h1>Todo</h1>
<p>coming soon</p>
<div class="flex flex-col gap-4">
<h1>Todos</h1>

<div class="lg:w-1/3 flex items-center gap-2">
<label for="add-todo" class="sr-only">Add a todo</label>
<Input
type="text"
id="add-todo"
v-model="task"
@keydown.enter.exact.prevent="addTodo"
placeholder="what are you working on?"
/>
<Button type="button" @click="addTodo"> Add </Button>
</div>
<div v-if="!tasks.length">
<h2>no todos created yet</h2>
</div>

<Table v-else class="lg:w-1/3">
<TableCaption>Todos.</TableCaption>
<TableHeader>
<TableRow>
<TableHead class="w-[100px]"> Completed? </TableHead>
<TableHead>Title</TableHead>
<TableHead class="text-right"> </TableHead>
<TableHead class="text-right"> </TableHead>
</TableRow>
</TableHeader>
<TableBody>
<TableRow v-for="todo in tasks" :key="todo.id">
<TableCell>
<Checkbox
:checked="todo.completed"
@click="toggleTodoStatus({ ...todo, completed: !todo.completed })"
/>
</TableCell>
<TableCell class="cursor-pointer">
<div v-if="todo.isEditing">
<Input
v-model="todo.title"
@keydown.enter="updateTodoTitle(todo)"
@blur="updateTodoTitle(todo)"
/>
</div>
<div v-else @click="startEditing(todo.id)">
{{ todo.title }}
</div>
</TableCell>
<TableCell class="text-right">
<Button variant="ghost" @click="startEditing(todo.id)">
<Pencil2Icon class="w-4 h-4" />
</Button>
</TableCell>
<TableCell class="text-right">
<Button variant="ghost" @click="deleteTodo(todo.id as string)">
<TrashIcon class="w-4 h-4" />
</Button>
</TableCell>
</TableRow>
</TableBody>
</Table>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import type { CheckboxRootEmits, CheckboxRootProps } from 'radix-vue'
import { CheckboxIndicator, CheckboxRoot, useForwardPropsEmits } from 'radix-vue'
import { CheckIcon } from '@radix-icons/vue'
import { cn } from '@/lib/utils'

const props = defineProps<CheckboxRootProps & { class?: HTMLAttributes['class'] }>()
const emits = defineEmits<CheckboxRootEmits>()

const delegatedProps = computed(() => {
const { class: _, ...delegated } = props

return delegated
})

const forwarded = useForwardPropsEmits(delegatedProps, emits)
</script>

<template>
<CheckboxRoot
v-bind="forwarded"
:class="
cn(
'peer h-4 w-4 shrink-0 rounded-sm border border-slate-200 border-slate-900 shadow focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-slate-950 disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-slate-900 data-[state=checked]:text-slate-50 dark:border-slate-800 dark:border-slate-50 dark:focus-visible:ring-slate-300 dark:data-[state=checked]:bg-slate-50 dark:data-[state=checked]:text-slate-900',
props.class
)
"
>
<CheckboxIndicator class="flex h-full w-full items-center justify-center text-current">
<slot>
<CheckIcon class="h-4 w-4" />
</slot>
</CheckboxIndicator>
</CheckboxRoot>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default as Checkbox } from './Checkbox.vue'
16 changes: 16 additions & 0 deletions javascript/dwa-starter-vue/src/components/ui/table/Table.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<div class="w-full overflow-auto">
<table :class="cn('w-full caption-bottom text-sm', props.class)">
<slot />
</table>
</div>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<tbody :class="cn('[&_tr:last-child]:border-0', props.class)">
<slot />
</tbody>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<caption :class="cn('mt-4 text-sm text-slate-500 dark:text-slate-400', props.class)">
<slot />
</caption>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<td
:class="
cn(
'p-2 align-middle [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5',
props.class,
)
"
>
<slot />
</td>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<script setup lang="ts">
import { type HTMLAttributes, computed } from 'vue'
import TableRow from './TableRow.vue'
import TableCell from './TableCell.vue'
import { cn } from '@/lib/utils'

const props = withDefaults(defineProps<{
class?: HTMLAttributes['class']
colspan?: number
}>(), {
colspan: 1,
})

const delegatedProps = computed(() => {
const { class: _, ...delegated } = props

return delegated
})
</script>

<template>
<TableRow>
<TableCell
:class="
cn(
'p-4 whitespace-nowrap align-middle text-sm text-slate-950 dark:text-slate-50',
props.class,
)
"
v-bind="delegatedProps"
>
<div class="flex items-center justify-center py-10">
<slot />
</div>
</TableCell>
</TableRow>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<tfoot :class="cn('border-t bg-slate-100/50 font-medium [&>tr]:last:border-b-0 dark:bg-slate-800/50', props.class)">
<slot />
</tfoot>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<th :class="cn('h-10 px-2 text-left align-middle font-medium text-slate-500 [&:has([role=checkbox])]:pr-0 [&>[role=checkbox]]:translate-y-0.5 dark:text-slate-400', props.class)">
<slot />
</th>
</template>
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'
const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<thead :class="cn('[&_tr]:border-b', props.class)">
<slot />
</thead>
</template>
14 changes: 14 additions & 0 deletions javascript/dwa-starter-vue/src/components/ui/table/TableRow.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<script setup lang="ts">
import type { HTMLAttributes } from 'vue'
import { cn } from '@/lib/utils'

const props = defineProps<{
class?: HTMLAttributes['class']
}>()
</script>

<template>
<tr :class="cn('border-b transition-colors hover:bg-slate-100/50 data-[state=selected]:bg-slate-100 dark:hover:bg-slate-800/50 dark:data-[state=selected]:bg-slate-800', props.class)">
<slot />
</tr>
</template>
Loading
Loading