Skip to content

Commit

Permalink
Kusama treasury request (#68)
Browse files Browse the repository at this point in the history
* feat: kusama treasury request

* change: update RPC
  • Loading branch information
b-avb authored Aug 5, 2024
1 parent 654e028 commit 2c81bfb
Show file tree
Hide file tree
Showing 27 changed files with 984 additions and 1,375 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ grass = "0.13.2"
reqwest = { version = "0.12.4", features = ["multipart", "json"] }
pulldown-cmark = "0.11.0"
blake2 = "0.10.6"
chrono = "0.4.38"

[patch.crates-io]
cookie = { git = "https://github.com/S0c5/cookie-rs.git" }
Expand Down
1,291 changes: 314 additions & 977 deletions public/js/xcm-programs.js

Large diffs are not rendered by default.

29 changes: 25 additions & 4 deletions public/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,16 @@ $fw-bold: 700;
padding: 44px 0;
}

.form__inputs__disclaimer {
@extend %text-sm-font-medium;
color: var(--text-secondary);
background: var(--fill-50);
padding: 12px;
border-radius: 8px;
margin: 4px 0;
white-space: pre-line;
}

.form__input {
display: flex;
gap: 8px;
Expand Down Expand Up @@ -728,6 +738,7 @@ $fw-bold: 700;
width: 60px;
padding: 0;
transition: background-color 0.2s ease-in;

&:hover {
background-color: var(--fill-600);
}
Expand Down Expand Up @@ -1113,9 +1124,7 @@ $fw-bold: 700;
background: var(--state-primary-active);
}

.markdown__wrapper--editor {

}
.markdown__wrapper--editor {}

.markdown__wrapper--preview {}

Expand Down Expand Up @@ -1393,6 +1402,15 @@ textarea::placeholder {
padding-top: 6px;
}

.input--help {
@extend %text-sm-font-medium;
color: var(--text-secondary);
display: flex;
gap: 2px;
align-items: center;
padding-top: 6px;
}

