Skip to content

Commit 2be2160

Browse files
authored
Feat/thaw components (#146)
* feat: extract utils as the library * fix: thaw_components dependencies
1 parent 9bf0f7d commit 2be2160

File tree

37 files changed

+89
-77
lines changed

37 files changed

+89
-77
lines changed

Cargo.toml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
[workspace]
22
resolver = "2"
3-
members = ["thaw", "thaw_utils", "demo", "demo_markdown"]
3+
members = ["thaw", "thaw_components", "thaw_utils", "demo", "demo_markdown"]
44
exclude = ["examples"]
55

66
[workspace.dependencies]
77
thaw = { version = "0.2.3", path = "./thaw" }
8+
thaw_components = { version = "0.0.1", path = "./thaw_components" }
89
thaw_utils = { version = "0.0.1", path = "./thaw_utils" }

thaw/Cargo.toml

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ license = "MIT"
1414

1515
[dependencies]
1616
leptos = { version = "0.6.9" }
17+
thaw_components = { workspace = true }
1718
thaw_utils = { workspace = true }
1819
web-sys = { version = "0.3.69", features = [
1920
"DomRect",
@@ -30,6 +31,6 @@ chrono = "0.4.35"
3031
palette = "0.7.5"
3132

3233
[features]
33-
csr = ["leptos/csr", "thaw_utils/csr"]
34-
ssr = ["leptos/ssr", "thaw_utils/ssr"]
35-
hydrate = ["leptos/hydrate", "thaw_utils/hydrate"]
34+
csr = ["leptos/csr", "thaw_components/csr", "thaw_utils/csr"]
35+
ssr = ["leptos/ssr", "thaw_components/ssr", "thaw_utils/ssr"]
36+
hydrate = ["leptos/hydrate", "thaw_components/hydrate", "thaw_utils/hydrate"]

thaw/src/alert/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ mod theme;
22

33
pub use theme::AlertTheme;
44

5-
use crate::{components::OptionComp, theme::use_theme, Icon, Theme};
5+
use crate::{theme::use_theme, Icon, Theme};
66
use leptos::*;
7+
use thaw_components::OptionComp;
78
use thaw_utils::{class_list, mount_style, OptionalProp};
89

910
#[derive(Clone)]

thaw/src/auto_complete/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,9 @@ mod theme;
22

33
pub use theme::AutoCompleteTheme;
44

5-
use crate::{
6-
components::{Binder, CSSTransition, Follower, FollowerPlacement, FollowerWidth},
7-
use_theme, ComponentRef, Input, InputPrefix, InputRef, InputSuffix, Theme,
8-
};
5+
use crate::{use_theme, ComponentRef, Input, InputPrefix, InputRef, InputSuffix, Theme};
96
use leptos::*;
7+
use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement, FollowerWidth};
108
use thaw_utils::{class_list, mount_style, Model, OptionalProp, StoredMaybeSignal};
119

1210
#[derive(Clone, PartialEq)]

thaw/src/avatar/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ mod theme;
22

33
pub use theme::AvatarTheme;
44

5-
use crate::{components::OptionComp, use_theme, Theme};
5+
use crate::{use_theme, Theme};
66
use leptos::*;
7+
use thaw_components::OptionComp;
78
use thaw_utils::{class_list, mount_style, OptionalProp};
89

910
#[component]

thaw/src/button/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,9 @@ mod theme;
44
pub use button_group::ButtonGroup;
55
pub use theme::ButtonTheme;
66

7-
use crate::{
8-
components::{OptionComp, Wave, WaveRef},
9-
icon::Icon,
10-
theme::*,
11-
};
7+
use crate::{icon::Icon, theme::*};
128
use leptos::*;
9+
use thaw_components::{OptionComp, Wave, WaveRef};
1310
use thaw_utils::{class_list, mount_style, ComponentRef, OptionalMaybeSignal, OptionalProp};
1411

1512
#[derive(Default, PartialEq, Clone, Copy)]

thaw/src/card/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
use crate::{components::*, use_theme, Theme};
1+
use crate::{use_theme, Theme};
22
use leptos::*;
3+
use thaw_components::*;
34
use thaw_utils::{class_list, mount_style, OptionalProp};
45

56
#[slot]

thaw/src/checkbox/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ mod checkbox_item;
44
pub use checkbox_group::CheckboxGroup;
55
pub use checkbox_item::CheckboxItem;
66

7-
use crate::{components::*, icon::*, theme::use_theme, Theme};
7+
use crate::{icon::*, theme::use_theme, Theme};
88
use leptos::*;
9+
use thaw_components::*;
910
use thaw_utils::{class_list, mount_style, Model, OptionalProp};
1011

1112
#[component]

thaw/src/collapse/collapse_item.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use super::use_collapse;
2-
use crate::{components::CSSTransition, Icon};
2+
use crate::Icon;
33
use leptos::*;
4+
use thaw_components::CSSTransition;
45
use thaw_utils::{class_list, OptionalProp, StoredMaybeSignal};
56

67
#[component]

thaw/src/color_picker/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ mod theme;
44
pub use color::*;
55
pub use theme::ColorPickerTheme;
66

7-
use crate::{
8-
components::{Binder, CSSTransition, Follower, FollowerPlacement},
9-
use_theme, Theme,
10-
};
7+
use crate::{use_theme, Theme};
118
use leptos::leptos_dom::helpers::WindowListenerHandle;
129
use leptos::*;
1310
use palette::{Hsv, IntoColor, Srgb};
11+
use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement};
1412
use thaw_utils::{class_list, mount_style, Model, OptionalProp};
1513

1614
#[component]

thaw/src/components/mod.rs

-19
This file was deleted.

thaw/src/date_picker/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ mod theme;
33

44
pub use theme::DatePickerTheme;
55

6-
use crate::{
7-
components::{Binder, Follower, FollowerPlacement},
8-
Icon, Input, InputSuffix, SignalWatch,
9-
};
6+
use crate::{Icon, Input, InputSuffix, SignalWatch};
107
use chrono::NaiveDate;
118
use leptos::*;
129
use panel::{Panel, PanelRef};
10+
use thaw_components::{Binder, Follower, FollowerPlacement};
1311
use thaw_utils::{mount_style, now_date, ComponentRef, Model, OptionalProp};
1412

1513
#[component]

thaw/src/date_picker/panel/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ mod date_panel;
22
mod month_panel;
33
mod year_panel;
44

5-
use crate::{components::CSSTransition, use_theme, Theme};
5+
use crate::{use_theme, Theme};
66
use chrono::NaiveDate;
77
use date_panel::DatePanel;
88
use leptos::*;
99
use month_panel::MonthPanel;
10+
use thaw_components::CSSTransition;
1011
use thaw_utils::{now_date, ComponentRef};
1112
use year_panel::YearPanel;
1213

thaw/src/drawer/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::{
2-
components::{CSSTransition, Teleport},
3-
Card,
4-
};
1+
use crate::Card;
52
use leptos::*;
3+
use thaw_components::{CSSTransition, Teleport};
64
use thaw_utils::{class_list, mount_style, use_lock_html_scroll, Model, OptionalProp};
75

86
#[component]

thaw/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ mod checkbox;
1010
mod code;
1111
mod collapse;
1212
mod color_picker;
13-
mod components;
1413
mod date_picker;
1514
mod divider;
1615
mod drawer;

thaw/src/loading_bar/loading_bar_provider.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use super::{LoadingBar, LoadingBarRef};
2-
use crate::components::Teleport;
32
use leptos::*;
3+
use thaw_components::Teleport;
44
use thaw_utils::ComponentRef;
55

66
#[component]

thaw/src/message/message_provider.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::{message_environment::MessageEnvironment, MessageVariant};
2-
use crate::components::Teleport;
32
use leptos::*;
43
use std::time::Duration;
4+
use thaw_components::Teleport;
55
use thaw_utils::{class_list, mount_style};
66
use uuid::Uuid;
77

thaw/src/message/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,9 @@ mod theme;
55
pub use message_provider::*;
66
pub use theme::MessageTheme;
77

8-
use crate::{
9-
components::{If, Then},
10-
theme::use_theme,
11-
Icon, Theme,
12-
};
8+
use crate::{theme::use_theme, Icon, Theme};
139
use leptos::*;
10+
use thaw_components::{If, Then};
1411
use uuid::Uuid;
1512

1613
#[derive(Default, Clone)]

thaw/src/mobile/nav_bar/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ mod theme;
22

33
pub use theme::NavBarTheme;
44

5-
use crate::{components::*, icon::*, use_theme, Theme};
5+
use crate::{icon::*, use_theme, Theme};
66
use leptos::*;
7+
use thaw_components::*;
78
use thaw_utils::{class_list, mount_style, OptionalProp};
89

910
#[slot]

thaw/src/mobile/tabbar/tabbar_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use super::use_tabbar;
2-
use crate::components::*;
32
use crate::{icon::Icon, theme::use_theme, Theme};
43
use leptos::*;
4+
use thaw_components::*;
55
use thaw_utils::{mount_style, StoredMaybeSignal};
66

77
#[component]

thaw/src/modal/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
use crate::{
2-
components::{CSSTransition, OptionComp, Teleport},
3-
Card, CardFooter, CardHeader, CardHeaderExtra, Icon,
4-
};
1+
use crate::{Card, CardFooter, CardHeader, CardHeaderExtra, Icon};
52
use leptos::*;
3+
use thaw_components::{CSSTransition, OptionComp, Teleport};
64
use thaw_utils::{mount_style, use_click_position, Model};
75

86
#[slot]

thaw/src/popover/mod.rs

+2-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@ mod theme;
22

33
pub use theme::PopoverTheme;
44

5-
use crate::{
6-
components::{Binder, CSSTransition, Follower, FollowerPlacement},
7-
use_theme, Theme,
8-
};
5+
use crate::{use_theme, Theme};
96
use leptos::{leptos_dom::helpers::TimeoutHandle, *};
107
use std::time::Duration;
8+
use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement};
119
use thaw_utils::{add_event_listener, class_list, mount_style, OptionalProp};
1210

