Skip to content

Commit 8278367

Browse files
committed
Style improvement and renam home component file
1 parent 68c5e24 commit 8278367

File tree

6 files changed

+106
-35
lines changed

6 files changed

+106
-35
lines changed

src/App.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { Home } from "./pages/Home/Main";
1+
import { Home } from "./pages/Home";
2+
import "./styles/global.css";
23

34
function App() {
45
return <Home />;

src/index.css

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/main.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import { StrictMode } from 'react'
2-
import { createRoot } from 'react-dom/client'
3-
import './index.css'
4-
import App from './App.tsx'
1+
import { StrictMode } from "react";
2+
import { createRoot } from "react-dom/client";
3+
import App from "./App.tsx";
54

6-
createRoot(document.getElementById('root')!).render(
5+
createRoot(document.getElementById("root")!).render(
76
<StrictMode>
87
<App />
9-
</StrictMode>,
10-
)
8+
</StrictMode>
9+
);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { render, screen } from "@testing-library/react";
22
import { describe, it, expect } from "vitest";
3-
import { Home } from "./Main";
3+
import { Home } from ".";
44
import userEvent from "@testing-library/user-event";
55

66
describe("Home – integration test", () => {
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export const Home = () => {
66
const { data, loading } = useUsers();
77

88
if (loading) {
9-
return <div>Loading...</div>;
9+
return <div className="page">Loading...</div>;
1010
}
1111

1212
const renderItem = (item: User) => {
@@ -17,20 +17,16 @@ export const Home = () => {
1717
const address = `${item.location.street}, ${item.location.city}, ${item.location.state}, ${item.location.country}`;
1818

1919
return (
20-
<div data-testid="data-item">
21-
<div>
22-
<strong>{fullName}</strong>
23-
</div>
24-
25-
<div>{item.job.title}</div>
26-
27-
<div>{address}</div>
20+
<div className="data-item" data-testid="data-item">
21+
<strong>{fullName}</strong>
22+
<div className="job">{item.job.title}</div>
23+
<div className="address">{address}</div>
2824
</div>
2925
);
3026
};
3127

3228
return (
33-
<div>
29+
<div className="page">
3430
<DataList
3531
items={data}
3632
keyExtractor={(item) => item.id}

src/styles/global.css

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
:root {
2+
--bg: #f8f9fb;
3+
--card-bg: #ffffff;
4+
--text-primary: #1f2933;
5+
--text-secondary: #6b7280;
6+
--border: #e5e7eb;
7+
--accent: #2563eb;
8+
}
9+
10+
* {
11+
box-sizing: border-box;
12+
}
13+
14+
body {
15+
margin: 0;
16+
font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
17+
Helvetica, Arial, sans-serif;
18+
background-color: var(--bg);
19+
color: var(--text-primary);
20+
}
21+
22+
/* Page container */
23+
.page {
24+
max-width: 900px;
25+
margin: 40px auto;
26+
padding: 0 16px;
27+
}
28+
29+
/* List */
30+
.data-list-items {
31+
display: flex;
32+
flex-direction: column;
33+
gap: 12px;
34+
}
35+
36+
/* Card */
37+
.data-item {
38+
background: var(--card-bg);
39+
border: 1px solid var(--border);
40+
border-radius: 8px;
41+
padding: 16px;
42+
}
43+
44+
.data-item strong {
45+
font-size: 1rem;
46+
display: block;
47+
margin-bottom: 4px;
48+
}
49+
50+
.data-item .job {
51+
font-size: 0.9rem;
52+
color: var(--text-secondary);
53+
margin-bottom: 6px;
54+
}
55+
56+
.data-item .address {
57+
font-size: 0.85rem;
58+
color: var(--text-secondary);
59+
}
60+
61+
/* Pagination */
62+
.data-list-pagination {
63+
display: flex;
64+
align-items: center;
65+
justify-content: space-between;
66+
margin-top: 24px;
67+
}
68+
69+
.data-list-pagination span {
70+
font-size: 0.9rem;
71+
color: var(--text-secondary);
72+
}
73+
74+
.data-list-pagination button {
75+
background: transparent;
76+
border: 1px solid var(--border);
77+
padding: 8px 14px;
78+
border-radius: 6px;
79+
cursor: pointer;
80+
font-size: 0.9rem;
81+
}
82+
83+
.data-list-pagination button:hover:not(:disabled) {
84+
border-color: var(--accent);
85+
color: var(--accent);
86+
}
87+
88+
.data-list-pagination button:disabled {
89+
opacity: 0.5;
90+
cursor: not-allowed;
91+
}

0 commit comments

Comments
 (0)