Skip to content

Commit a8eb13b

Browse files
Use stable Rust for Leptos
1 parent 8928507 commit a8eb13b

25 files changed

Lines changed: 387 additions & 374 deletions

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
uses: actions/checkout@v4
2020

2121
- name: Set up Rust toolchain
22-
run: rustup toolchain install nightly --no-self-update --profile default --target wasm32-unknown-unknown
22+
run: rustup toolchain install stable --no-self-update --profile default --target wasm32-unknown-unknown
2323

2424
- name: Set up Rust cache
2525
uses: swatinem/rust-cache@v2

packages/leptos/example/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ version.workspace = true
1313
console_error_panic_hook.workspace = true
1414
console_log.workspace = true
1515
floating-ui-leptos = { path = ".." }
16-
leptos = { workspace = true, features = ["csr", "nightly"] }
16+
leptos = { workspace = true, features = ["csr"] }
1717
log.workspace = true
1818
wasm-bindgen.workspace = true
1919
web-sys.workspace = true

packages/leptos/example/src/app.rs

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -40,22 +40,29 @@ pub fn App() -> impl IntoView {
4040
.while_elements_mounted_auto_update(),
4141
);
4242

43-
let static_side = move || placement().side().opposite();
44-
let arrow_data = move || -> Option<ArrowData> { middleware_data().get_as(ARROW_NAME) };
45-
let arrow_x =
46-
move || arrow_data().and_then(|arrow_data| arrow_data.x.map(|x| format!("{}px", x)));
47-
let arrow_y =
48-
move || arrow_data().and_then(|arrow_data| arrow_data.y.map(|y| format!("{}px", y)));
43+
let static_side = Signal::derive(move || placement.get().side().opposite());
44+
let arrow_data =
45+
Signal::derive(move || -> Option<ArrowData> { middleware_data.get().get_as(ARROW_NAME) });
46+
let arrow_x = Signal::derive(move || {
47+
arrow_data
48+
.get()
49+
.and_then(|arrow_data| arrow_data.x.map(|x| format!("{}px", x)))
50+
});
51+
let arrow_y = Signal::derive(move || {
52+
arrow_data
53+
.get()
54+
.and_then(|arrow_data| arrow_data.y.map(|y| format!("{}px", y)))
55+
});
4956

