Skip to content

Commit f3db74a

Browse files
netr0msebastianvitterso
authored andcommitted
refactor: rework design (eds)
1 parent cb5a09b commit f3db74a

File tree

14 files changed

+145
-79
lines changed

14 files changed

+145
-79
lines changed

api/src/tests/unit/features/todo/use_cases/test_delete_todo_by_id.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@ def test_delete_todo_should_return_not_success(todo_repository: TodoRepositoryIn
2020
id = "unkown"
2121
with pytest.raises(NotFoundException):
2222
delete_todo_use_case(id=id, todo_repository=todo_repository)
23-
assert error.message == "The todos item you specified does not exist."

api/src/tests/unit/features/todo/use_cases/test_get_todo_by_id.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,3 @@ def test_get_todo_by_id_should_throw_todo_not_found_error(todo_repository: TodoR
2222
id = "unknown"
2323
with pytest.raises(NotFoundException):
2424
get_todo_by_id_use_case(id, todo_repository=todo_repository)
25-
assert error.message == "The todos item you specified does not exist."

web/.pnp.cjs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Binary file not shown.

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"dependencies": {
1010
"@equinor/eds-core-react": "^0.20.3",
11+
"@equinor/eds-icons": "^0.15.0",
1112
"axios": "^0.27.2",
1213
"react": "^18.2.0",
1314
"react-dom": "^18.2.0",

web/src/App.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
import { router } from './router'
22
import { RouterProvider } from 'react-router-dom'
3+
import Header from './common/components/Header'
34

45
function App() {
5-
return <RouterProvider router={router} />
6+
return (
7+
<>
8+
<Header />
9+
<RouterProvider router={router} />
10+
</>
11+
)
612
}
713

814
export default App
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { useContext } from 'react'
2+
import { AuthContext } from 'react-oauth2-code-pkce'
3+
import { Icon, TopBar, Typography } from '@equinor/eds-core-react'
4+
import { receipt } from '@equinor/eds-icons'
5+
6+
Icon.add({ receipt })
7+
8+
const Header = () => {
9+
const { tokenData, token } = useContext(AuthContext)
10+
return (
11+
<TopBar>
12+
<TopBar.Header>
13+
<Icon name="receipt" />
14+
Todo App
15+
</TopBar.Header>
16+
<TopBar.Actions>
17+
<Typography variant="caption">
18+
Logged in as {token && tokenData?.['unique_name']}
19+
</Typography>
20+
</TopBar.Actions>
21+
</TopBar>
22+
)
23+
}
24+
25+
export default Header
Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
import styled from 'styled-components'
2+
import { Typography } from '@equinor/eds-core-react'
23

3-
export const StyledTodoItem = styled.div`
4-
font-weight: bold;
5-
cursor: pointer;
4+
export const StyledTodoItemTitle = styled(Typography)`
65
text-decoration: ${(props: { is_completed?: boolean }) =>
76
props.is_completed ? 'line-through' : 'none'};
87
`
9-
10-
export const StyledTodoContent = styled.div`
11-
display: flex;
12-
padding: 4px;
13-
`
14-
15-
export const StyledTodoItemTitle = styled.div`
16-
flex: 1 1 auto;
17-
`

web/src/features/todos/todo-list/TodoItem.tsx

Lines changed: 47 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,53 @@
1-
import React from 'react'
1+
import { StyledTodoItemTitle } from './TodoItem.styled'
22
import {
3-
StyledTodoContent,
4-
StyledTodoItem,
5-
StyledTodoItemTitle,
6-
} from './TodoItem.styled'
7-
import { Button } from '@equinor/eds-core-react'
3+
Button,
4+
Card,
5+
Typography,
6+
Icon,
7+
Tooltip,
8+
} from '@equinor/eds-core-react'
9+
import { undo, done, remove_outlined } from '@equinor/eds-icons'
10+
import { AddTodoResponse } from '../../../api/generated'
811

9-
const TodoItem = (props: any) => {
10-
const { todo, index, onToggle, onRemove } = props
12+
Icon.add({ undo, done, remove_outlined })
13+
14+
const TodoItem = (props: {
15+
todo: AddTodoResponse
16+
onToggle: (id: string) => void
17+
onRemove: (id: string) => void
18+
}) => {
19+
const { todo, onToggle, onRemove } = props
1120
return (
12-
<StyledTodoItem
13-
is_completed={todo.is_completed}
14-
onClick={() => onToggle(todo.id, todo.is_completed as boolean, index)}
15-
>
16-
<StyledTodoContent>
17-
<StyledTodoItemTitle>{todo.title}</StyledTodoItemTitle>
18-
<Button onClick={() => onRemove(todo.id, index)}>Remove</Button>
19-
</StyledTodoContent>
20-
</StyledTodoItem>
21+
<Card>
22+
<Card.Header>
23+
<Card.HeaderTitle>
24+
<StyledTodoItemTitle
25+
variant="h5"
26+
className="todoTitle"
27+
is_completed={todo.is_completed}
28+
>
29+
{todo.title}
30+
</StyledTodoItemTitle>
31+
<Typography variant="body_short">
32+
{todo.is_completed ? 'Done' : 'Todo'}
33+
</Typography>
34+
</Card.HeaderTitle>
35+
<Tooltip title={`Mark as ${todo.is_completed ? 'incomplete' : 'done'}`}>
36+
<Button variant="ghost_icon" onClick={() => onToggle(todo.id)}>
37+
<Icon
38+
name={todo.is_completed ? 'undo' : 'done'}
39+
size={24}
40+
title={todo.is_completed ? 'incomplete' : 'done'}
41+
/>
42+
</Button>
43+
</Tooltip>
44+
<Tooltip title="Remove">
45+
<Button variant="ghost_icon" onClick={() => onRemove(todo.id)}>
46+
<Icon name="remove_outlined" size={24} title="Remove" />
47+
</Button>
48+
</Tooltip>
49+
</Card.Header>
50+
</Card>
2151
)
2252
}
2353

web/src/features/todos/todo-list/TodoList.styled.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,11 @@ export const StyledTodoList = styled.div`
44
width: 400px;
55
padding: 30px;
66
`
7+
8+
export const StyledInput = styled.div`
9+
display: flex;
10+
11+
.input {
12+
margin-right: 5px;
13+
}
14+
`

0 commit comments

Comments
 (0)