Skip to content

Commit f144511

Browse files
authored
Add card animations on currencies list page (#17)
* Fix long texts in the currencies index page * Add animations on cards * When the page loads, the percentage circle is discovered from the right, while collapsing the white container
1 parent 654a633 commit f144511

3 files changed

Lines changed: 63 additions & 9 deletions

File tree

assets/css/animations.css

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
2+
@keyframes slide-in-right {
3+
0% {
4+
overflow: hidden;
5+
width: 0;
6+
opacity: 0;
7+
transform: translateX(-40px);
8+
margin-left: 0;
9+
}
10+
20% {
11+
visibility: visible;
12+
}
13+
30% {
14+
margin-left: 0.8rem;
15+
width: 35%;
16+
transform: translateX(30px);
17+
}
18+
50% {
19+
opacity: 1;
20+
width: 35%;
21+
transform: translateX(30px);
22+
}
23+
70% {
24+
margin-left: 0.5rem;
25+
width: 27%;
26+
transform: translateX(0);
27+
}
28+
85% {
29+
}
30+
100% {
31+
width: 27%;
32+
opacity: 1;
33+
transform: translateX(0);
34+
margin-left: 1rem;
35+
margin-right: 1rem;
36+
}
37+
}
38+
39+
.animate-slide-in-right {
40+
animation-name: slide-in-right;
41+
animation-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
42+
animation-delay: 0.2s;
43+
animation-duration: 2s;
44+
animation-fill-mode: forwards;
45+
width: 0;
46+
}

assets/css/app.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
@import "./fonts.css";
77
@import "./widgets/scrollbar.css";
88

9-
@import "./colors.css"
9+
@import "./colors.css";
10+
@import "./animations.css"

lib/ex_finance_web/live/public/currency_live/index.html.heex

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<section class="body-font transparent h-full flex justify-center items-center m-2">
1+
<section class="body-font transparent h-full m-2">
22
<div
33
class="flex flex-wrap -m-4 text-center justify-center sm:px-4 md:px-8 lg:px-16"
44
id="currencies"
@@ -9,7 +9,7 @@
99
id={dom_id}
1010
class="
1111
p-4
12-
w-full sm:w-full md:w-1/2 lg:w-1/2 xl:w-1/3 2xl:w-1/4
12+
1313
duration-500 cursor-default group
1414
"
1515
>
@@ -22,19 +22,23 @@
2222
focus:shadow-sm
2323
shadow-zinc-400 dark:shadow-zinc-900
2424
border-zinc-200 dark:border-zinc-700 border-[1px]
25+
w-[420px]
2526
cursor-pointer
26-
2727
bg-gradient-to-br
2828
from-#{get_color_by_price_direction(currency)}-100/75 to-#{get_color_by_price_direction(currency)}-900/75
2929
"}
3030
id={"currencies-#{currency.id}-card"}
3131
phx-click={JS.navigate(~p"/currencies/#{currency.id}")}
32+
style="overflow:hidden;"
3233
>
33-
<div class="
34-
text-left card-bg p-4 rounded-lg rounded-br-xl rounded-tr-xl border-zinc-300 dark:border-zinc-700 border-r-[1px] w-4/6
34+
<div
35+
class="
36+
text-left card-bg p-4 rounded-lg rounded-br-xl rounded-tr-xl border-zinc-300 dark:border-zinc-700 border-r-[1px] flex-[1_1_0%] min-w-[180px] max-w-[420px]
3537
shadow-zinc-300 dark:shadow-zinc-900 shadow-[3px_0_5px_-2px]
3638
transition duration-700
37-
">
39+
"
40+
id={"currency-details-#{currency.id}"}
41+
>
3842
<h2 class="text-zinc-700 dark:text-zinc-100 text-lg font-medium group-hover:underline group-hover:text-primary">
3943
<%= currency.name %>
4044
</h2>
@@ -50,7 +54,7 @@
5054
</h3>
5155
<% end %>
5256
<%= if currency.info_type == :market do %>
53-
<h3 class="mt-2 text-lg font-bold text-default dark:text-zinc-200 text-left cursor-text">
57+
<h3 class="mt-2 text-lg font-bold text-default dark:text-zinc-200 text-left cursor-text whitespace-nowrap">
5458
<%= render_price(currency.buy_price) %> - <%= render_price(
5559
currency.sell_price
5660
) %>
@@ -77,7 +81,10 @@
7781
</button>
7882
</div>
7983
</div>
80-
<div class="w-[30%]">
84+
<div
85+
class="animate-slide-in-right"
86+
id={"currency-variation-#{currency.id}"}
87+
>
8188
<div class="w-[6.5rem] h-[6.5rem] flex justify-center items-center overflow-hidden">
8289
<div class="relative">
8390
<div class={"

0 commit comments

Comments
 (0)