Skip to content

Commit

Permalink
Merge branch 'main' into feat/paginator
Browse files Browse the repository at this point in the history
  • Loading branch information
ail3ngrimaldi authored Oct 10, 2024
2 parents ec85a71 + 8944002 commit b7055be
Show file tree
Hide file tree
Showing 25 changed files with 1,450 additions and 397 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
import {
XcmProgramsExecutor,
globallyInjectPrograms,
} from "https://unpkg.com/@virtonetwork/xcm-programs@1.0.0/dist/xcm-programs.js";
} from "https://unpkg.com/@virtonetwork/xcm-programs@latest/dist/xcm-programs.js";
import init from "/{base_path}/assets/dioxus/{app_name}.js";

const executor = new XcmProgramsExecutor({
Expand Down
36 changes: 35 additions & 1 deletion public/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -302,11 +302,11 @@ $fw-bold: 700;
"sidebar header"
"sidebar main"
"sidebar footer";
grid-template-columns: auto 1fr;
grid-template-rows: 90px auto auto;
width: 100%;
max-width: 100vw;
min-height: 100vh;

}

.grid-header {
Expand Down Expand Up @@ -696,6 +696,7 @@ $fw-bold: 700;
.tooltip {
border: 1px solid rgba(0, 0, 0, 0);
width: 30%;
height: fit-content;
padding: var(--size-1);
text-align: left;
position: fixed;
Expand Down Expand Up @@ -1457,6 +1458,8 @@ $fw-bold: 700;
border-radius: 12px;
list-style: none;
z-index: 10;
max-height: 30vh;
overflow: auto;
}

.dropdown--right .dropdown__list {
Expand Down Expand Up @@ -2379,6 +2382,21 @@ textarea::placeholder {
width: max-content;
}

.deposit__form__inputs {
display: flex;
flex-direction: column;
gap: 24px;
}

.deposit__row {
display: flex;
gap: 32px;
}

.summary .dropdown__label {
color: var(--text-secondary);
}

.balances {
display: flex;
flex-direction: column;
Expand Down Expand Up @@ -3585,3 +3603,19 @@ small.summary__item__value {
transform: translateY(0);
}
}

.card--skeleton {
animation: loadingBackground 1.5s infinite;
}

@keyframes loadingBackground {
0% {
background-color: var(--fill-100);
}
50% {
background-color: var(--fill-50);
}
100% {
background-color: var(--fill-100);
}
}
11 changes: 11 additions & 0 deletions src/components/atoms/card_skeleton.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
use dioxus::prelude::*;

#[component]
pub fn CardSkeleton() -> Element {
rsx!(
section { class: "card card--skeleton",
div { class: "card__container",
}
}
)
}
2 changes: 2 additions & 0 deletions src/components/atoms/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub mod badge;
pub mod bar;
pub mod button;
pub mod card;
pub mod card_skeleton;
pub mod checkbox_card;
pub mod combo_input;
pub mod dropdown;
Expand Down Expand Up @@ -36,6 +37,7 @@ pub use badge::Badge;
pub use bar::Bar;
pub use button::Button;
pub use card::Card;
pub use card_skeleton::CardSkeleton;
pub use checkbox_card::CheckboxCard;
pub use combo_input::ComboInput;
pub use dropdown::Dropdown;
Expand Down
32 changes: 24 additions & 8 deletions src/components/molecules/action_request_list.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use dioxus::prelude::*;
use dioxus_std::{i18n::use_i18, translate};
use crate::{
components::atoms::ActionRequest,
hooks::use_initiative::{
ActionItem, AddMembersAction, ConvictionVote, KusamaTreasuryAction, VoteType,
VotingOpenGovAction,
ActionItem, AddMembersAction, CommunityTransferAction, ConvictionVote,
KusamaTreasuryAction, VoteType, VotingOpenGovAction,
},
};
use dioxus::prelude::*;
use dioxus_std::{i18n::use_i18, translate};
#[derive(PartialEq, Props, Clone)]
pub struct ActionRequestListProps {
actions: Vec<ActionItem>,
Expand All @@ -15,7 +15,7 @@ pub fn ActionRequestList(props: ActionRequestListProps) -> Element {
let i18 = use_i18();
let render_add_members = |action: &AddMembersAction| {
rsx!(
ActionRequest { name: "Add Members", details: action.members.len().to_string() }
ActionRequest { name: translate!(i18, "initiative.steps.actions.add_members.title"), details: action.members.len().to_string() }
ul { class: "requests",
for member in action.members.iter() {
li {
Expand All @@ -27,7 +27,7 @@ pub fn ActionRequestList(props: ActionRequestListProps) -> Element {
};
let render_kusama_treasury = |action: &KusamaTreasuryAction| {
rsx!(
ActionRequest { name: "Kusama Treasury Request" }
ActionRequest { name: translate!(i18, "initiative.steps.actions.kusama_treasury.title") }
ul { class: "requests",
for (index , period) in action.periods.iter().enumerate() {
li {
Expand All @@ -42,7 +42,7 @@ pub fn ActionRequestList(props: ActionRequestListProps) -> Element {
};
let render_voting_open_gov = |action: &VotingOpenGovAction| {
rsx!(
ActionRequest { name: "Voting Open Gov", details: action.proposals.len().to_string() }
ActionRequest { name: translate!(i18, "initiative.steps.actions.voting_open_gov.title"), details: action.proposals.len().to_string() }
ul { class: "requests",
for proposal in action.proposals.iter() {
li {
Expand Down Expand Up @@ -70,13 +70,29 @@ pub fn ActionRequestList(props: ActionRequestListProps) -> Element {
}
)
};
let render_community_transfer = |action: &CommunityTransferAction| {
rsx!(
ActionRequest { name: translate!(i18, "initiative.steps.actions.community_transfer.title") }
ul { class: "requests",
for transfer in action.transfers.iter() {
li {
ActionRequest {
name: format!("{}", transfer.account),
details: format!("{} KSM", transfer.value as f64 / 1_000_000_000_000.0)
}
}
}
}
)
};
rsx!(
for request in props.actions.iter() {
div { class: "requests",
match request {
ActionItem::AddMembers(action) => render_add_members(& action),
ActionItem::KusamaTreasury(action) => render_kusama_treasury(& action),
ActionItem::VotingOpenGov(action) => render_voting_open_gov(& action) }
ActionItem::VotingOpenGov(action) => render_voting_open_gov(& action) ,
ActionItem::CommunityTransfer(action) => render_community_transfer(& action) }
}
}
)
Expand Down
2 changes: 2 additions & 0 deletions src/components/molecules/actions/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub mod members;
pub mod treasury;
pub mod voting;
pub mod transfer;
pub use transfer::TransferAction;
pub use members::MembersAction;
pub use treasury::TreasuryAction;
pub use voting::VotingAction;
113 changes: 113 additions & 0 deletions src/components/molecules/actions/transfer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
use crate::{
components::atoms::{
dropdown::ElementSize, icon_button::Variant, AddPlus, Icon, IconButton,
Input, MinusCircle,
},
hooks::use_initiative::{use_initiative, ActionItem, CommunityTransferAction, TransferItem},
};
use dioxus::prelude::*;
use dioxus_std::{i18n::use_i18, translate};
#[derive(PartialEq, Props, Clone)]
pub struct VotingProps {
index: usize,
meta: CommunityTransferAction,
}
const KUSAMA_PRECISION_DECIMALS: u64 = 1_000_000_000_000;
pub fn TransferAction(props: VotingProps) -> Element {
let i18 = use_i18();
let mut initiative = use_initiative();
rsx!(
ul { class: "form__inputs form__inputs--combo",
{
props.meta.transfers.iter().enumerate().map(|(index_meta, transfer)| {
rsx!(
li {
div {
style: "
width: 100%;
display: flex;
gap: 4px;
",
Input {
message: transfer.account.clone(),
size: ElementSize::Small,
placeholder: translate!(i18, "initiative.steps.actions.community_transfer.dest.placeholder"),
error: None,
on_input: move |event: Event<FormData>| {
if let ActionItem::CommunityTransfer(ref mut meta) = initiative.get_action(props.index) {
meta.transfers[index_meta].account = event.value() ;
initiative.update_action(props.index, ActionItem::CommunityTransfer(meta.clone()));
}
},
on_keypress: move |_| {},
on_click: move |_| {},
}
Input {
message: (transfer.value / KUSAMA_PRECISION_DECIMALS).to_string(),
size: ElementSize::Small,
placeholder: translate!(i18, "initiative.steps.actions.community_transfer.amount.placeholder"),
error: None,
right_text: {
rsx!(
span { class: "input--right__text",
"KSM"
}
)
},
on_input: move |event: Event<FormData>| {
if let ActionItem::CommunityTransfer(ref mut meta) = initiative.get_action(props.index) {
// Scale amount
let amount = event.value().parse::<f64>().unwrap_or(0.0);
let scaled_amount = amount * KUSAMA_PRECISION_DECIMALS as f64;
meta.transfers[index_meta].value = scaled_amount as u64 ;
initiative.update_action(props.index, ActionItem::CommunityTransfer(meta.clone()));
}
},
on_keypress: move |_| {},
on_click: move |_| {},
}
}
IconButton {
variant: Variant::Round,
size: ElementSize::Small,
class: "button--avatar",
body: rsx!(
Icon {
icon: MinusCircle,
height: 24,
width: 24,
fill: "var(--state-primary-active)"
}
),
on_click: move |_| {
if let ActionItem::CommunityTransfer(ref mut meta) = initiative.get_action(props.index) {
meta.transfers.remove(index_meta);
initiative.update_action(props.index, ActionItem::CommunityTransfer(meta.clone()));
}
}
}
}
)
})
},
IconButton {
variant: Variant::Round,
size: ElementSize::Small,
class: "button--avatar",
body: rsx!(
Icon { icon : AddPlus, height : 24, width : 24, fill :
"var(--state-primary-active)" }
),
on_click: move |_| {
if let ActionItem::CommunityTransfer(ref mut meta) = initiative
.get_action(props.index)
{
meta.add_transfer(TransferItem::default());
initiative
.update_action(props.index, ActionItem::CommunityTransfer(meta.clone()));
}
}
}
}
)
}
10 changes: 9 additions & 1 deletion src/components/molecules/initiative/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
dropdown::ElementSize, icon_button::Variant, AddPlus, Dropdown, Icon,
IconButton, SubstractLine,
},
molecules::{MembersAction, TreasuryAction, VotingAction},
molecules::{MembersAction, TransferAction, TreasuryAction, VotingAction},
},
hooks::use_initiative::{
use_initiative, ActionItem, AddMembersAction, MediumOptions, MemberItem,
Expand Down Expand Up @@ -87,6 +87,14 @@ pub fn InitiativeActions() -> Element {
}
)
}
ActionItem::CommunityTransfer(meta) => {
rsx!(
TransferAction {
index: index,
meta: meta.clone()
}
)
}
}
}
)
Expand Down
Loading

0 comments on commit b7055be

Please sign in to comment.