.avatar {
width: var(--avatar-size);
min-width: var(--avatar-size);
Expand Down Expand Up @@ -2125,17 +2143,19 @@ textarea::placeholder {
justify-content: space-between;
height: 300px;
transition: all 0.2s ease-out;

&:hover {
background-color: var(--fill-200);
box-shadow: 0px 16px 32px 0px #00221833;
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}
}

.card--reverse {
flex-direction: column-reverse;
background: var(--fill-100);
box-shadow: none;

&:hover {
background-color: var(--fill-200);
transform: scale(1.05);
Expand Down Expand Up @@ -2179,6 +2199,7 @@ textarea::placeholder {
.card__title {
@extend %text-3xl-font-bold;
color: var(--text-primary);
text-align: left
}

.card__description {
Expand Down
93 changes: 51 additions & 42 deletions src/components/atoms/combo_input.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,28 @@
use dioxus::prelude::*;
use dioxus_std::{i18n::use_i18, translate};

use crate::components::atoms::{dropdown::DropdownItem, Dropdown, Input};
use crate::components::atoms::{dropdown::DropdownItem, input::InputType, Dropdown, Input};

use super::dropdown::ElementSize;

#[derive(PartialEq, Clone)]
#[derive(PartialEq, Clone, Debug)]
pub enum ComboInputOption {
Dropdown(DropdownItem),
Date(String),
None,
}

#[derive(PartialEq, Clone, Debug)]
pub struct ComboInputValue {
pub dropdown: DropdownItem,
pub option: ComboInputOption,
pub input: String,
}

#[derive(PartialEq, Props, Clone)]
pub struct ComboInputProps {
value: ComboInputValue,
placeholder: String,
error: Option<String>,
#[props(default = ElementSize::Medium)]
size: ElementSize,
on_change: EventHandler<ComboInputValue>,
Expand All @@ -23,27 +31,14 @@ pub struct ComboInputProps {
pub fn ComboInput(props: ComboInputProps) -> Element {
let i18 = use_i18();

let mut dropdown_value = use_signal::<DropdownItem>(|| props.value.dropdown);
let mut option_value = use_signal(|| props.value.option.clone());
let mut input_value = use_signal::<String>(|| props.value.input.clone());
let mut soon = use_signal::<bool>(|| {
dropdown_value().key == "Email" || dropdown_value().key == "Telegram"
});

let mut items = vec![];
let mut dropdown_options = vec![
DropdownItem {
key: "Wallet".to_string(),
value: translate!(i18, "onboard.invite.form.wallet.label"),
},
// DropdownItem {
// key: "Email".to_string(),
// value: translate!(i18, "onboard.invite.form.email.label"),
// },
// DropdownItem {
// key: "Telegram".to_string(),
// value: translate!(i18, "onboard.invite.form.phone.label"),
// },
];
let dropdown_options = vec![DropdownItem {
key: "Wallet".to_string(),
value: translate!(i18, "onboard.invite.form.wallet.label"),
}];

for account in dropdown_options.clone().into_iter() {
items.push(rsx!(span {
Expand All @@ -54,35 +49,49 @@ pub fn ComboInput(props: ComboInputProps) -> Element {
rsx!(
div {
class: "combo-input",
class: if soon() { "combo-input--comming-soon" },
Dropdown {
class: "dropdown--left".to_string(),
value: dropdown_value(),
placeholder: translate!(i18, "header.cta.account"),
size: props.size.clone(),
default: None,
on_change: move |event: usize| {
let to_assign = &dropdown_options[event];

if to_assign.value == "Email" || to_assign.value == "Telegram" {
soon.set(true)
} else {
soon.set(false)
match option_value() {
ComboInputOption::Date(value) => rsx!(
Input {
message: value,
size: props.size.clone(),
itype: InputType::Date,
placeholder: props.placeholder.clone(),
error: None,
on_input: move |event: Event<FormData>| {
option_value.set(ComboInputOption::Date(event.value().clone()));
props.on_change.call(ComboInputValue { option: ComboInputOption::Date(event.value().clone()), input: input_value().clone() })
},
on_keypress: move |_| {},
on_click: move |_| {},
}

dropdown_value.set(to_assign.clone());
props.on_change.call(ComboInputValue { dropdown: dropdown_value(), input: input_value().clone() })
},
body: items
),
ComboInputOption::Dropdown(value) => rsx!(
Dropdown {
class: "dropdown--left".to_string(),
value: value,
placeholder: translate!(i18, "header.cta.account"),
size: props.size.clone(),
default: None,
on_change: move |event: usize| {
let to_assign = &dropdown_options[event];
option_value.set(ComboInputOption::Dropdown(to_assign.clone()));
props.on_change.call(ComboInputValue { option: ComboInputOption::Dropdown(to_assign.clone()), input: input_value().clone() })
},
body: items
}
),
ComboInputOption::None => {
rsx!()
}
}
Input {
message: props.value.input.clone(),
size: props.size,
placeholder: props.placeholder,
error: None,
error: props.error,
on_input: move |event: Event<FormData>| {
input_value.set(event.value().clone());
props.on_change.call(ComboInputValue { dropdown: dropdown_value().clone(), input: input_value().clone() })
props.on_change.call(ComboInputValue { option: option_value(), input: input_value().clone() })
},
on_keypress: move |_| {},
on_click: move |_| {},
Expand Down
37 changes: 37 additions & 0 deletions src/components/atoms/input.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use dioxus::prelude::*;
use wasm_bindgen::JsCast;
use web_sys::HtmlInputElement;

use crate::components::atoms::{Icon, IconButton, Search, WarningSign};

Expand All @@ -10,6 +12,7 @@ pub enum InputType {
Message,
Search,
Password,
Date,
}

#[derive(PartialEq, Props, Clone)]
Expand All @@ -20,6 +23,7 @@ pub struct InputProps {
placeholder: String,
#[props(!optional)]
error: Option<String>,
help: Option<String>,
#[props(default = ElementSize::Medium)]
size: ElementSize,
label: Option<String>,
Expand All @@ -33,6 +37,8 @@ pub struct InputProps {
}

pub fn Input(props: InputProps) -> Element {
let mut input_ref = use_signal::<Option<Box<HtmlInputElement>>>(|| None);

let input_error_container = if let Some(_) = props.error {
"input--error-container"
} else {
Expand All @@ -43,6 +49,7 @@ pub fn Input(props: InputProps) -> Element {
InputType::Text => "text",
InputType::Search => "text",
InputType::Message => "text",
InputType::Date => "date",
InputType::Password => "password",
};

Expand Down Expand Up @@ -72,6 +79,27 @@ pub fn Input(props: InputProps) -> Element {
input {
r#type: "{input_type}",
class: "input",
onmounted: move |event| {
event.data.downcast::<web_sys::Element>()
.and_then(|element| element.clone().dyn_into::<HtmlInputElement>().ok())
.map(|html_element| input_ref.set(Some(Box::new(html_element.clone()))));

if input_type == "date" {
if let Some(input_element) = input_ref() {
input_element.set_type("text")
}
}
},
onfocus: move |_| {
if let Some(input_element) = input_ref() {
input_element.set_type(input_type)
}
},
onblur: move |_| {
if let Some(input_element) = input_ref() {
input_element.set_type("text")
}
},
value: props.message,
required: props.required,
maxlength: i64::from(props.maxlength),
Expand All @@ -98,6 +126,15 @@ pub fn Input(props: InputProps) -> Element {
}
}
}
if props.error.is_none() {
if let Some(help) = props.help {
div {
class: "input--help",
"{help}"
}
}
}

if let Some(error) = props.error {
div {
class: "input--error",
Expand Down
49 changes: 16 additions & 33 deletions src/components/atoms/search_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ use dioxus::prelude::*;

use crate::components::atoms::{Icon, IconButton, Search};

use super::{dropdown::ElementSize, input::InputType};
use super::dropdown::ElementSize;

#[derive(PartialEq, Props, Clone)]
pub struct SearchInputProps {
#[props(default = InputType::Text)]
itype: InputType,
message: String,
placeholder: String,
#[props(!optional)]
Expand All @@ -27,60 +25,45 @@ pub fn SearchInput(props: SearchInputProps) -> Element {
""
};

let input_type = match props.itype {
InputType::Text => "text",
InputType::Search => "text",
InputType::Message => "text",
InputType::Password => "password",
};

let size = match props.size {
ElementSize::Big => "input-wrapper__container--big",
ElementSize::Medium => "input-wrapper__container--medium",
ElementSize::Small => "input-wrapper__container--small",
};

let is_search = if matches!(props.itype, InputType::Search) {
"input__wrapper--search"
} else {
""
};

let mut is_active = use_signal::<bool>(|| false);

rsx!(
section {
class: "input__wrapper {is_search}",
class: "input__wrapper input__wrapper--search",
class: if is_active() {"input__wrapper--active"},
if let Some(value) = props.label {
label { class: "input__label", "{value}" }
}
div {
class: "input-wrapper {size} {input_error_container}",
input {
r#type: "{input_type}",
r#type: "text",
class: "input",
value: props.message,
placeholder: "{props.placeholder}",
oninput: move |event| props.on_input.call(event),
onkeypress: move |event| props.on_keypress.call(event)
}
if matches!(props.itype, InputType::Search) {
IconButton {
class: "button--avatar bg--transparent",
size: props.size,
body: rsx!(
Icon {
icon: Search,
height: 26,
width: 26,
stroke_width: 1.5,
fill: "var(--text-secondary)"
}
),
on_click: move |_| {
is_active.toggle();
IconButton {
class: "button--avatar bg--transparent",
size: props.size,
body: rsx!(
Icon {
icon: Search,
height: 26,
width: 26,
stroke_width: 1.5,
fill: "var(--text-secondary)"
}
),
on_click: move |_| {
is_active.toggle();
}
}
}
Expand Down
Loading

0 comments on commit 2c81bfb

Please sign in to comment.