Skip to content

Commit

Permalink
Add Playwright test script and arrow visual test
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielleHuisman committed Mar 31, 2024
1 parent 3bb08f7 commit 65752af
Show file tree
Hide file tree
Showing 10 changed files with 585 additions and 17 deletions.
13 changes: 10 additions & 3 deletions packages/dom/src/middleware.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use floating_ui_core::middleware::{
Arrow as CoreArrow, AutoPlacement as CoreAutoPlacement, Flip as CoreFlip, Offset as CoreOffset,
Shift as CoreShift,
Arrow as CoreArrow, AutoPlacement as CoreAutoPlacement, Flip as CoreFlip, Hide as CoreHide,
Offset as CoreOffset, Shift as CoreShift,
};
use web_sys::{Element, Window};

pub use floating_ui_core::middleware::{
ArrowData, ArrowOptions, AutoPlacementData, AutoPlacementDataOverflow, AutoPlacementOptions,
FlipData, FlipDataOverflow, FlipOptions, OffsetData, OffsetOptions, OffsetOptionsValues,
ShiftData, ShiftOptions, ARROW_NAME, AUTO_PLACEMENT_NAME, FLIP_NAME, OFFSET_NAME, SHIFT_NAME,
ShiftData, ShiftOptions, ARROW_NAME, AUTO_PLACEMENT_NAME, FLIP_NAME, HIDE_NAME, OFFSET_NAME,
SHIFT_NAME,
};

/// Provides data to position an inner element of the floating element so that it appears centered to the reference element.
Expand All @@ -27,6 +28,12 @@ pub type AutoPlacement<'a> = CoreAutoPlacement<'a, Element, Window>;
/// See <https://floating-ui.com/docs/flip> for the original documentation.
pub type Flip<'a> = CoreFlip<'a, Element, Window>;

/// Provides data to hide the floating element in applicable situations,
/// such as when it is not in the same clipping context as the reference element.
///
/// See <https://floating-ui.com/docs/hide> for the original documentation.
pub type Hide<'a> = CoreHide<'a, Element, Window>;

/// Modifies the placement by translating the floating element along the specified axes.
///
/// See <https://floating-ui.com/docs/offset> for the original documentation.
Expand Down
2 changes: 1 addition & 1 deletion packages/leptos/src/arrow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ where
&self,
state: MiddlewareState<web_sys::Element, web_sys::Window>,
) -> MiddlewareReturn {
let element = self.options.element.get();
let element = self.options.element.get_untracked();

if let Some(element) = element {
let element: &web_sys::Element = &element;
Expand Down
5 changes: 3 additions & 2 deletions packages/leptos/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ pub use use_floating::*;

#[doc(no_inline)]
pub use floating_ui_dom::{
auto_update, compute_position, dom, AlignedPlacement, Alignment, AutoPlacement,
auto_update, compute_position, dom, AlignedPlacement, Alignment, ArrowData, AutoPlacement,
AutoPlacementData, AutoPlacementDataOverflow, AutoPlacementOptions, AutoUpdateOptions, Axis,
ClientRectObject, ComputePositionConfig, ComputePositionReturn, Coords, DetectOverflowOptions,
Dimensions, ElementOrVirtual, ElementRects, Flip, FlipData, FlipDataOverflow, FlipOptions,
Length, Middleware, MiddlewareData, MiddlewareReturn, MiddlewareState, MiddlewareVec,
MiddlewareWithOptions, Offset, OffsetData, OffsetOptions, OffsetOptionsValues, Padding,
Placement, Rect, Shift, ShiftData, ShiftOptions, Side, Strategy, VirtualElement,
Placement, Rect, Shift, ShiftData, ShiftOptions, Side, Strategy, VirtualElement, ARROW_NAME,
AUTO_PLACEMENT_NAME, FLIP_NAME, HIDE_NAME, OFFSET_NAME, SHIFT_NAME,
};
29 changes: 28 additions & 1 deletion packages/leptos/test/visual/src/app.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,36 @@
use leptos::*;
use leptos_router::{Outlet, Route, Router, Routes, A};

use crate::spec::arrow::Arrow;
use crate::spec::placement::Placement;
use crate::spec::relative::Relative;
use crate::utils::new::New;

const ROUTES: [&str; 2] = ["placement", "relative"];
const ROUTES: [&str; 23] = [
"placement",
"relative",
"transform",
"border",
"scroll",
"decimal-size",
"table",
"scrollbars",
"shift",
"flip",
"size",
"arrow",
"offset",
"hide",
"autoPlacement",
"inline",
"AutoUpdate",
"shadom-DOM",
"containing-block",
"virtual-element",
"perf",
"iframe",
"top-layer",
];

#[component]
pub fn AppWrapper() -> impl IntoView {
Expand Down Expand Up @@ -65,6 +90,8 @@ pub fn App() -> impl IntoView {
<Route path="new" view=New />
<Route path="placement" view=Placement />
<Route path="relative" view=Relative />

<Route path="arrow" view=Arrow />
</Route>
</Routes>
</Router>
Expand Down
1 change: 1 addition & 0 deletions packages/leptos/test/visual/src/spec.rs
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
pub mod arrow;
pub mod placement;
pub mod relative;
Loading

0 comments on commit 65752af

Please sign in to comment.