Merge branch 'main' into feat/date-component

# Conflicts:
#	src/app.rs
#	src/common/mod.rs
#	src/components/mod.rs
#	src/pages/api/scholarships.rs
#	src/pages/home_page.rs
#	src/pages/mod.rs
#	src/pages/scholarship_info.rs
This commit is contained in:
alphafetus committed 2026-01-14 11:24:27 -05:00
commit 26ee1cf7b4
50 files changed
+3428 -2237

No files matched your search

+14
View File
@@ -0,0 +1,14 @@
use leptos_animate::animations::classes::{In, Out};
pub fn pop_in_out() -> (In, Out) {
(
In::default()
.source("opacity-0 -translate-y-2 scale-90")
.active("transition-all duration-150 transform-gpu")
.target("opacity-100 translate-y-0 scale-100"),
Out::default()
.source("opacity-100 translate-y-0 scale-100")
.active("transition-all duration-150 transform-gpu")
.target("opacity-0 -translate-y-2 scale-90"),
)
}
+1
View File
@@ -23,6 +23,7 @@ pub struct ComparisonData {
}
impl ComparisonData {
#[allow(unused)]
pub fn new(
id: impl Into<String>,
member: impl Into<String>,
-1
View File
@@ -3,7 +3,6 @@ mod lists;
mod number;
mod text;
mod traits;
mod utils;
pub use self::{base::*, lists::*, number::*, text::*, traits::*};
-28
View File
@@ -1,28 +0,0 @@
use crate::common::ValueType;
/// This function is a work in progress. It's designed to flatten a list of maps by using the
/// given key and verifier function, however it currently doesn't work and just needs to be
/// planned out a little more.
fn flatten_map_helper<F>(
list: &Vec<ValueType>,
key: &String,
verifier: F,
) -> Result<Vec<ValueType>, String>
where
F: Fn(&ValueType) -> Option<&ValueType>,
{
let mut out = Vec::new();
for item in list {
let map = match item {
ValueType::Map(Some(map)) => map,
_ => return Err("Expected a map".to_owned()),
};
// Get the key, and verify that the value is the correct type. If so, push it.
if let Some(value) = map.get(key).and_then(|v| verifier(v)) {
out.push(value.clone());
}
}
Ok(out)
}
+34 -37
View File
@@ -1,8 +1,6 @@
use crate::common::ValueType;
use crate::components::{CheckboxList, OutlinedTextField, RadioList, Row, Select};
use leptos::either::EitherOf5;
use leptos::prelude::RwSignal;
use leptos::{IntoView, view};
use crate::components::{CheckboxList, OutlinedTextField, RadioList, Row, Select, TextFieldType};
use leptos::prelude::*;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@@ -11,85 +9,82 @@ use std::collections::HashMap;
pub enum InputType {
/// Represents a text input. Requires a `String` key, `String` label, and `String` placeholder.
/// The entered value will be returned as a single `String` value.
Text(String, String, String),
Text(String, String, String, bool),
/// Represents a number input. Requires a `String` key, `String` label, and a `String` placeholder.
/// The entered value will be returned as a `String`, and will be parseable into any number type
/// (i.e. an `i32`, `i64`, etc)
Number(String, String, String),
Number(String, String, String, bool),
/// Represents a radio input. Requires a `String` key, `String` label, and a series of `String`
/// options. The selected value will be returned as a `String`.
Radio(String, String, Vec<String>),
Radio(String, String, Vec<String>, bool),
/// Represents a checkbox input. Requires a `String` key, `String` label, and a series of `String`
/// options. The selected values will be returned as a `Vec<String>`.
Checkbox(String, String, Vec<String>),
Checkbox(String, String, Vec<String>, bool),
/// Represents a dropdown input. Requires a `String` key, `String` label, and a series
/// of `String` options. The selected value will be returned as a `String`.
Select(String, String, Vec<String>),
Select(String, String, Vec<String>, bool),
}
impl InputType {
pub fn into_view(self, data_map: RwSignal<HashMap<String, ValueType>>) -> impl IntoView {
view! {
{match self {
InputType::Text(member, label, placeholder) =>
EitherOf5::A(view! {
InputType::Text(member, label, placeholder, required) =>
view! {
<Row>
<OutlinedTextField
label = label.clone()
placeholder = placeholder.clone()
data_member = member.clone()
data_map = data_map
required = required
/>
</Row>
}),
InputType::Number(member, label, placeholder) =>
EitherOf5::B(view! {
}.into_any(),
InputType::Number(member, label, placeholder, required) =>
view! {
<OutlinedTextField
label = label.clone()
placeholder = placeholder.clone()
data_member = member.clone()
data_map = data_map
input_type = "number"
input_type = TextFieldType::Number
required = required
/>
}),
InputType::Checkbox(member, label, options) =>
EitherOf5::C(view! {
}.into_any(),
InputType::Checkbox(member, label, options, required) =>
view! {
<CheckboxList
label = label.clone()
items = options.clone()
data_member = member.clone()
data_map = data_map
required = required
/>
}),
InputType::Radio(member, label, options) =>
EitherOf5::D(view! {
}.into_any(),
InputType::Radio(member, label, options, required) =>
view! {
<RadioList
label = label.clone()
data_member = member.clone()
data_map = data_map
items = options.clone()
required = required
/>
}),
InputType::Select(member, label, options) =>
EitherOf5::E(view! {
}.into_any(),
InputType::Select(member, label, options, required) =>
view! {
<Select
label = label.clone()
value_list = options.clone()
data_member = member.clone()
data_map = data_map
required = required
/>
})
}.into_any()
}}
}
}
pub fn into_view_rows(self, data_map: RwSignal<HashMap<String, ValueType>>) -> impl IntoView {
view! {
<Row>
{self.into_view(data_map)}
</Row>
}
}
}
/// Shorthand macro for creating `InputType` enums.
@@ -104,19 +99,21 @@ impl InputType {
/// ```
#[macro_export]
macro_rules! input {
($variant:ident, $key:expr, $label:expr, [$($option:expr),* $(,)?]) => {
($variant:ident, $key:expr, $label:expr, $required:expr, [$($option:expr),* $(,)?]) => {
$crate::common::InputType::$variant(
$key.to_string(),
$label.to_string(),
vec![$($option.to_string()), *]
vec![$($option.to_string()), *],
$required
)
};
($variant:ident, $key:expr, $label:expr, $placeholder:expr) => {
($variant:ident, $key:expr, $label:expr, $required:expr, $placeholder:expr) => {
$crate::common::InputType::$variant(
$key.to_string(),
$label.to_string(),
$placeholder.to_string()
$placeholder.to_string(),
$required
)
};
}
+1
View File
@@ -6,6 +6,7 @@ mod form_schema;
mod submit_status;
mod user;
mod value_type;
pub mod animations;
pub use self::{
comparison::*, date_info::*, expandable_info::*, form_params::*, form_schema::*,
+1 -1
View File
@@ -3,5 +3,5 @@ pub enum SubmitStatus {
Idle,
Sending,
Success,
Error(String),
Error(()),
}
+28
View File
@@ -113,3 +113,31 @@ impl Display for ValueType {
write!(f, "{}", str)
}
}
#[cfg(feature = "ssr")]
use aws_sdk_dynamodb::types::AttributeValue;
#[cfg(feature = "ssr")]
impl From<&AttributeValue> for ValueType {
fn from(attr: &AttributeValue) -> Self {
match attr {
AttributeValue::S(s) => ValueType::String(Some(s.clone())),
AttributeValue::N(n) => ValueType::Number(Some(n.clone())),
AttributeValue::L(l) => ValueType::List(Some(l.iter().map(|v| v.into()).collect())),
AttributeValue::M(m) => ValueType::Map(Some(m.iter().map(|(k, v)| (k.clone(), v.into())).collect())),
_ => ValueType::default(),
}
}
}
#[cfg(feature = "ssr")]
impl Into<AttributeValue> for ValueType {
fn into(self) -> AttributeValue {
match self {
ValueType::String(s) => AttributeValue::S(s.unwrap_or_default()),
ValueType::Number(n) => AttributeValue::N(n.unwrap_or_default()),
ValueType::List(l) => AttributeValue::L(l.unwrap_or_default().into_iter().map(|v| v.into()).collect()),
ValueType::Map(m) => AttributeValue::M(m.unwrap_or_default().into_iter().map(|(k, v)| (k, v.into())).collect()),
}
}
}