Skip to content

Commit 8142f2a

Browse files
committed
Introduce a floating hearts animation upon hovering the "Buy Me a Coffee" button
1 parent 126650c commit 8142f2a

2 files changed

Lines changed: 52 additions & 3 deletions

File tree

packages/vscode/src/view/frontend/home/HomeView/HomeView.module.scss

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
}
3737

3838
.footer {
39+
position: relative;
3940
display: flex;
4041
justify-content: space-between;
4142
gap: var(--padding-8px);
@@ -72,10 +73,10 @@
7273

7374
&--buy-me-a-coffee {
7475
background-color: #f7d600;
75-
transition: all 0.2s ease-in-out;
76+
transition: var(--transition);
7677

7778
&:hover {
78-
transform: scale(1.1) rotate(-7deg);
79+
transform: scale(0.95);
7980
}
8081

8182
> svg {
@@ -130,6 +131,33 @@
130131
opacity: 1;
131132
}
132133
}
134+
135+
&__heart {
136+
position: absolute;
137+
bottom: 28px;
138+
animation-name: float-up;
139+
animation-timing-function: ease-out;
140+
animation-fill-mode: forwards;
141+
pointer-events: none;
142+
opacity: 0;
143+
}
144+
}
145+
146+
@keyframes float-up {
147+
from {
148+
transform: translateY(0);
149+
opacity: 0;
150+
}
151+
10% {
152+
opacity: 1;
153+
}
154+
40% {
155+
opacity: 1;
156+
}
157+
to {
158+
transform: translateY(-60px);
159+
opacity: 0;
160+
}
133161
}
134162

135163
.top {

packages/vscode/src/view/frontend/home/HomeView/HomeView.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,16 @@ const api_mode_labels: Record<ApiMode, string> = {
7979
export const HomeView: React.FC<Props> = (props) => {
8080
const [estimated_input_tokens, set_estimated_input_tokens] = useState(0)
8181
// We need this because we can't use overflow: hidden
82-
// due to absolutely positioned dropdown menu
82+
// due to absolutely positioned dropdown menu.
8383
const [dropdown_max_width, set_dropdown_max_width] = useState<
8484
number | undefined
8585
>(undefined)
8686

8787
const dropdown_container_ref = useRef<HTMLDivElement>(null)
8888
const container_ref = useRef<HTMLDivElement>(null)
8989
const switch_container_ref = useRef<HTMLDivElement>(null)
90+
const [is_buy_me_coffee_hovered, set_is_buy_me_coffee_hovered] =
91+
useState(false)
9092
const [is_showing_commands, set_is_showing_commands] = useState(false)
9193

9294
const calculate_dropdown_max_width = () => {
@@ -484,6 +486,8 @@ export const HomeView: React.FC<Props> = (props) => {
484486
)}
485487
href="https://buymeacoffee.com/robertpiosik"
486488
title="Support author"
489+
onMouseEnter={() => set_is_buy_me_coffee_hovered(true)}
490+
onMouseLeave={() => set_is_buy_me_coffee_hovered(false)}
487491
>
488492
<Icon variant="BUY_ME_A_COFFEE" />
489493
</a>
@@ -534,6 +538,23 @@ export const HomeView: React.FC<Props> = (props) => {
534538
PINNED COMMANDS
535539
</button>
536540
</div>
541+
{is_buy_me_coffee_hovered &&
542+
Array.from({ length: 20 }).map((_, i) => (
543+
<span
544+
key={i}
545+
className={styles.footer__heart}
546+
style={
547+
{
548+
left: `${18 + (Math.random() - 0.5) * 20}px`,
549+
animationDelay: `${i == 0 ? 0 : (i + Math.random()) / 3}s`,
550+
animationDuration: `${2 - Math.random()}s`,
551+
fontSize: `${10 + Math.random() * 8}px`
552+
} as React.CSSProperties
553+
}
554+
>
555+
❤️
556+
</span>
557+
))}
537558
</div>
538559
</div>
539560
)

0 commit comments

Comments
 (0)