1311
#[slot]

thaw/src/select/mod.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,10 @@ mod theme;
22

33
pub use theme::SelectTheme;
44

5-
use crate::{
6-
components::{Binder, CSSTransition, Follower, FollowerPlacement, FollowerWidth},
7-
theme::use_theme,
8-
Theme,
9-
};
5+
use crate::{theme::use_theme, Theme};
106
use leptos::*;
117
use std::hash::Hash;
8+
use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement, FollowerWidth};
129
use thaw_utils::{class_list, mount_style, Model, OptionalProp};
1310

1411
#[derive(Clone, PartialEq, Eq, Hash)]

thaw/src/slider/mod.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ mod theme;
44
pub use slider_label::SliderLabel;
55
pub use theme::SliderTheme;
66

7-
use crate::{components::OptionComp, theme::use_theme, Theme};
7+
use crate::{theme::use_theme, Theme};
88
use leptos::*;
9+
use thaw_components::OptionComp;
910
use thaw_utils::{class_list, mount_style, Model, OptionalProp};
1011
use web_sys::DomRect;
1112

thaw/src/time_picker/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ mod theme;
33
pub use theme::TimePickerTheme;
44

55
use crate::{
6-
components::{Binder, CSSTransition, Follower, FollowerPlacement},
76
use_theme, Button, ButtonSize, ButtonVariant, Icon, Input, InputSuffix, SignalWatch, Theme,
87
};
98
use chrono::{Local, NaiveTime, Timelike};
109
use leptos::*;
10+
use thaw_components::{Binder, CSSTransition, Follower, FollowerPlacement};
1111
use thaw_utils::{mount_style, ComponentRef, Model, OptionalProp};
1212

