Skip to content

Commit

Permalink
Merge branch 'main' into fix_doc_rs
Browse files Browse the repository at this point in the history
  • Loading branch information
lpotthast authored Mar 7, 2024
2 parents 9100bac + 426444e commit b278041
Show file tree
Hide file tree
Showing 27 changed files with 286 additions and 450 deletions.
File renamed without changes.
File renamed without changes.
2 changes: 2 additions & 0 deletions leptonic/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ tiptap = ["components", "dep:leptos-tiptap", "dep:leptos-tiptap-build"]

full = ["hooks", "atoms", "components", "clipboard", "tiptap"]

nightly = ["leptos/nightly"]

# Disable the build script when running on docs.rs
docsrs = []

Expand Down
176 changes: 0 additions & 176 deletions leptonic/LICENSE-APACHE

This file was deleted.

23 changes: 0 additions & 23 deletions leptonic/LICENSE-MIT

This file was deleted.

7 changes: 3 additions & 4 deletions leptonic/src/atoms/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,15 @@ use crate::{
prelude::UseButtonReturn,
press::{PressEvent, UsePressInput},
},
prelude::Consumer,
utils::aria::{AriaExpanded, AriaHasPopup},
OptMaybeSignal,
OptMaybeSignal, Out,
};

use super::AttributeExt;

#[component]
pub fn Button(
#[prop(into)] on_press: Consumer<PressEvent>,
#[prop(into)] on_press: Out<PressEvent>,
#[prop(into, optional)] disabled: OptMaybeSignal<bool>,
#[prop(into, optional)] id: Option<AttributeValue>,
#[prop(into, optional)] class: Option<AttributeValue>,
Expand Down Expand Up @@ -47,7 +46,7 @@ pub fn Button(
use_press_input: UsePressInput {
disabled: disabled.or(false),
on_press: Callback::new(move |e| {
on_press.consume(e);
on_press.set(e);
}),
on_press_up: None,
on_press_start: None,
Expand Down
5 changes: 2 additions & 3 deletions leptonic/src/components/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use leptos_router::{State, ToHref};
use crate::{
atoms,
hooks::press::PressEvent,
prelude::Consumer,
utils::aria::{AriaExpanded, AriaHasPopup},
OptMaybeSignal,
OptMaybeSignal, Out,
};

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
Expand Down Expand Up @@ -94,7 +93,7 @@ impl Display for ButtonSize {

#[component]
pub fn Button(
#[prop(into)] on_press: Consumer<PressEvent>,
#[prop(into)] on_press: Out<PressEvent>,
#[prop(into, optional)] variant: OptMaybeSignal<ButtonVariant>,
#[prop(into, optional)] color: OptMaybeSignal<ButtonColor>,
#[prop(into, optional)] size: OptMaybeSignal<ButtonSize>,
Expand Down
6 changes: 3 additions & 3 deletions leptonic/src/components/chip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::fmt::{Display, Formatter};
use leptos::*;
use web_sys::MouseEvent;

use crate::{components::icon::Icon, OptMaybeSignal};
use crate::{components::icon::Icon, OptMaybeSignal, Out};

#[derive(Debug, Default, Clone, Copy, PartialEq, Eq)]
pub enum ChipColor {
Expand Down Expand Up @@ -38,7 +38,7 @@ impl Display for ChipColor {
#[component]
pub fn Chip(
#[prop(into, optional)] color: OptMaybeSignal<ChipColor>,
#[prop(into, optional)] dismissible: Option<Callback<MouseEvent>>,
#[prop(into, optional)] dismissible: Option<Out<MouseEvent>>,
#[prop(into, optional)] id: Option<AttributeValue>,
#[prop(into, optional)] class: Option<AttributeValue>,
#[prop(into, optional)] style: Option<AttributeValue>,
Expand All @@ -49,7 +49,7 @@ pub fn Chip(
{ children() }
{ match dismissible {
Some(callback) => view! {
<Icon class="dismiss" icon=icondata::BsXCircleFill on:click=move |e| callback.call(e) />
<Icon class="dismiss" icon=icondata::BsXCircleFill on:click=move |e| callback.set(e) />
}.into_view(),
None => ().into_view(),
} }
Expand Down
9 changes: 4 additions & 5 deletions leptonic/src/components/color_picker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,13 @@ pub fn ColorPicker(
let saturation = Signal::derive(move || hsv.get().saturation);
let value = Signal::derive(move || hsv.get().value);

let set_hue = Callback::new(move |new_hue| set_hsv.set(hsv.get_untracked().with_hue(new_hue)));
let set_hue = move |new_hue| set_hsv.set(hsv.get_untracked().with_hue(new_hue));

let set_saturation = Callback::new(move |new_saturation| {
let set_saturation = move |new_saturation| {
set_hsv.set(hsv.get_untracked().with_saturation(new_saturation));
});
};

let set_value =
Callback::new(move |new_value| set_hsv.set(hsv.get_untracked().with_value(new_value)));
let set_value = move |new_value| set_hsv.set(hsv.get_untracked().with_value(new_value));

let rgb = Signal::derive(move || RGB8::from(hsv.get()));

Expand Down
5 changes: 3 additions & 2 deletions leptonic/src/components/date_selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use leptos::*;
use crate::{
hooks::calendar::use_calendar,
utils::time::{GuideMode, InMonth},
Out,
};

#[derive(Debug, PartialEq, Eq, Clone, Copy)]
Expand All @@ -16,7 +17,7 @@ enum Selection {
#[allow(clippy::too_many_lines)]
pub fn DateSelector(
value: time::OffsetDateTime,
#[prop(into)] on_change: Callback<time::OffsetDateTime>,
#[prop(into)] on_change: Out<time::OffsetDateTime>,
#[prop(optional)] min: Option<time::OffsetDateTime>,
#[prop(optional)] max: Option<time::OffsetDateTime>,
#[prop(into, optional, default = GuideMode::CalendarFirst.into())] guide_mode: MaybeSignal<
Expand All @@ -25,7 +26,7 @@ pub fn DateSelector(
) -> impl IntoView {
let calendar = use_calendar(value, min, max);

create_effect(move |_| on_change.call(calendar.selected.get()));
create_effect(move |_| on_change.set(calendar.selected.get()));

let (show, set_show) = create_signal(match guide_mode.get() {
GuideMode::CalendarFirst => Selection::Day,
Expand Down
2 changes: 1 addition & 1 deletion leptonic/src/components/datetime_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ pub fn DateTimeInput(
let date_selector = move || {
DateSelector(DateSelectorProps {
value: get.get().unwrap(),
on_change: Callback::new(move |new_value| {
on_change: Out::new_func(move |new_value| {
tracing::info!("Received new value {:?}", new_value);
// Skip propagating a change event when the received value does not deviate from the current value.
if let Some(current) = get.get() {
Expand Down
Loading

0 comments on commit b278041

Please sign in to comment.