Skip to content

Commit

Permalink
replaced icons with more pragmatic leptos::icon_gen macro
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-medicala-yral committed Dec 11, 2024
1 parent fb692dc commit 8e8bbc2
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 94 deletions.
24 changes: 7 additions & 17 deletions ssr/src/component/icons/airdrop_icon.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
use leptos::*;
use crate::utils::icon::icon_gen;

#[component]
pub fn AirdropIcon(
#[prop(optional, default = "w-full h-full".to_string())] classes: String,
) -> impl IntoView {
view! {
<svg
class=format!("{}", classes)
viewBox="0 0 30 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<mask
icon_gen!(
AirdropIcon,
view_box = "0 0 30 30",
r###"<mask
id="mask0_694_2577"
style="mask-type:alpha"
maskUnits="userSpaceOnUse"
Expand Down Expand Up @@ -40,7 +32,5 @@ pub fn AirdropIcon(
fill="currentColor"
/>
</g>
</g>
</svg>
}
}
</g>"###
);
24 changes: 7 additions & 17 deletions ssr/src/component/icons/arrow_left_right_icon.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
use leptos::*;
use crate::utils::icon::icon_gen;

#[component]
pub fn ArrowLeftRightIcon(
#[prop(optional, default = "w-full h-full".to_string())] classes: String,
) -> impl IntoView {
view! {
<svg
class=format!("{}", classes)
viewBox="0 0 31 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<mask
icon_gen!(
ArrowLeftRightIcon,
view_box = "0 0 31 30",
r###"<mask
id="mask0_500_15031"
style="mask-type:alpha"
maskUnits="userSpaceOnUse"
Expand All @@ -27,7 +19,5 @@ pub fn ArrowLeftRightIcon(
d="M10.9024 22.3831C10.6176 22.6398 10.1854 22.6413 9.8988 22.3866L6.27834 19.1684C5.83082 18.7706 5.83082 18.0714 6.27834 17.6736L9.89869 14.4555C10.1853 14.2007 10.6177 14.2023 10.9024 14.4591C11.2354 14.7593 11.2335 15.2824 10.8984 15.5802L8.50245 17.7098H17.8106C18.2034 17.7098 18.5218 18.0282 18.5218 18.421C18.5218 18.8138 18.2034 19.1322 17.8106 19.1322H8.50245L10.8984 21.262C11.2336 21.5599 11.2354 22.0829 10.9024 22.3831ZM21.6013 16.9979C21.3147 17.2527 20.8823 17.2511 20.5975 16.9943C20.2646 16.6941 20.2664 16.1711 20.6015 15.8732L22.9976 13.7434H13.6893C13.2966 13.7434 12.9782 13.425 12.9782 13.0323C12.9782 12.6396 13.2966 12.3212 13.6893 12.3212H22.9976L20.6016 10.1914C20.2664 9.89355 20.2646 9.37054 20.5975 9.07027C20.8823 8.81346 21.3147 8.81192 21.6013 9.06669L25.2217 12.2848C25.6692 12.6826 25.6692 13.3818 25.2217 13.7796L21.6013 16.9979Z"
fill="currentColor"
/>
</g>
</svg>
}
}
</g>"###
);
24 changes: 7 additions & 17 deletions ssr/src/component/icons/chevron_right_icon.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
use leptos::*;
use crate::utils::icon::icon_gen;

#[component]
pub fn ChevronRightIcon(
#[prop(optional, default = "w-full h-full".to_string())] classes: String,
) -> impl IntoView {
view! {
<svg
class=format!("{}", classes)
viewBox="0 0 30 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
icon_gen!(
ChevronRightIcon,
view_box = "0 0 30 30",
r###"<path
d="M12.1224 24.0156C11.7522 24.3858 11.1518 24.3858 10.7815 24.0156V24.0156C10.4113 23.6453 10.4113 23.0449 10.7815 22.6746L17.891 15.5652L10.7815 8.45569C10.4113 8.08541 10.4113 7.48507 10.7815 7.11479V7.11479C11.1518 6.74451 11.7522 6.74451 12.1224 7.11479L19.8657 14.8581C20.2562 15.2486 20.2562 15.8818 19.8657 16.2723L12.1224 24.0156Z"
fill="currentColor"
/>
</svg>
}
}
/>"###
);
25 changes: 7 additions & 18 deletions ssr/src/component/icons/send_icon.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,9 @@
use leptos::*;
use crate::utils::icon::icon_gen;

#[component]
pub fn SendIcon(
#[prop(optional, default = "w-full h-full".to_string())] classes: String,
#[prop(optional)] filled: bool,
) -> impl IntoView {
view! {
<svg
class=format!("{}", classes)
viewBox="0 0 31 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<mask
icon_gen!(
SendIcon,
view_box = "0 0 31 30",
r###"<mask
id="mask0_500_15024"
style="mask-type:alpha"
maskUnits="userSpaceOnUse"
Expand All @@ -30,7 +21,5 @@ pub fn SendIcon(
fill=move || format!("{} ", if filled { "currentColor" } else { "none" })
stroke-width="1.2"
/>
</g>
</svg>
}
}
</g>"###
);
24 changes: 7 additions & 17 deletions ssr/src/component/icons/share_icon.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
use leptos::*;
use crate::utils::icon::icon_gen;

#[component]
pub fn ShareIcon(
#[prop(optional, default = "w-full h-full".to_string())] classes: String,
) -> impl IntoView {
view! {
<svg
class=format!("{}", classes)
viewBox="0 0 31 30"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<mask
icon_gen!(
ShareIcon,
view_box = "0 0 31 30",
r###"<mask
id="mask0_500_15047"
style="mask-type:alpha"
maskUnits="userSpaceOnUse"
Expand Down Expand Up @@ -40,7 +32,5 @@ pub fn ShareIcon(
fill="currentColor"
/>
</g>
</g>
</svg>
}
}
</g>"###
);
17 changes: 9 additions & 8 deletions ssr/src/page/icpump/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::collections::VecDeque;

use futures::StreamExt;
use leptos::*;
use leptos_icons::Icon;

use crate::component::buttons::LinkButton;
use crate::component::icons::airdrop_icon::AirdropIcon;
Expand Down Expand Up @@ -188,19 +189,19 @@ pub fn TokenCard(
</div>
<div class="flex gap-4 justify-between items-center p-2">
<ActionButton label="Send".to_string() href=format!("/token/transfer/{root}")>
<SendIcon classes="w-full h-full".to_string() />
<Icon class="w-full h-full" icon=SendIcon />
</ActionButton>
<ActionButton label="Buy/Sell".to_string() href="#".to_string() disabled=true>
<ArrowLeftRightIcon classes="w-full h-full".to_string() />
<Icon class="w-full h-full" icon=ArrowLeftRightIcon />
</ActionButton>
<ActionButton label="Airdrop".to_string() href="#".to_string() disabled=true>
<AirdropIcon classes="w-full h-full".to_string() />
<Icon class="w-full h-full" icon=AirdropIcon />
</ActionButton>
<ActionButtonWithHandler label="Share".to_string() on_click=move || {let _ =copy_to_clipboard(&format!("/token/info/{root}?airdrop_amt=100"));} >
<ShareIcon classes="w-full h-full".to_string() />
<ActionButtonWithHandler label="Share".to_string() on_click=move || {let _ =copy_to_clipboard(&format!("https://icpump.fun/token/info/{root}?airdrop_amt=100"));} >
<Icon class="w-full h-full" icon=ShareIcon />
</ActionButtonWithHandler>
<ActionButton label="Details".to_string() href=details.link>
<ChevronRightIcon classes="w-full h-full".to_string() />
<Icon class="w-full h-full" icon=ChevronRightIcon />
</ActionButton>
</div>
</div>
Expand All @@ -219,7 +220,7 @@ pub fn PageSelector(page: RwSignal<u64>, end_of_list: RwSignal<bool>) -> impl In
}
disabled=move || page.get() == 1
>
<ChevronRightIcon classes="w-4 h-4 rotate-180".to_string() />
<Icon class="w-4 h-4 rotate-180" icon=ChevronRightIcon />
</button>
<div class="w-8 h-8 rounded-lg flex items-center justify-center text-white bg-[#3D8EFF]">{page}</div>
<button
Expand All @@ -229,7 +230,7 @@ pub fn PageSelector(page: RwSignal<u64>, end_of_list: RwSignal<bool>) -> impl In
}
disabled=move || end_of_list.get()
>
<ChevronRightIcon classes="w-4 h-4".to_string() />
<Icon class="w-4 h-4" icon=ChevronRightIcon />
</button>
</div>
}
Expand Down

0 comments on commit 8e8bbc2

Please sign in to comment.