5057
view! {
5158
<button
5259
_ref=reference_ref
5360
id="button"
5461
aria-describedby="tooltip"
55-
on:mouseenter=move |_| set_open(true)
56-
on:mouseleave=move |_| set_open(false)
57-
on:focus=move |_| set_open(true)
58-
on:blur=move |_| set_open(false)
62+
on:mouseenter=move |_| set_open.set(true)
63+
on:mouseleave=move |_| set_open.set(false)
64+
on:focus=move |_| set_open.set(true)
65+
on:blur=move |_| set_open.set(false)
5966
>
6067
My button
6168
</button>
@@ -64,33 +71,33 @@ pub fn App() -> impl IntoView {
6471
_ref=floating_ref
6572
id="tooltip"
6673
role="tooltip"
67-
style:display=move || match open() {
74+
style:display=move || match open.get() {
6875
true => "block",
6976
false => "none"
7077
}
71-
style:position=move || floating_styles().style_position()
72-
style:top=move || floating_styles().style_top()
73-
style:left=move || floating_styles().style_left()
74-
style:transform=move || floating_styles().style_transform()
75-
style:will-change=move || floating_styles().style_will_change()
78+
style:position=move || floating_styles.get().style_position()
79+
style:top=move || floating_styles.get().style_top()
80+
style:left=move || floating_styles.get().style_left()
81+
style:transform=move || floating_styles.get().style_transform()
82+
style:will-change=move || floating_styles.get().style_will_change()
7683
>
7784
My tooltip with more content
7885
<div
7986
_ref=arrow_ref
8087
id="arrow"
81-
style:left=move || match static_side() {
88+
style:left=move || match static_side.get() {
8289
Side::Left => Some("-4px".into()),
83-
_ => arrow_x()
90+
_ => arrow_x.get()
8491
}
85-
style:top=move || match static_side() {
92+
style:top=move || match static_side.get() {
8693
Side::Top => Some("-4px".into()),
87-
_ => arrow_y()
94+
_ => arrow_y.get()
8895
}
89-
style:right=move || match static_side() {
96+
style:right=move || match static_side.get() {
9097
Side::Right => Some("-4px"),
9198
_ => None
9299
}
93-
style:bottom=move || match static_side() {
100+
style:bottom=move || match static_side.get() {
94101
Side::Bottom => Some("-4px"),
95102
_ => None
96103
}

packages/leptos/tests/visual/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ console_error_panic_hook.workspace = true
1414
console_log.workspace = true
1515
convert_case = "0.6.0"
1616
floating-ui-leptos = { path = "../.." }
17-
leptos = { workspace = true, features = ["csr", "nightly"] }
17+
leptos = { workspace = true, features = ["csr"] }
1818
leptos_router = { workspace = true, features = ["csr"] }
1919
log.workspace = true
2020
wasm-bindgen.workspace = true

packages/leptos/tests/visual/src/spec/arrow.rs

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn Arrow() -> impl IntoView {
4242
.placement(placement.into())
4343
.while_elements_mounted_auto_update()
4444
.middleware(MaybeProp::derive(move || {
45-
let mut middleware: MiddlewareVec = match add_offset() {
45+
let mut middleware: MiddlewareVec = match add_offset.get() {
4646
true => vec![Box::new(Offset::new(OffsetOptions::Value(20.0)))],
4747
false => vec![],
4848
};
@@ -52,18 +52,18 @@ pub fn Arrow() -> impl IntoView {
5252
DetectOverflowOptions::default().padding(Padding::All(10.0)),
5353
))),
5454
Box::new(Arrow::new(
55-
ArrowOptions::new(arrow_ref).padding(Padding::All(padding() as f64)),
55+
ArrowOptions::new(arrow_ref).padding(Padding::All(padding.get() as f64)),
5656
)),
5757
]);
5858

5959
Some(middleware)
6060
})),
6161
);
6262

63-
let static_side = move || resultant_placement().side().opposite();
63+
let static_side = move || resultant_placement.get().side().opposite();
6464

6565
let arrow_data = move || {
66-
let arrow_data: Option<ArrowData> = middleware_data().get_as(ARROW_NAME);
66+
let arrow_data: Option<ArrowData> = middleware_data.get().get_as(ARROW_NAME);
6767
arrow_data
6868
};
6969
let arrow_x = move || arrow_data().and_then(|arrow_data| arrow_data.x);
@@ -92,12 +92,12 @@ pub fn Arrow() -> impl IntoView {
9292

9393
let floating_view = move || {
9494
let base = view! {
95-
{move || match center_offset() {
95+
{move || match center_offset.get() {
9696
true => center_offset_value().map_or("".into(), |center_offset_value| center_offset_value.to_string()),
9797
false => "Floating".into()
9898
}}
9999

100-
{move || match svg() {
100+
{move || match svg.get() {
101101
true => view!{
102102
<svg
103103
class="arrow"
@@ -157,17 +157,17 @@ pub fn Arrow() -> impl IntoView {
157157
}}
158158
};
159159

160-
match nested() {
160+
match nested.get() {
161161
true => view! {
162162
<div
163163
_ref=floating_ref
164-
style:position=move || floating_styles().style_position()
165-
style:top=move || floating_styles().style_top()
166-
style:left=move || floating_styles().style_left()
167-
style:transform=move || floating_styles().style_transform()
168-
style:will-change=move || floating_styles().style_will_change()
169-
style:width=move || format!("{}px", floating_size())
170-
style:height=move || format!("{}px", floating_size())
164+
style:position=move || floating_styles.get().style_position()
165+
style:top=move || floating_styles.get().style_top()
166+
style:left=move || floating_styles.get().style_left()
167+
style:transform=move || floating_styles.get().style_transform()
168+
style:will-change=move || floating_styles.get().style_will_change()
169+
style:width=move || format!("{}px", floating_size.get())
170+
style:height=move || format!("{}px", floating_size.get())
171171
>
172172
<div class="floating" style:position="relative" style:border="5px solid black">
173173
{base}
@@ -178,13 +178,13 @@ pub fn Arrow() -> impl IntoView {
178178
<div
179179
_ref=floating_ref
180180
class="floating"
181-
style:position=move || floating_styles().style_position()
182-
style:top=move || floating_styles().style_top()
183-
style:left=move || floating_styles().style_left()
184-
style:transform=move || floating_styles().style_transform()
185-
style:will-change=move || floating_styles().style_will_change()
186-
style:width=move || format!("{}px", floating_size())
187-
style:height=move || format!("{}px", floating_size())
181+
style:position=move || floating_styles.get().style_position()
182+
style:top=move || floating_styles.get().style_top()
183+
style:left=move || floating_styles.get().style_left()
184+
style:transform=move || floating_styles.get().style_transform()
185+
style:will-change=move || floating_styles.get().style_will_change()
186+
style:width=move || format!("{}px", floating_size.get())
187+
style:height=move || format!("{}px", floating_size.get())
188188
>
189189
{base}
190190
</div>
@@ -195,16 +195,16 @@ pub fn Arrow() -> impl IntoView {
195195
view! {
196196
<h1>Arrow</h1>
197197
<p></p>
198-
<div class="container" style:will-change=move || match svg() {
198+
<div class="container" style:will-change=move || match svg.get() {
199199
true => "transform",
200200
false => "",
201201
}>
202202
<div _ref=scroll_ref class="scroll" data-x="" style:position="relative">
203203
<div
204204
_ref=reference_ref
205205
class="reference"
206-
style:width=move || format!("{}px", reference_size())
207-
style:height=move || format!("{}px", reference_size())
206+
style:width=move || format!("{}px", reference_size.get())
207+
style:height=move || format!("{}px", reference_size.get())
208208
>
209209
Reference
210210
</div>
@@ -220,11 +220,11 @@ pub fn Arrow() -> impl IntoView {
220220
children=move |size| view! {
221221
<button
222222
data-testid=format!("reference-{size}")
223-
style:background-color=move || match reference_size() == size {
223+
style:background-color=move || match reference_size.get() == size {
224224
true => "black",
225225
false => ""
226226
}
227-
on:click=move |_| set_reference_size(size)
227+
on:click=move |_| set_reference_size.set(size)
228228
>
229229
{format!("{size}")}
230230
</button>
@@ -240,11 +240,11 @@ pub fn Arrow() -> impl IntoView {
240240
children=move |size| view! {
241241
<button
242242
data-testid=format!("floating-{size}")
243-
style:background-color=move || match floating_size() == size {
243+
style:background-color=move || match floating_size.get() == size {
244244
true => "black",
245245
false => ""
246246
}
247-
on:click=move |_| set_floating_size(size)
247+
on:click=move |_| set_floating_size.set(size)
248248
>
249249
{format!("{size}")}
250250
</button>
@@ -262,12 +262,12 @@ pub fn Arrow() -> impl IntoView {
262262
view! {
263263
<button
264264
data-testid=format!("arrow-padding-{size}")
265-
style:background-color=move || match padding() == size {
265+
style:background-color=move || match padding.get() == size {
266266
true => "black",
267267
false => ""
268268
}
269269
on:click=move |_| {
270-
set_padding(size);
270+
set_padding.set(size);
271271
// Match React test behaviour
272272
padding_update_scroll();
273273
}
@@ -289,12 +289,12 @@ pub fn Arrow() -> impl IntoView {
289289
view! {
290290
<button
291291
data-testid=format!("add-offset-{}", value)
292-
style:background-color=move || match add_offset() == value {
292+
style:background-color=move || match add_offset.get() == value {
293293
true => "black",
294294
false => ""
295295
}
296296
on:click=move |_| {
297-
set_add_offset(value);
297+
set_add_offset.set(value);
298298
// Match React test behaviour
299299
add_offset_update_scroll();
300300
}
@@ -316,12 +316,12 @@ pub fn Arrow() -> impl IntoView {
316316
view! {
317317
<button
318318
data-testid=format!("Placement{:?}", local_placement).to_case(Case::Kebab)
319-
style:background-color=move || match placement() == local_placement {
319+
style:background-color=move || match placement.get() == local_placement {
320320
true => "black",
321321
false => ""
322322
}
323323
on:click=move |_| {
324-
set_placement(local_placement);
324+
set_placement.set(local_placement);
325325
// Match React test behaviour
326326
placement_update_scroll();
327327
}
@@ -343,12 +343,12 @@ pub fn Arrow() -> impl IntoView {
343343
view! {
344344
<button
345345
data-testid=format!("svg-{}", value)
346-
style:background-color=move || match svg() == value {
346+
style:background-color=move || match svg.get() == value {
347347
true => "black",
348348
false => ""
349349
}
350350
on:click=move |_| {
351-
set_svg(value);
351+
set_svg.set(value);
352352
svg_update();
353353
}
354354
>
@@ -369,12 +369,12 @@ pub fn Arrow() -> impl IntoView {
369369
view! {
370370
<button
371371
data-testid=format!("nested-{}", value)
372-
style:background-color=move || match nested() == value {
372+
style:background-color=move || match nested.get() == value {
373373
true => "black",
374374
false => ""
375375
}
376376
on:click=move |_| {
377-
set_nested(value);
377+
set_nested.set(value);
378378
nested_update();
379379
}
380380
>
@@ -395,22 +395,22 @@ pub fn Arrow() -> impl IntoView {
395395
view! {
396396
<button
397397
data-testid=format!("centerOffset-{}", value)
398-
style:background-color=move || match center_offset() == value {
398+
style:background-color=move || match center_offset.get() == value {
399399
true => "black",
400400
false => ""
401401
}
402402
on:click=move |_| {
403-
set_center_offset(value);
403+
set_center_offset.set(value);
404404
if value {
405-
set_reference_size(25);
406-
set_floating_size(125);
407-
set_placement(Placement::LeftEnd);
408-
set_padding(25);
405+
set_reference_size.set(25);
406+
set_floating_size.set(125);
407+
set_placement.set(Placement::LeftEnd);
408+
set_padding.set(25);
409409
} else {
410-
set_reference_size(125);
411-
set_floating_size(75);
412-
set_placement(Placement::Bottom);
413-
set_padding(0);
410+
set_reference_size.set(125);
411+
set_floating_size.set(75);
412+
set_placement.set(Placement::Bottom);
413+
set_padding.set(0);
414414
}
415415
// Match React test behaviour
416416
center_offset_update_scroll();

0 commit comments

Comments
 (0)