I am building an internal tool for our colleagues. Since Vaadin 24.4.x supports the use of Hilla out of the box I have refactored some of the foundational setup to follow the defaults.
In src/main/frontend/@layout.tsx
I have defined a drawer supported layout.
import {createMenuItems, useViewConfig} from '@vaadin/hilla-file-router/runtime.js';
import {effect, signal} from '@vaadin/hilla-react-signals';
import {AppLayout, DrawerToggle, Icon, SideNav, SideNavItem} from '@vaadin/react-components';
import {Suspense, useEffect} from 'react';
import {Link, Outlet, useLocation, useNavigate} from 'react-router-dom';
const defaultTitle = document.title;
const documentTitleSignal = signal('');
effect(() => {
document.title = documentTitleSignal.value;
});
// Publish for Vaadin to use
(window as any).Vaadin.documentTitleSignal = documentTitleSignal;
export default function MainLayout() {
const currentTitle = useViewConfig()?.title ?? defaultTitle;
const navigate = useNavigate();
const location = useLocation();
useEffect(() => {
documentTitleSignal.value = currentTitle;
}, [currentTitle]);
return (
<AppLayout primarySection="drawer">
<div slot="drawer" className="flex flex-col justify-between h-full p-m">
<header className="flex flex-col gap-m">
<Link to={"/"} className={"font-semibold text-l text-header decoration-none"}>FooBar</Link>
<SideNav onNavigate={({ path }) => navigate(path!)} location={location}>
{createMenuItems().map(({ to, title, icon }) => (
<SideNavItem path={to} key={to} className={`item-${to.replace(/^\//, '')}`}>
{icon ? <Icon src={icon} slot="prefix"></Icon> : <></>}
{title}
</SideNavItem>
))}
</SideNav>
</header>
</div>
<DrawerToggle slot="navbar" aria-label="Menu toggle"></DrawerToggle>
<h1 slot="navbar" className="text-l m-0">
{documentTitleSignal}
</h1>
<Suspense>
<Outlet />
</Suspense>
</AppLayout>
);
}
Now, we have a LoginView that is defined using Flow. That now always uses the React layout I’ve defined. However, I do want my LoginView to use a different layout that is simply a blank page.
When I add an empty LoginLayout (that inherits AppLayout)
@Route
class LoginLayout : AppLayout(){
}
and use that in
@Route("login", layout = LoginLayout::class)
@AnonymousAllowed
class OAuthLoginView : VerticalLayout() {
It also still uses the Hilla @layout.tsx
.
Is there anyway to force Flow to not use the default layout defined in my frontend code?