Skip to content

Commit 98878c4

Browse files
author
DidierRLopes
committed
looking good
1 parent 8807726 commit 98878c4

File tree

1 file changed

+25
-6
lines changed

1 file changed

+25
-6
lines changed

src/components/BlogHistory.tsx

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
5858

5959
const [activeIndex, setActiveIndex] = React.useState<number | null>(null);
6060
const [isHoveringBar, setIsHoveringBar] = React.useState(false);
61+
const [tooltipOpacity, setTooltipOpacity] = React.useState(0);
6162

6263
const getOptimalInterval = (months: Date[]) => {
6364
const totalMonths = months.length;
@@ -66,6 +67,7 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
6667
if (totalMonths <= 8) return 1; // Show all labels if 8 or fewer months
6768
if (totalMonths <= 16) return 2; // Every 2 months if <= 16 months
6869
if (totalMonths <= 24) return 3; // Every quarter if <= 2 years
70+
if (totalMonths <= 36) return 4; // Every 4 months if <= 3 years
6971
if (totalMonths <= 48) return 6; // Every 6 months if <= 4 years
7072
return 12; // Every year for longer periods
7173
};
@@ -99,9 +101,9 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
99101
year: "numeric",
100102
month: "short",
101103
}),
102-
showLabel,
104+
showLabel, // This property is already being set based on getOptimalInterval
103105
posts: postsInMonth,
104-
...postSizes, // Spread individual post sizes
106+
...postSizes,
105107
};
106108
});
107109

@@ -128,12 +130,24 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
128130
<XAxis
129131
dataKey="monthDisplay"
130132
type="category"
131-
interval={0}
132-
angle={-45}
133-
textAnchor="end"
133+
interval={getOptimalInterval(months) - 1}
134134
height={60}
135+
tick={{ fontSize: 14 }}
136+
/>
137+
<YAxis
138+
label={{
139+
value: "Volume",
140+
angle: -90,
141+
position: "insideLeft",
142+
offset: -1,
143+
style: {
144+
textAnchor: "middle",
145+
fontSize: 14,
146+
},
147+
}}
148+
tick={false}
149+
width={30}
135150
/>
136-
<YAxis />
137151
<Tooltip
138152
cursor={{ fill: "rgba(0, 0, 0, 0.1)" }}
139153
content={({ active, payload, label }) => {
@@ -161,6 +175,9 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
161175
borderRadius: "8px",
162176
boxShadow: "0 2px 10px rgba(0,0,0,0.1)",
163177
width: "600px",
178+
opacity: tooltipOpacity,
179+
transition: "all 1s ease-in-out",
180+
transform: `translateY(${tooltipOpacity ? "0" : "10px"})`,
164181
}}
165182
>
166183
<div style={{ display: "flex", alignItems: "center" }}>
@@ -256,9 +273,11 @@ export default function BlogHistory({ posts = [] }: BlogHistoryProps) {
256273
onMouseOver={(_, index) => {
257274
setActiveIndex(i);
258275
setIsHoveringBar(true);
276+
setTooltipOpacity(1); // Fade in
259277
}}
260278
onMouseLeave={() => {
261279
setIsHoveringBar(false);
280+
setTooltipOpacity(0); // Fade out
262281
}}
263282
onClick={(entry, index) => {
264283
if (entry && monthlyData[index].posts[i]) {

0 commit comments

Comments
 (0)