1313
#[component]

thaw_components/Cargo.toml

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[package]
2+
name = "thaw_components"
3+
version = "0.0.1"
4+
edition = "2021"
5+
keywords = ["leptos", "thaw", "components"]
6+
readme = "../README.md"
7+
authors = ["luoxiaozero"]
8+
description = "Shared Thaw internal components"
9+
repository = "https://github.com/thaw-ui/thaw"
10+
license = "MIT"
11+
12+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
13+
14+
[dependencies]
15+
leptos = { version = "0.6.9" }
16+
thaw_utils = { workspace = true }
17+
web-sys = { version = "0.3.69", features = ["DomRect"] }
18+
cfg-if = "1.0.0"
19+
20+
[features]
21+
csr = ["leptos/csr"]
22+
ssr = ["leptos/ssr"]
23+
hydrate = ["leptos/hydrate"]
File renamed without changes.

thaw/src/components/binder/mod.rs thaw_components/src/binder/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ mod get_placement_style;
22

33
pub use get_placement_style::FollowerPlacement;
44

5-
use crate::components::Teleport;
5+
use crate::Teleport;
66
use get_placement_style::{get_follower_placement_offset, FollowerPlacementOffset};
77
use leptos::{
88
html::{AnyElement, ElementDescriptor, ToHtmlElement},
File renamed without changes.

thaw_components/src/lib.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
mod binder;
2+
mod css_transition;
3+
mod if_comp;
4+
mod option_comp;
5+
mod teleport;
6+
mod wave;
7+
8+
pub use binder::{Binder, Follower, FollowerPlacement, FollowerWidth};
9+
pub use css_transition::CSSTransition;
10+
pub use if_comp::{ElseIf, If, Then};
11+
pub use option_comp::OptionComp;
12+
pub use teleport::Teleport;
13+
pub use wave::{Wave, WaveRef};
14+
15+
use leptos::*;
16+
17+
#[slot]
18+
pub struct Fallback {
19+
children: ChildrenFn,
20+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

thaw_utils/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ mod optional_prop;
66
mod signals;
77
mod time;
88

9-
pub use event_listener::*;
9+
pub use event_listener::{add_event_listener, EventListenerHandle};
1010
pub use hooks::{use_click_position, use_lock_html_scroll};
1111
pub use mount_style::mount_style;
1212
pub use optional_prop::OptionalProp;

0 commit comments

Comments
 (0)