Skip to content

Commit 18a1f27

Browse files
committedFeb 28, 2023
🚀 finished simple graph
1 parent d44e082 commit 18a1f27

File tree

3 files changed

+85
-2
lines changed

3 files changed

+85
-2
lines changed
 

‎src/components/Sales/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Card } from "../Card";
22
import { IconPolygon } from "../Icons/IconPolygon";
3+
import { SimpleGraph } from "../SimpleGraph";
34
import { InfoOfTheDay } from "./components/InfoOfTheDay";
45

56
export const Sales: React.FC = () => {
@@ -27,8 +28,7 @@ export const Sales: React.FC = () => {
2728
</div>
2829

2930
<div>
30-
{/* Graph */}
31-
GRÁFICO
31+
<SimpleGraph />
3232
</div>
3333
</div>
3434
</div>

‎src/components/SimpleGraph/index.tsx

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import classNames from "classnames";
2+
3+
interface IDaysType {
4+
day: string;
5+
value: number;
6+
}
7+
8+
const DAYS: IDaysType[] = [
9+
{
10+
day: "dom",
11+
value: 2,
12+
},
13+
{
14+
day: "seg",
15+
value: 5,
16+
},
17+
{
18+
day: "ter",
19+
value: 4,
20+
},
21+
{
22+
day: "qua",
23+
value: 6,
24+
},
25+
{
26+
day: "qui",
27+
value: 5,
28+
},
29+
{
30+
day: "sex",
31+
value: 4.5,
32+
},
33+
{
34+
day: "sab",
35+
value: 3,
36+
},
37+
];
38+
39+
export const SimpleGraph: React.FC = () => {
40+
const calcularValor = (value: number) => {
41+
let valueTotal = value * 10;
42+
43+
if (valueTotal < 0) return 1;
44+
else if (valueTotal > 140) return 140;
45+
46+
return valueTotal;
47+
};
48+
49+
return (
50+
<div className="h-full">
51+
<div className="flex justify-between items-end h-full">
52+
{DAYS.map((item) => {
53+
const value = calcularValor(item.value);
54+
55+
const divStyle = {
56+
height: `${value}px`,
57+
};
58+
59+
return (
60+
<div
61+
key={item.day}
62+
className="flex flex-col justify-center items-center"
63+
>
64+
<div
65+
className={classNames(
66+
// height,
67+
"bg-custom-cyan-600 w-[15px] rounded-full"
68+
)}
69+
style={divStyle}
70+
/>
71+
<span className="font-inter font-medium text-sm text-white">
72+
{item.day}
73+
</span>
74+
</div>
75+
);
76+
})}
77+
</div>
78+
</div>
79+
);
80+
};

‎tailwind.config.cjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = {
1616
green: {
1717
500: "#81FBB8",
1818
},
19+
cyan: {
20+
600: "#90F7EC",
21+
},
1922
},
2023
},
2124
fontFamily: {

0 commit comments

Comments
 (0)