Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ cssparser = "0.34"
dominator = "0.5"
futures = "0.3"
futures-signals = "0.3"
futures-signals-component-macro = { version = "0.4.0", features = [
futures-signals-component-macro = { version = "0.5.0", features = [
"dominator",
] }
gloo-timers = { version = "0.3.0", features = ["futures"] }
Expand Down Expand Up @@ -63,3 +63,8 @@ debug = "line-tables-only"

[profile.test]
debug = "line-tables-only"

# Temporary while developing futures-signals-component-macro 0.5.0; drop once
# it is published to crates.io.
[patch.crates-io]
futures-signals-component-macro = { path = "../../gui/futures-signals-component-macro" }
5 changes: 3 additions & 2 deletions crates/dwui/src/components/containers/card.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::theme::prelude::*;
use dominator::{html, Dom};
use dwind::prelude::*;
use futures_signals::signal::{option, SignalExt};
use futures_signals::signal::SignalExt;
use futures_signals_component_macro::component;

/// Dictates the color scheme of the component
Expand All @@ -23,6 +23,7 @@ pub enum CardPadding {
#[component(render_fn = card)]
struct Card {
#[signal]
#[required]
content: Dom,

#[signal]
Expand Down Expand Up @@ -56,6 +57,6 @@ pub fn card(props: CardProps) -> Dom {
.dwclass_signal!("p-4", padding.signal().map(|v| v == CardPadding::Medium))
.dwclass_signal!("p-6", padding.signal().map(|v| v == CardPadding::Large))
.apply_if(apply.is_some(), |b| b.apply(apply.unwrap()))
.child_signal(option(content))
.child_signal(content.map(Some))
})
}
2 changes: 2 additions & 0 deletions crates/dwui/src/components/content/avatar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,13 @@ struct Avatar {
/// Image URL; when `None`, initials derived from `name` are shown
#[signal]
#[default(None)]
#[into]
src: Option<String>,

/// Display name; used for the `alt` text and initials fallback
#[signal]
#[default("".to_string())]
#[into]
name: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/content/divider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use futures_signals_component_macro::component;
struct Divider {
#[signal]
#[default("".to_string())]
#[into]
label: String,
}

Expand Down
5 changes: 3 additions & 2 deletions crates/dwui/src/components/content/heading.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::theme::prelude::*;
use dominator::{html, Dom};
use dwind::prelude::*;
use futures_signals::signal::{option, SignalExt};
use futures_signals::signal::SignalExt;
use futures_signals_component_macro::component;

#[derive(Clone, Copy, Eq, PartialEq)]
Expand Down Expand Up @@ -58,6 +58,7 @@ impl HeadingLevel {
#[component(render_fn = heading)]
struct Heading {
#[signal]
#[required]
content: Dom,

#[signal]
Expand Down Expand Up @@ -85,6 +86,6 @@ pub fn heading(props: HeadingProps) -> Dom {
.dwclass!("w-auto font-semibold m-0")
.dwclass!("dwui-text-on-primary-100 is(.light *):dwui-text-on-primary-900")
.apply_if(apply.is_some(), |b| b.apply(apply.unwrap()))
.child_signal(option(content))
.child_signal(content.map(Some))
})
}
1 change: 1 addition & 0 deletions crates/dwui/src/components/content/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct List {

#[signal]
#[default(None)]
#[into]
selected_index: Option<usize>,

#[default(Box::new(|_|{}))]
Expand Down
5 changes: 3 additions & 2 deletions crates/dwui/src/components/content/virtual_scroll.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ struct VirtualScroll {
#[default(400.0)]
height: f64,

#[default(Box::new(|_| html!("div")))]
#[required]
render_item: dyn Fn(usize) -> Dom + 'static,

#[default(Box::new(|| {}))]
Expand All @@ -50,6 +50,7 @@ struct VirtualScroll {
/// Accessible name for the list
#[signal]
#[default("List".to_string())]
#[into]
aria_label: String,
}

Expand Down Expand Up @@ -174,7 +175,7 @@ pub fn virtual_scroll(props: VirtualScrollProps) -> Dom {
.child(spinner(
SpinnerProps::new()
.size(SpinnerSize::Small)
.label("Loading more".to_string()),
.label("Loading more"),
))
})
})
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Checkbox {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[default(Box::new(|_| {}))]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/date_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct DatePicker {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
3 changes: 3 additions & 0 deletions crates/dwui/src/components/input/number_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,17 @@ struct NumberInput {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
#[default(None)]
#[into]
min: Option<f64>,

#[signal]
#[default(None)]
#[into]
max: Option<f64>,

#[signal]
Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/input/radio_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct RadioGroup {

#[signal]
#[default("".to_string())]
#[into]
value: String,

#[default(Box::new(|_|{}))]
Expand All @@ -37,6 +38,7 @@ struct RadioGroup {
/// Visible group label
#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/select.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct Select {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct Slider {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/switch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct Switch {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[default(Box::new(|_| {}))]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ struct TextArea {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/input/text_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct TextInput {

#[signal]
#[default("".to_string())]
#[into]
label: String,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/accordion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct Accordion {

/// Index of the panel that starts open
#[default(None)]
#[into]
initial_open: Option<usize>,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/widgets/alert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,12 @@ struct Alert {

#[signal]
#[default("".to_string())]
#[into]
title: String,

#[signal]
#[default(None)]
#[into]
content: Option<Dom>,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/badge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ pub enum BadgeVariant {
struct Badge {
#[signal]
#[default(None)]
#[into]
content: Option<Dom>,

#[signal]
Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub enum ButtonSize {
struct Button {
#[signal]
#[default(None)]
#[into]
content: Option<Dom>,
#[default(Box::new(| _: events::Click | {}))]
on_click: dyn Fn(events::Click) -> () + 'static,
Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/widgets/drawer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum DrawerSize {
struct Drawer {
#[signal]
#[default(None)]
#[into]
content: Option<Dom>,

#[signal]
Expand All @@ -52,6 +53,7 @@ struct Drawer {

#[signal]
#[default("Drawer".to_string())]
#[into]
aria_label: String,
}

Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/dropdown_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ struct DropdownMenu {
/// Trigger button text
#[signal]
#[default("Menu".to_string())]
#[into]
label: String,

#[default(Box::new(|_|{}))]
Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/widgets/modal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ pub enum ModalSize {
struct Modal {
#[signal]
#[default(None)]
#[into]
content: Option<Dom>,

#[signal]
Expand All @@ -93,6 +94,7 @@ struct Modal {
/// Accessible name announced by screen readers when the dialog opens
#[signal]
#[default("Dialog".to_string())]
#[into]
aria_label: String,
}

Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/pagination.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ struct Pagination {

#[signal]
#[default("Pagination".to_string())]
#[into]
aria_label: String,
}

Expand Down
3 changes: 3 additions & 0 deletions crates/dwui/src/components/widgets/popover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ pub enum PopoverPosition {
struct Popover {
#[signal]
#[default(None)]
#[into]
anchor: Option<Dom>,

#[signal]
#[default(None)]
#[into]
content: Option<Dom>,

#[signal]
Expand All @@ -44,6 +46,7 @@ struct Popover {

#[signal]
#[default("Popover".to_string())]
#[into]
aria_label: String,
}

Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/progress.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct Progress {
/// Accessible name for the progress bar
#[signal]
#[default("Progress".to_string())]
#[into]
label: String,
}

Expand Down
1 change: 1 addition & 0 deletions crates/dwui/src/components/widgets/spinner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct Spinner {
/// Accessible label announced while loading
#[signal]
#[default("Loading".to_string())]
#[into]
label: String,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/widgets/tab_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ struct TabList {

#[signal]
#[default("".to_string())]
#[into]
selected: String,

#[default(Box::new(|_|{}))]
Expand All @@ -34,6 +35,7 @@ struct TabList {
/// Accessible name for the tab list
#[signal]
#[default("Tabs".to_string())]
#[into]
aria_label: String,
}

Expand Down
2 changes: 2 additions & 0 deletions crates/dwui/src/components/widgets/tooltip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ pub enum TooltipPosition {
struct Tooltip {
#[signal]
#[default(None)]
#[into]
anchor: Option<Dom>,

#[signal]
#[default("".to_string())]
#[into]
text: String,

#[signal]
Expand Down
Loading
Loading