Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
T
TodoList
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Sakilesh J
TodoList
Commits
7b8d7dc7
Commit
7b8d7dc7
authored
Jun 05, 2024
by
Sakilesh J
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes in the code
parent
98c2977c
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
75 additions
and
93 deletions
+75
-93
todoTypes.ts
Types/todoTypes.ts
+1
-8
form.module.css
components/Top-Level/Form/form.module.css
+1
-4
form.stories.tsx
components/Top-Level/Form/form.stories.tsx
+5
-4
Item.tsx
components/Top-Level/Item/Item.tsx
+12
-11
item.module.css
components/Top-Level/Item/item.module.css
+4
-0
item.stories.tsx
components/Top-Level/Item/item.stories.tsx
+10
-7
Button.stories.tsx
components/base/Button/Button.stories.tsx
+2
-2
Heading.stories.tsx
components/base/Heading/Heading.stories.tsx
+1
-1
Input.stories.tsx
components/base/input/Input.stories.tsx
+5
-2
List.tsx
components/layout/List/List.tsx
+7
-5
list.stories.tsx
components/layout/List/list.stories.tsx
+11
-7
db.json
db.json
+9
-8
TodoApi.ts
lib/TodoApi.ts
+0
-0
Todo.tsx
pages/Todo.tsx
+5
-9
globals.css
styles/globals.css
+2
-25
No files found.
Types/todoTypes.ts
View file @
7b8d7dc7
export
type
TodoListItems
=
{
export
interface
TodoListItems
{
id
:
number
;
id
:
number
;
task
:
string
;
task
:
string
;
isCompleted
:
boolean
;
isCompleted
:
boolean
;
}
}
export
interface
ItemMethods
{
onDelete
:
(
id
:
number
)
=>
void
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
\ No newline at end of file
components/Top-Level/Form/form.module.css
View file @
7b8d7dc7
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
padding
:
17px
;
padding
:
17px
;
width
:
100%
;
width
:
100%
;
flex-wrap
:
wrap
;
flex-wrap
:
wrap
;
gap
:
1
5
px
;
gap
:
1
0
px
;
background-color
:
white
;
background-color
:
white
;
}
}
...
@@ -13,9 +13,6 @@
...
@@ -13,9 +13,6 @@
flex
:
1
;
flex
:
1
;
}
}
.inputWrapper
>
input
{
width
:
100%
;
}
.buttonWrapper
>
button
{
.buttonWrapper
>
button
{
min-width
:
100%
;
min-width
:
100%
;
...
...
components/Top-Level/Form/form.stories.tsx
View file @
7b8d7dc7
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
FormComponent
from
"./FormComponent"
;
import
FormComponent
from
"./FormComponent"
;
import
{
fn
}
from
"@storybook/test"
;
const
meta
:
Meta
<
typeof
FormComponent
>
=
{
const
meta
:
Meta
<
typeof
FormComponent
>
=
{
title
:
"Top-Level"
,
title
:
"Top-Level"
,
component
:
FormComponent
,
component
:
FormComponent
,
argTypes
:
{
onPost
:
{
action
:
"onPost"
}
}
}
}
export
default
meta
;
export
default
meta
;
...
@@ -11,7 +13,5 @@ export default meta;
...
@@ -11,7 +13,5 @@ export default meta;
type
story
=
StoryObj
<
typeof
meta
>
type
story
=
StoryObj
<
typeof
meta
>
export
const
Form
:
story
=
{
export
const
Form
:
story
=
{
args
:
{
onPost
:
fn
()
}
}
}
\ No newline at end of file
components/Top-Level/Item/Item.tsx
View file @
7b8d7dc7
...
@@ -4,17 +4,19 @@ import styles from './item.module.css'
...
@@ -4,17 +4,19 @@ import styles from './item.module.css'
import
Input
from
'@/components/base/input/Input'
;
import
Input
from
'@/components/base/input/Input'
;
import
closeIcon
from
'@/public/icons/red-x-10333.svg'
;
import
closeIcon
from
'@/public/icons/red-x-10333.svg'
;
import
Image
from
'next/image'
;
import
Image
from
'next/image'
;
import
{
ItemMethod
s
}
from
'@/Types/todoTypes'
;
import
{
TodoListItem
s
}
from
'@/Types/todoTypes'
;
interface
ItemProps
extends
ItemMethods
{
interface
ItemProps
{
id
:
number
;
data
:
TodoListItems
task
:
string
;
onDelete
:
(
id
:
number
)
=>
void
;
isCompleted
:
boolean
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
}
const
Item
:
React
.
FC
<
ItemProps
>
=
({
task
,
isCompleted
,
onDelete
,
updateTask
,
id
})
=>
{
const
Item
:
React
.
FC
<
ItemProps
>
=
({
onDelete
,
updateTask
,
data
})
=>
{
const
[
isChecked
,
setisChecked
]
=
useState
(
isCompleted
)
const
{
id
,
task
,
isCompleted
}
=
data
;
const
[
isChecked
,
setisChecked
]
=
useState
(
isCompleted
);
useEffect
(()
=>
{
useEffect
(()
=>
{
setisChecked
(
isCompleted
)
setisChecked
(
isCompleted
)
},
[
isCompleted
])
},
[
isCompleted
])
...
@@ -22,22 +24,21 @@ const Item: React.FC<ItemProps> = ({ task, isCompleted, onDelete, updateTask, id
...
@@ -22,22 +24,21 @@ const Item: React.FC<ItemProps> = ({ task, isCompleted, onDelete, updateTask, id
const
handleChange
=
async
()
=>
{
const
handleChange
=
async
()
=>
{
await
updateTask
(
id
,
task
,
!
isCompleted
)
await
updateTask
(
id
,
task
,
!
isCompleted
)
setisChecked
(
!
isChecked
)
setisChecked
(
!
isChecked
)
}
}
const
handleItem
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleItem
=
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
updateTask
(
id
,
e
.
target
.
value
,
isCompleted
)
updateTask
?.
(
id
,
e
.
target
.
value
,
isCompleted
)
}
}
const
handleClose
=
()
=>
{
const
handleClose
=
()
=>
{
onDelete
(
id
)
onDelete
?.
(
id
)
}
}
return
(
return
(
<
div
className=
{
styles
.
item
}
>
<
div
className=
{
styles
.
item
}
>
<
input
type=
'checkbox'
checked=
{
isChecked
}
onChange=
{
handleChange
}
className=
{
styles
.
checkbox
}
/>
<
input
type=
'checkbox'
checked=
{
isChecked
}
onChange=
{
handleChange
}
className=
{
styles
.
checkbox
}
/>
<
Input
id=
"Todo-input"
placeholder=
'Enter item...'
defaultValue=
{
task
}
onBlur=
{
handleItem
}
style=
{
{
<
Input
id=
"Todo-input"
placeholder=
'Enter item...'
defaultValue=
{
task
}
onBlur=
{
handleItem
}
style=
{
{
textDecoration
:
isChecked
?
'line-through'
:
'
none
'
textDecoration
:
isChecked
?
'line-through'
:
''
}
}
/>
}
}
/>
<
div
className=
{
styles
.
actions
}
onClick=
{
handleClose
}
>
<
div
className=
{
styles
.
actions
}
onClick=
{
handleClose
}
>
<
Image
src=
{
closeIcon
}
alt=
""
width=
{
22
}
height=
{
22
}
className=
{
styles
.
closeIcon
}
/>
<
Image
src=
{
closeIcon
}
alt=
""
width=
{
22
}
height=
{
22
}
className=
{
styles
.
closeIcon
}
/>
...
...
components/Top-Level/Item/item.module.css
View file @
7b8d7dc7
...
@@ -23,6 +23,10 @@
...
@@ -23,6 +23,10 @@
font-size
:
18px
;
font-size
:
18px
;
}
}
.item
>
div
>
input
:focus
{
border
:
none
;
}
.actions
{
.actions
{
margin-left
:
auto
;
margin-left
:
auto
;
min-width
:
1.3rem
;
min-width
:
1.3rem
;
...
...
components/Top-Level/Item/item.stories.tsx
View file @
7b8d7dc7
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
Item
from
"./Item"
;
import
Item
from
"./Item"
;
import
{
fn
}
from
"@storybook/test"
;
const
meta
:
Meta
<
typeof
Item
>
=
{
const
meta
:
Meta
<
typeof
Item
>
=
{
title
:
"Top-Level"
,
title
:
"Top-Level"
,
component
:
Item
,
component
:
Item
,
argTypes
:
{
onDelete
:
{
action
:
"onDelete"
},
updateTask
:
{
action
:
"onEdit"
},
},
}
}
export
default
meta
;
export
default
meta
;
...
@@ -12,13 +14,14 @@ export default meta;
...
@@ -12,13 +14,14 @@ export default meta;
type
story
=
StoryObj
<
typeof
meta
>
type
story
=
StoryObj
<
typeof
meta
>
export
const
Item_
:
story
=
{
export
const
Item_
:
story
=
{
args
:
{
args
:
{
id
:
1
,
data
:
{
isCompleted
:
true
,
id
:
1
,
task
:
'Buy groceries'
,
isCompleted
:
true
,
onDelete
:
fn
(),
task
:
'Buy groceries'
updateTask
:
fn
()
}
},
},
}
}
components/base/Button/Button.stories.tsx
View file @
7b8d7dc7
...
@@ -4,7 +4,7 @@ import Button from './Button';
...
@@ -4,7 +4,7 @@ import Button from './Button';
const
meta
:
Meta
<
typeof
Button
>
=
{
const
meta
:
Meta
<
typeof
Button
>
=
{
title
:
'Basic/Button'
,
title
:
'Basic/Button'
,
component
:
Button
,
component
:
Button
,
tags
:
[
'autodocs'
]
tags
:
[
'autodocs'
]
,
};
};
export
default
meta
;
export
default
meta
;
...
@@ -13,7 +13,7 @@ type Story = StoryObj<typeof meta>;
...
@@ -13,7 +13,7 @@ type Story = StoryObj<typeof meta>;
const
Template
=
()
=>
{
const
Template
=
()
=>
{
return
(
return
(
<
div
>
<
div
>
<
h6
className=
"mb-2 font-semibold"
>
Size
</
h6
>
<
h6
className=
"mb-2 font-semibold"
>
Size
</
h6
>
<
div
className=
"flex gap-5 mb-4 flex-wrap items-center"
>
<
div
className=
"flex gap-5 mb-4 flex-wrap items-center"
>
<
Button
size=
"sm"
>
<
Button
size=
"sm"
>
...
...
components/base/Heading/Heading.stories.tsx
View file @
7b8d7dc7
...
@@ -2,7 +2,7 @@ import { Meta, StoryObj } from "@storybook/react";
...
@@ -2,7 +2,7 @@ import { Meta, StoryObj } from "@storybook/react";
import
Heading
from
"./Heading"
;
import
Heading
from
"./Heading"
;
const
meta
:
Meta
<
typeof
Heading
>
=
{
const
meta
:
Meta
<
typeof
Heading
>
=
{
title
:
"Basic
/Header
"
,
title
:
"Basic"
,
component
:
Heading
,
component
:
Heading
,
}
}
...
...
components/base/input/Input.stories.tsx
View file @
7b8d7dc7
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
{
Meta
,
StoryObj
}
from
"@storybook/react"
;
import
Input
from
"./Input"
;
import
Input
from
"./Input"
;
import
{
fn
}
from
"@storybook/test"
;
import
React
from
"react"
;
import
React
from
"react"
;
const
meta
:
Meta
<
typeof
Input
>
=
{
const
meta
:
Meta
<
typeof
Input
>
=
{
title
:
"Basic"
,
title
:
"Basic"
,
component
:
Input
,
component
:
Input
,
argTypes
:
{
onChange
:
{
action
:
'onChange'
}
}
}
}
export
default
meta
export
default
meta
...
@@ -14,7 +18,6 @@ type story = StoryObj<typeof meta>;
...
@@ -14,7 +18,6 @@ type story = StoryObj<typeof meta>;
export
const
Input_
:
story
=
{
export
const
Input_
:
story
=
{
args
:
{
args
:
{
placeholder
:
'Enter the value...'
,
placeholder
:
'Enter the value...'
,
onChange
:
fn
(),
},
},
render
:
(
args
)
=>
{
render
:
(
args
)
=>
{
return
<
React
.
Fragment
>
return
<
React
.
Fragment
>
...
...
components/layout/List/List.tsx
View file @
7b8d7dc7
import
Item
from
"@/components/Top-Level/Item/Item"
;
import
Item
from
"@/components/Top-Level/Item/Item"
;
import
styles
from
"./list.module.css"
;
import
styles
from
"./list.module.css"
;
import
{
ItemMethods
,
TodoListItems
}
from
"@/Types/todoTypes"
;
import
{
TodoListItems
}
from
"@/Types/todoTypes"
;
interface
ListItemProps
extends
ItemMethods
{
interface
ListItemProps
{
data
:
TodoListItems
[];
data
:
TodoListItems
[];
onDelete
:
(
id
:
number
)
=>
void
;
updateTask
:
(
id
:
number
,
task
:
string
,
isCompleted
:
boolean
)
=>
void
;
}
}
const
ListItem
:
React
.
FC
<
ListItemProps
>
=
({
data
,
updateTask
,
onDelete
})
=>
{
const
ListItem
:
React
.
FC
<
ListItemProps
>
=
({
data
,
onDelete
,
updateTask
})
=>
{
return
(
return
(
<
div
className=
{
styles
.
list
}
>
<
div
className=
{
styles
.
list
}
>
{
{
...
@@ -12,9 +14,9 @@ const ListItem: React.FC<ListItemProps> = ({ data, updateTask, onDelete }) => {
...
@@ -12,9 +14,9 @@ const ListItem: React.FC<ListItemProps> = ({ data, updateTask, onDelete }) => {
return
(
return
(
<
Item
<
Item
key=
{
item
.
id
}
key=
{
item
.
id
}
{
...
item
}
data=
{
item
}
updateTask=
{
updateTask
}
onDelete=
{
onDelete
}
onDelete=
{
onDelete
}
updateTask=
{
updateTask
}
/>
/>
)
)
})
})
...
...
components/layout/List/list.stories.tsx
View file @
7b8d7dc7
import
type
{
Meta
,
StoryObj
}
from
'@storybook/react'
;
import
type
{
Meta
,
StoryObj
}
from
'@storybook/react'
;
import
List
from
'./List'
;
import
List
from
'./List'
;
import
{
List_data
}
from
'@/utils/data'
;
import
{
List_data
}
from
'@/utils/data'
;
import
{
fn
}
from
'@storybook/test
'
;
import
{
action
}
from
'@storybook/addon-actions
'
;
import
Heading
from
'@/components/base/Heading/Heading'
;
import
Heading
from
'@/components/base/Heading/Heading'
;
import
FormComponent
from
'@/components/Top-Level/Form/FormComponent'
;
import
FormComponent
from
'@/components/Top-Level/Form/FormComponent'
;
const
meta
:
Meta
<
typeof
List
>
=
{
const
meta
:
Meta
<
typeof
List
>
=
{
title
:
'Layout'
,
title
:
'Layout'
,
component
:
List
,
component
:
List
,
argTypes
:
{
onDelete
:
{
action
:
'onDelete'
,
},
updateTask
:
{
action
:
'UpdateTask'
,
}
}
};
};
export
default
meta
;
export
default
meta
;
...
@@ -17,16 +26,12 @@ type Story = StoryObj<typeof meta>;
...
@@ -17,16 +26,12 @@ type Story = StoryObj<typeof meta>;
export
const
List_
:
Story
=
{
export
const
List_
:
Story
=
{
args
:
{
args
:
{
data
:
List_data
,
data
:
List_data
,
onDelete
:
fn
(),
updateTask
:
fn
()
}
}
};
};
export
const
Todos
:
Story
=
{
export
const
Todos
:
Story
=
{
args
:
{
args
:
{
data
:
List_data
,
data
:
List_data
,
onDelete
:
fn
(),
updateTask
:
fn
()
},
},
render
:
(
args
)
=>
(
render
:
(
args
)
=>
(
<
div
style=
{
{
<
div
style=
{
{
...
@@ -35,7 +40,6 @@ export const Todos: Story = {
...
@@ -35,7 +40,6 @@ export const Todos: Story = {
flexShrink
:
1
,
flexShrink
:
1
,
width
:
'100%'
,
width
:
'100%'
,
}
}
>
}
}
>
<
div
style=
{
{
<
div
style=
{
{
boxShadow
:
'2px 2px 3px rgba(0,0,0,0.06), -2px -2px 3px rgba(0,0,0,0.06)'
,
boxShadow
:
'2px 2px 3px rgba(0,0,0,0.06), -2px -2px 3px rgba(0,0,0,0.06)'
,
flexBasis
:
'100%'
,
flexBasis
:
'100%'
,
...
@@ -44,7 +48,7 @@ export const Todos: Story = {
...
@@ -44,7 +48,7 @@ export const Todos: Story = {
}
}
>
}
}
>
<
Heading
count=
{
args
.
data
.
length
}
/>
<
Heading
count=
{
args
.
data
.
length
}
/>
<
List
{
...
args
}
/>
<
List
{
...
args
}
/>
<
FormComponent
onPost=
{
fn
(
)
}
/>
<
FormComponent
onPost=
{
action
(
'onClick'
)
}
/>
</
div
>
</
div
>
</
div
>
</
div
>
)
)
...
...
db.json
View file @
7b8d7dc7
{
{
"tasks"
:
[
"tasks"
:
[
{
{
"task"
:
"
new todo
"
,
"task"
:
"
New Items
"
,
"isCompleted"
:
tru
e
,
"isCompleted"
:
fals
e
,
"id"
:
1
"id"
:
4
},
},
{
{
"task"
:
"new
element
"
,
"task"
:
"new
task anther
"
,
"isCompleted"
:
fals
e
,
"isCompleted"
:
tru
e
,
"id"
:
2
"id"
:
5
},
},
{
{
"task"
:
"
Nothing
"
,
"task"
:
"
sdf
"
,
"isCompleted"
:
false
,
"isCompleted"
:
false
,
"id"
:
3
"id"
:
7
}
}
]
]
}
}
\ No newline at end of file
lib/Todo
Operations
.ts
→
lib/Todo
Api
.ts
View file @
7b8d7dc7
File moved
pages/Todo.tsx
View file @
7b8d7dc7
...
@@ -5,8 +5,8 @@ import style from "./todoapp.module.css"
...
@@ -5,8 +5,8 @@ import style from "./todoapp.module.css"
import
Heading
from
"@/components/base/Heading/Heading"
;
import
Heading
from
"@/components/base/Heading/Heading"
;
import
List
from
"@/components/layout/List/List"
;
import
List
from
"@/components/layout/List/List"
;
import
FormComponent
from
"@/components/Top-Level/Form/FormComponent"
;
import
FormComponent
from
"@/components/Top-Level/Form/FormComponent"
;
import
{
TodoListItems
}
from
"@/
components/t
ypes"
;
import
{
TodoListItems
}
from
"@/
Types/todoT
ypes"
;
import
AddTask
,
{
UpdateTask
,
DeleteTask
}
from
"@/lib/Todo
Operations
"
;
import
AddTask
,
{
UpdateTask
,
DeleteTask
}
from
"@/lib/Todo
Api
"
;
import
getall
from
"@/lib/getall"
;
import
getall
from
"@/lib/getall"
;
interface
StateTodo
{
interface
StateTodo
{
data
?:
TodoListItems
[],
data
?:
TodoListItems
[],
...
@@ -15,7 +15,7 @@ interface StateTodo {
...
@@ -15,7 +15,7 @@ interface StateTodo {
}
}
const
Todo
=
()
=>
{
const
Todo
=
()
=>
{
const
[
refresh
,
setrefresh
]
=
useState
<
boolean
>
(
false
)
const
[
refresh
,
setrefresh
]
=
useState
(
false
)
const
[
TodoList
,
setTodoList
]
=
useState
<
StateTodo
>
({
const
[
TodoList
,
setTodoList
]
=
useState
<
StateTodo
>
({
isError
:
false
,
isError
:
false
,
isLoading
:
true
,
isLoading
:
true
,
...
@@ -84,9 +84,4 @@ const Todo = () => {
...
@@ -84,9 +84,4 @@ const Todo = () => {
);
);
}
}
export
default
Todo
;
export
default
Todo
;
\ No newline at end of file
styles/globals.css
View file @
7b8d7dc7
@tailwind
base
;
@tailwind
base
;
@tailwind
components
;
@tailwind
components
;
@tailwind
utilities
;
@tailwind
utilities
;
\ No newline at end of file
/*
.container {
width: 100%;
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background: radial-gradient(circle, #b3b3b3 10%, transparent 11%), radial-gradient(circle at bottom left, #b3b3b3 5%, transparent 6%), radial-gradient(circle at bottom right, #b3b3b3 5%, transparent 6%), radial-gradient(circle at top left, #b3b3b3 5%, transparent 6%), radial-gradient(circle at top right, #b3b3b3 5%, transparent 6%);
background-size: 1em 1em;
background-color: #ffffff;
}
* {
background-color: white;
}
.list-container {
margin-top: 10px;
} */
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment