Skip to content

Commit fd6a82e

Browse files
committed
1 parent 82c83f1 commit fd6a82e

File tree

9 files changed

+687
-23
lines changed

9 files changed

+687
-23
lines changed

examples/graphql/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"@types/node": "^12.0.0",
1111
"@types/react": "^16.9.0",
1212
"@types/react-dom": "^16.9.0",
13+
"antd": "^4.6.6",
14+
"classnames": "^2.2.6",
1315
"node-sass": "^4.14.1",
1416
"normalize.css": "^8.0.1",
1517
"react": "^16.13.1",
@@ -41,6 +43,7 @@
4143
]
4244
},
4345
"devDependencies": {
46+
"@types/classnames": "^2.2.10",
4447
"@types/react-router": "^5.1.8",
4548
"@types/react-router-dom": "^5.1.5"
4649
}
Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
1+
// vars
12
.app {
2-
&-header {
3-
background-color: #282c34;
4-
display: flex;
5-
flex-direction: column;
6-
align-items: center;
7-
justify-content: center;
3+
--clr-foreground: #fff;
4+
--clr-foreground--hover: #f6faff;
5+
--clr-foreground--selected: #dfecff;
6+
}
7+
// normalize
8+
.app {
9+
li {
10+
list-style: none;
11+
}
12+
}
13+
// app styles
14+
.app {
15+
display: flex;
16+
flex-direction: column;
17+
18+
.page {
19+
margin: auto 10%;
20+
&-title {
21+
display: flex;
22+
justify-content: center;
23+
margin: 10px;
24+
}
25+
}
26+
}
27+
28+
// common class-styles
29+
.app {
30+
.text-white {
831
color: white;
932
}
1033
}

examples/graphql/src/app/index.tsx

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
import React from 'react';
2+
import { Layout } from "antd";
23
import Routing from "pages";
34
import './index.scss';
45

56
const App = () => {
67
return (
78
<div className="app">
8-
<header className="app-header">
9-
TODO App
10-
</header>
11-
<Routing />
9+
<Layout>
10+
<Layout.Header>
11+
<span className="app-title text-white">
12+
Todo App
13+
</span>
14+
</Layout.Header>
15+
<Layout.Content>
16+
<Routing />
17+
</Layout.Content>
18+
</Layout>
1219
</div>
1320
);
1421
}

examples/graphql/src/index.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import ReactDOM from 'react-dom';
33
import App from './app';
44
import * as serviceWorker from './serviceWorker';
55
import "normalize.css";
6+
import 'antd/dist/antd.css';
67

78
ReactDOM.render(
89
<React.StrictMode>

examples/graphql/src/pages/tasks-list/index.tsx

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,35 @@
11
import React from 'react'
2+
import { Breadcrumb, Spin, Alert } from "antd";
23
import { useFetch } from "shared/hooks";
4+
import { TaskItem } from "shared/components";
5+
6+
// TODO: autogenerate by location
7+
const TasksListTitle = () => (
8+
<Breadcrumb className="page-title">
9+
<Breadcrumb.Item href="/">
10+
TasksList
11+
</Breadcrumb.Item>
12+
</Breadcrumb>
13+
);
314

415
const TasksList = () => {
516
const { data, error, loading } = useFetch<Task[]>("");
6-
if (error) alert(error);
717

818
return (
919
<div className="page page-tasks-list">
10-
<div className="page-title">
11-
Tasks List
12-
</div>
20+
<TasksListTitle />
1321
<div className="page-content">
14-
{loading && "Loading..."}
22+
{error && (
23+
<Alert
24+
type="error"
25+
message={error}
26+
showIcon
27+
/>
28+
)}
29+
{loading && <Spin />}
1530
<ul>
16-
{data?.map(({ id, title }) => (
17-
<li>{id}: {title}</li>
31+
{data?.map((taskProps) => (
32+
<li><TaskItem {...taskProps} /></li>
1833
))}
1934
{data?.length === 0 && (
2035
<li>There are not tasks found</li>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as TaskItem } from "./task-item";
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.task-item {
2+
transition: 0.25s;
3+
4+
&.completed {
5+
text-decoration: line-through;
6+
}
7+
8+
&:hover {
9+
background-color: var(--clr-foreground--hover);
10+
}
11+
&:active {
12+
background-color: var(--clr-foreground--selected);
13+
}
14+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from 'react'
2+
import cn from "classnames";
3+
import { Card } from "antd";
4+
import "./index.scss";
5+
6+
type Props = Task;
7+
8+
const TaskItem = (props: Props) => {
9+
const { completed, id, title, userId } = props;
10+
return (
11+
<Card className={cn("task-item", { completed })}>
12+
[{id}] {title}
13+
</Card>
14+
)
15+
}
16+
17+
export default TaskItem

0 commit comments

Comments
 (0)